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 DA0D8431FBC
\r
6 for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 04:49:56 -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 pbhvxRegn5ku for <notmuch@notmuchmail.org>;
\r
11 Wed, 2 Dec 2009 04:49:56 -0800 (PST)
\r
12 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 58C06431FAE
\r
14 for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 04:49:56 -0800 (PST)
\r
15 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247])
\r
16 by e23smtp03.au.ibm.com (8.14.3/8.13.1) with ESMTP id nB2Cl8ZU001705
\r
17 for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 23:47:08 +1100
\r
18 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96])
\r
19 by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id
\r
21 for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 23:46:13 +1100
\r
22 Received: from d23av01.au.ibm.com (loopback [127.0.0.1])
\r
23 by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id
\r
25 for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 23:49:52 +1100
\r
26 Received: from localhost.localdomain ([9.124.212.174])
\r
27 by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id
\r
28 nB2CnhZm009904; Wed, 2 Dec 2009 23:49:47 +1100
\r
29 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
\r
30 To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com
\r
31 Date: Wed, 2 Dec 2009 18:19:38 +0530
\r
33 <1259758178-26584-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
34 X-Mailer: git-send-email 1.6.5.2.74.g610f9
\r
35 In-Reply-To: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com>
\r
36 References: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com>
\r
37 Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
\r
38 Subject: [notmuch] [PATCH -v2] notmuch.el: Support for customizing search
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.12
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Wed, 02 Dec 2009 12:49:57 -0000
\r
54 From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
56 This patch helps in customizing search result display
\r
57 similar to mutt's index_format. The customization is done
\r
58 by defining an alist as below
\r
60 (setq notmuch-search-result-format '(("date" . "%s ")
\r
61 ("authors" . "%-40s ")
\r
65 The supported keywords are date, count, authors, subject and tags.
\r
67 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
71 tags can be specified any where in the result format.
\r
72 Dropped notmuch-tag-face-alist which implies we cannot
\r
73 fontify select list of tag names.
\r
75 notmuch.el | 56 +++++++++++++++++++++++++++++++++++++++-----------------
\r
76 1 files changed, 39 insertions(+), 17 deletions(-)
\r
78 diff --git a/notmuch.el b/notmuch.el
\r
79 index 1e5bf5b..bd8a6ce 100644
\r
82 @@ -119,6 +119,14 @@ pattern can still test against the entire line).")
\r
83 (defvar notmuch-show-body-read-visible nil)
\r
84 (defvar notmuch-show-citations-visible nil)
\r
85 (defvar notmuch-show-signatures-visible nil)
\r
86 +(defcustom notmuch-search-result-format nil
\r
87 + "Search result formating. Supported fields are
\r
88 + date, count, authors, subject, tags
\r
89 +ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
\r
90 + \(\"subject\" . \"%s\"\)\)\)"
\r
91 +:type '(alist :key-type (string) :value-type (string))
\r
94 (defvar notmuch-show-headers-visible nil)
\r
96 ; XXX: This should be a generic function in emacs somewhere, not here
\r
97 @@ -1060,11 +1068,6 @@ thread from that buffer can be show when done with this one)."
\r
98 "Notmuch search mode face used to highligh tags."
\r
101 -(defvar notmuch-tag-face-alist nil
\r
102 - "List containing the tag list that need to be highlighed")
\r
104 -(defvar notmuch-search-font-lock-keywords nil)
\r
107 (defun notmuch-search-mode ()
\r
108 "Major mode displaying results of a notmuch search.
\r
109 @@ -1100,17 +1103,7 @@ Complete list of currently available key bindings:
\r
110 (setq truncate-lines t)
\r
111 (setq major-mode 'notmuch-search-mode
\r
112 mode-name "notmuch-search")
\r
113 - (setq buffer-read-only t)
\r
114 - (if (not notmuch-tag-face-alist)
\r
115 - (add-to-list 'notmuch-search-font-lock-keywords (list
\r
116 - "(\\([^)]*\\))$" '(1 'notmuch-tag-face)))
\r
117 - (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))
\r
118 - (loop for notmuch-search-tag in notmuch-search-tags
\r
119 - do (add-to-list 'notmuch-search-font-lock-keywords (list
\r
120 - (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
\r
121 - `(1 ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
\r
122 - (set (make-local-variable 'font-lock-defaults)
\r
123 - '(notmuch-search-font-lock-keywords t)))
\r
124 + (setq buffer-read-only t))
\r
126 (defun notmuch-search-find-thread-id ()
\r
127 "Return the thread for the current thread"
\r
128 @@ -1217,6 +1210,30 @@ This function advances the next thread when finished."
\r
129 (insert (format " (process returned %d)" exit-status)))
\r
130 (insert "\n"))))))))))
\r
132 +(defun insert-tags (tags)
\r
133 + (insert (concat "(" (propertize tags
\r
134 + 'font-lock-face 'notmuch-tag-face) ")")))
\r
136 +(defun insert-field (field date count authors subject tags)
\r
137 +(if (string-equal field "date")
\r
138 + (insert (format (cdr (assoc field notmuch-search-result-format)) date))
\r
139 + (if (string-equal field "count")
\r
140 + (insert (format (cdr (assoc field notmuch-search-result-format)) count))
\r
141 + (if (string-equal field "authors")
\r
142 + (insert (format (cdr (assoc field notmuch-search-result-format)) authors))
\r
143 + (if (string-equal field "subject")
\r
144 + (insert (format (cdr (assoc field notmuch-search-result-format)) subject))
\r
145 + (if (string-equal field "tags")
\r
146 + (insert-tags (format (cdr (assoc field notmuch-search-result-format)) tags)))
\r
149 +(defun notmuch-search-show-result (date count authors subject tags)
\r
150 +(let ((fields) (field))
\r
151 + (setq fields (mapcar 'car notmuch-search-result-format))
\r
152 + (loop for field in fields
\r
153 + do (insert-field field date count authors subject tags)))
\r
156 (defun notmuch-search-process-filter (proc string)
\r
157 "Process and filter the output of \"notmuch search\""
\r
158 (let ((buffer (process-buffer proc)))
\r
159 @@ -1239,7 +1256,12 @@ This function advances the next thread when finished."
\r
160 (set 'authors (concat (substring authors 0 (- 40 3)) "...")))
\r
161 (goto-char (point-max))
\r
162 (let ((beg (point-marker)))
\r
163 - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
\r
164 + (if (not notmuch-search-result-format)
\r
165 + (progn (insert (format "%s %-7s %-40s %s" date count authors subject))
\r
166 + ;; insert the fontified tag
\r
167 + (insert-tags (format "%s" tags))
\r
169 + (notmuch-search-show-result date count authors subject tags))
\r
170 (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id))
\r
171 (set 'line (match-end 0)))
\r
172 (set 'more nil))))))
\r