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 89A9640F1ED for ; Sat, 7 Jan 2012 14:28:26 -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 IiyOQXMRMMdN for ; Sat, 7 Jan 2012 14:28:25 -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 BA0E940F21F for ; Sat, 7 Jan 2012 14:28:23 -0800 (PST) Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) by fire-doxen-postvirus (Postfix) with ESMTP id 6611B2E50DCE for ; Sat, 7 Jan 2012 14:28:23 -0800 (PST) X-Spam-Scanned: at Caltech-IMSS on fire-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 fire-doxen-submit (Postfix) with ESMTP id 8A73C2E50DE4 for ; Sat, 7 Jan 2012 14:28:21 -0800 (PST) Received: by finestructure.net (Postfix, from userid 1000) id D16311118; Sat, 7 Jan 2012 14:28:20 -0800 (PST) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging Date: Sat, 7 Jan 2012 14:28:12 -0800 Message-Id: <1325975294-646-3-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1325975294-646-2-git-send-email-jrollins@finestructure.net> References: <1325975294-646-1-git-send-email-jrollins@finestructure.net> <1325975294-646-2-git-send-email-jrollins@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: Sat, 07 Jan 2012 22:28:26 -0000 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) ;; 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)) + (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. + (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))))))) (defun notmuch-show-archive-thread () "Archive each message in thread, then show next thread from search. @@ -1441,12 +1447,12 @@ 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-tag-thread-internal "-" "inbox" 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-tag-thread-internal "-" "inbox" nil)) (defun notmuch-show-stash-cc () "Copy CC field of current message to kill-ring." -- 1.7.7.3