1 Return-Path: <keithp@keithp.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id C18BA431FBF
\r
6 for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 23:15:24 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id OY06CbIGgdIX for <notmuch@notmuchmail.org>;
\r
11 Fri, 20 Nov 2009 23:15:21 -0800 (PST)
\r
12 Received: from keithp.com (home.keithp.com [63.227.221.253])
\r
13 by olra.theworths.org (Postfix) with ESMTP id E5F46431FBC
\r
14 for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 23:15:17 -0800 (PST)
\r
15 Received: from localhost (localhost [127.0.0.1])
\r
16 by keithp.com (Postfix) with ESMTP id 680B3760228
\r
17 for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 23:15:17 -0800 (PST)
\r
18 X-Virus-Scanned: Debian amavisd-new at keithp.com
\r
19 Received: from keithp.com ([127.0.0.1])
\r
20 by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024)
\r
21 with LMTP id C8uqZH6hDBhn; Fri, 20 Nov 2009 23:15:14 -0800 (PST)
\r
22 Received: by keithp.com (Postfix, from userid 1033)
\r
23 id B3AFE760220; Fri, 20 Nov 2009 23:15:13 -0800 (PST)
\r
24 Received: from koto.keithp.com (localhost [127.0.0.1])
\r
25 by keithp.com (Postfix) with ESMTP id B01AE76012C;
\r
26 Fri, 20 Nov 2009 23:15:13 -0800 (PST)
\r
27 Received: by koto.keithp.com (Postfix, from userid 1488)
\r
28 id 487DD1982A8; Fri, 20 Nov 2009 23:15:13 -0800 (PST)
\r
29 From: Keith Packard <keithp@keithp.com>
\r
30 To: notmuch@notmuchmail.org
\r
31 Date: Fri, 20 Nov 2009 23:15:08 -0800
\r
32 Message-Id: <1258787708-21121-3-git-send-email-keithp@keithp.com>
\r
33 X-Mailer: git-send-email 1.6.5.2
\r
34 In-Reply-To: <1258787708-21121-2-git-send-email-keithp@keithp.com>
\r
35 References: <1258787708-21121-1-git-send-email-keithp@keithp.com>
\r
36 <1258787708-21121-2-git-send-email-keithp@keithp.com>
\r
37 Subject: [notmuch] [PATCH 3/3] Add notmuch-index mode to display message
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.12
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Sat, 21 Nov 2009 07:15:25 -0000
\r
53 Index mode takes a (user-configurable) list of search patterns and
\r
54 produces a list of those patterns and the count of messages that they
\r
55 match. When an entry in this list is selected, a search window with
\r
56 the defined search is opened. The set of indexes is defined as a
\r
57 list, each element contains the name of the index and the query string
\r
60 This provides a view similar to a folder list in a more traditional
\r
63 Signed-off-by: Keith Packard <keithp@keithp.com>
\r
65 notmuch.el | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
66 1 files changed, 81 insertions(+), 0 deletions(-)
\r
68 diff --git a/notmuch.el b/notmuch.el
\r
69 index 4f369de..454320e 100644
\r
72 @@ -1046,4 +1046,85 @@ current search results AND that are tagged with the given tag."
\r
74 (setq mail-user-agent 'message-user-agent)
\r
76 +(defvar notmuch-index-mode-map
\r
77 + (let ((map (make-sparse-keymap)))
\r
78 + (define-key map "n" 'next-line)
\r
79 + (define-key map "p" 'previous-line)
\r
80 + (define-key map "x" 'kill-this-buffer)
\r
81 + (define-key map "q" 'kill-this-buffer)
\r
82 + (define-key map "s" 'notmuch-search)
\r
83 + (define-key map (kbd "RET") 'notmuch-index-show-search)
\r
84 + (define-key map "<" 'beginning-of-buffer)
\r
85 + (define-key map "=" 'notmuch-index)
\r
86 + (define-key map "?" 'describe-mode)
\r
87 + (define-key map [mouse-1] 'notmuch-index-show-search)
\r
89 + "Keymap for \"notmuch index\" buffers.")
\r
91 +(fset 'notmuch-index-mode-map notmuch-index-mode-map)
\r
93 +(defcustom notmuch-indexes (quote (("inbox" . "tag:inbox") ("unread" . "tag:unread")))
\r
94 + "List of searches for the notmuch index view"
\r
95 + :type '(alist :key-type (string) :value-type (string))
\r
98 +(defun notmuch-index-mode ()
\r
99 + "Major mode for showing index of notmuch tags.
\r
101 +This buffer contains a list of messages counts returned by a
\r
102 +customizable set of searches of your email archives. Each line
\r
103 +in the buffer shows the search terms and the resulting message count.
\r
105 +Pressing RET on any line opens a search window containing the search
\r
106 +results for the search terms in that line.
\r
108 +\\{notmuch-index-mode-map}"
\r
110 + (kill-all-local-variables)
\r
111 + (use-local-map 'notmuch-index-mode-map)
\r
112 + (setq truncate-lines t)
\r
114 + (setq major-mode 'notmuch-index-mode
\r
115 + mode-name "notmuch-index")
\r
116 + (setq buffer-read-only t))
\r
118 +(defun notmuch-index-add (indexes)
\r
120 + (let ((name (car (car indexes)))
\r
121 + (inhibit-read-only t)
\r
122 + (search (cdr (car indexes))))
\r
125 + (call-process notmuch-command nil t nil "count" search)
\r
126 + (notmuch-index-add (cdr indexes)))))
\r
128 +(defun notmuch-index-find-name ()
\r
130 + (beginning-of-line)
\r
131 + (let ((beg (point)))
\r
133 + (filter-buffer-substring beg (point)))))
\r
135 +(defun notmuch-index-show-search (&optional index)
\r
136 + "Show a search window for the search related to the specified index."
\r
139 + (setq index (notmuch-index-find-name)))
\r
140 + (let ((search (assoc index notmuch-indexes)))
\r
142 + (notmuch-search (cdr search) t))))
\r
144 +(defun notmuch-index ()
\r
145 + "Show the message index and update the displayed counts."
\r
147 + (let ((buffer (get-buffer-create "*notmuch-index*")))
\r
148 + (switch-to-buffer buffer)
\r
149 + (let ((inhibit-read-only t)
\r
150 + (n (line-number-at-pos)))
\r
152 + (notmuch-index-mode)
\r
153 + (notmuch-index-add notmuch-indexes)
\r
154 + (goto-char (point-min))
\r