From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C1276416017 for ; Fri, 24 Feb 2012 14:33:33 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 yNo0EdQbYeNz for ; Fri, 24 Feb 2012 14:33:32 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D676540A39E for ; Fri, 24 Feb 2012 14:33:31 -0800 (PST) Received: by mail-ww0-f45.google.com with SMTP id dt12so2226566wgb.2 for ; Fri, 24 Feb 2012 14:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of pieter@praet.org designates 10.180.84.41 as permitted sender) client-ip=10.180.84.41; Authentication-Results: mr.google.com; spf=pass (google.com: domain of pieter@praet.org designates 10.180.84.41 as permitted sender) smtp.mail=pieter@praet.org Received: from mr.google.com ([10.180.84.41]) by 10.180.84.41 with SMTP id v9mr1892673wiy.11.1330122811610 (num_hops = 1); Fri, 24 Feb 2012 14:33:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.84.41 with SMTP id v9mr1466888wiy.11.1330122811554; Fri, 24 Feb 2012 14:33:31 -0800 (PST) Received: from localhost ([109.131.181.26]) by mx.google.com with ESMTPS id h19sm6281406wiw.9.2012.02.24.14.33.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Feb 2012 14:33:31 -0800 (PST) From: Pieter Praet To: David Bremner , Dmitry Kurochkin Subject: [PATCH v2 6/6] emacs: `notmuch-show-tag-all' with prefix arg only tags open messages Date: Fri, 24 Feb 2012 23:30:40 +0100 Message-Id: <1330122640-18895-7-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <1330122640-18895-1-git-send-email-pieter@praet.org> References: <87wr7xqpuf.fsf@rocinante.cs.unb.ca> <1330122640-18895-1-git-send-email-pieter@praet.org> X-Gm-Message-State: ALoCoQkHwEgRqcSgUsWH2P172kGcyTAP78BDGxIq0fuOzwTQSge5VFIje50IMRuPRbNM9IZeM/PK Cc: Notmuch Mail 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: Fri, 24 Feb 2012 22:33:34 -0000 * emacs/notmuch-show.el (notmuch-show-get-messages-ids): If provided with optional argument PREDICATE, only return Message-Id's of messages for which PREDICATE returns non-nil. (notmuch-show-tag-all): New argument ONLY-OPEN (set to `current-prefix-arg' if running interactively): if non-nil, only change tags of *open* messages. Also correct original docstring: 's/thread/buffer/'. (notmuch-show-archive-thread): Update wrt changes to `notmuch-show-tag-all'. * test/emacs - Subtest "notmuch-show: change tags of open messages in current buffer" is no longer broken... --- emacs/notmuch-show.el | 33 ++++++++++++++++++++++++--------- test/emacs | 1 - 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 05606fc..4bd1a7c 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1339,14 +1339,18 @@ (defun notmuch-show-get-message-id () "Return the message id of the current message." (concat "id:\"" (notmuch-show-get-prop :id) "\"")) -(defun notmuch-show-get-messages-ids (&optional separator) +(defun notmuch-show-get-messages-ids (&optional separator predicate) "Return a list of Message-Id's of all messages in the current buffer. If provided with optional argument SEPARATOR, return a string -instead, consisting of all Message-Id's separated by SEPARATOR." +instead, consisting of all Message-Id's separated by SEPARATOR. + +If provided with optional argument PREDICATE, only return +Message-Id's of messages for which PREDICATE returns non-nil." (let ((message-ids)) (notmuch-show-mapc - (lambda () (push (notmuch-show-get-message-id) message-ids))) + (lambda () (push (notmuch-show-get-message-id) message-ids)) + predicate) (if separator (mapconcat 'identity message-ids separator) message-ids))) @@ -1633,18 +1637,29 @@ (defun notmuch-show-tag (&optional initial-input) initial-input (notmuch-show-get-message-id)))) (apply 'notmuch-show-tag-message tag-changes))) -(defun notmuch-show-tag-all (&rest tag-changes) - "Change tags for all messages in the current thread. +(defun notmuch-show-tag-all (only-open &rest tag-changes) + "Change tags of all messages in the current buffer. + +If ONLY-OPEN is non-nil, only change tags of *open* messages in +the current buffer. TAG-CHANGES is a list of tag operations for `notmuch-tag'." - (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id)) - (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes) + (interactive (cons current-prefix-arg + (notmuch-read-tag-changes nil notmuch-show-thread-id))) + (apply 'notmuch-tag + (notmuch-show-get-messages-ids + " or " + `(lambda () + ,(if only-open '(notmuch-show-message-visible-p) t))) + tag-changes) (notmuch-show-mapc (lambda () (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)))))) + (notmuch-show-set-tags new-tags)))) + `(lambda () + ,(if only-open '(notmuch-show-message-visible-p) t)))) (defun notmuch-show-add-tag () "Same as `notmuch-show-tag' but sets initial input to '+'." @@ -1724,7 +1739,7 @@ (defun notmuch-show-archive-thread (&optional unarchive) buffer." (interactive "P") (let ((op (if unarchive "+" "-"))) - (notmuch-show-tag-all (concat op "inbox")))) + (notmuch-show-tag-all nil (concat op "inbox")))) (defun notmuch-show-archive-thread-then-next () "Archive each message in thread, then show next thread from search." diff --git a/test/emacs b/test/emacs index 9088ced..e6b0503 100755 --- a/test/emacs +++ b/test/emacs @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == TOTAL test_begin_subtest "notmuch-show: change tags of open messages in current buffer" -test_subtest_known_broken query="$os_x_darwin_thread" filter="from:Jiang" add_tag="notmuch-show-tag-all" -- 1.7.8.1