unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/7] emacs: hello: separate out the saved-search display function
Date: Sun, 11 May 2014 09:34:36 +0100	[thread overview]
Message-ID: <1399797282-20389-2-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com>

Separate the code that prints a saved-search and count into its own
function.
---
 emacs/notmuch-hello.el |   30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 3de5238..0a7004c 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -475,6 +475,22 @@ (defun notmuch-hello-filtered-query (query filter)
     (concat "(" query ") and (" filter ")"))
    (t query)))
 
+(defun notmuch-hello-batch-message-count (elem-plist options)
+  "Update the message count for a saved search.
+
+This takes the next line in the current buffer (the output from a
+call to notmuch count --batch) as the message count and sets
+the :count property in ELEM-PLIST to it."
+  (let* ((count (prog1 (read (current-buffer))
+		  (forward-line 1)))
+	 (search-query (plist-get elem-plist :query))
+	 (filtered-query (notmuch-hello-filtered-query
+			  search-query (plist-get options :filter))))
+    (when (and filtered-query (or (plist-get options :show-empty-searches)
+				  (> count 0)))
+      (setq elem-plist (plist-put elem-plist :query filtered-query))
+      (plist-put elem-plist :count (notmuch-hello-nice-number count)))))
+
 (defun notmuch-hello-query-counts (query-list &rest options)
   "Compute list of counts of matched messages from QUERY-LIST.
 
@@ -514,15 +530,8 @@ (defun notmuch-hello-query-counts (query-list &rest options)
      #'identity
      (mapcar
       (lambda (elem)
-	(let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
-	       (search-query (plist-get elem-plist :query))
-	       (filtered-query (notmuch-hello-filtered-query
-				search-query (plist-get options :filter)))
-	       (message-count (prog1 (read (current-buffer))
-				(forward-line 1))))
-	  (when (and filtered-query (or (plist-get options :show-empty-searches) (> message-count 0)))
-	    (setq elem-plist (plist-put elem-plist :query filtered-query))
-	    (plist-put elem-plist :count message-count))))
+	(let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)))
+	  (notmuch-hello-batch-message-count elem-plist options)))
       query-list))))
 
 (defun notmuch-hello-insert-buttons (searches)
@@ -558,8 +567,7 @@ (defun notmuch-hello-insert-buttons (searches)
 				     (oldest-first t)
 				     (otherwise notmuch-search-oldest-first)))
 		     (msg-count (plist-get elem :count)))
-		(widget-insert (format "%8s "
-				       (notmuch-hello-nice-number msg-count)))
+		(widget-insert (format "%8s " msg-count))
 		(widget-create 'push-button
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
-- 
1.7.10.4

  reply	other threads:[~2014-05-11  8:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-11  8:34 [PATCH 0/7] emacs: hello: custom display of saved searches Mark Walters
2014-05-11  8:34 ` Mark Walters [this message]
2017-03-11 14:57   ` [PATCH 1/7] emacs: hello: separate out the saved-search display function David Bremner
2014-05-11  8:34 ` [PATCH 2/7] emacs: hello: allow saved search display functions Mark Walters
2014-05-12 14:03   ` David Edmondson
2014-05-12 15:20     ` Mark Walters
2014-05-11  8:34 ` [PATCH 3/7] emacs: hello: store previous saved-search results Mark Walters
2014-05-11  8:34 ` [PATCH 4/7] emacs: hello: add a threads-and-messages function Mark Walters
2014-05-11  8:34 ` [PATCH 5/7] emacs: hello: require cl Mark Walters
2017-03-11 15:01   ` David Bremner
2014-05-11  8:34 ` [PATCH 6/7] emacs: hello: add highlight newly arrived messages option Mark Walters
2014-05-12 13:58   ` David Edmondson
2014-05-12 15:33     ` Mark Walters
2016-01-07 22:52   ` Tomi Ollila
2014-05-11  8:34 ` [PATCH 7/7] emacs: hello: add option to omit count for a search Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399797282-20389-2-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).