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