[PATCH 5/5] emacs: show tag completion
authorMark Walters <markwalters1009@gmail.com>
Fri, 30 Nov 2012 08:21:31 +0000 (08:21 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:12 +0000 (09:51 -0800)
a9/97c9f9425a1a0acef60817208656a609fe8b12 [new file with mode: 0644]

diff --git a/a9/97c9f9425a1a0acef60817208656a609fe8b12 b/a9/97c9f9425a1a0acef60817208656a609fe8b12
new file mode 100644 (file)
index 0000000..d454854
--- /dev/null
@@ -0,0 +1,138 @@
+Return-Path: <markwalters1009@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 E01ED431FD9\r
+       for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:44 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       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 BcPPxPnFZjD1 for <notmuch@notmuchmail.org>;\r
+       Fri, 30 Nov 2012 00:23:43 -0800 (PST)\r
+Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
+ [74.125.82.47])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 890B1429E2F   for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:28 -0800\r
+ (PST)\r
+Received: by mail-wg0-f47.google.com with SMTP id dq11so77771wgb.2\r
+       for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 00:23:27 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=9HqEC0BEnsSKkk4YUs6e8JVAZluwmFRZErzAeRmkf6A=;\r
+       b=hDAPu1dkQNSvGhxD7hBXQ0QgDMU1IlLMf/sqfgTjIpA71qBlqAxMnBeZhHmhzE5KAa\r
+       VI7iQo20LCtOzKWLEQEALTsLU9YHJeE09yCQl//inKfdOMjkaR9QawdEiYTtCmQ76lnJ\r
+       3xvHTpVisPTMIKf2w9MCidj1mxD3rBzwEJdXzqBowLjw2gZNzway+S4ZnaGTkWyJsURO\r
+       WM96bvwIJi5U1TuzI2e9BmM2laYcb54e5iScwQLIIXTkQ/qgf3bbynBanhorZCfcV9Bm\r
+       WhrDyBJDtYkROCnY2W7X6gOVnDb76mRC7MGfQwzzXaUCBQD8ACXi6UMO+xCS4GoUS2aq\r
+       Z/oA==\r
+Received: by 10.180.87.39 with SMTP id u7mr42399506wiz.6.1354263807247;\r
+       Fri, 30 Nov 2012 00:23:27 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id s12sm14297513wik.11.2012.11.30.00.23.25\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 30 Nov 2012 00:23:26 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/5] emacs: show tag completion\r
+Date: Fri, 30 Nov 2012 08:21:31 +0000\r
+Message-Id: <1354263691-19715-6-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354263691-19715-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354263691-19715-1-git-send-email-markwalters1009@gmail.com>\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: Fri, 30 Nov 2012 08:23:45 -0000\r
+\r
+From: markwalters1009 <markwalters1009@gmail.com>\r
+\r
+This makes tagging in show mode pass the list of tags that it believes\r
+occur to the tag completion function. This means that tag-completion\r
+will complete to any tag that the user can see (even if it is no\r
+longer present).\r
+---\r
+The function to get all tags for a thread was taken from Damien's\r
+notmuch-labeler series.\r
+\r
+ emacs/notmuch-show.el |   32 +++++++++++++++++++++++++-------\r
+ 1 files changed, 25 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 489e32c..c2fef7b 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1439,6 +1439,16 @@ current thread."\r
+   "Return the tags of the current message."\r
+   (notmuch-show-get-prop :tags))\r
+ \r
++(defun notmuch-show-thread-tags ()\r
++  "Return the list of tags for the current thread."\r
++  (let ((tags (list)))\r
++    (notmuch-show-mapc (lambda ()\r
++                       (mapcar (lambda (elt)\r
++                                 ;; Avoid adding duplicate tags\r
++                                 (add-to-list 'tags elt))\r
++                               (notmuch-show-get-tags))))\r
++    tags))\r
++\r
+ (defun notmuch-show-message-visible-p ()\r
+   "Is the current message visible?"\r
+   (notmuch-show-get-prop :message-visible))\r
+@@ -1730,9 +1740,13 @@ TAG-CHANGES is a list of tag operations for `notmuch-tag'."\r
+ \r
+ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+   (interactive)\r
+-  (setq tag-changes (funcall 'notmuch-tag (notmuch-show-get-message-id) tag-changes))\r
+-  (let* ((current-tags (notmuch-show-get-tags))\r
+-       (new-tags (notmuch-update-tags current-tags tag-changes)))\r
++  (let ((current-tags (notmuch-show-get-tags))\r
++      (new-tags))\r
++    (setq tag-changes (funcall 'notmuch-tag\r
++                             (notmuch-show-get-message-id)\r
++                             tag-changes\r
++                             current-tags))\r
++    (setq new-tags (notmuch-update-tags current-tags tag-changes))\r
+     (unless (equal current-tags new-tags)\r
+       (notmuch-show-set-tags new-tags))))\r
+ \r
+@@ -1741,13 +1755,17 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+ \r
+ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+   (interactive)\r
+-  (setq tag-changes (funcall 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes))\r
+-  (notmuch-show-mapc\r
+-   (lambda ()\r
++  (let ((existing-tags (notmuch-show-thread-tags)))\r
++    (setq tag-changes (funcall 'notmuch-tag\r
++                             (notmuch-show-get-messages-ids-search)\r
++                             tag-changes\r
++                             existing-tags))\r
++    (notmuch-show-mapc\r
++     (lambda ()\r
+      (let* ((current-tags (notmuch-show-get-tags))\r
+           (new-tags (notmuch-update-tags current-tags tag-changes)))\r
+        (unless (equal current-tags new-tags)\r
+-       (notmuch-show-set-tags new-tags))))))\r
++       (notmuch-show-set-tags new-tags)))))))\r
+ \r
+ (defun notmuch-show-add-tag ()\r
+   "Same as `notmuch-show-tag' but sets initial input to '+'."\r
+-- \r
+1.7.9.1\r
+\r