1 Return-Path: <aneesh.kumar@linux.vnet.ibm.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 E40B6431FAE
\r
6 for <notmuch@notmuchmail.org>; Thu, 11 Feb 2010 08:41:55 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-3.879 tagged_above=-999 required=5 tests=[AWL=0.120,
\r
12 BAYES_50=0.001, RCVD_IN_DNSWL_MED=-4] autolearn=unavailable
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Qo38WPjX93d5 for <notmuch@notmuchmail.org>;
\r
16 Thu, 11 Feb 2010 08:41:54 -0800 (PST)
\r
17 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 97B7C431FBC
\r
19 for <notmuch@notmuchmail.org>; Thu, 11 Feb 2010 08:41:53 -0800 (PST)
\r
20 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245])
\r
21 by e23smtp07.au.ibm.com (8.14.3/8.13.1) with ESMTP id o1BGfpPd024202
\r
22 for <notmuch@notmuchmail.org>; Fri, 12 Feb 2010 03:41:51 +1100
\r
23 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139])
\r
24 by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id
\r
26 for <notmuch@notmuchmail.org>; Fri, 12 Feb 2010 03:41:51 +1100
\r
27 Received: from d23av04.au.ibm.com (loopback [127.0.0.1])
\r
28 by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id
\r
30 for <notmuch@notmuchmail.org>; Fri, 12 Feb 2010 03:41:51 +1100
\r
31 Received: from localhost.localdomain ([9.124.211.8])
\r
32 by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id
\r
33 o1BGfnbn018882; Fri, 12 Feb 2010 03:41:49 +1100
\r
34 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
\r
35 To: cworth@cworth.org
\r
36 Date: Thu, 11 Feb 2010 22:11:46 +0530
\r
38 <1265906506-10395-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
39 X-Mailer: git-send-email 1.7.0.rc2
\r
40 In-Reply-To: <87bpg3e9u9.fsf@yoom.home.cworth.org>
\r
41 References: <87bpg3e9u9.fsf@yoom.home.cworth.org>
\r
42 Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
\r
43 Subject: [notmuch] [PATCH -V3] notmuch.el: Support for customizing search
\r
45 X-BeenThere: notmuch@notmuchmail.org
\r
46 X-Mailman-Version: 2.1.13
\r
48 List-Id: "Use and development of the notmuch mail system."
\r
49 <notmuch.notmuchmail.org>
\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
53 List-Post: <mailto:notmuch@notmuchmail.org>
\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
57 X-List-Received-Date: Thu, 11 Feb 2010 16:41:56 -0000
\r
59 From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
61 This patch helps in customizing search result display
\r
62 similar to mutt's index_format. The customization is done
\r
63 by defining an alist as below
\r
65 (setq notmuch-search-result-format '(("date" . "%s ")
\r
66 ("authors" . "%-40s ")
\r
70 The supported keywords are date, count, authors, subject and tags.
\r
72 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
74 notmuch.el | 56 +++++++++++++++++++++++++++++++++++++++-----------------
\r
75 1 files changed, 39 insertions(+), 17 deletions(-)
\r
77 diff --git a/notmuch.el b/notmuch.el
\r
78 index 040997e..a4a89ac 100644
\r
81 @@ -141,6 +141,19 @@ remaining lines into a button.")
\r
82 (defvar notmuch-show-body-read-visible nil)
\r
83 (defvar notmuch-show-citations-visible nil)
\r
84 (defvar notmuch-show-signatures-visible nil)
\r
85 +(defcustom notmuch-search-result-format
\r
87 + ("count" . "%-7s")
\r
88 + ("authors" . "%-40s")
\r
89 + ("subject" . "%s")
\r
91 + "Search result formating. Supported fields are
\r
92 + date, count, authors, subject, tags
\r
93 +ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
\r
94 + \(\"subject\" . \"%s\"\)\)\)"
\r
95 +:type '(alist :key-type (string) :value-type (string))
\r
98 (defvar notmuch-show-headers-visible nil)
\r
100 ; XXX: This should be a generic function in emacs somewhere, not here
\r
101 @@ -1175,11 +1188,6 @@ matching this search term are shown if non-nil. "
\r
102 "Notmuch search mode face used to highligh tags."
\r
105 -(defvar notmuch-tag-face-alist nil
\r
106 - "List containing the tag list that need to be highlighed")
\r
108 -(defvar notmuch-search-font-lock-keywords nil)
\r
111 (defun notmuch-search-mode ()
\r
112 "Major mode displaying results of a notmuch search.
\r
113 @@ -1215,17 +1223,7 @@ Complete list of currently available key bindings:
\r
114 (setq truncate-lines t)
\r
115 (setq major-mode 'notmuch-search-mode
\r
116 mode-name "notmuch-search")
\r
117 - (setq buffer-read-only t)
\r
118 - (if (not notmuch-tag-face-alist)
\r
119 - (add-to-list 'notmuch-search-font-lock-keywords (list
\r
120 - "(\\([^)]*\\))$" '(1 'notmuch-tag-face)))
\r
121 - (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))
\r
122 - (loop for notmuch-search-tag in notmuch-search-tags
\r
123 - do (add-to-list 'notmuch-search-font-lock-keywords (list
\r
124 - (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
\r
125 - `(1 ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
\r
126 - (set (make-local-variable 'font-lock-defaults)
\r
127 - '(notmuch-search-font-lock-keywords t)))
\r
128 + (setq buffer-read-only t))
\r
130 (defun notmuch-search-find-thread-id ()
\r
131 "Return the thread for the current thread"
\r
132 @@ -1340,6 +1338,30 @@ This function advances the next thread when finished."
\r
133 (insert (format " (process returned %d)" exit-status)))
\r
134 (insert "\n"))))))))))
\r
136 +(defun insert-tags (tags)
\r
137 + (insert (concat "(" (propertize tags
\r
138 + 'font-lock-face 'notmuch-tag-face) ")")))
\r
140 +(defun insert-field (field date count authors subject tags)
\r
141 +(if (string-equal field "date")
\r
142 + (insert (format (cdr (assoc field notmuch-search-result-format)) date))
\r
143 + (if (string-equal field "count")
\r
144 + (insert (format (cdr (assoc field notmuch-search-result-format)) count))
\r
145 + (if (string-equal field "authors")
\r
146 + (insert (format (cdr (assoc field notmuch-search-result-format)) authors))
\r
147 + (if (string-equal field "subject")
\r
148 + (insert (format (cdr (assoc field notmuch-search-result-format)) subject))
\r
149 + (if (string-equal field "tags")
\r
150 + (insert-tags (format (cdr (assoc field notmuch-search-result-format)) tags)))
\r
153 +(defun notmuch-search-show-result (date count authors subject tags)
\r
154 +(let ((fields) (field))
\r
155 + (setq fields (mapcar 'car notmuch-search-result-format))
\r
156 + (loop for field in fields
\r
157 + do (insert-field field date count authors subject tags)))
\r
160 (defun notmuch-search-process-filter (proc string)
\r
161 "Process and filter the output of \"notmuch search\""
\r
162 (let ((buffer (process-buffer proc)))
\r
163 @@ -1362,7 +1384,7 @@ This function advances the next thread when finished."
\r
164 (set 'authors (concat (substring authors 0 (- 40 3)) "...")))
\r
165 (goto-char (point-max))
\r
166 (let ((beg (point-marker)))
\r
167 - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
\r
168 + (notmuch-search-show-result date count authors subject tags)
\r
169 (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
\r
170 (put-text-property beg (point-marker) 'notmuch-search-authors authors)
\r
171 (put-text-property beg (point-marker) 'notmuch-search-subject subject))
\r