X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-tag.el;h=959778819617f9cd23498818b2344103fb008c12;hp=4c974679944871aec3dd8301ea9e820b0b43807c;hb=cc2c3a383d12ce421c5ec1bdfb7bfacc60a0f368;hpb=9b2a548189728e7c25dea853ed19b17889f4dc36 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.