Like other menus that allow tagging (for example, the attach-file menu), simply require "quit"'ing the menu to automatically select tagged entries.
Previously, tagging entries in the query menu also required hitting enter to "select" an arbitrary (and ignored) entry, which is unintuitive if you've tagged entries. Just hitting "quit" with tagged entries did not select them. With this change, you can tag one or more results, quit from the menu, and the selections are copied to the prompt. --- NOTE: this patch may be better viewed in "ignore whitespace mode". See https://gitlab.com/muttmua/mutt/-/commit/a70fb3899ae5485b0e13308bac77de06b88d11d0 It makes it clearer that I'm just changing it to check menu->tagged for scanning and entering tagged results, and otherwise checking (done == 2) which means they hit enter. The actual copy result code is unchanged. query.c | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/query.c b/query.c index 96d93788..3d66b902 100644 --- a/query.c +++ b/query.c @@ -503,48 +503,46 @@ static void query_menu(char *buf, size_t buflen, QUERY *results, int retbuf) } /* if we need to return the selected entries */ - if (retbuf && (done == 2)) + if (retbuf) { - int tagged = 0; - size_t curpos = 0; - memset(buf, 0, buflen); - /* check for tagged entries */ - for (i = 0; i < menu->max; i++) + if (menu->tagged) { - if (QueryTable[i].tagged) + size_t curpos = 0; + + for (i = 0; i < menu->max; i++) { - if (curpos == 0) + if (QueryTable[i].tagged) { - ADDRESS *tmpa = result_to_addr(QueryTable[i].data); - mutt_addrlist_to_local(tmpa); - tagged = 1; - rfc822_write_address(buf, buflen, tmpa, 0); - curpos = mutt_strlen(buf); - rfc822_free_address(&tmpa); - } - else if (curpos + 2 < buflen) - { - ADDRESS *tmpa = result_to_addr(QueryTable[i].data); - mutt_addrlist_to_local(tmpa); - strcat(buf, ", "); /* __STRCAT_CHECKED__ */ - rfc822_write_address((char *) buf + curpos + 2, buflen - curpos - 2, - tmpa, 0); - curpos = mutt_strlen(buf); - rfc822_free_address(&tmpa); + if (curpos == 0) + { + ADDRESS *tmpa = result_to_addr(QueryTable[i].data); + mutt_addrlist_to_local(tmpa); + rfc822_write_address(buf, buflen, tmpa, 0); + curpos = mutt_strlen(buf); + rfc822_free_address(&tmpa); + } + else if (curpos + 2 < buflen) + { + ADDRESS *tmpa = result_to_addr(QueryTable[i].data); + mutt_addrlist_to_local(tmpa); + strcat(buf, ", "); /* __STRCAT_CHECKED__ */ + rfc822_write_address((char *) buf + curpos + 2, buflen - curpos - 2, + tmpa, 0); + curpos = mutt_strlen(buf); + rfc822_free_address(&tmpa); + } } } } - /* then enter current message */ - if (!tagged) + else if (done == 2) { ADDRESS *tmpa = result_to_addr(QueryTable[menu->current].data); mutt_addrlist_to_local(tmpa); rfc822_write_address(buf, buflen, tmpa, 0); rfc822_free_address(&tmpa); } - } free_query(&results); -- 2.53.0
