--- /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 826D0431FC0\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:35:02 -0700 (PDT)\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 OwnegEcCY-IC for <notmuch@notmuchmail.org>;\r
+ Sun, 11 May 2014 01:34:57 -0700 (PDT)\r
+Received: from mail-we0-f170.google.com (mail-we0-f170.google.com\r
+ [74.125.82.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 51272431FC2\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:52 -0700 (PDT)\r
+Received: by mail-we0-f170.google.com with SMTP id u57so5679413wes.1\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:51 -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=tFUNxtP9FiPlA6qcZwXcKL2GX0EwZefYH4nKn19Z9zo=;\r
+ b=1FhhgPygeimQUyq85gVmORWmWAXs8Y7opvKy0nUIcA2sb6J15mFGrrICNayTkwQrrY\r
+ GFgT/6/JgUbjubY2Wx6eGdsXe+TUIlVsDLWDkBekf9k6Cs98BfF/UnU7/wjESL6i1jW7\r
+ 93hEm8+Akm/4AHzMLrsiwGa4bTX5nFZoa1xacdJsmLN4mjnLAeM2xnYhnu5T0b0MQBIK\r
+ h6fJwReIm/CCSptZPyNIhzsN2oGFwmjQ6LW9Ri/GGRXLC4a8AygfIq+xLoOlg7ZB3E2Q\r
+ IADRGydCl9Mz9R4fYokJcSdlQiHrLO3HWFXHY65Ng1W++7yoyfoeV/5osUMOWRTf+2bq\r
+ SXpA==\r
+X-Received: by 10.180.107.5 with SMTP id gy5mr10704882wib.44.1399797291083;\r
+ Sun, 11 May 2014 01:34:51 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by mx.google.com with ESMTPSA id dz5sm3841145wib.22.2014.05.11.01.34.50\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 11 May 2014 01:34:50 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/7] emacs: hello: allow saved search display functions\r
+Date: Sun, 11 May 2014 09:34:37 +0100\r
+Message-Id: <1399797282-20389-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1399797282-20389-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: Sun, 11 May 2014 08:35:02 -0000\r
+\r
+Extend the saved search plist to include a :display-function property\r
+that can customise the display of the saved search. It can change the\r
+count string displayed and the name string. Thus the user can\r
+customise so that a particular search:\r
+\r
+does not show a count (and is thus hello is faster), shows a thread\r
+count, show a combined message/thread count, changes colour of the\r
+search button based on new messages arriving etc.\r
+\r
+The display function should use (&rest args) to take a keyword list of\r
+arguments. The advantage of this is that it is easy to add extra\r
+arguments in a backwards compatible way (existing user scripts will\r
+still work).\r
+\r
+If a user uses this it will not take advantage of the batch counting\r
+currently done so will make things slower over remote links (except in\r
+cases where no query is done!).\r
+\r
+It also deletes the :count-query option from the customise for saved\r
+searches as this method is much more general. The code still supports\r
+the :count-query option though (just the defcustom does not).\r
+---\r
+ emacs/notmuch-hello.el | 47 +++++++++++++++++++++++++++++++----------------\r
+ 1 file changed, 31 insertions(+), 16 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 0a7004c..7075860 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -85,12 +85,13 @@ (define-widget 'notmuch-saved-search-plist 'list\r
+ (group :format "%v" :inline t (const :format " Query: " :query) (string :format "%v")))\r
+ (checklist :inline t\r
+ :format "%v"\r
+- (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
+ (group :format "%v" :inline t (const :format "" :sort-order)\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 "Display-function: " :display-function) (function :format "%v")))))\r
++\r
+ \r
+ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
+ (:name "unread" :query "tag:unread"))\r
+@@ -101,12 +102,19 @@ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\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
++ :display-function Optional function to generate the count and\r
++ name to be displayed. The function takes a\r
++ keyword list of arguments (it should use\r
++ &rest). Keywords include :current for the\r
++ current saved search plist and :options. If\r
++ this function is not set then the default\r
++ display of message count and name is used. The\r
++ function should return an updated saved search\r
++ plist including :name and :count as the name\r
++ and count-string to be displayed.\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
+@@ -507,15 +515,16 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
+ `notmuch-hello-insert-searches'."\r
+ (with-temp-buffer\r
+ (dolist (elem query-list nil)\r
+- (let ((count-query (or (notmuch-saved-search-get elem :count-query)\r
+- (notmuch-saved-search-get elem :query))))\r
+- (insert\r
+- (replace-regexp-in-string\r
+- "\n" " "\r
+- (notmuch-hello-filtered-query count-query\r
+- (or (plist-get options :filter-count)\r
+- (plist-get options :filter))))\r
+- "\n")))\r
++ (unless (notmuch-saved-search-get elem :display-function)\r
++ (let ((count-query (or (notmuch-saved-search-get elem :count-query)\r
++ (notmuch-saved-search-get elem :query))))\r
++ (insert\r
++ (replace-regexp-in-string\r
++ "\n" " "\r
++ (notmuch-hello-filtered-query count-query\r
++ (or (plist-get options :filter-count)\r
++ (plist-get options :filter))))\r
++ "\n"))))\r
+ \r
+ (unless (= (call-process-region (point-min) (point-max) notmuch-command\r
+ t t nil "count" "--batch") 0)\r
+@@ -530,8 +539,14 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
+ #'identity\r
+ (mapcar\r
+ (lambda (elem)\r
+- (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)))\r
+- (notmuch-hello-batch-message-count elem-plist options)))\r
++ (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))\r
++ (display-function (plist-get elem-plist :display-function))\r
++ (result (if display-function\r
++ (funcall display-function\r
++ :current elem-plist\r
++ :option options)\r
++ (notmuch-hello-batch-message-count elem-plist options))))\r
++ result))\r
+ query-list))))\r
+ \r
+ (defun notmuch-hello-insert-buttons (searches)\r
+-- \r
+1.7.10.4\r
+\r