- note: TAB completion of 'tag:' names is available
modify-labels:
- - add or remove notmuch tags; [+]<tag> to add, -<tag> to remove
+ - add, remove, or toggle notmuch tags; [+]<tag> to add, -<tag> to remove, !<tag> to toggle
- default key: `
- note: TAB completion of tag names is available
- example: "+AAA +BBB -CCC"
<emphasis role="comment"># modify (notmuch) tags</emphasis>
bind index,pager \` modify-labels
+<emphasis role="comment"># modify (notmuch) tag non-interactively.</emphasis>
+bind index,pager tt "<modify-labels>!todo\n" "Toggle the 'todo' tag"
+
<emphasis role="comment"># generate virtual folder from query</emphasis>
bind index,pager \eX vfolder-from-query
return msg;
}
+static bool nm_message_has_tag(notmuch_message_t *msg, char *tag)
+{
+ const char *possible_match_tag;
+ notmuch_tags_t *tags;
+
+ for (tags = notmuch_message_get_tags(msg); notmuch_tags_valid(tags);
+ notmuch_tags_move_to_next(tags))
+ {
+ possible_match_tag = notmuch_tags_get(tags);
+ if (mutt_strncmp(possible_match_tag, tag, mutt_strlen(tag)) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
static int update_tags(notmuch_message_t *msg, const char *tags)
{
char *tag = NULL, *end = NULL, *p;
dprint(1, (debugfile, "nm: remove tag: '%s'\n", tag + 1));
notmuch_message_remove_tag(msg, tag + 1);
}
+ else if (*tag == '!')
+ {
+ dprint(1, (debugfile, "nm: toggle tag: '%s'\n", tag + 1));
+ if (nm_message_has_tag (msg, tag + 1))
+ {
+ notmuch_message_remove_tag (msg, tag + 1);
+ }
+ else
+ {
+ notmuch_message_add_tag (msg, tag + 1);
+ }
+ }
else
{
dprint(1, (debugfile, "nm: add tag: '%s'\n", (*tag == '+') ? tag + 1 : tag));