]> granicus.if.org Git - neomutt/commitdiff
Add TAB completion of tag names in <modify-labels>*
authorTim Stoakes <tim@stoakes.net>
Sat, 22 Sep 2012 07:31:54 +0000 (09:31 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 14 Mar 2016 23:11:42 +0000 (23:11 +0000)
<modify-labels> and <modify-labels-then-hide> can now use TAB completion of tag
names supplied after + and -.

README.notmuch
curs_main.c
enter.c
init.c
mutt.h
protos.h

index c6a19508a3f798ce516c622f8b5cd2c505bf7f27..0822b2063d22b90d5f9a5a98ba4ed7e877991d8b 100644 (file)
@@ -87,11 +87,13 @@ notmuch support for mutt
    modify-labels:
       - add or remove notmuch tags; [+]<tag> to add, -<tag> to remove
       - default key: `
+      - note: TAB completion of tag names is available
       - example: "+AAA +BBB -CCC"
 
    modify-labels-then-hide:
       - same as <modify-labels> but message is marked by <quasi-delete>
       - not mapped to any key
+      - note: TAB completion of tag names is available
       - example (add "archive" notmuch tag and remove message from screen):
 
        macro index A "<modify-labels-then-hide>+archive -inbox\n<sync-mailbox>"
index 831052a38c6cbb152e4d4d39d339ba71f9bbd0ba..4ee36f91704ffb3fcc539cdf922ed37ffed28340 100644 (file)
@@ -1396,7 +1396,7 @@ int mutt_index_menu (void)
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
        *buf = '\0';
-       if (mutt_get_field ("Add/remove labels: ", buf, sizeof (buf), 0) || !*buf)
+       if (mutt_get_field ("Add/remove labels: ", buf, sizeof (buf), M_NM_TAG) || !*buf)
        {
           mutt_message _("No label specified, aborting.");
           break;
diff --git a/enter.c b/enter.c
index d4ed1fffb09e7382d705c4c8c32321a2c22fbf0c..f52227e94a82d17edc68d4ad0f78b7f95eaa368b 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -632,6 +632,16 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
 
            replace_part (state, 0, buf);
          }
+         else if (flags & M_NM_TAG)
+         {
+           my_wcstombs (buf, buflen, state->wbuf, state->curpos);
+           i = strlen (buf);
+           if (!mutt_nm_tag_complete(buf, buflen, i, state->tabs))
+             BEEP ();
+
+           replace_part (state, 0, buf);
+         }
+
 #endif
          else
            goto self_insert;
diff --git a/init.c b/init.c
index d11cc335027cb3e16d893d0ec42180dd097da588..94b75c9d11a5c1ec56f2e79c6e2b524b211bcf66 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2762,6 +2762,28 @@ int mutt_nm_query_complete (char *buffer, size_t len, int pos, int numtabs)
   return 1;
 }
 
+/* Complete the nearest "+" or "-" -prefixed string previous to pos. */
+int mutt_nm_tag_complete (char *buffer, size_t len, int pos, int numtabs)
+{
+  char *pt = buffer;
+  int spaces;
+  const char *first_plus = NULL;
+  const char *first_minus = NULL;
+
+  SKIPWS (buffer);
+  spaces = buffer - pt;
+
+  first_plus = rstrnstr((char *)buffer, pos, "+");
+  first_minus = rstrnstr((char *)buffer, pos, "-");
+  pt = (char *)MAX(first_plus, first_minus);
+
+  if (pt != NULL) {
+    pt++;
+
+    if (numtabs == 1)
+    {
+      /* First TAB. Collect all the matches */
+      complete_all_nm_tags(pt);
 
       /* All matches are stored. Longest non-ambiguous string is ""
        * i.e. don't change 'buffer'. Fake successful return this time.
diff --git a/mutt.h b/mutt.h
index 1d9c8cf586affab80a42234de8356c60abd9ab66..b3457da7dd1edba52004b6b7e11d2276e43aee87 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -98,6 +98,7 @@
 #define  M_PATTERN (1<<7) /* pattern mode - only used for history classes */
 #if USE_NOTMUCH
 #define  M_NM_QUERY (1<<8) /* Notmuch query mode. */
+#define  M_NM_TAG   (1<<9) /* Notmuch tag +/- mode. */
 #endif
 
 /* flags for mutt_get_token() */
index ca0437e2e47be8f66db628b161788ee3bffe8e21..b0745c05d0cf39395630f60f4524a8ab6f861497 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -290,6 +290,7 @@ int mutt_command_complete (char *, size_t, int, int);
 int mutt_var_value_complete (char *, size_t, int);
 #if USE_NOTMUCH
 int mutt_nm_query_complete (char *buffer, size_t len, int pos, int numtabs);
+int mutt_nm_tag_complete (char *buffer, size_t len, int pos, int numtabs);
 #endif
 int mutt_complete (char *, size_t);
 int mutt_compose_attachment (BODY *a);