From: Ian Zimmerman Date: Sat, 15 Dec 2018 22:56:21 +0000 (-0800) Subject: Pass current folder to external search tool X-Git-Tag: 2019-10-25~435 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11b07decef55312f47eded9557fe9b1fe8db8498;p=neomutt Pass current folder to external search tool Or "/", if needed --- diff --git a/init.h b/init.h index f485ce7e5..4a1ec9af4 100644 --- a/init.h +++ b/init.h @@ -939,6 +939,11 @@ struct ConfigDef MuttVars[] = { ** runs the old but well loved mairix indexer with the arguments ** given to mairix_filter, in the "raw" mode of mairix, producing ** on the standard output a list of Message-IDs, one per line. + ** .pp + ** If possible, it also filters down the results coming from mairix + ** such that only messages in the current folder remain. It can do + ** this because it gets a hidden first argument which is the path + ** to the folder. ** (This can be the type of clean and simple script called a \fIone-liner\fP.) ** .pp ** Now if NeoMutt gets a limit or tag command followed by the pattern diff --git a/pattern.c b/pattern.c index 568c00184..51b906750 100644 --- a/pattern.c +++ b/pattern.c @@ -297,6 +297,19 @@ static bool eat_query(struct Pattern *pat, struct Buffer *s, struct Buffer *err) mutt_buffer_init(&cmd_buf); mutt_buffer_addstr(&cmd_buf, SearchCommand); mutt_buffer_addch(&cmd_buf, ' '); + if (!Context || !Context->mailbox) + { + mutt_buffer_addch(&cmd_buf, '/'); + } + else + { + char *escaped_folder = mutt_path_escape(Context->mailbox->path); + mutt_debug(2, "escaped folder path: %s\n", escaped_folder); + mutt_buffer_addch(&cmd_buf, '\''); + mutt_buffer_addstr(&cmd_buf, escaped_folder); + mutt_buffer_addch(&cmd_buf, '\''); + } + mutt_buffer_addch(&cmd_buf, ' '); mutt_buffer_addstr(&cmd_buf, tok_buf.data); FREE(&tok_buf.data);