Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 55FD2421189 for ; Tue, 17 Jan 2012 10:05:46 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K10-RABCzsly for ; Tue, 17 Jan 2012 10:05:45 -0800 (PST) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 965E741ED89 for ; Tue, 17 Jan 2012 10:05:37 -0800 (PST) Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) by earth-doxen-postvirus (Postfix) with ESMTP id 3C08666E019E for ; Tue, 17 Jan 2012 10:05:37 -0800 (PST) X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new Received: from finestructure.net (cpe-76-174-137-84.socal.res.rr.com [76.174.137.84]) (Authenticated sender: jrollins) by earth-doxen-submit (Postfix) with ESMTP id 4093166E00F4 for ; Tue, 17 Jan 2012 10:05:32 -0800 (PST) Received: by finestructure.net (Postfix, from userid 1000) id E019E514; Tue, 17 Jan 2012 10:05:31 -0800 (PST) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH 1/6] emacs: break up notmuch-show-archive-thread-internal into two generally useful functions Date: Tue, 17 Jan 2012 10:05:26 -0800 Message-Id: <1326823531-14549-1-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <871uqy19yo.fsf@servo.finestructure.net> References: <871uqy19yo.fsf@servo.finestructure.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2012 18:05:46 -0000 Brake up notmuch-show-archive-thread-internal into two new functions: notmuch-show-tag-thread-internal: applies a tag to all messages in thread. If option remove flag is t, tags will be removed instead of added. notmuch-show-next-thread: moves to the next thread in the search result. If given a prefix, will show the next result, otherwise will just move to it in the search view. Two new interactive functions, notmuch-show-{add,remove}-tag-thread, are also added. Together, these provide a better suit of thread tagging and navigation tools. The higher level thread archiving functions are modified to use these new functions. --- emacs/notmuch-show.el | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 03c1f6b..3625afd 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1421,12 +1421,29 @@ argument, hide all of the messages." (interactive) (backward-button 1)) -(defun notmuch-show-archive-thread-internal (show-next) - ;; Remove the tag from the current set of messages. +(defun notmuch-show-tag-thread-internal (tag &optional remove) + ;; Add tag to the current set of messages. If the remove switch is + ;; given, tags will be removed instead of added. (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 ((tag-function 'notmuch-show-add-tag)) + (if remove + (setq tag-function 'notmuch-show-remove-tag)) + (loop do (funcall tag-function tag) + until (not (notmuch-show-goto-message-next))))) + +(defun notmuch-show-add-tag-thread (tag) + "Add tag to all messages in the current thread." + (interactive) + (notmuch-show-tag-thread-internal tag)) + +(defun notmuch-show-remove-tag-thread (tag) + "Remove tag from all messages in the current thread." + (interactive) + (notmuch-show-tag-thread-internal tag t)) + +(defun notmuch-show-next-thread (&optional show-next) + "Move to the next item in the search results, if any." + (interactive) (let ((parent-buffer notmuch-show-parent-buffer)) (notmuch-kill-this-buffer) (if parent-buffer @@ -1448,12 +1465,14 @@ being delivered to the same thread. It does not archive the entire thread, but only the messages shown in the current buffer." (interactive) - (notmuch-show-archive-thread-internal t)) + (notmuch-show-remove-tag-thread "inbox") + (notmuch-show-next-thread t)) (defun notmuch-show-archive-thread-then-exit () "Archive each message in thread, then exit back to search results." (interactive) - (notmuch-show-archive-thread-internal nil)) + (notmuch-show-remove-tag-thread "inbox") + (notmuch-show-next-thread)) (defun notmuch-show-stash-cc () "Copy CC field of current message to kill-ring." -- 1.7.7.3