[PATCH v2 2/5] emacs: allow notmuch-tag to accept string inputs and prompt for tags
authorJameson Graef Rollins <jrollins@finestructure.net>
Sat, 14 Apr 2012 20:49:07 +0000 (13:49 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:24 +0000 (09:46 -0800)
46/a2f5e54c76e681f78eb5a0e01407af7acd95f4 [new file with mode: 0644]

diff --git a/46/a2f5e54c76e681f78eb5a0e01407af7acd95f4 b/46/a2f5e54c76e681f78eb5a0e01407af7acd95f4
new file mode 100644 (file)
index 0000000..d2baa17
--- /dev/null
@@ -0,0 +1,116 @@
+Return-Path: <jrollins@finestructure.net>\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 B1440431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:49:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] 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 9lKSyBEFQf0w for <notmuch@notmuchmail.org>;\r
+       Sat, 14 Apr 2012 13:49:09 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+       [131.215.239.19])\r
+       by olra.theworths.org (Postfix) with ESMTP id DD0BF431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:49:09 -0700 (PDT)\r
+Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+       by fire-doxen-postvirus (Postfix) with ESMTP id 7C039328031\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:49:09 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
+Received: from finestructure.net (unknown [76.89.193.65])\r
+       (Authenticated sender: jrollins)\r
+       by fire-doxen-submit (Postfix) with ESMTP id A11D032802A\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:49:07 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+       id 3FD2745D; Sat, 14 Apr 2012 13:49:07 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v2 2/5] emacs: allow notmuch-tag to accept string inputs and\r
+       prompt for tags\r
+Date: Sat, 14 Apr 2012 13:49:07 -0700\r
+Message-Id: <1334436547-10260-1-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <1334429574-12918-3-git-send-email-jrollins@finestructure.net>\r
+References: <1334429574-12918-3-git-send-email-jrollins@finestructure.net>\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, 14 Apr 2012 20:49:11 -0000\r
+\r
+notmuch-tag is extended to accept various formats of the tag changes.\r
+In particular, user prompting for tag changes is now incorporated\r
+here, so it is common for modes.\r
+\r
+The tag binary and the notmuch-{before,after}-tag-hooks are only\r
+called if tag changes is non-nil.\r
+\r
+In all cases tag-changes is returned as a list.\r
+---\r
+This addresses Mark Walters concerns in regards to a code comment.\r
+\r
+ emacs/notmuch-tag.el |   20 +++++++++++++++-----\r
+ 1 file changed, 15 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
+index c25cff8..0c0fc87 100644\r
+--- a/emacs/notmuch-tag.el\r
++++ b/emacs/notmuch-tag.el\r
+@@ -108,18 +108,26 @@ from TAGS if present."\r
+          (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))\r
+     (sort result-tags 'string<)))\r
\r
+-(defun notmuch-tag (query &rest tag-changes)\r
++(defun notmuch-tag (query &optional tag-changes)\r
+   "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
\r
+-TAG-CHANGES should be a list of strings of the form \"+tag\" or\r
+-\"-tag\" and QUERY should be a string containing the\r
+-search-query.\r
++QUERY should be a string containing the search-terms.\r
++TAG-CHANGES can take multiple forms.  If TAG-CHANGES is a list of\r
++strings of the form \"+tag\" or \"-tag\" then those are the tag\r
++changes applied.  If TAG-CHANGES is a string then it is\r
++interpreted as a single tag change.  If TAG-CHANGES is the string\r
++\"-\" or \"+\", or null, then the user is prompted to enter the\r
++tag changes.\r
\r
+ Note: Other code should always use this function alter tags of\r
+ messages instead of running (notmuch-call-notmuch-process \"tag\" ..)\r
+ directly, so that hooks specified in notmuch-before-tag-hook and\r
+ notmuch-after-tag-hook will be run."\r
+   ;; Perform some validation\r
++  (if (string-or-null-p tag-changes)\r
++      (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))\r
++        (setq tag-changes (notmuch-read-tag-changes tag-changes query))\r
++      (setq tag-changes (list tag-changes))))\r
+   (mapc (lambda (tag-change)\r
+         (unless (string-match-p "^[-+]\\S-+$" tag-change)\r
+           (error "Tag must be of the form `+this_tag' or `-that_tag'")))\r
+@@ -128,7 +136,9 @@ notmuch-after-tag-hook will be run."\r
+     (run-hooks 'notmuch-before-tag-hook)\r
+     (apply 'notmuch-call-notmuch-process "tag"\r
+          (append tag-changes (list "--" query)))\r
+-    (run-hooks 'notmuch-after-tag-hook)))\r
++    (run-hooks 'notmuch-after-tag-hook))\r
++  ;; in all cases we return tag-changes as a list\r
++  tag-changes)\r
\r
+ ;;\r
\r
+-- \r
+1.7.9.5\r
+\r