From: aneesh.kumar@gmail.com
To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com
Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
Subject: [PATCH 3/3] notmuch.el: Support for customizing search result display
Date: Tue, 1 Dec 2009 21:45:49 +0530 [thread overview]
Message-ID: <1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com> (raw)
In-Reply-To: <1259684149-9574-2-git-send-email-aneesh.kumar@gmail.com>
From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
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 <aneesh.kumar@gmail.com>
---
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
next prev parent reply other threads:[~2009-12-01 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-01 16:15 [PATCH 1/3] Use default face for the button types so that the underlines go away aneesh.kumar
2009-12-01 16:15 ` [PATCH 2/3] notmuch.el: Fix the message summary button to be active even on first column aneesh.kumar
2009-12-01 16:15 ` aneesh.kumar [this message]
2009-12-02 12:49 ` [PATCH -v2] notmuch.el: Support for customizing search result display Aneesh Kumar K.V
2009-12-11 5:34 ` Aneesh Kumar K. V
2010-02-05 19:55 ` Carl Worth
2010-02-11 16:41 ` [PATCH -V3] " Aneesh Kumar K.V
2010-02-11 17:17 ` Aneesh Kumar K. V
2009-12-03 21:04 ` [PATCH 1/3] Use default face for the button types so that the underlines go away Carl Worth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259684149-9574-3-git-send-email-aneesh.kumar@gmail.com \
--to=aneesh.kumar@gmail.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=cworth@cworth.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).