]> granicus.if.org Git - mutt/commitdiff
Permit tab completion of pattern expressions with ~y (labels).
authorKevin McCarthy <kevin@8t8.us>
Tue, 31 Jan 2017 22:27:28 +0000 (14:27 -0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 31 Jan 2017 22:27:28 +0000 (14:27 -0800)
Thanks to David Champion for the original patch.  This version is
slightly different, as I couldn't get the original patch working.
This version simply scans backward for the first ~, and if it is ~y,
invokes completion.

enter.c

diff --git a/enter.c b/enter.c
index d8fc2a51312602322428890be82e9535275f3965..db2e4977e96e5a7b771379d745d74d867a030cc6 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -568,7 +568,6 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
          }
          else if (flags & MUTT_LABEL && ch == OP_EDITOR_COMPLETE)
          {
-           /* invoke the alias-menu to get more addresses */
            for (i = state->curpos; i && state->wbuf[i-1] != ',' && 
                 state->wbuf[i-1] != ':'; i--)
              ;
@@ -584,6 +583,26 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
            }
            break;
          }
+          else if (flags & MUTT_PATTERN && ch == OP_EDITOR_COMPLETE)
+          {
+            for (i = state->curpos; i && state->wbuf[i-1] != '~'; i--)
+              ;
+            if (i && state->wbuf[i-1] == '~' && state->wbuf[i] == 'y')
+            {
+              i++;
+              my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
+              r = mutt_label_complete (buf, buflen, strlen (buf), state->tabs);
+              replace_part (state, i, buf);
+              if (!r)
+              {
+                rv = 1;
+                goto bye;
+              }
+            }
+            else
+              goto self_insert;
+            break;
+          }
          else if (flags & MUTT_ALIAS && ch == OP_EDITOR_COMPLETE_QUERY)
          {
            /* invoke the query-menu to get more addresses */