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