1 Return-Path: <aneesh.kumar@gmail.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 07A70431FBC
\r
6 for <notmuch@notmuchmail.org>; Tue, 1 Dec 2009 08:16:05 -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 6IGYtgV-8Mv8 for <notmuch@notmuchmail.org>;
\r
11 Tue, 1 Dec 2009 08:16:04 -0800 (PST)
\r
12 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141])
\r
13 by olra.theworths.org (Postfix) with ESMTP id C6A87431FBD
\r
14 for <notmuch@notmuchmail.org>; Tue, 1 Dec 2009 08:16:03 -0800 (PST)
\r
15 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246])
\r
16 by e23smtp08.au.ibm.com (8.14.3/8.13.1) with ESMTP id nB23G2E9032656
\r
17 for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 14:16:02 +1100
\r
18 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139])
\r
19 by d23relay04.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 03:12:27 +1100
\r
22 Received: from d23av04.au.ibm.com (loopback [127.0.0.1])
\r
23 by d23av04.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 03:16:02 +1100
\r
26 Received: from localhost.localdomain ([9.124.215.21])
\r
27 by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id
\r
28 nB1GFr3i008630; Wed, 2 Dec 2009 03:16:00 +1100
\r
29 From: aneesh.kumar@gmail.com
\r
30 To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com
\r
31 Date: Tue, 1 Dec 2009 21:45:49 +0530
\r
32 Message-Id: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com>
\r
33 X-Mailer: git-send-email 1.6.5.2.74.g610f9
\r
34 In-Reply-To: <1259684149-9574-2-git-send-email-aneesh.kumar@gmail.com>
\r
35 References: <1259684149-9574-1-git-send-email-aneesh.kumar@gmail.com>
\r
36 <1259684149-9574-2-git-send-email-aneesh.kumar@gmail.com>
\r
37 X-Mailman-Approved-At: Tue, 01 Dec 2009 08:25:29 -0800
\r
38 Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
\r
39 Subject: [notmuch] [PATCH 3/3] notmuch.el: Support for customizing search
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.12
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Tue, 01 Dec 2009 16:16:05 -0000
\r
55 From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
57 This patch helps in customizing search result display
\r
58 similar to mutt's index_format. The customization is done
\r
59 by defining an alist as below
\r
61 (setq notmuch-search-result-format '(("date" . "%s ")
\r
62 ("authors" . "%-40s ")
\r
66 The supported keywords are date, count, authors, subject and tags.
\r
67 tags need to be last element for it to get highlighted by notmuch-tag-face.
\r
69 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
71 notmuch.el | 31 ++++++++++++++++++++++++++++++-
\r
72 1 files changed, 30 insertions(+), 1 deletions(-)
\r
74 diff --git a/notmuch.el b/notmuch.el
\r
75 index 6a0c119..cbee989 100644
\r
78 @@ -125,6 +125,13 @@ 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: \(\(\"date\" \"%s\"\) \(\"count\" \"%-7s\) \(\"authors\" \"%-40s\"\) \(\"subject %s\"\) \(\"tag\" \"(%s)\"\)\)"
\r
86 +:type '(alist :key-type (string) :value-type (string))
\r
89 (defvar notmuch-show-headers-visible nil)
\r
91 ; XXX: This should be a generic function in emacs somewhere, not here
\r
92 @@ -1117,6 +1124,26 @@ This function advances point to the next line when finished."
\r
93 (insert (format " (process returned %d)" exit-status)))
\r
94 (insert "\n"))))))))))
\r
96 +(defun insert_field (field date count authors subject tags)
\r
97 +(if (string-equal field "date")
\r
98 + (insert (format (cdr (assoc field notmuch-search-result-format)) date))
\r
99 + (if (string-equal field "count")
\r
100 + (insert (format (cdr (assoc field notmuch-search-result-format)) count))
\r
101 + (if (string-equal field "authors")
\r
102 + (insert (format (cdr (assoc field notmuch-search-result-format)) authors))
\r
103 + (if (string-equal field "subject")
\r
104 + (insert (format (cdr (assoc field notmuch-search-result-format)) subject))
\r
105 + (if (string-equal field "tags")
\r
106 + (insert (format (cdr (assoc field notmuch-search-result-format)) tags)))
\r
109 +(defun notmuch-search-show-result (date count authors subject tags)
\r
110 +(let ((fields) (field))
\r
111 + (setq fields (mapcar 'car notmuch-search-result-format))
\r
112 + (loop for field in fields
\r
113 + do (insert_field field date count authors subject tags)))
\r
116 (defun notmuch-search-process-filter (proc string)
\r
117 "Process and filter the output of \"notmuch search\""
\r
118 (let ((buffer (process-buffer proc)))
\r
119 @@ -1139,7 +1166,9 @@ This function advances point to the next line when finished."
\r
120 (set 'authors (concat (substring authors 0 (- 40 3)) "...")))
\r
121 (goto-char (point-max))
\r
122 (let ((beg (point-marker)))
\r
123 - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
\r
124 + (if (not notmuch-search-result-format)
\r
125 + (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
\r
126 + (notmuch-search-show-result date count authors subject tags))
\r
127 (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id))
\r
128 (set 'line (match-end 0)))
\r
129 (set 'more nil))))))
\r