Re: [PATCH 3/6] emacs: make "+" and "-" tagging operations more robust
authorJeremy Nickurak <not-much@trk.nickurak.ca>
Sat, 28 Jan 2012 16:49:33 +0000 (09:49 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:28 +0000 (09:43 -0800)
b9/659021034103fd255dc0242cadfead021ccdf4 [new file with mode: 0644]

diff --git a/b9/659021034103fd255dc0242cadfead021ccdf4 b/b9/659021034103fd255dc0242cadfead021ccdf4
new file mode 100644 (file)
index 0000000..4af818a
--- /dev/null
@@ -0,0 +1,491 @@
+Return-Path: <jeremy@nickurak.ca>\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 34D0F431FBC\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 08:49:37 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7]\r
+       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 albkhuaxi1vt for <notmuch@notmuchmail.org>;\r
+       Sat, 28 Jan 2012 08:49:35 -0800 (PST)\r
+Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
+       [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 9AE26431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 08:49:35 -0800 (PST)\r
+Received: by qcpx40 with SMTP id x40so1767495qcp.26\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 08:49:34 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=nickurak.ca; s=google-dkim;\r
+       h=mime-version:sender:x-originating-ip:in-reply-to:references:date\r
+       :x-google-sender-auth:message-id:subject:from:to:cc:content-type\r
+       :content-transfer-encoding;\r
+       bh=LLshUyKd/l/DsQCeTB9H4gQbGM9vX1XCWio68YUjJ78=;\r
+       b=FZHZdgsuja8a9yeLLVzPIOtzqJG6ef8U3AsSzriP1caruNmpXcnoZWcm7cjUJVoMaU\r
+       Lxnyw3MkOb8wdglm+FhykMaHstxCYPTxsFnJZxUcyRMuRWTkzjSdfVxmtmNr73jmzRaY\r
+       ST+v909sCuAY+izIJoiEBWDjOkuqls+fT0xz0=\r
+MIME-Version: 1.0\r
+Received: by 10.224.193.66 with SMTP id dt2mr14127747qab.92.1327769373917;\r
+       Sat, 28 Jan 2012 08:49:33 -0800 (PST)\r
+Sender: jeremy@nickurak.ca\r
+Received: by 10.229.40.149 with HTTP; Sat, 28 Jan 2012 08:49:33 -0800 (PST)\r
+X-Originating-IP: [68.148.28.35]\r
+In-Reply-To: <1327725684-5887-3-git-send-email-dmitry.kurochkin@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
+Date: Sat, 28 Jan 2012 09:49:33 -0700\r
+X-Google-Sender-Auth: OSeSH6EVx_Xvqi41HewaQa8PWVM\r
+Message-ID:\r
+ <CA+eQo_0Ddb89pRELBsXSrrkC69PGGrm9fwYg5YGU8g59LqACvQ@mail.gmail.com>\r
+Subject: Re: [PATCH 3/6] emacs: make "+" and "-" tagging operations more\r
+ robust\r
+From: Jeremy Nickurak <not-much@trk.nickurak.ca>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\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 16:49:37 -0000\r
+\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
+\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 a=\r
+dd\r
+> and remove multiple tags. =C2=A0The only difference between "+" and "-" i=\r
+s\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 arg=\r
+s))\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" (&option=\r
+al 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-ta=\r
+gs))\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 curr=\r
+ent\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' e=\r
+xited 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 =C2=\r
+=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-tags=\r
+)\r
+> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq result-tags (push add-t=\r
+ag 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 re=\r
+sult-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 curr=\r
+ent-tags toadd)))\r
+> -\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(new-tags (notmuch-update-tags current-tags =\r
+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) c=\r
+hanged-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-message=\r
+-id))))\r
+> +(defun notmuch-show-tag (&optional initial-input)\r
+> + =C2=A0"Change tags for the current message, read input from the minibuf=\r
+fer."\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 curr=\r
+ent-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-output\r
+> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (apply 'call-process notmuch-=\r
+command nil t\r
+> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ni=\r
+l "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=A0ta=\r
+g-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-term=\r
+s)))\r
+> + =C2=A0 "\n+" t))\r
+>\r
+> =C2=A0(defun notmuch-select-tag-with-completion (prompt &rest search-term=\r
+s)\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=\r
+est 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" f=\r
+unction.\r
+> - =C2=A0 =C2=A0 =C2=A0 ;; Re-bind it to insert a space instead. =C2=A0Not=\r
+e 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-comp=\r
+letion-map)\r
+> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(define-key map " " 'self-insert-comm=\r
+and)\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 &res=\r
+t 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 'c=\r
+oncat "-")\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-t=\r
+erms)))\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(tag-list (append add-tag-list remove-tag-li=\r
+st))\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 w=\r
+ord" function.\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Re-bind it to insert a space instead. =C2=\r
+=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-com=\r
+pletion-map)\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (define-key map " " 'self-insert-com=\r
+mand)\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 -dro=\r
+p): 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 result.\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 changed-=\r
+tag 0 1))\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (tag (su=\r
+bstring 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 beg=\r
+ 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 en=\r
+d) " 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-find=\r
+-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 (po=\r
+int-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 m=\r
+ax-line))\r
+> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-set-tags (delete-dups (sort=\r
+ (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-find=\r
+-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-search=\r
+ 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-pos=\r
+ (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-li=\r
+ne max-line))\r
+> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-search-set-tags (delete tag (notmu=\r
+ch-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-search-=\r
+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 end)=\r
+)\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) (poi=\r
+nt)))\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(search-string (notmuch-search-find-thread-i=\r
+d-region-search beg end))\r
+> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(tags (notmuch-select-tags-with-completion i=\r
+nitial-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) (regi=\r
+on-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 e=\r
+nd))\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
+> =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 pre=\r
+fixed 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 -dro=\r
+p): 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