]> granicus.if.org Git - neomutt/commitdiff
Pass current folder to external search tool
authorIan Zimmerman <itz@no-use.mooo.com>
Sat, 15 Dec 2018 22:56:21 +0000 (14:56 -0800)
committerRichard Russon <rich@flatcap.org>
Sun, 16 Dec 2018 14:06:11 +0000 (14:06 +0000)
Or "/", if needed

init.h
pattern.c

diff --git a/init.h b/init.h
index f485ce7e5d8679fad80398e88f1a0b65d18797b2..4a1ec9af49e09d7d91001f83a85d6f5a4720a2b9 100644 (file)
--- 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
index 568c00184765c1c5ef7d45f76ca6c54043ac64ef..51b906750e280906777207de2716d800bc0ee3b4 100644 (file)
--- 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);