--- /dev/null
+Return-Path: <aneesh.kumar@linux.vnet.ibm.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id DA0D8431FBC\r
+ for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 04:49:56 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id pbhvxRegn5ku for <notmuch@notmuchmail.org>;\r
+ Wed, 2 Dec 2009 04:49:56 -0800 (PST)\r
+Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145])\r
+ by olra.theworths.org (Postfix) with ESMTP id 58C06431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 04:49:56 -0800 (PST)\r
+Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247])\r
+ by e23smtp03.au.ibm.com (8.14.3/8.13.1) with ESMTP id nB2Cl8ZU001705\r
+ for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 23:47:08 +1100\r
+Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96])\r
+ by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id\r
+ nB2CkD9S1487000\r
+ for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 23:46:13 +1100\r
+Received: from d23av01.au.ibm.com (loopback [127.0.0.1])\r
+ by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id\r
+ nB2Cnq2m009949\r
+ for <notmuch@notmuchmail.org>; Wed, 2 Dec 2009 23:49:52 +1100\r
+Received: from localhost.localdomain ([9.124.212.174])\r
+ by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id\r
+ nB2CnhZm009904; Wed, 2 Dec 2009 23:49:47 +1100\r
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>\r
+To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com\r
+Date: Wed, 2 Dec 2009 18:19:38 +0530\r
+Message-Id:\r
+ <1259758178-26584-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
+X-Mailer: git-send-email 1.6.5.2.74.g610f9\r
+In-Reply-To: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com>\r
+References: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com>\r
+Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org\r
+Subject: [notmuch] [PATCH -v2] notmuch.el: Support for customizing search\r
+ result display\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 02 Dec 2009 12:49:57 -0000\r
+\r
+From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\r
+\r
+This patch helps in customizing search result display\r
+similar to mutt's index_format. The customization is done\r
+by defining an alist as below\r
+\r
+(setq notmuch-search-result-format '(("date" . "%s ")\r
+ ("authors" . "%-40s ")\r
+ ("subject" . "%s ")\r
+ ("tags" . "(%s)")))\r
+\r
+The supported keywords are date, count, authors, subject and tags.\r
+\r
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\r
+---\r
+\r
+Changes from V1:\r
+ tags can be specified any where in the result format.\r
+ Dropped notmuch-tag-face-alist which implies we cannot\r
+ fontify select list of tag names.\r
+\r
+ notmuch.el | 56 +++++++++++++++++++++++++++++++++++++++-----------------\r
+ 1 files changed, 39 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 1e5bf5b..bd8a6ce 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -119,6 +119,14 @@ pattern can still test against the entire line).")\r
+ (defvar notmuch-show-body-read-visible nil)\r
+ (defvar notmuch-show-citations-visible nil)\r
+ (defvar notmuch-show-signatures-visible nil)\r
++(defcustom notmuch-search-result-format nil\r
++ "Search result formating. Supported fields are\r
++ date, count, authors, subject, tags\r
++ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)\r
++ \(\"subject\" . \"%s\"\)\)\)"\r
++:type '(alist :key-type (string) :value-type (string))\r
++:group 'notmuch)\r
++\r
+ (defvar notmuch-show-headers-visible nil)\r
+ \r
+ ; XXX: This should be a generic function in emacs somewhere, not here\r
+@@ -1060,11 +1068,6 @@ thread from that buffer can be show when done with this one)."\r
+ "Notmuch search mode face used to highligh tags."\r
+ :group 'notmuch)\r
+ \r
+-(defvar notmuch-tag-face-alist nil\r
+- "List containing the tag list that need to be highlighed")\r
+-\r
+-(defvar notmuch-search-font-lock-keywords nil)\r
+-\r
+ ;;;###autoload\r
+ (defun notmuch-search-mode ()\r
+ "Major mode displaying results of a notmuch search.\r
+@@ -1100,17 +1103,7 @@ Complete list of currently available key bindings:\r
+ (setq truncate-lines t)\r
+ (setq major-mode 'notmuch-search-mode\r
+ mode-name "notmuch-search")\r
+- (setq buffer-read-only t)\r
+- (if (not notmuch-tag-face-alist)\r
+- (add-to-list 'notmuch-search-font-lock-keywords (list\r
+- "(\\([^)]*\\))$" '(1 'notmuch-tag-face)))\r
+- (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))\r
+- (loop for notmuch-search-tag in notmuch-search-tags\r
+- do (add-to-list 'notmuch-search-font-lock-keywords (list\r
+- (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")\r
+- `(1 ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))\r
+- (set (make-local-variable 'font-lock-defaults)\r
+- '(notmuch-search-font-lock-keywords t)))\r
++ (setq buffer-read-only t))\r
+ \r
+ (defun notmuch-search-find-thread-id ()\r
+ "Return the thread for the current thread"\r
+@@ -1217,6 +1210,30 @@ This function advances the next thread when finished."\r
+ (insert (format " (process returned %d)" exit-status)))\r
+ (insert "\n"))))))))))\r
+ \r
++(defun insert-tags (tags)\r
++ (insert (concat "(" (propertize tags\r
++ 'font-lock-face 'notmuch-tag-face) ")")))\r
++\r
++(defun insert-field (field date count authors subject tags)\r
++(if (string-equal field "date")\r
++ (insert (format (cdr (assoc field notmuch-search-result-format)) date))\r
++ (if (string-equal field "count")\r
++ (insert (format (cdr (assoc field notmuch-search-result-format)) count))\r
++ (if (string-equal field "authors")\r
++ (insert (format (cdr (assoc field notmuch-search-result-format)) authors))\r
++ (if (string-equal field "subject")\r
++ (insert (format (cdr (assoc field notmuch-search-result-format)) subject))\r
++ (if (string-equal field "tags")\r
++ (insert-tags (format (cdr (assoc field notmuch-search-result-format)) tags)))\r
++)))))\r
++\r
++(defun notmuch-search-show-result (date count authors subject tags)\r
++(let ((fields) (field))\r
++ (setq fields (mapcar 'car notmuch-search-result-format))\r
++ (loop for field in fields\r
++ do (insert-field field date count authors subject tags)))\r
++(insert "\n"))\r
++\r
+ (defun notmuch-search-process-filter (proc string)\r
+ "Process and filter the output of \"notmuch search\""\r
+ (let ((buffer (process-buffer proc)))\r
+@@ -1239,7 +1256,12 @@ This function advances the next thread when finished."\r
+ (set 'authors (concat (substring authors 0 (- 40 3)) "...")))\r
+ (goto-char (point-max))\r
+ (let ((beg (point-marker)))\r
+- (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))\r
++ (if (not notmuch-search-result-format)\r
++ (progn (insert (format "%s %-7s %-40s %s" date count authors subject))\r
++ ;; insert the fontified tag\r
++ (insert-tags (format "%s" tags))\r
++ (insert "\n"))\r
++ (notmuch-search-show-result date count authors subject tags))\r
+ (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id))\r
+ (set 'line (match-end 0)))\r
+ (set 'more nil))))))\r
+-- \r
+1.6.5.2.74.g610f9\r
+\r