Re: [PATCH 3/6] emacs: make "+" and "-" tagging operations more robust
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sat, 28 Jan 2012 17:17:47 +0000 (21:17 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:28 +0000 (09:43 -0800)
15/5e215a0576361706afbe1156e72397be29c4c9 [new file with mode: 0644]

diff --git a/15/5e215a0576361706afbe1156e72397be29c4c9 b/15/5e215a0576361706afbe1156e72397be29c4c9
new file mode 100644 (file)
index 0000000..02785c7
--- /dev/null
@@ -0,0 +1,507 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 840EA431FDA\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 09:19:04 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id LSqPd5cVltuK for <notmuch@notmuchmail.org>;\r
+       Sat, 28 Jan 2012 09:19:01 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id BD979431FD2\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 09:19:00 -0800 (PST)\r
+Received: by bke11 with SMTP id 11so176016bke.26\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 09:18:59 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+       :message-id:mime-version:content-type:content-transfer-encoding;\r
+       bh=HOkTn2/KsE9BrrqbY9XecSxJjN/Quq7tnsqZCNdiVzs=;\r
+       b=b0Okv806WPlrafSq7MffoWNVeIi+OZvjyq9AVP2SGQQBc18FUfvsMuH7HyrKgA5zli\r
+       mgei5JH8Lc9jnFs6JpLnJhGdP6V5B2yGjISBchSBzio0pFcFxjU0ejwPNGfwD+ypKoud\r
+       G9Pomyvnm5mA1MUDGW5DrmZkDptAvB5OFL8GQ=\r
+Received: by 10.204.10.65 with SMTP id o1mr5321645bko.19.1327771137649;\r
+       Sat, 28 Jan 2012 09:18:57 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id ez5sm24395359bkc.15.2012.01.28.09.18.56\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 28 Jan 2012 09:18:56 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Jeremy Nickurak <not-much@trk.nickurak.ca>\r
+Subject: Re: [PATCH 3/6] emacs: make "+" and "-" tagging operations more\r
+ robust\r
+In-Reply-To:\r
+ <CA+eQo_0Ddb89pRELBsXSrrkC69PGGrm9fwYg5YGU8g59LqACvQ@mail.gmail.com>\r
+References: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+       <1327725684-5887-3-git-send-email-dmitry.kurochkin@gmail.com>\r
+       <CA+eQo_0Ddb89pRELBsXSrrkC69PGGrm9fwYg5YGU8g59LqACvQ@mail.gmail.com>\r
+User-Agent: Notmuch/0.11+134~g7ddba9d (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sat, 28 Jan 2012 21:17:47 +0400\r
+Message-ID: <87pqe3926c.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 28 Jan 2012 17:19:04 -0000\r
+\r
+On Sat, 28 Jan 2012 09:49:33 -0700, Jeremy Nickurak <not-much@trk.nickurak.=\r
+ca> wrote:\r
+> Is it safe to assume that any reasonable seperator (comma, space,\r
+> semicolon, plus or minus sign, anything) won't show up in a tag name?\r
+>=20\r
+\r
+No.  Threre are existing issues with tag names that contain "unexpected"\r
+characters.  This series does not aim to resolve them and not make it\r
+worse.  Also see Jani's reply to another patch in the series.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+[1] id:"CAB+hUn834oJ+XGx-YyYSGxSnzrBYCMvcu4Vd73ws28qTS2riuA@mail.gmail.com"\r
+\r
+> On Fri, Jan 27, 2012 at 21:41, Dmitry Kurochkin\r
+> <dmitry.kurochkin@gmail.com> wrote:\r
+> > Before the change, "+" and "-" tagging operations in notmuch-search\r
+> > and notmuch-show views accepted only a single tag. =C2=A0The patch makes\r
+> > them use the recently added `notmuch-select-tags-with-completion'\r
+> > function, which allows to enter multiple tags with "+" and "-"\r
+> > prefixes. =C2=A0So after the change, "+" and "-" bindings allow to both=\r
+ add\r
+> > and remove multiple tags. =C2=A0The only difference between "+" and "-"=\r
+ is\r
+> > the minibuffer initial input ("+" and "-" respectively).\r
+> > ---\r
+> > =C2=A0emacs/notmuch-show.el | =C2=A0 65 +++++++------------\r
+> > =C2=A0emacs/notmuch.el =C2=A0 =C2=A0 =C2=A0| =C2=A0165 ++++++++++++++++=\r
++++++++++------------------------\r
+> > =C2=A02 files changed, 107 insertions(+), 123 deletions(-)\r
+> >\r
+> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> > index 84ac624..03eadfb 100644\r
+> > --- a/emacs/notmuch-show.el\r
+> > +++ b/emacs/notmuch-show.el\r
+> > @@ -38,8 +38,9 @@\r
+> >\r
+> > =C2=A0(declare-function notmuch-call-notmuch-process "notmuch" (&rest a=\r
+rgs))\r
+> > =C2=A0(declare-function notmuch-fontify-headers "notmuch" nil)\r
+> > -(declare-function notmuch-select-tag-with-completion "notmuch" (prompt=\r
+ &rest search-terms))\r
+> > +(declare-function notmuch-select-tags-with-completion "notmuch" (&opti=\r
+onal initial-input &rest search-terms))\r
+> > =C2=A0(declare-function notmuch-search-show-thread "notmuch" nil)\r
+> > +(declare-function notmuch-update-tags "notmuch" (current-tags changed-=\r
+tags))\r
+> >\r
+> > =C2=A0(defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date")\r
+> > =C2=A0 "Headers that should be shown in a message, in this order.\r
+> > @@ -1267,7 +1268,7 @@ Some useful entries are:\r
+> >\r
+> > =C2=A0(defun notmuch-show-mark-read ()\r
+> > =C2=A0 "Mark the current message as read."\r
+> > - =C2=A0(notmuch-show-remove-tag "unread"))\r
+> > + =C2=A0(notmuch-show-tag-message "-unread"))\r
+> >\r
+> > =C2=A0;; Functions for getting attributes of several messages in the cu=\r
+rrent\r
+> > =C2=A0;; thread.\r
+> > @@ -1470,51 +1471,33 @@ than only the current message."\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message (format "Command '%s'=\r
+ exited abnormally with code %d"\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =\r
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 shell-command exit-code))))))))\r
+> >\r
+> > -(defun notmuch-show-add-tags-worker (current-tags add-tags)\r
+> > - =C2=A0"Add to `current-tags' with any tags from `add-tags' not\r
+> > -currently present and return the result."\r
+> > - =C2=A0(let ((result-tags (copy-sequence current-tags)))\r
+> > - =C2=A0 =C2=A0(mapc (lambda (add-tag)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (member add-tag current-ta=\r
+gs)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq result-tags (push add=\r
+-tag result-tags))))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 add-tags)\r
+> > - =C2=A0 =C2=A0(sort result-tags 'string<)))\r
+> > -\r
+> > -(defun notmuch-show-del-tags-worker (current-tags del-tags)\r
+> > - =C2=A0"Remove any tags in `del-tags' from `current-tags' and return\r
+> > -the result."\r
+> > - =C2=A0(let ((result-tags (copy-sequence current-tags)))\r
+> > - =C2=A0 =C2=A0(mapc (lambda (del-tag)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq result-tags (delete del-tag =\r
+result-tags)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 del-tags)\r
+> > - =C2=A0 =C2=A0result-tags))\r
+> > -\r
+> > -(defun notmuch-show-add-tag (&rest toadd)\r
+> > - =C2=A0"Add a tag to the current message."\r
+> > - =C2=A0(interactive\r
+> > - =C2=A0 (list (notmuch-select-tag-with-completion "Tag to add: ")))\r
+> > +(defun notmuch-show-tag-message (&rest changed-tags)\r
+> > + =C2=A0"Change tags for the current message.\r
+> >\r
+> > +`Changed-tags' is a list of tag operations for \"notmuch tag\",\r
+> > +i.e. a list of tags to change with '+' and '-' prefixes."\r
+> > =C2=A0 (let* ((current-tags (notmuch-show-get-tags))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0(new-tags (notmuch-show-add-tags-worker cu=\r
+rrent-tags toadd)))\r
+> > -\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(new-tags (notmuch-update-tags current-tag=\r
+s changed-tags)))\r
+> > =C2=A0 =C2=A0 (unless (equal current-tags new-tags)\r
+> > - =C2=A0 =C2=A0 =C2=A0(apply 'notmuch-tag (notmuch-show-get-message-id)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(mapcar (lambda (s) (concat =\r
+"+" s)) toadd))\r
+> > + =C2=A0 =C2=A0 =C2=A0(apply 'notmuch-tag (notmuch-show-get-message-id)=\r
+ changed-tags)\r
+> > =C2=A0 =C2=A0 =C2=A0 (notmuch-show-set-tags new-tags))))\r
+> >\r
+> > -(defun notmuch-show-remove-tag (&rest toremove)\r
+> > - =C2=A0"Remove a tag from the current message."\r
+> > - =C2=A0(interactive\r
+> > - =C2=A0 (list (notmuch-select-tag-with-completion\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Tag to remove: " (notmuch-show-get-messa=\r
+ge-id))))\r
+> > +(defun notmuch-show-tag (&optional initial-input)\r
+> > + =C2=A0"Change tags for the current message, read input from the minib=\r
+uffer."\r
+> > + =C2=A0(interactive)\r
+> > + =C2=A0(let ((changed-tags (notmuch-select-tags-with-completion\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0initial-input (notmuch-show-get-message-id))))\r
+> > + =C2=A0 =C2=A0(apply 'notmuch-show-tag-message changed-tags)))\r
+> >\r
+> > - =C2=A0(let* ((current-tags (notmuch-show-get-tags))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0(new-tags (notmuch-show-del-tags-worker cu=\r
+rrent-tags toremove)))\r
+> > +(defun notmuch-show-add-tag ()\r
+> > + =C2=A0"Same as `notmuch-show-tag' but sets initial input to '+'."\r
+> > + =C2=A0(interactive)\r
+> > + =C2=A0(notmuch-show-tag "+"))\r
+> >\r
+> > - =C2=A0 =C2=A0(unless (equal current-tags new-tags)\r
+> > - =C2=A0 =C2=A0 =C2=A0(apply 'notmuch-tag (notmuch-show-get-message-id)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(mapcar (lambda (s) (concat =\r
+"-" s)) toremove))\r
+> > - =C2=A0 =C2=A0 =C2=A0(notmuch-show-set-tags new-tags))))\r
+> > +(defun notmuch-show-remove-tag ()\r
+> > + =C2=A0"Same as `notmuch-show-tag' but sets initial input to '-'."\r
+> > + =C2=A0(interactive)\r
+> > + =C2=A0(notmuch-show-tag "-"))\r
+> >\r
+> > =C2=A0(defun notmuch-show-toggle-headers ()\r
+> > =C2=A0 "Toggle the visibility of the current message headers."\r
+> > @@ -1559,7 +1542,7 @@ argument, hide all of the messages."\r
+> > =C2=A0(defun notmuch-show-archive-thread-internal (show-next)\r
+> > =C2=A0 ;; Remove the tag from the current set of messages.\r
+> > =C2=A0 (goto-char (point-min))\r
+> > - =C2=A0(loop do (notmuch-show-remove-tag "inbox")\r
+> > + =C2=A0(loop do (notmuch-show-tag-message "-inbox")\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0until (not (notmuch-show-goto-message-next)))\r
+> > =C2=A0 ;; Move to the next item in the search results, if any.\r
+> > =C2=A0 (let ((parent-buffer notmuch-show-parent-buffer))\r
+> > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> > index ff46617..24b0ea3 100644\r
+> > --- a/emacs/notmuch.el\r
+> > +++ b/emacs/notmuch.el\r
+> > @@ -76,38 +76,56 @@ For example:\r
+> > =C2=A0(defvar notmuch-query-history nil\r
+> > =C2=A0 "Variable to store minibuffer history for notmuch queries")\r
+> >\r
+> > -(defun notmuch-tag-completions (&optional prefixes search-terms)\r
+> > - =C2=A0(let ((tag-list\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0(split-string\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (with-output-to-string\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (with-current-buffer standard-outp=\r
+ut\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (apply 'call-process notmuc=\r
+h-command nil t\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+nil "search-tags" search-terms)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 "\n+" t)))\r
+> > - =C2=A0 =C2=A0(if (null prefixes)\r
+> > - =C2=A0 =C2=A0 =C2=A0 tag-list\r
+> > - =C2=A0 =C2=A0 =C2=A0(apply #'append\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(mapcar (lambda (tag)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0(mapcar (lambda (prefix)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(concat prefix tag)) prefixes))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+tag-list)))))\r
+> > +(defun notmuch-tag-completions (&optional search-terms)\r
+> > + =C2=A0(split-string\r
+> > + =C2=A0 (with-output-to-string\r
+> > + =C2=A0 =C2=A0 (with-current-buffer standard-output\r
+> > + =C2=A0 =C2=A0 =C2=A0 (apply 'call-process notmuch-command nil t\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nil "search-tags" search-te=\r
+rms)))\r
+> > + =C2=A0 "\n+" t))\r
+> >\r
+> > =C2=A0(defun notmuch-select-tag-with-completion (prompt &rest search-te=\r
+rms)\r
+> > - =C2=A0(let ((tag-list (notmuch-tag-completions nil search-terms)))\r
+> > + =C2=A0(let ((tag-list (notmuch-tag-completions search-terms)))\r
+> > =C2=A0 =C2=A0 (completing-read prompt tag-list)))\r
+> >\r
+> > -(defun notmuch-select-tags-with-completion (prompt &optional prefixes =\r
+&rest search-terms)\r
+> > - =C2=A0(let ((tag-list (notmuch-tag-completions prefixes search-terms))\r
+> > - =C2=A0 =C2=A0 =C2=A0 (crm-separator " ")\r
+> > - =C2=A0 =C2=A0 =C2=A0 ;; By default, space is bound to "complete word"=\r
+ function.\r
+> > - =C2=A0 =C2=A0 =C2=A0 ;; Re-bind it to insert a space instead. =C2=A0N=\r
+ote that <tab>\r
+> > - =C2=A0 =C2=A0 =C2=A0 ;; still does the completion.\r
+> > - =C2=A0 =C2=A0 =C2=A0 (crm-local-completion-map\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((map (make-sparse-keymap)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(set-keymap-parent map crm-local-co=\r
+mpletion-map)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(define-key map " " 'self-insert-co=\r
+mmand)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0map)))\r
+> > - =C2=A0 =C2=A0(delete "" (completing-read-multiple prompt tag-list))))\r
+> > +(defun notmuch-select-tags-with-completion (&optional initial-input &r=\r
+est search-terms)\r
+> > + =C2=A0(let* ((add-tag-list (mapcar (apply-partially 'concat "+")\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-tag-completions)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(remove-tag-list (mapcar (apply-partially =\r
+'concat "-")\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-tag-completions search-=\r
+terms)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(tag-list (append add-tag-list remove-tag-=\r
+list))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(crm-separator " ")\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0;; By default, space is bound to "complete=\r
+ word" function.\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Re-bind it to insert a space instead. =\r
+=C2=A0Note that <tab>\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0;; still does the completion.\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(crm-local-completion-map\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((map (make-sparse-keymap)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-keymap-parent map crm-local-c=\r
+ompletion-map)\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (define-key map " " 'self-insert-c=\r
+ommand)\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 map)))\r
+> > + =C2=A0 =C2=A0(delete "" (completing-read-multiple\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Operations (+add -d=\r
+rop): notmuch tag " tag-list nil\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nil initial-input))))\r
+> > +\r
+> > +(defun notmuch-update-tags (current-tags changed-tags)\r
+> > + =C2=A0"Update `current-tags' with `changed-tags' and return the resul=\r
+t.\r
+> > +\r
+> > +`Changed-tags' is a list of tag operations given to \"notmuch\r
+> > +tag\", i.e. a list of changed tags with '+' and '-' prefixes."\r
+> > + =C2=A0(let ((result-tags (copy-sequence current-tags)))\r
+> > + =C2=A0 =C2=A0(mapc (lambda (changed-tag)\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (string=3D changed-tag "")\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((op (substring change=\r
+d-tag 0 1))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (tag (=\r
+substring changed-tag 1)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cond ((string=3D op=\r
+ "+")\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0(unless (member tag result-tags)\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0 =C2=A0(push tag result-tags)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ ((string=3D op "-")\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0(setq result-tags (delete tag result-tags)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ (t\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0(error "Changed tag must be of the form `+this_tag' or `-that_tag'")=\r
+)))))\r
+> > + =C2=A0 =C2=A0 =C2=A0 changed-tags)\r
+> > + =C2=A0 =C2=A0(sort result-tags 'string<)))\r
+> >\r
+> > =C2=A0(defun notmuch-foreach-mime-part (function mm-handle)\r
+> > =C2=A0 (cond ((stringp (car mm-handle))\r
+> > @@ -447,6 +465,10 @@ Complete list of currently available key bindings:\r
+> > =C2=A0 "Return a list of threads for the current region"\r
+> > =C2=A0 (notmuch-search-properties-in-region 'notmuch-search-thread-id b=\r
+eg end))\r
+> >\r
+> > +(defun notmuch-search-find-thread-id-region-search (beg end)\r
+> > + =C2=A0"Return a search string for threads for the current region"\r
+> > + =C2=A0(mapconcat 'identity (notmuch-search-find-thread-id-region beg =\r
+end) " or "))\r
+> > +\r
+> > =C2=A0(defun notmuch-search-find-authors ()\r
+> > =C2=A0 "Return the authors for the current thread"\r
+> > =C2=A0 (get-text-property (point) 'notmuch-search-authors))\r
+> > @@ -590,74 +612,55 @@ the messages that were tagged"\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-line 1))\r
+> > =C2=A0 =C2=A0 =C2=A0 output)))\r
+> >\r
+> > -(defun notmuch-search-add-tag-thread (tag)\r
+> > - =C2=A0(notmuch-search-add-tag-region tag (point) (point)))\r
+> > +(defun notmuch-search-tag-thread (&rest tags)\r
+> > + =C2=A0"Change tags for the currently selected thread.\r
+> >\r
+> > -(defun notmuch-search-add-tag-region (tag beg end)\r
+> > - =C2=A0(let ((search-id-string (mapconcat 'identity (notmuch-search-fi=\r
+nd-thread-id-region beg end) " or ")))\r
+> > - =C2=A0 =C2=A0(notmuch-tag search-id-string (concat "+" tag))\r
+> > - =C2=A0 =C2=A0(save-excursion\r
+> > - =C2=A0 =C2=A0 =C2=A0(let ((last-line (line-number-at-pos end))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (max-line (- (line-number-at-pos (=\r
+point-max)) 2)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 (goto-char beg)\r
+> > - =C2=A0 =C2=A0 =C2=A0 (while (<=3D (line-number-at-pos) (min last-line=\r
+ max-line))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-set-tags (delete-dups (so=\r
+rt (cons tag (notmuch-search-get-tags)) 'string<)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (forward-line))))))\r
+> > +See `notmuch-search-tag-region' for details."\r
+> > + =C2=A0(apply 'notmuch-search-tag-region (point) (point) tags))\r
+> >\r
+> > -(defun notmuch-search-remove-tag-thread (tag)\r
+> > - =C2=A0(notmuch-search-remove-tag-region tag (point) (point)))\r
+> > +(defun notmuch-search-tag-region (beg end &rest tags)\r
+> > + =C2=A0"Change tags for threads in the given region.\r
+> >\r
+> > -(defun notmuch-search-remove-tag-region (tag beg end)\r
+> > - =C2=A0(let ((search-id-string (mapconcat 'identity (notmuch-search-fi=\r
+nd-thread-id-region beg end) " or ")))\r
+> > - =C2=A0 =C2=A0(notmuch-tag search-id-string (concat "-" tag))\r
+> > +`Tags' is a list of tag operations for \"notmuch tag\", i.e. a\r
+> > +list of tags to change with '+' and '-' prefixes. =C2=A0The tags are\r
+> > +added or removed for all threads in the region from `beg' to\r
+> > +`end'."\r
+> > + =C2=A0(let ((search-string (notmuch-search-find-thread-id-region-sear=\r
+ch beg end)))\r
+> > + =C2=A0 =C2=A0(apply 'notmuch-tag search-string tags)\r
+> > =C2=A0 =C2=A0 (save-excursion\r
+> > =C2=A0 =C2=A0 =C2=A0 (let ((last-line (line-number-at-pos end))\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(max-line (- (line-number-at-p=\r
+os (point-max)) 2)))\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char beg)\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (<=3D (line-number-at-pos) (min last-=\r
+line max-line))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-set-tags (delete tag (not=\r
+much-search-get-tags)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-set-tags\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-update-tags (notmuch-searc=\r
+h-get-tags) tags))\r
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-line))))))\r
+> >\r
+> > -(defun notmuch-search-add-tag (tag)\r
+> > - =C2=A0"Add a tag to the currently selected thread or region.\r
+> > -\r
+> > -The tag is added to all messages in the currently selected thread\r
+> > -or threads in the current region."\r
+> > - =C2=A0(interactive\r
+> > - =C2=A0 (list (notmuch-select-tag-with-completion "Tag to add: ")))\r
+> > - =C2=A0(save-excursion\r
+> > - =C2=A0 =C2=A0(if (region-active-p)\r
+> > - =C2=A0 =C2=A0 =C2=A0 (let* ((beg (region-beginning))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(end (region-end)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-add-tag-region tag beg en=\r
+d))\r
+> > - =C2=A0 =C2=A0 =C2=A0(notmuch-search-add-tag-thread tag))))\r
+> > -\r
+> > -(defun notmuch-search-remove-tag (tag)\r
+> > - =C2=A0"Remove a tag from the currently selected thread or region.\r
+> > +(defun notmuch-search-tag (&optional initial-input)\r
+> > + =C2=A0"Change tags for the currently selected thread or region."\r
+> > + =C2=A0(interactive)\r
+> > + =C2=A0(let* ((beg (if (region-active-p) (region-beginning) (point)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(end (if (region-active-p) (region-end) (p=\r
+oint)))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(search-string (notmuch-search-find-thread=\r
+-id-region-search beg end))\r
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(tags (notmuch-select-tags-with-completion=\r
+ initial-input search-string)))\r
+> > + =C2=A0 =C2=A0(apply 'notmuch-search-tag-region beg end tags)))\r
+> > +\r
+> > +(defun notmuch-search-add-tag ()\r
+> > + =C2=A0"Same as `notmuch-search-tag' but sets initial input to '+'."\r
+> > + =C2=A0(interactive)\r
+> > + =C2=A0(notmuch-search-tag "+"))\r
+> >\r
+> > -The tag is removed from all messages in the currently selected\r
+> > -thread or threads in the current region."\r
+> > - =C2=A0(interactive\r
+> > - =C2=A0 (list (notmuch-select-tag-with-completion\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Tag to remove: "\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (region-active-p)\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (mapconcat 'identity\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0 =C2=A0(notmuch-search-find-thread-id-region (region-beginning) (reg=\r
+ion-end))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=\r
+ =C2=A0 =C2=A0" ")\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-find-thread-id)))))\r
+> > - =C2=A0(save-excursion\r
+> > - =C2=A0 =C2=A0(if (region-active-p)\r
+> > - =C2=A0 =C2=A0 =C2=A0 (let* ((beg (region-beginning))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(end (region-end)))\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-remove-tag-region tag beg=\r
+ end))\r
+> > - =C2=A0 =C2=A0 =C2=A0(notmuch-search-remove-tag-thread tag))))\r
+> > +(defun notmuch-search-remove-tag ()\r
+> > + =C2=A0"Same as `notmuch-search-tag' but sets initial input to '-'."\r
+> > + =C2=A0(interactive)\r
+> > + =C2=A0(notmuch-search-tag "-"))\r
+> >\r
+> > =C2=A0(defun notmuch-search-archive-thread ()\r
+> > =C2=A0 "Archive the currently selected thread (remove its \"inbox\" tag=\r
+).\r
+> >\r
+> > =C2=A0This function advances the next thread when finished."\r
+> > =C2=A0 (interactive)\r
+> > - =C2=A0(notmuch-search-remove-tag-thread "inbox")\r
+> > + =C2=A0(notmuch-search-tag-thread "-inbox")\r
+> > =C2=A0 (notmuch-search-next-thread))\r
+> >\r
+> > =C2=A0(defvar notmuch-search-process-filter-data nil\r
+> > @@ -893,9 +896,7 @@ will prompt for tags to be added or removed. Tags p=\r
+refixed with\r
+> > =C2=A0Each character of the tag name may consist of alphanumeric\r
+> > =C2=A0characters as well as `_.+-'.\r
+> > =C2=A0"\r
+> > - =C2=A0(interactive (notmuch-select-tags-with-completion\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Operations (+add -d=\r
+rop): notmuch tag "\r
+> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '("+" "-")))\r
+> > + =C2=A0(interactive (notmuch-select-tags-with-completion))\r
+> > =C2=A0 (apply 'notmuch-tag notmuch-search-query-string actions))\r
+> >\r
+> > =C2=A0(defun notmuch-search-buffer-title (query)\r
+> > --\r
+> > 1.7.8.3\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r