--- /dev/null
+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 824EB431FC2\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 22:45:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.7\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.7 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
+ FREEMAIL_REPLY=2.499, 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 muHs4sMzqnAx for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 22:45:05 -0700 (PDT)\r
+Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
+ [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A7DC7431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 22:45:04 -0700 (PDT)\r
+Received: by mail-wi0-f176.google.com with SMTP id r20so3354329wiv.3\r
+ for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 22:45:03 -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;\r
+ bh=W4rjkiAAHOI4J9zsDwrGYyYIPPUircbWpiot3yyIoro=;\r
+ b=TdQWzMyNfBV8SADbCLvH6UIjjMbk7Gapr7Ogc/XjNsvZIlemI1zLKi0kmqDpjbxZLf\r
+ vnReenYPn4D/8qECHZp7WMj/obykThnaLtngwGuwKMu0S37+1CtWwS6PcyEtGR1e/OLP\r
+ Qc/vfoqXNXrtF+egB/AMWjePLpljDTJokbO2K1mfNlntHdLT1ojZoctkubwRbLZRDldP\r
+ NZCpBLUrsuDL4rhKTiu5DHV87+efpznkJE5jhzRAqwDUn7XLeVhUsHOrhWx96bNFuH3K\r
+ cy7uvkY8HqJK0iv0X5+UajK4CEns2IYPQDsZ/EXbIodaqNqFjn/Q+4IwwyJ3TE4bIP1i\r
+ C+Iw==\r
+X-Received: by 10.194.82.9 with SMTP id e9mr32622726wjy.45.1396763103078;\r
+ Sat, 05 Apr 2014 22:45:03 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id t1sm7454979wia.1.2014.04.05.22.45.02\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 05 Apr 2014 22:45:02 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ amdragon@MIT.EDU\r
+Subject: [PATCH v2 0/5] emacs: hello: convert saved-searches to plists\r
+Date: Sun, 6 Apr 2014 06:44:44 +0100\r
+Message-Id: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\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: Sun, 06 Apr 2014 05:45:10 -0000\r
+\r
+This is v2 of the series; v1 is at\r
+id:1396733065-32602-1-git-send-email-markwalters1009@gmail.com\r
+\r
+I have made all the changes suggested by Austin in his review of v1. I\r
+include the diff from v1 below.\r
+\r
+There is now one slight oddity in the patch ordering: the\r
+documentation for the plist form appears in patch 3 while the users\r
+and references to that documentation appear in patch 2.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+Mark Walters (5):\r
+ emacs: hello: add helper functions for saved-searches\r
+ emacs: hello: use the saved-search helper functions\r
+ emacs: hello: add a customize for saved-searches\r
+ emacs: hello: switch notmuch-hello-insert-buttons to plists\r
+ emacs: Add a sort-order option to saved-searches\r
+\r
+ emacs/notmuch-hello.el | 127 ++++++++++++++++++++++++++++++++----------------\r
+ emacs/notmuch-lib.el | 54 ++++++++++++++++++--\r
+ emacs/notmuch.el | 6 +--\r
+ 3 files changed, 139 insertions(+), 48 deletions(-)\r
+\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 6a28372..f0675f2 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -272,17 +272,17 @@ (defun notmuch-hello-search (&optional search)\r
+ (defun notmuch-saved-search-get (saved-search field)\r
+ "Get FIELD from SAVED-SEARCH.\r
+ \r
+-In the new style saved-search (a plist) this is just plist-get\r
+-but, for backwards compatibility, this deals with the two\r
+-old-style forms: cons cells (NAME . QUERY) and lists (NAME QUERY\r
+-COUNT-QUERY)."\r
++If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
++backwards compatibility, this also deals with the two other\r
++possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and\r
++lists (NAME QUERY COUNT-QUERY)."\r
+ (cond\r
+- ((plist-get saved-search :name)\r
++ ((keywordp (car saved-search))\r
+ (plist-get saved-search field))\r
+ ;; It is not a plist so it is an old-style entry.\r
+ ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)\r
+ (case field\r
+- (:name (car saved-search))\r
++ (:name (first saved-search))\r
+ (:query (second saved-search))\r
+ (:count-query (third saved-search))\r
+ (t nil)))\r
+@@ -293,16 +293,15 @@ (defun notmuch-saved-search-get (saved-search field)\r
+ (t nil)))))\r
+ \r
+ (defun notmuch-hello-saved-search-to-plist (saved-search)\r
+- "Convert a saved-search variable into plist form.\r
++ "Return a copy of SAVED-SEARCH in plist form.\r
+ \r
+-The new style saved search is just a plist, but for backwards\r
+-compatatibility we use this function to give them in\r
+-plist-form. In all cases a new copy is returned so it is safe to\r
+-modify the returned value."\r
+- (if (and (listp (cdr saved-search)) (plist-member saved-search :name))\r
++If saved search is a plist then just return a copy. In other\r
++cases, for backwards compatability, convert to plist form and\r
++return that."\r
++ (if (keywordp (car saved-search))\r
+ (copy-seq saved-search)\r
+ (let ((fields (list :name :query :count-query))\r
+- (plist-search))\r
++ plist-search)\r
+ (dolist (field fields plist-search)\r
+ (let ((string (notmuch-saved-search-get saved-search field)))\r
+ (when string\r
+@@ -424,11 +423,11 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
+ \r
+ QUERY-LIST must be a list of saved-searches. Ideally each of\r
+ these is a plist but other options are available for backwards\r
+-compatibility: see notmuch-saved-search-get for details.\r
++compatibility: see `notmuch-saved-searches' for details.\r
+ \r
+ The result is a list of plists each of which includes the\r
+-pairs :name NAME, :query QUERY and :count COUNT, together with\r
+-any pairs in the original saved-search.\r
++properties :name NAME, :query QUERY and :count COUNT, together\r
++with any properties in the original saved-search.\r
+ \r
+ The values :show-empty-searches, :filter and :filter-count from\r
+ options will be handled as specified for\r
+@@ -464,20 +463,20 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
+ search-query (plist-get options :filter)))\r
+ (message-count (prog1 (read (current-buffer))\r
+ (forward-line 1))))\r
+- (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
+- (setq elem-plist (plist-put elem-plist :query filtered-query))\r
+- (plist-put elem-plist :count message-count))))\r
++ (when (and filtered-query (or (plist-get options :show-empty-searches) (> message-count 0)))\r
++ (setq elem-plist (plist-put elem-plist :query filtered-query))\r
++ (plist-put elem-plist :count message-count))))\r
+ query-list))))\r
+ \r
+ (defun notmuch-hello-insert-buttons (searches)\r
+ "Insert buttons for SEARCHES.\r
+ \r
+ SEARCHES must be a list of plists each of which should contain at\r
+-least pairs for :name NAME :query QUERY and :count COUNT, where\r
+-QUERY is the query to start when the button for the corresponding\r
+-entry is activated, and COUNT should be the number of messages\r
+-matching the query. Such a plist can be computed with\r
+-`notmuch-hello-query-counts'."\r
++least the properties :name NAME :query QUERY and :count COUNT,\r
++where QUERY is the query to start when the button for the\r
++corresponding entry is activated, and COUNT should be the number\r
++of messages matching the query. Such a plist can be computed\r
++with `notmuch-hello-query-counts'."\r
+ (let* ((widest (notmuch-hello-longest-label searches))\r
+ (tags-and-width (notmuch-hello-tags-per-line widest))\r
+ (tags-per-line (car tags-and-width))\r
+@@ -497,13 +496,10 @@ (defun notmuch-hello-insert-buttons (searches)\r
+ (widget-insert (make-string column-indent ? )))\r
+ (let* ((name (plist-get elem :name))\r
+ (query (plist-get elem :query))\r
+- (oldest-first (cond\r
+- ((eq (plist-get elem :sort-order) 'newest-first)\r
+- nil)\r
+- ((eq (plist-get elem :sort-order) 'oldest-first)\r
+- t)\r
+- (t\r
+- notmuch-search-oldest-first)))\r
++ (oldest-first (case (plist-get elem :sort-order)\r
++ (newest-first nil)\r
++ (oldest-first t)\r
++ (otherwise notmuch-search-oldest-first)))\r
+ (msg-count (plist-get elem :count)))\r
+ (widget-insert (format "%8s "\r
+ (notmuch-hello-nice-number msg-count)))\r
+@@ -741,7 +737,7 @@ (defun notmuch-hello-insert-searches (title query-list &rest options)\r
+ \r
+ QUERY-LIST should ideally be a plist but for backwards\r
+ compatibility other forms are also accepted (see\r
+-`notmuch-saved-search-get' for details). The plist should\r
++`notmuch-saved-searches' for details). The plist should\r
+ contain keys :name and :query; if :count-query is also present\r
+ then it specifies an alternate query to be used to generate the\r
+ count for the associated search.\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 8aa8cfc..3a3c69d 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -134,7 +134,26 @@ (define-widget 'notmuch-saved-search-plist 'list\r
+ \r
+ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
+ (:name "unread" :query "tag:unread"))\r
+- "A list of saved searches to display."\r
++ "A list of saved searches to display.\r
++\r
++The saved search can be given in 3 forms. The preferred way is as\r
++a plist. Supported properties are\r
++\r
++ :name Name of the search (required).\r
++ :query Search to run (required).\r
++ :count-query Optional extra query to generate the count\r
++ shown. If not present then the :query property\r
++ is used.\r
++ :sort-order Specify the sort order to be used for the search.\r
++ Possible values are 'oldest-first 'newest-first or\r
++ nil. Nil means use the default sort order.\r
++\r
++Other accepted forms are a cons cell of the form (NAME . QUERY)\r
++or a list of the form (NAME QUERY COUNT-QUERY)."\r
++;; The saved-search format is also used by the all-tags notmuch-hello\r
++;; section. This section generates its own saved-search list in one of\r
++;; the latter two forms.\r
++\r
+ :get 'notmuch--saved-searches-to-plist\r
+ :type '(repeat notmuch-saved-search-plist)\r
+ :tag "List of Saved Searches"\r
+\r
+-- \r
+1.7.10.4\r
+\r