unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists
Date: Sat,  5 Apr 2014 22:24:24 +0100	[thread overview]
Message-ID: <1396733065-32602-5-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>

Switching notmuch-hello-insert-buttons to plists means we can easily
pass extra options through to the buttons.
---
 emacs/notmuch-hello.el |   33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index c729af2..aa40e6f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -425,7 +425,9 @@ (defun notmuch-hello-query-counts (query-list &rest options)
 these is a plist but other options are available for backwards
 compatibility: see notmuch-saved-search-get for details.
 
-The result is the list of elements of the form (NAME QUERY COUNT).
+The result is a list of plists each of which includes the
+pairs :name NAME, :query QUERY and :count COUNT, together with
+any pairs in the original saved-search.
 
 The values :show-empty-searches, :filter and :filter-count from
 options will be handled as specified for
@@ -455,23 +457,26 @@ (defun notmuch-hello-query-counts (query-list &rest options)
      #'identity
      (mapcar
       (lambda (elem)
-	(let ((name (notmuch-saved-search-get elem :name))
-	      (search-query (notmuch-saved-search-get elem :query))
-	      (message-count (prog1 (read (current-buffer))
+	(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))))
 	  (and (or (plist-get options :show-empty-searches) (> message-count 0))
-	       (list name (notmuch-hello-filtered-query
-			   search-query (plist-get options :filter))
-		     message-count))))
+	       (setq elem-plist (plist-put elem-plist :query filtered-query))
+	       (plist-put elem-plist :count message-count))))
       query-list))))
 
 (defun notmuch-hello-insert-buttons (searches)
   "Insert buttons for SEARCHES.
 
-SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where
-QUERY is the query to start when the button for the corresponding entry is
-activated. COUNT should be the number of messages matching the query.
-Such a list can be computed with `notmuch-hello-query-counts'."
+SEARCHES must be a list of plists each of which should contain at
+least pairs for :name NAME :query QUERY and :count COUNT, where
+QUERY is the query to start when the button for the corresponding
+entry is activated, and COUNT should be the number of messages
+matching the query.  Such a plist can be computed with
+`notmuch-hello-query-counts'."
   (let* ((widest (notmuch-hello-longest-label searches))
 	 (tags-and-width (notmuch-hello-tags-per-line widest))
 	 (tags-per-line (car tags-and-width))
@@ -489,9 +494,9 @@ (defun notmuch-hello-insert-buttons (searches)
 	    (when elem
 	      (if (> column-indent 0)
 		  (widget-insert (make-string column-indent ? )))
-	      (let* ((name (first elem))
-		     (query (second elem))
-		     (msg-count (third elem)))
+	      (let* ((name (plist-get elem :name))
+		     (query (plist-get elem :query))
+		     (msg-count (plist-get elem :count)))
 		(widget-insert (format "%8s "
 				       (notmuch-hello-nice-number msg-count)))
 		(widget-create 'push-button
-- 
1.7.10.4

  parent reply	other threads:[~2014-04-05 21:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
2014-04-05 21:24 ` [PATCH 1/5] emacs: hello: add helper functions for saved-searches Mark Walters
2014-04-06  0:58   ` Austin Clements
2014-04-05 21:24 ` [PATCH 2/5] emacs: hello: use the saved-search helper functions Mark Walters
2014-04-06  1:06   ` Austin Clements
2014-04-05 21:24 ` [PATCH 3/5] emacs: hello: add a customize for saved-searches Mark Walters
2014-04-05 21:24 ` Mark Walters [this message]
2014-04-06  1:24   ` [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists Austin Clements
2014-04-06  5:31     ` Mark Walters
2014-04-05 21:24 ` [PATCH 5/5] emacs: Add a sort-order option to saved-searches Mark Walters
2014-04-06  1:30   ` Austin Clements
2014-04-06  5:32     ` Mark Walters
2014-04-06  0:52 ` [PATCH 0/5] emacs: hello: convert saved-searches to plists David Bremner
2014-04-06  5:34   ` Mark Walters
2014-04-06  8:04   ` Tomi Ollila

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=1396733065-32602-5-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).