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 CFA14431FBF for ; Tue, 22 Oct 2013 17:22:42 -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 SjPu9ujcn4EZ for ; Tue, 22 Oct 2013 17:22:37 -0700 (PDT) Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id B8A6F431FBC for ; Tue, 22 Oct 2013 17:22:16 -0700 (PDT) X-AuditID: 1209190f-b7fa08e0000009c6-c9-526716b84dd7 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 4E.A6.02502.8B617625; Tue, 22 Oct 2013 20:22:16 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r9N0M5gb017164; Tue, 22 Oct 2013 20:22:05 -0400 Received: from drake.dyndns.org (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [216.15.114.40]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9N0M3XF005841 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 22 Oct 2013 20:22:04 -0400 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1VYmD5-0008KI-Nt; Tue, 22 Oct 2013 20:22:03 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 3/8] emacs: Use interactive specifications for tag changes in show Date: Tue, 22 Oct 2013 20:21:56 -0400 Message-Id: <1382487721-31776-4-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1382487721-31776-1-git-send-email-amdragon@mit.edu> References: <1382487721-31776-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixG6nrrtDLD3IoHm7kMXquTwW12/OZHZg 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mt6sNCs4JlNx4MdDtgbGJ+JdjJwcEgImEpMn 3WGBsMUkLtxbz9bFyMUhJLCPUeLE8i1QzkZGib7/HewQzh0miYuTjkE5cxkldvfvYAfpZxPQ kNi2fzkjiC0iIC2x8+5sVhCbWcBR4vP+RWwgtrBAqMTUzTPB9rEIqEos/f8NrJ5XwEHiw6/p UHcoSSw8tQ2slxOo982OD2C9QkA1U3aeYZnAyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqR rolebmaJXmpK6SZGUCBxSvLvYPx2UOkQowAHoxIP74OWtCAh1sSy4srcQ4ySHExKorzq/OlB QnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4m32BynlTEiurUovyYVLSHCxK4rw3OeyDhATSE0tS s1NTC1KLYLIyHBxKErxMwIgREixKTU+tSMvMKUFIM3FwggznARquDFLDW1yQmFucmQ6RP8Wo KCXOe0YUKCEAksgozYPrhUX6K0ZxoFeEeZ+BVPEAkwRc9yugwUxAg6csAbm6uCQRISXVwKj9 q2fTqpm/mY67pyp26Jcz/5C2LXXaxvDU5N5RVtlPeqd+OzoXvzpz7mbRkYykedOs+Zok7LV+ /cssjD+xrCJ11wWlFa+X99wxEn5xv8/7o+Xctrl7d69imKSY9sU5IedB6xMNX6mJStdnMj1+ 550Za+BQl7W9o1CSXeYpn24/Y2Xy3sv3W5RYijMSDbWYi4oTAUgxkkTPAgAA 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: Wed, 23 Oct 2013 00:22:43 -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 | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7325792..f66d669 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1780,23 +1780,28 @@ 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)))) + (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 +1809,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