From: Tim Stoakes Date: Sat, 22 Sep 2012 07:31:54 +0000 (+0200) Subject: Add TAB completion of tag names in * X-Git-Tag: neomutt-20160404~13^2~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb555c1c0cf0957496310085983b80f97d21a34c;p=neomutt Add TAB completion of tag names in * and can now use TAB completion of tag names supplied after + and -. --- diff --git a/README.notmuch b/README.notmuch index c6a19508a..0822b2063 100644 --- a/README.notmuch +++ b/README.notmuch @@ -87,11 +87,13 @@ notmuch support for mutt modify-labels: - add or remove notmuch tags; [+] to add, - to remove - default key: ` + - note: TAB completion of tag names is available - example: "+AAA +BBB -CCC" modify-labels-then-hide: - same as but message is marked by - 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 "+archive -inbox\n" diff --git a/curs_main.c b/curs_main.c index 25341a03c..618e06de4 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1394,7 +1394,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 e07a901ff..e2604b9d7 100644 --- a/enter.c +++ b/enter.c @@ -640,6 +640,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 e356ae44c..edce02670 100644 --- 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 faed9fbbe..35c59a8aa 100644 --- a/mutt.h +++ b/mutt.h @@ -103,6 +103,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() */ diff --git a/protos.h b/protos.h index 6bcb28c90..c00de1be0 100644 --- a/protos.h +++ b/protos.h @@ -291,6 +291,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);