aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-02-12 16:27:39 -0400
committerDavid Bremner <david@tethera.net>2022-02-26 07:58:14 -0400
commitcc2c3a383d12ce421c5ec1bdfb7bfacc60a0f368 (patch)
tree17e019ffb4c18319101d464b1c1a71115a752143 /emacs
parent9b2a548189728e7c25dea853ed19b17889f4dc36 (diff)
emacs: add notmuch-tag-undo
Keybindings are deferred to a future commit.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/notmuch-tag.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 4c974679..95977881 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -278,6 +278,7 @@ This can be used with `notmuch-tag-format-image-data'."
;;; 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
@@ -502,6 +503,19 @@ notmuch-after-tag-hook will be run."
(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.