[PATCH 1/2] emacs: allow saved searches to select tree-view
authorMark Walters <markwalters1009@gmail.com>
Wed, 14 Oct 2015 08:38:22 +0000 (09:38 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:44 +0000 (14:49 -0700)
c3/5a7234f6a3e40107180683075bc569cfe0ece9 [new file with mode: 0644]

diff --git a/c3/5a7234f6a3e40107180683075bc569cfe0ece9 b/c3/5a7234f6a3e40107180683075bc569cfe0ece9
new file mode 100644 (file)
index 0000000..84f604f
--- /dev/null
@@ -0,0 +1,148 @@
+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 arlo.cworth.org (Postfix) with ESMTP id E3D526DE177D\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Oct 2015 01:38:49 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.578\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.578 tagged_above=-999 required=5\r
+ tests=[AWL=-0.008, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id xomYsON1JWjc for <notmuch@notmuchmail.org>;\r
+ Wed, 14 Oct 2015 01:38:48 -0700 (PDT)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+ [209.85.212.181])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 608926DE1789\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Oct 2015 01:38:41 -0700 (PDT)\r
+Received: by wicgb1 with SMTP id gb1so120071259wic.1\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Oct 2015 01:38:39 -0700 (PDT)\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:in-reply-to:references;\r
+ bh=kE0PTwl/Xl0PL124w5W7pYsOgMKusWUWr6oXbKOLX9I=;\r
+ b=RoSa3cMj2h8NByr9BO2hex/6hq4NMS232buwcA1SV6Tu4C12g0/gl/HWlqIYtTWXkI\r
+ OfY9qxzqyJ/0e0/Zs1VuGXcWM8yUfJIsuDb5xQUkEyZFHQXt3Ze9+1DqM1/kPVhCZGjt\r
+ 9LrHsgX1UyD9C2shqEYk8m21q64l051Q2HSmNz7Wr9mr5jDQChctJPK4FBimfczey5JN\r
+ 5rPsFcpXDLcZfR0Vgdw3RKnlLgPZvPfaa9ZIUyWcHOIobdau7F6sIixbknIAwUBziny/\r
+ 1taFr2MkJgfGznuY3WlY7vi/CXncWRfytMzrYy8zKV3gOHZp7gmouPV5GYH72PlFEWrA\r
+ lSWg==\r
+X-Received: by 10.194.84.42 with SMTP id v10mr2753699wjy.1.1444811918774;\r
+ Wed, 14 Oct 2015 01:38:38 -0700 (PDT)\r
+Received: from localhost ([161.23.118.65])\r
+ by smtp.gmail.com with ESMTPSA id z2sm6171989wij.1.2015.10.14.01.38.37\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Wed, 14 Oct 2015 01:38:37 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] emacs: allow saved searches to select tree-view\r
+Date: Wed, 14 Oct 2015 09:38:22 +0100\r
+Message-Id: <1444811903-16741-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1444811903-16741-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1444811903-16741-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Wed, 14 Oct 2015 08:38:50 -0000\r
+\r
+This patch allows the user to customize a saved search to choose tree\r
+view rather than the default search view. It also updates notmuch-jump\r
+so that it respects this choice.\r
+---\r
+ emacs/notmuch-hello.el | 21 ++++++++++++++++-----\r
+ emacs/notmuch-jump.el  |  4 +++-\r
+ 2 files changed, 19 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 7bfa752..d9fe3ff 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -28,6 +28,8 @@\r
\r
+ (declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))\r
+ (declare-function notmuch-poll "notmuch" ())\r
++(declare-function notmuch-tree "notmuch-tree"\r
++                  (&optional query query-context target buffer-name open-target))\r
\r
+ (defun notmuch-saved-search-get (saved-search field)\r
+   "Get FIELD from SAVED-SEARCH.\r
+@@ -91,7 +93,11 @@ searches so they still work in customize."\r
+                           (choice :tag " Sort Order"\r
+                                   (const :tag "Default" nil)\r
+                                   (const :tag "Oldest-first" oldest-first)\r
+-                                  (const :tag "Newest-first" newest-first))))))\r
++                                  (const :tag "Newest-first" newest-first)))\r
++                   (group :format "%v" :inline t (const :format "" :search-type)\r
++                          (choice :tag " Search Type"\r
++                                  (const :tag "Search mode" nil)\r
++                                  (const :tag "Tree mode" tree))))))\r
\r
+ (defcustom notmuch-saved-searches\r
+   `((:name "inbox" :query "tag:inbox" :key ,(kbd "i"))\r
+@@ -425,10 +431,13 @@ diagonal."\r
+         append (notmuch-hello-reflect-generate-row ncols nrows row list))))\r
\r
+ (defun notmuch-hello-widget-search (widget &rest ignore)\r
+-  (notmuch-search (widget-get widget\r
+-                            :notmuch-search-terms)\r
+-                (widget-get widget\r
+-                            :notmuch-search-oldest-first)))\r
++  (if (widget-get widget :notmuch-search-type)\r
++      (notmuch-tree (widget-get widget\r
++                              :notmuch-search-terms))\r
++    (notmuch-search (widget-get widget\r
++                              :notmuch-search-terms)\r
++                  (widget-get widget\r
++                              :notmuch-search-oldest-first))))\r
\r
+ (defun notmuch-saved-search-count (search)\r
+   (car (process-lines notmuch-command "count" search)))\r
+@@ -564,6 +573,7 @@ with `notmuch-hello-query-counts'."\r
+                                    (newest-first nil)\r
+                                    (oldest-first t)\r
+                                    (otherwise notmuch-search-oldest-first)))\r
++                   (search-type (eq (plist-get elem :search-type) 'tree))\r
+                    (msg-count (plist-get elem :count)))\r
+               (widget-insert (format "%8s "\r
+                                      (notmuch-hello-nice-number msg-count)))\r
+@@ -571,6 +581,7 @@ with `notmuch-hello-query-counts'."\r
+                              :notify #'notmuch-hello-widget-search\r
+                              :notmuch-search-terms query\r
+                              :notmuch-search-oldest-first oldest-first\r
++                             :notmuch-search-type search-type\r
+                              name)\r
+               (setq column-indent\r
+                     (1+ (max 0 (- column-width (length name)))))))\r
+diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el\r
+index 20e24b2..506ae2c 100644\r
+--- a/emacs/notmuch-jump.el\r
++++ b/emacs/notmuch-jump.el\r
+@@ -54,7 +54,9 @@ fast way to jump to a saved search from anywhere in Notmuch."\r
+                  (oldest-first t)\r
+                  (otherwise (default-value 'notmuch-search-oldest-first)))))\r
+           (push (list key name\r
+-                      `(lambda () (notmuch-search ',query ',oldest-first)))\r
++                      (if (eq (plist-get saved-search :search-type) 'tree)\r
++                          `(lambda () (notmuch-tree ',query))\r
++                        `(lambda () (notmuch-search ',query ',oldest-first))))\r
+                 action-map)))))\r
+     (setq action-map (nreverse action-map))\r
\r
+-- \r
+2.1.4\r
+\r