[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging
Aaron Ecay
aaronecay at gmail.com
Sun Jan 8 17:08:59 PST 2012
Jameson,
Some comments below:
On Sat, 7 Jan 2012 14:28:12 -0800, Jameson Graef Rollins <jrollins at finestructure.net> wrote:
> Instead of having a function that is only used for archiving a thread,
> we instead make it useful for any tagging operation. The new
> function, notmuch-show-tag-thread-internal, now takes two more
> arguments, for the "sign" of the tagging operation ("-" or "+"), and
> the tag to be added or removed. This will allow this function to be
> used for any generic thread tagging operation.
>
> The higher level functions that call this function are modified
> accordingly.
> ---
> emacs/notmuch-show.el | 34 ++++++++++++++++++++--------------
> 1 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5502efd..1e16f05 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1414,20 +1414,26 @@ argument, hide all of the messages."
> (interactive)
> (backward-button 1))
>
> -(defun notmuch-show-archive-thread-internal (show-next)
> +(defun notmuch-show-tag-thread-internal (sign tag show-next)
A couple of comments on the arguments:
- It would be good to make show-next &optional. This will enable code
to call the fn with only two arguments, and not showing next will be
the default behavior.
- A more lispy way of specifying the sign would be to use a
boolean. Perhaps you could call this “remove”; a value of ‘t’ would
remove the tag; ‘nil’ would add it. Moving this argument after ‘tag’
and also making it &optional woudl allow this fn to be called with one
arg to add a tag. (Maybe this is too minimalist and API, however.)
> ;; Remove the tag from the current set of messages.
> (goto-char (point-min))
> - (loop do (notmuch-show-remove-tag "inbox")
> - until (not (notmuch-show-goto-message-next)))
> - ;; Move to the next item in the search results, if any.
> - (let ((parent-buffer notmuch-show-parent-buffer))
> - (notmuch-kill-this-buffer)
> - (if parent-buffer
> - (progn
> - (switch-to-buffer parent-buffer)
> - (forward-line)
> - (if show-next
> - (notmuch-search-show-thread))))))
> + (let ((tag-function))
No second set of parens is needed around tag-function.
> + (cond
> + ((string= sign "-")
> + (setq tag-function 'notmuch-show-remove-tag))
> + ((string= sign "+")
> + (setq tag-function 'notmuch-show-add-tag)))
> + (loop do (funcall tag-function tag)
> + until (not (notmuch-show-goto-message-next)))
> + ;; Move to the next item in the search results, if any.
Does it make sense to separate the tagging and the movement? It seems
plausible that some code somewhere might want to add/remove a tag from
all messages in the thread w/o changing the display.
> + (let ((parent-buffer notmuch-show-parent-buffer))
> + (notmuch-kill-this-buffer)
> + (if parent-buffer
> + (progn
> + (switch-to-buffer parent-buffer)
> + (forward-line)
> + (if show-next
> + (notmuch-search-show-thread)))))))
--
Aaron Ecay
More information about the notmuch
mailing list