Description: Make "simple search keywords" optional.
 Patch written on 2012-06-04.
Bug: https://gitlab.com/muttmua/trac-tickets/-/blob/master/tickets/open/3586-make_simple_search_keywords_optional.txt
Author: Vincent Lefevre <vincent@vinc17.net>
Last-Update: 2022-06-09

diff --git a/PATCHES b/PATCHES
index e69de29b..4b14e958 100644
--- a/PATCHES
+++ b/PATCHES
@@ -0,0 +1,1 @@
+patch-20220609.vl.simplesearchkw.1
diff --git a/init.h b/init.h
index e3d43851..802909d4 100644
--- a/init.h
+++ b/init.h
@@ -3796,12 +3796,18 @@ struct option_t MuttVars[] = {
   ** Specifies how Mutt should expand a simple search into a real search
   ** pattern.  A simple search is one that does not contain any of the ``~'' pattern
   ** modifiers.  See ``$patterns'' for more information on search patterns.
+  ** Simple search is also affected by $$simple_search_keywords.
   ** .pp
   ** For example, if you simply type ``joe'' at a search or limit prompt, Mutt
   ** will automatically expand it to the value specified by this variable by
   ** replacing ``%s'' with the supplied string.
   ** For the default value, ``joe'' would be expanded to: ``~f joe | ~s joe''.
   */
+  { "simple_search_keywords",	DT_BOOL, R_NONE, {.l=OPTSIMPLESEARCHKEYWORDS}, {.l=1} },
+  /*
+  ** .pp
+  ** This flag controls whether ``simple search keywords'' are enabled.
+  */
   { "size_show_bytes",	DT_BOOL, R_MENU, {.l=OPTSIZESHOWBYTES}, {.l=0} },
   /*
   ** .pp
diff --git a/mutt.h b/mutt.h
index bb29e7a6..09b7f4bf 100644
--- a/mutt.h
+++ b/mutt.h
@@ -552,6 +552,7 @@ enum
 #endif
   OPTSIGDASHES,
   OPTSIGONTOP,
+  OPTSIMPLESEARCHKEYWORDS,
   OPTSIZESHOWBYTES,
   OPTSIZESHOWMB,
   OPTSIZESHOWFRACTIONS,
diff --git a/pattern.c b/pattern.c
index 28a33d81..02b847c6 100644
--- a/pattern.c
+++ b/pattern.c
@@ -1837,6 +1837,8 @@ void mutt_check_simple (BUFFER *s, const char *simple)
 
   if (do_simple) /* yup, so spoof a real request */
   {
+    if (!option (OPTSIMPLESEARCHKEYWORDS))
+      goto expand_simple;
     /* convert old tokens into the new format */
     if (ascii_strcasecmp ("all", mutt_b2s (s)) == 0 ||
 	!mutt_strcmp ("^", mutt_b2s (s)) ||
@@ -1860,6 +1862,7 @@ void mutt_check_simple (BUFFER *s, const char *simple)
       mutt_buffer_strcpy (s, "~U");
     else
     {
+    expand_simple:
       tmp = mutt_buffer_pool_get ();
       quote_simple (tmp, mutt_b2s (s));
       mutt_expand_fmt (s, simple, mutt_b2s (tmp));
