--- /dev/null
+Return-Path: <keithp@keithp.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 C18BA431FBF\r
+ for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 23:15:24 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 OY06CbIGgdIX for <notmuch@notmuchmail.org>;\r
+ Fri, 20 Nov 2009 23:15:21 -0800 (PST)\r
+Received: from keithp.com (home.keithp.com [63.227.221.253])\r
+ by olra.theworths.org (Postfix) with ESMTP id E5F46431FBC\r
+ for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 23:15:17 -0800 (PST)\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by keithp.com (Postfix) with ESMTP id 680B3760228\r
+ for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 23:15:17 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at keithp.com\r
+Received: from keithp.com ([127.0.0.1])\r
+ by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024)\r
+ with LMTP id C8uqZH6hDBhn; Fri, 20 Nov 2009 23:15:14 -0800 (PST)\r
+Received: by keithp.com (Postfix, from userid 1033)\r
+ id B3AFE760220; Fri, 20 Nov 2009 23:15:13 -0800 (PST)\r
+Received: from koto.keithp.com (localhost [127.0.0.1])\r
+ by keithp.com (Postfix) with ESMTP id B01AE76012C;\r
+ Fri, 20 Nov 2009 23:15:13 -0800 (PST)\r
+Received: by koto.keithp.com (Postfix, from userid 1488)\r
+ id 487DD1982A8; Fri, 20 Nov 2009 23:15:13 -0800 (PST)\r
+From: Keith Packard <keithp@keithp.com>\r
+To: notmuch@notmuchmail.org\r
+Date: Fri, 20 Nov 2009 23:15:08 -0800\r
+Message-Id: <1258787708-21121-3-git-send-email-keithp@keithp.com>\r
+X-Mailer: git-send-email 1.6.5.2\r
+In-Reply-To: <1258787708-21121-2-git-send-email-keithp@keithp.com>\r
+References: <1258787708-21121-1-git-send-email-keithp@keithp.com>\r
+ <1258787708-21121-2-git-send-email-keithp@keithp.com>\r
+Subject: [notmuch] [PATCH 3/3] Add notmuch-index mode to display message\r
+ counts\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\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: Sat, 21 Nov 2009 07:15:25 -0000\r
+\r
+Index mode takes a (user-configurable) list of search patterns and\r
+produces a list of those patterns and the count of messages that they\r
+match. When an entry in this list is selected, a search window with\r
+the defined search is opened. The set of indexes is defined as a\r
+list, each element contains the name of the index and the query string\r
+to count.\r
+\r
+This provides a view similar to a folder list in a more traditional\r
+mail client.\r
+\r
+Signed-off-by: Keith Packard <keithp@keithp.com>\r
+---\r
+ notmuch.el | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 81 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 4f369de..454320e 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -1046,4 +1046,85 @@ current search results AND that are tagged with the given tag."\r
+ \r
+ (setq mail-user-agent 'message-user-agent)\r
+ \r
++(defvar notmuch-index-mode-map\r
++ (let ((map (make-sparse-keymap)))\r
++ (define-key map "n" 'next-line)\r
++ (define-key map "p" 'previous-line)\r
++ (define-key map "x" 'kill-this-buffer)\r
++ (define-key map "q" 'kill-this-buffer)\r
++ (define-key map "s" 'notmuch-search)\r
++ (define-key map (kbd "RET") 'notmuch-index-show-search)\r
++ (define-key map "<" 'beginning-of-buffer)\r
++ (define-key map "=" 'notmuch-index)\r
++ (define-key map "?" 'describe-mode)\r
++ (define-key map [mouse-1] 'notmuch-index-show-search)\r
++ map)\r
++ "Keymap for \"notmuch index\" buffers.")\r
++\r
++(fset 'notmuch-index-mode-map notmuch-index-mode-map)\r
++\r
++(defcustom notmuch-indexes (quote (("inbox" . "tag:inbox") ("unread" . "tag:unread")))\r
++ "List of searches for the notmuch index view"\r
++ :type '(alist :key-type (string) :value-type (string))\r
++ :group 'notmuch)\r
++ \r
++(defun notmuch-index-mode ()\r
++ "Major mode for showing index of notmuch tags.\r
++\r
++This buffer contains a list of messages counts returned by a\r
++customizable set of searches of your email archives. Each line\r
++in the buffer shows the search terms and the resulting message count.\r
++\r
++Pressing RET on any line opens a search window containing the search\r
++results for the search terms in that line.\r
++\r
++\\{notmuch-index-mode-map}"\r
++ (interactive)\r
++ (kill-all-local-variables)\r
++ (use-local-map 'notmuch-index-mode-map)\r
++ (setq truncate-lines t)\r
++ (hl-line-mode 1)\r
++ (setq major-mode 'notmuch-index-mode\r
++ mode-name "notmuch-index")\r
++ (setq buffer-read-only t))\r
++\r
++(defun notmuch-index-add (indexes)\r
++ (if indexes\r
++ (let ((name (car (car indexes)))\r
++ (inhibit-read-only t)\r
++ (search (cdr (car indexes))))\r
++ (insert name)\r
++ (indent-to 16 1)\r
++ (call-process notmuch-command nil t nil "count" search)\r
++ (notmuch-index-add (cdr indexes)))))\r
++\r
++(defun notmuch-index-find-name ()\r
++ (save-excursion\r
++ (beginning-of-line)\r
++ (let ((beg (point)))\r
++ (forward-word)\r
++ (filter-buffer-substring beg (point)))))\r
++\r
++(defun notmuch-index-show-search (&optional index)\r
++ "Show a search window for the search related to the specified index."\r
++ (interactive)\r
++ (if (null index)\r
++ (setq index (notmuch-index-find-name)))\r
++ (let ((search (assoc index notmuch-indexes)))\r
++ (if search\r
++ (notmuch-search (cdr search) t))))\r
++\r
++(defun notmuch-index ()\r
++ "Show the message index and update the displayed counts."\r
++ (interactive)\r
++ (let ((buffer (get-buffer-create "*notmuch-index*")))\r
++ (switch-to-buffer buffer)\r
++ (let ((inhibit-read-only t)\r
++ (n (line-number-at-pos)))\r
++ (erase-buffer)\r
++ (notmuch-index-mode)\r
++ (notmuch-index-add notmuch-indexes)\r
++ (goto-char (point-min))\r
++ (goto-line n))))\r
++\r
+ (provide 'notmuch)\r
+-- \r
+1.6.5.2\r
+\r