For example, to replace a tag with another string, simply use
that string as a formatting expression. To change the foreground
of a tag to red, use the expression
- (propertize tag 'face '(:foreground \"red\"))
+ (propertize tag \\='face \\='(:foreground \"red\"))
See also `notmuch-tag-format-image', which can help replace tags
with images."
unless strike-through is not available (e.g., emacs is running in
a terminal) in which case it uses inverse video. To hide deleted
tags completely set this to
- '((\".*\" nil))
+ \\='((\".*\" nil))
See `notmuch-tag-formats' for full documentation."
:group 'notmuch-show
;;; track history of tag operations
(defvar-local notmuch-tag-history nil
"Buffer local history of `notmuch-tag' function.")
+(put 'notmuch-tag-history 'permanent-local t)
;;; Format Handling
(defcustom notmuch-before-tag-hook nil
"Hooks that are run before tags of a message are modified.
-'tag-changes' will contain the tags that are about to be added or removed as
+`tag-changes' will contain the tags that are about to be added or removed as
a list of strings of the form \"+TAG\" or \"-TAG\".
-'query' will be a string containing the search query that determines
+`query' will be a string containing the search query that determines
the messages that are about to be tagged."
:type 'hook
:options '(notmuch-hl-line-mode)
(defcustom notmuch-after-tag-hook nil
"Hooks that are run after tags of a message are modified.
-'tag-changes' will contain the tags that were added or removed as
+`tag-changes' will contain the tags that were added or removed as
a list of strings of the form \"+TAG\" or \"-TAG\".
-'query' will be a string containing the search query that determines
+`query' will be a string containing the search query that determines
the messages that were tagged."
:type 'hook
:options '(notmuch-hl-line-mode)
(query query))
(run-hooks 'notmuch-after-tag-hook)))
+(defun notmuch-tag-undo ()
+ "Undo the previous tagging operation in the current buffer. Uses
+buffer local variable `notmuch-tag-history' to determine what
+that operation was."
+ (interactive)
+ (when (null notmuch-tag-history)
+ (error "no further notmuch undo information"))
+ (let* ((action (pop notmuch-tag-history))
+ (query (plist-get action :query))
+ (changes (notmuch-tag-change-list (plist-get action :tag-changes) t)))
+ (notmuch-tag query changes t))
+ (notmuch-refresh-this-buffer))
+
(defun notmuch-tag-change-list (tags &optional reverse)
"Convert TAGS into a list of tag changes.