From fc463fe5b1b718f61eeb7f17d5691b0fd92a4021 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 23 Oct 2013 15:50:52 +2000 Subject: [PATCH] [PATCH 3/8] emacs: Use interactive specifications for tag changes in show --- 89/d1a8273c4b502b37b6c8e18fc593ff8df45c46 | 160 ++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 89/d1a8273c4b502b37b6c8e18fc593ff8df45c46 diff --git a/89/d1a8273c4b502b37b6c8e18fc593ff8df45c46 b/89/d1a8273c4b502b37b6c8e18fc593ff8df45c46 new file mode 100644 index 000000000..4bd0fdcbf --- /dev/null +++ b/89/d1a8273c4b502b37b6c8e18fc593ff8df45c46 @@ -0,0 +1,160 @@ +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 B7455429E35 + for ; Tue, 22 Oct 2013 12:51:24 -0700 (PDT) +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 0JfpifREDQeO for ; + Tue, 22 Oct 2013 12:51:19 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu + [18.9.25.14]) + by olra.theworths.org (Postfix) with ESMTP id 93524431E64 + for ; Tue, 22 Oct 2013 12:51:08 -0700 (PDT) +X-AuditID: 1209190e-b7f828e0000009cf-1f-5266d72a22e8 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id B2.0E.02511.A27D6625; Tue, 22 Oct 2013 15:51:06 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r9MJp3Rm030253; + Tue, 22 Oct 2013 15:51:04 -0400 +Received: from drake.dyndns.org (31-33-57.wireless.csail.mit.edu + [128.31.33.57]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9MJp1wi005194 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 22 Oct 2013 15:51:03 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1VYhym-0006yi-Oc; Tue, 22 Oct 2013 15:51:00 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 3/8] emacs: Use interactive specifications for tag changes in + show +Date: Tue, 22 Oct 2013 15:50:52 -0400 +Message-Id: <1382471457-26056-4-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.8.4.rc3 +In-Reply-To: <1382471457-26056-1-git-send-email-amdragon@mit.edu> +References: <1382471457-26056-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixCmqrat1PS3IYOdNFYvrN2cyOzB6PFt1 + izmAMYrLJiU1J7MstUjfLoEr48A2s4IHMhU3X/1la2D8Lt7FyMkhIWAi8eL5BmYIW0ziwr31 + bF2MXBxCAvsYJZa/aYByNjJK7L93hAmkSkjgGJPEq68hEIm5jBJ/fn4FS7AJaEhs27+cEcQW + EZCW2Hl3NmsXIwcHs4CaxJ8uFZCwsECQxLSzi8BKWARUJdbu2sQCYvMKOEgc2LuFEeIKJYmF + p7axgticAo4S0/f9YwMZIwRUc+oOxwRG/gWMDKsYZVNyq3RzEzNzilOTdYuTE/PyUot0jfVy + M0v0UlNKNzGCA0aSbwfj14NKhxgFOBiVeHgt2tOChFgTy4orcw8xSnIwKYnyRlwFCvEl5adU + ZiQWZ8QXleakFh9ilOBgVhLhbfYFyvGmJFZWpRblw6SkOViUxHlvctgHCQmkJ5akZqemFqQW + wWRlODiUJHgfgQwVLEpNT61Iy8wpQUgzcXCCDOcBGn4MpIa3uCAxtzgzHSJ/ilFRSpx3CUhC + ACSRUZoH1wuL6FeM4kCvCEO08wCTAVz3K6DBTECDpywBG1ySiJCSamDMyN75NvaGvJPDtSsq + Ed9nbld4u1N1nkB6cUeb+qp1P2OcTL8Ls6tdEZJ7XZGl3PpslyenqdH0Z9vf9RptX9v2/I1T + 9S4WuR3NP+ZUzFM7o3FxdYbxu4dWe3+mJkzI0b/xQuvtWRndMxv+xJvUXT71sVeOsZeJ86HY + C+tJs1K+ndqzYvqqrQzaSizFGYmGWsxFxYkAetusnsMCAAA= +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, 22 Oct 2013 19:51:25 -0000 + +This modifies all tagging operations in show to call +`notmuch-read-tag-changes' in their interactive specification to input +tag changes, rather than depending on lower-level functions to prompt +for tag changes regardless of their calling context. + +Besides being more Elispy and providing a more consistent programmatic +API, this enables callers to provide two call site-specific pieces of +information: an appropriate prompt, and the set of visible tags. The +prompt lets us differentiate * from +/-. Providing visible tags +enables a more consistent user experience than retrieving the +(potentially different) tags from the database, and avoids a +round-trip to the CLI and database. +--- + emacs/notmuch-show.el | 34 +++++++++++++++++++++------------- + 1 file changed, 21 insertions(+), 13 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 7325792..ef77839 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1780,23 +1780,29 @@ TAG-CHANGES is a list of tag operations for `notmuch-tag'." + (notmuch-tag (notmuch-show-get-message-id) tag-changes) + (notmuch-show-set-tags new-tags)))) + +-(defun notmuch-show-tag (&optional tag-changes) ++(defun notmuch-show-tag (tag-changes) + "Change tags for the current message. + + See `notmuch-tag' for information on the format of TAG-CHANGES." +- (interactive) +- (let* ((tag-changes (notmuch-tag (notmuch-show-get-message-id) tag-changes)) +- (current-tags (notmuch-show-get-tags)) ++ (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags) ++ "Tag message"))) ++ (notmuch-tag (notmuch-show-get-message-id) tag-changes) ++ (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)))) + +-(defun notmuch-show-tag-all (&optional tag-changes) ++(defun notmuch-show-tag-all (tag-changes) + "Change tags for all messages in the current show buffer. + + See `notmuch-tag' for information on the format of TAG-CHANGES." +- (interactive) +- (setq tag-changes (notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)) ++ (interactive ++ (list (let (tags) ++ (notmuch-show-mapc ++ (lambda () (setq tags (append (notmuch-show-get-tags) tags)))) ++ (delete-dups tags) ++ (notmuch-read-tag-changes tags "Tag thread")))) ++ (notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes) + (notmuch-show-mapc + (lambda () + (let* ((current-tags (notmuch-show-get-tags)) +@@ -1804,19 +1810,21 @@ See `notmuch-tag' for information on the format of TAG-CHANGES." + (unless (equal current-tags new-tags) + (notmuch-show-set-tags new-tags)))))) + +-(defun notmuch-show-add-tag () ++(defun notmuch-show-add-tag (tag-changes) + "Change tags for the current message (defaulting to add). + + Same as `notmuch-show-tag' but sets initial input to '+'." +- (interactive) +- (notmuch-show-tag "+")) ++ (interactive ++ (list (notmuch-read-tag-changes (notmuch-show-get-tags) "Tag message" "+"))) ++ (notmuch-show-tag tag-changes)) + +-(defun notmuch-show-remove-tag () ++(defun notmuch-show-remove-tag (tag-changes) + "Change tags for the current message (defaulting to remove). + + Same as `notmuch-show-tag' but sets initial input to '-'." +- (interactive) +- (notmuch-show-tag "-")) ++ (interactive ++ (list (notmuch-read-tag-changes (notmuch-show-get-tags) "Tag message" "-"))) ++ (notmuch-show-tag tag-changes)) + + (defun notmuch-show-toggle-visibility-headers () + "Toggle the visibility of the current message headers." +-- +1.8.4.rc3 + -- 2.26.2