Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 07A70431FBC for ; Tue, 1 Dec 2009 08:16:05 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6IGYtgV-8Mv8 for ; Tue, 1 Dec 2009 08:16:04 -0800 (PST) Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by olra.theworths.org (Postfix) with ESMTP id C6A87431FBD for ; Tue, 1 Dec 2009 08:16:03 -0800 (PST) Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp08.au.ibm.com (8.14.3/8.13.1) with ESMTP id nB23G2E9032656 for ; Wed, 2 Dec 2009 14:16:02 +1100 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nB1GCR1l1569002 for ; Wed, 2 Dec 2009 03:12:27 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id nB1GG2vZ008751 for ; Wed, 2 Dec 2009 03:16:02 +1100 Received: from localhost.localdomain ([9.124.215.21]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id nB1GFr3i008630; Wed, 2 Dec 2009 03:16:00 +1100 From: aneesh.kumar@gmail.com To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com Date: Tue, 1 Dec 2009 21:45:49 +0530 Message-Id: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com> X-Mailer: git-send-email 1.6.5.2.74.g610f9 In-Reply-To: <1259684149-9574-2-git-send-email-aneesh.kumar@gmail.com> References: <1259684149-9574-1-git-send-email-aneesh.kumar@gmail.com> <1259684149-9574-2-git-send-email-aneesh.kumar@gmail.com> X-Mailman-Approved-At: Tue, 01 Dec 2009 08:25:29 -0800 Cc: "Aneesh Kumar K.V" , notmuch@notmuchmail.org Subject: [notmuch] [PATCH 3/3] notmuch.el: Support for customizing search result display X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2009 16:16:05 -0000 From: Aneesh Kumar K.V This patch helps in customizing search result display similar to mutt's index_format. The customization is done by defining an alist as below (setq notmuch-search-result-format '(("date" . "%s ") ("authors" . "%-40s ") ("subject" . "%s ") ("tags" . "(%s)"))) The supported keywords are date, count, authors, subject and tags. tags need to be last element for it to get highlighted by notmuch-tag-face. Signed-off-by: Aneesh Kumar K.V --- notmuch.el | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/notmuch.el b/notmuch.el index 6a0c119..cbee989 100644 --- a/notmuch.el +++ b/notmuch.el @@ -125,6 +125,13 @@ pattern can still test against the entire line).") (defvar notmuch-show-body-read-visible nil) (defvar notmuch-show-citations-visible nil) (defvar notmuch-show-signatures-visible nil) +(defcustom notmuch-search-result-format nil + "Search result formating. Supported fields are + date, count, authors, subject, tags +ex: \(\(\"date\" \"%s\"\) \(\"count\" \"%-7s\) \(\"authors\" \"%-40s\"\) \(\"subject %s\"\) \(\"tag\" \"(%s)\"\)\)" +:type '(alist :key-type (string) :value-type (string)) +:group 'notmuch) + (defvar notmuch-show-headers-visible nil) ; XXX: This should be a generic function in emacs somewhere, not here @@ -1117,6 +1124,26 @@ This function advances point to the next line when finished." (insert (format " (process returned %d)" exit-status))) (insert "\n")))))))))) +(defun insert_field (field date count authors subject tags) +(if (string-equal field "date") + (insert (format (cdr (assoc field notmuch-search-result-format)) date)) + (if (string-equal field "count") + (insert (format (cdr (assoc field notmuch-search-result-format)) count)) + (if (string-equal field "authors") + (insert (format (cdr (assoc field notmuch-search-result-format)) authors)) + (if (string-equal field "subject") + (insert (format (cdr (assoc field notmuch-search-result-format)) subject)) + (if (string-equal field "tags") + (insert (format (cdr (assoc field notmuch-search-result-format)) tags))) +))))) + +(defun notmuch-search-show-result (date count authors subject tags) +(let ((fields) (field)) + (setq fields (mapcar 'car notmuch-search-result-format)) + (loop for field in fields + do (insert_field field date count authors subject tags))) +(insert "\n")) + (defun notmuch-search-process-filter (proc string) "Process and filter the output of \"notmuch search\"" (let ((buffer (process-buffer proc))) @@ -1139,7 +1166,9 @@ This function advances point to the next line when finished." (set 'authors (concat (substring authors 0 (- 40 3)) "..."))) (goto-char (point-max)) (let ((beg (point-marker))) - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags)) + (if (not notmuch-search-result-format) + (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags)) + (notmuch-search-show-result date count authors subject tags)) (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)) (set 'line (match-end 0))) (set 'more nil)))))) -- 1.6.5.2.74.g610f9