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 E0EDE431FC0
\r
6 for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 02:09:59 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-4.438 tagged_above=-999 required=5 tests=[AWL=0.672,
\r
12 BAYES_05=-1.11, 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 CbJZVVG8R0At for <notmuch@notmuchmail.org>;
\r
16 Sat, 23 Jan 2010 02:09:59 -0800 (PST)
\r
17 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143])
\r
18 by olra.theworths.org (Postfix) with ESMTP id CA693431FBC
\r
19 for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 02:09:58 -0800 (PST)
\r
20 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245])
\r
21 by e23smtp01.au.ibm.com (8.14.3/8.13.1) with ESMTP id o0NA84Vt024585
\r
22 for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 21:08:04 +1100
\r
23 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138])
\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>; Sat, 23 Jan 2010 21:09:57 +1100
\r
27 Received: from d23av02.au.ibm.com (loopback [127.0.0.1])
\r
28 by d23av02.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id
\r
30 for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 21:09:57 +1100
\r
31 Received: from localhost.localdomain ([9.77.206.84])
\r
32 by d23av02.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id
\r
33 o0NA9pjf008498; Sat, 23 Jan 2010 21:09:53 +1100
\r
34 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
\r
35 To: cworth@cworth.org
\r
36 Date: Sat, 23 Jan 2010 15:39:49 +0530
\r
37 Message-Id: <1264241389-6326-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
38 X-Mailer: git-send-email 1.6.6.1.394.gdedc0
\r
39 Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
\r
40 Subject: [notmuch] [PATCH -V2] notmuch.el: Support for customizing search
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Sat, 23 Jan 2010 10:10:00 -0000
\r
56 From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
58 This patch helps in customizing search result display
\r
59 similar to mutt's index_format. The customization is done
\r
60 by defining an alist as below
\r
62 (setq notmuch-search-result-format '(("date" . "%s ")
\r
63 ("authors" . "%-40s ")
\r
67 The supported keywords are date, count, authors, subject and tags.
\r
69 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
71 notmuch.el | 56 +++++++++++++++++++++++++++++++++++++++-----------------
\r
72 1 files changed, 39 insertions(+), 17 deletions(-)
\r
74 diff --git a/notmuch.el b/notmuch.el
\r
75 index 97914f2..89dc32a 100644
\r
78 @@ -119,6 +119,14 @@ pattern can still test against the entire line).")
\r
79 (defvar notmuch-show-body-read-visible nil)
\r
80 (defvar notmuch-show-citations-visible nil)
\r
81 (defvar notmuch-show-signatures-visible nil)
\r
82 +(defcustom notmuch-search-result-format nil
\r
83 + "Search result formating. Supported fields are
\r
84 + date, count, authors, subject, tags
\r
85 +ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
\r
86 + \(\"subject\" . \"%s\"\)\)\)"
\r
87 +:type '(alist :key-type (string) :value-type (string))
\r
90 (defvar notmuch-show-headers-visible nil)
\r
92 ; XXX: This should be a generic function in emacs somewhere, not here
\r
93 @@ -1065,11 +1073,6 @@ matching this search term are shown if non-nil. "
\r
94 "Notmuch search mode face used to highligh tags."
\r
97 -(defvar notmuch-tag-face-alist nil
\r
98 - "List containing the tag list that need to be highlighed")
\r
100 -(defvar notmuch-search-font-lock-keywords nil)
\r
103 (defun notmuch-search-mode ()
\r
104 "Major mode displaying results of a notmuch search.
\r
105 @@ -1105,17 +1108,7 @@ Complete list of currently available key bindings:
\r
106 (setq truncate-lines t)
\r
107 (setq major-mode 'notmuch-search-mode
\r
108 mode-name "notmuch-search")
\r
109 - (setq buffer-read-only t)
\r
110 - (if (not notmuch-tag-face-alist)
\r
111 - (add-to-list 'notmuch-search-font-lock-keywords (list
\r
112 - "(\\([^)]*\\))$" '(1 'notmuch-tag-face)))
\r
113 - (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))
\r
114 - (loop for notmuch-search-tag in notmuch-search-tags
\r
115 - do (add-to-list 'notmuch-search-font-lock-keywords (list
\r
116 - (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
\r
117 - `(1 ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
\r
118 - (set (make-local-variable 'font-lock-defaults)
\r
119 - '(notmuch-search-font-lock-keywords t)))
\r
120 + (setq buffer-read-only t))
\r
122 (defun notmuch-search-find-thread-id ()
\r
123 "Return the thread for the current thread"
\r
124 @@ -1230,6 +1223,30 @@ This function advances the next thread when finished."
\r
125 (insert (format " (process returned %d)" exit-status)))
\r
126 (insert "\n"))))))))))
\r
128 +(defun insert-tags (tags)
\r
129 + (insert (concat "(" (propertize tags
\r
130 + 'font-lock-face 'notmuch-tag-face) ")")))
\r
132 +(defun insert-field (field date count authors subject tags)
\r
133 +(if (string-equal field "date")
\r
134 + (insert (format (cdr (assoc field notmuch-search-result-format)) date))
\r
135 + (if (string-equal field "count")
\r
136 + (insert (format (cdr (assoc field notmuch-search-result-format)) count))
\r
137 + (if (string-equal field "authors")
\r
138 + (insert (format (cdr (assoc field notmuch-search-result-format)) authors))
\r
139 + (if (string-equal field "subject")
\r
140 + (insert (format (cdr (assoc field notmuch-search-result-format)) subject))
\r
141 + (if (string-equal field "tags")
\r
142 + (insert-tags (format (cdr (assoc field notmuch-search-result-format)) tags)))
\r
145 +(defun notmuch-search-show-result (date count authors subject tags)
\r
146 +(let ((fields) (field))
\r
147 + (setq fields (mapcar 'car notmuch-search-result-format))
\r
148 + (loop for field in fields
\r
149 + do (insert-field field date count authors subject tags)))
\r
152 (defun notmuch-search-process-filter (proc string)
\r
153 "Process and filter the output of \"notmuch search\""
\r
154 (let ((buffer (process-buffer proc)))
\r
155 @@ -1252,7 +1269,12 @@ This function advances the next thread when finished."
\r
156 (set 'authors (concat (substring authors 0 (- 40 3)) "...")))
\r
157 (goto-char (point-max))
\r
158 (let ((beg (point-marker)))
\r
159 - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
\r
160 + (if (not notmuch-search-result-format)
\r
161 + (progn (insert (format "%s %-7s %-40s %s" date count authors subject))
\r
162 + ;; insert the fontified tag
\r
163 + (insert-tags (format "%s" tags))
\r
165 + (notmuch-search-show-result date count authors subject tags))
\r
166 (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
\r
167 (put-text-property beg (point-marker) 'notmuch-search-authors authors)
\r
168 (put-text-property beg (point-marker) 'notmuch-search-subject subject))
\r