[PATCH 4/6] emacs: add support for custom tag changes on message/thread archive

Jani Nikula jani at nikula.org
Mon Sep 3 05:08:17 PDT 2012


On Mon, 03 Sep 2012, Michal Nazarewicz <mina86 at mina86.com> wrote:
> Jani Nikula <jani at nikula.org> writes:
>> Add support for customization of the tag changes that are applied when
>> a message or a thread is archived. Instead of hard-coded removal of
>> the "inbox" tag, the user can now specify a list of tag changes to
>> perform.
>
>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
>> index ce5ea6f..e701aec 100644
>> --- a/emacs/notmuch-show.el
>> +++ b/emacs/notmuch-show.el
>> @@ -1748,18 +1748,20 @@ argument, hide all of the messages."
>>  (defun notmuch-show-archive-thread (&optional unarchive)
>>    "Archive each message in thread.
>>  
>> -Archive each message currently shown by removing the \"inbox\"
>> -tag from each.  If a prefix argument is given, the messages will
>> -be \"unarchived\" (ie. the \"inbox\" tag will be added instead of
>> -removed).
>> +Archive each message currently shown by applying the tag changes
>> +in `notmuch-archive-tags' to each (remove the \"inbox\" tag by
>> +default). If a prefix argument is given, the messages will be
>> +\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
>> +will be reversed.
>>  
>>  Note: This command is safe from any race condition of new messages
>>  being delivered to the same thread. It does not archive the
>>  entire thread, but only the messages shown in the current
>>  buffer."
>>    (interactive "P")
>> -  (let ((op (if unarchive "+" "-")))
>> -    (notmuch-show-tag-all (concat op "inbox"))))
>> +  (when notmuch-archive-tags
>
> Strictly speaking (when) should not be needed here (an in the following
> changes).  Or is it?

I noticed it was needed in some places, so decided to slam it in all
places for similarity. No harm in that, IMO.

Thanks for the review.

Jani.


>
>> +    (notmuch-show-tag-all
>> +     (notmuch-tag-change-list notmuch-archive-tags unarchive))))
>>  
>>  (defun notmuch-show-archive-thread-then-next ()
>>    "Archive all messages in the current buffer, then show next thread from search."
>> @@ -1774,14 +1776,17 @@ buffer."
>>    (notmuch-show-next-thread))
>>  
>>  (defun notmuch-show-archive-message (&optional unarchive)
>> -  "Archive the current message (remove \"inbox\" tag).
>> +  "Archive the current message.
>>  
>> -If a prefix argument is given, the message will be
>> -\"unarchived\" (ie. the \"inbox\" tag will be added instead of
>> -removed)."
>> +Archive the current message by applying the tag changes in
>> +`notmuch-archive-tags' to it (remove the \"inbox\" tag by
>> +default). If a prefix argument is given, the message will be
>> +\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
>> +will be reversed."
>>    (interactive "P")
>> -  (let ((op (if unarchive "+" "-")))
>> -    (notmuch-show-tag-message (concat op "inbox"))))
>> +  (when notmuch-archive-tags
>> +    (apply 'notmuch-show-tag-message
>> +	   (notmuch-tag-change-list notmuch-archive-tags unarchive))))
>>  
>>  (defun notmuch-show-archive-message-then-next-or-exit ()
>>    "Archive the current message, then show the next open message in the current thread.
>> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
>> index 1c43d3e..64caa3e 100644
>> --- a/emacs/notmuch.el
>> +++ b/emacs/notmuch.el
>> @@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
>>    (notmuch-search-tag "-"))
>>  
>>  (defun notmuch-search-archive-thread ()
>> -  "Archive the currently selected thread (remove its \"inbox\" tag).
>> +  "Archive the currently selected thread.
>> +
>> +Archive each message in the currently selected thread by applying
>> +the tag changes in `notmuch-archive-tags' to each (remove the
>> +\"inbox\" tag by default). If a prefix argument is given, the
>> +messages will be \"unarchived\" (i.e. the tag changes in
>> +`notmuch-archive-tags' will be reversed).
>>  
>>  This function advances the next thread when finished."
>>    (interactive)
>> -  (notmuch-search-tag '("-inbox"))
>> +  (when notmuch-archive-tags
>> +    (notmuch-search-tag
>> +     (notmuch-tag-change-list notmuch-archive-tags)))
>>    (notmuch-search-next-thread))
>>  
>>  (defun notmuch-search-update-result (result &optional pos)
>> -- 
>> 1.7.9.5
>>
>
> -- 
> Best regards,                                         _     _
> .o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
> ..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
> ooo +----<email/xmpp: mpn at google.com>--------------ooO--(_)--Ooo--


More information about the notmuch mailing list