From: Austin Clements Date: Wed, 23 Oct 2013 00:21:56 +0000 (-0400) Subject: emacs: Use interactive specifications for tag changes in show X-Git-Tag: 0.17_rc1~97 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=47792533b37b24d353aa351c303562860509441b;p=notmuch.git emacs: Use interactive specifications for tag changes in show This modifies all tagging operations in show to call `notmuch-read-tag-changes' in their interactive specification to input tag changes, rather than depending on lower-level functions to prompt for tag changes regardless of their calling context. Besides being more Elispy and providing a more consistent programmatic API, this enables callers to provide two call site-specific pieces of information: an appropriate prompt, and the set of visible tags. The prompt lets us differentiate * from +/-. Providing visible tags enables a more consistent user experience than retrieving the (potentially different) tags from the database, and avoids a round-trip to the CLI and database. --- diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 8ba81676..81ee87a8 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1782,23 +1782,28 @@ TAG-CHANGES is a list of tag operations for `notmuch-tag'." (notmuch-tag (notmuch-show-get-message-id) tag-changes) (notmuch-show-set-tags new-tags)))) -(defun notmuch-show-tag (&optional tag-changes) +(defun notmuch-show-tag (tag-changes) "Change tags for the current message. See `notmuch-tag' for information on the format of TAG-CHANGES." - (interactive) - (let* ((tag-changes (notmuch-tag (notmuch-show-get-message-id) tag-changes)) - (current-tags (notmuch-show-get-tags)) + (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags) + "Tag message"))) + (notmuch-tag (notmuch-show-get-message-id) tag-changes) + (let* ((current-tags (notmuch-show-get-tags)) (new-tags (notmuch-update-tags current-tags tag-changes))) (unless (equal current-tags new-tags) (notmuch-show-set-tags new-tags)))) -(defun notmuch-show-tag-all (&optional tag-changes) +(defun notmuch-show-tag-all (tag-changes) "Change tags for all messages in the current show buffer. See `notmuch-tag' for information on the format of TAG-CHANGES." - (interactive) - (setq tag-changes (notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)) + (interactive + (list (let (tags) + (notmuch-show-mapc + (lambda () (setq tags (append (notmuch-show-get-tags) tags)))) + (notmuch-read-tag-changes tags "Tag thread")))) + (notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes) (notmuch-show-mapc (lambda () (let* ((current-tags (notmuch-show-get-tags)) @@ -1806,19 +1811,21 @@ See `notmuch-tag' for information on the format of TAG-CHANGES." (unless (equal current-tags new-tags) (notmuch-show-set-tags new-tags)))))) -(defun notmuch-show-add-tag () +(defun notmuch-show-add-tag (tag-changes) "Change tags for the current message (defaulting to add). Same as `notmuch-show-tag' but sets initial input to '+'." - (interactive) - (notmuch-show-tag "+")) + (interactive + (list (notmuch-read-tag-changes (notmuch-show-get-tags) "Tag message" "+"))) + (notmuch-show-tag tag-changes)) -(defun notmuch-show-remove-tag () +(defun notmuch-show-remove-tag (tag-changes) "Change tags for the current message (defaulting to remove). Same as `notmuch-show-tag' but sets initial input to '-'." - (interactive) - (notmuch-show-tag "-")) + (interactive + (list (notmuch-read-tag-changes (notmuch-show-get-tags) "Tag message" "-"))) + (notmuch-show-tag tag-changes)) (defun notmuch-show-toggle-visibility-headers () "Toggle the visibility of the current message headers."