unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] Use default face for the button types so that the underlines go away
@ 2009-12-01 16:15 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-03 21:04 ` [PATCH 1/3] Use default face for the button types so that the underlines go away Carl Worth
  0 siblings, 2 replies; 10+ messages in thread
From: aneesh.kumar @ 2009-12-01 16:15 UTC (permalink / raw)
  To: cworth, aneesh.kumar; +Cc: notmuch

From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>

Since we know what these buttons do it seems like the underlines are
unnecessary. This also backs out the attempt at fixing the button
alignment on the message row, which is broken because of some
interaction with indent-rigidly in some threads
---
 notmuch.el |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 65473ba..c1e8257 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -560,15 +560,23 @@ which this thread was originally shown."
   (force-window-update)
   (redisplay t))
 
-(define-button-type 'notmuch-button-invisibility-toggle-type 'action 'notmuch-toggle-invisible-action 'follow-link t)
-(define-button-type 'notmuch-button-citation-toggle-type 'help-echo "mouse-1, RET: Show citation"
+(define-button-type 'notmuch-button-invisibility-toggle-type
+  'action 'notmuch-toggle-invisible-action
+  'follow-link t
+  'face "default")
+(define-button-type 'notmuch-button-citation-toggle-type
+  'help-echo "mouse-1, RET: Show citation"
   :supertype 'notmuch-button-invisibility-toggle-type)
-(define-button-type 'notmuch-button-signature-toggle-type 'help-echo "mouse-1, RET: Show signature"
+(define-button-type 'notmuch-button-signature-toggle-type
+  'help-echo "mouse-1, RET: Show signature"
   :supertype 'notmuch-button-invisibility-toggle-type)
-(define-button-type 'notmuch-button-headers-toggle-type 'help-echo "mouse-1, RET: Show headers"
-  :supertype 'notmuch-button-invisibility-toggle-type)
-(define-button-type 'notmuch-button-body-toggle-type 'help-echo "mouse-1, RET: Show message"
+(define-button-type 'notmuch-button-headers-toggle-type
+  'help-echo "mouse-1, RET: Show headers"
   :supertype 'notmuch-button-invisibility-toggle-type)
+(define-button-type 'notmuch-button-body-toggle-type 
+  'help-echo "mouse-1, RET: Show message"
+  'face '(:inverse-video . t)
+  :supertype 'notmuch-button-invisibility-toggle-type )
 
 (defun notmuch-show-markup-citations-region (beg end depth)
   (goto-char beg)
@@ -715,8 +723,11 @@ which this thread was originally shown."
         (btn nil))
     (end-of-line)
     ; Inverse video for subject
-    (overlay-put (make-overlay beg (point)) 'face '(:inverse-video t))
-    (setq btn (make-button beg (point) :type 'notmuch-button-body-toggle-type))
+    (let ((message-overlay (make-overlay beg (point))))
+      (overlay-put message-overlay 'face '(:inverse-video t))
+      (setq btn (make-button (line-beginning-position)
+			     (overlay-end message-overlay)
+			     :type 'notmuch-button-body-toggle-type)))
     (forward-line 1)
     (end-of-line)
     (let ((beg-hidden (point-marker)))
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] notmuch.el: Fix the message summary button to be active even on first column
  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 ` aneesh.kumar
  2009-12-01 16:15   ` [PATCH 3/3] notmuch.el: Support for customizing search result display aneesh.kumar
  2009-12-03 21:04 ` [PATCH 1/3] Use default face for the button types so that the underlines go away Carl Worth
  1 sibling, 1 reply; 10+ messages in thread
From: aneesh.kumar @ 2009-12-01 16:15 UTC (permalink / raw)
  To: cworth, aneesh.kumar; +Cc: Aneesh Kumar K.V, notmuch

From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

This make we have button activated even on the first column of
the message summary line. Remove the inverse video overlay
on the message summary line.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
 notmuch.el |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index c1e8257..6a0c119 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -575,7 +575,7 @@ which this thread was originally shown."
   :supertype 'notmuch-button-invisibility-toggle-type)
 (define-button-type 'notmuch-button-body-toggle-type 
   'help-echo "mouse-1, RET: Show message"
-  'face '(:inverse-video . t)
+  'face 'message-header-other
   :supertype 'notmuch-button-invisibility-toggle-type )
 
 (defun notmuch-show-markup-citations-region (beg end depth)
@@ -721,13 +721,7 @@ which this thread was originally shown."
   (forward-line)
   (let ((beg (point-marker))
         (btn nil))
-    (end-of-line)
-    ; Inverse video for subject
-    (let ((message-overlay (make-overlay beg (point))))
-      (overlay-put message-overlay 'face '(:inverse-video t))
-      (setq btn (make-button (line-beginning-position)
-			     (overlay-end message-overlay)
-			     :type 'notmuch-button-body-toggle-type)))
+
     (forward-line 1)
     (end-of-line)
     (let ((beg-hidden (point-marker)))
@@ -747,7 +741,12 @@ which this thread was originally shown."
           (overlay-put (make-overlay beg-hidden end)
                        'invisible invis-spec)
           (goto-char beg)
+	  ;; mail summary
+	  (setq btn (make-button (line-beginning-position)
+                               (line-end-position)
+                               :type 'notmuch-button-body-toggle-type))
           (forward-line)
+	  ;; subject line
           (make-button (line-beginning-position) (line-end-position)
                         'invisibility-spec (cons invis-spec t)
                         :type 'notmuch-button-headers-toggle-type))
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] notmuch.el: Support for customizing search result display
  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
  2009-12-02 12:49     ` [PATCH -v2] " Aneesh Kumar K.V
  0 siblings, 1 reply; 10+ messages in thread
From: aneesh.kumar @ 2009-12-01 16:15 UTC (permalink / raw)
  To: cworth, aneesh.kumar; +Cc: Aneesh Kumar K.V, notmuch

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH -v2] notmuch.el: Support for customizing search result display
  2009-12-01 16:15   ` [PATCH 3/3] notmuch.el: Support for customizing search result display aneesh.kumar
@ 2009-12-02 12:49     ` Aneesh Kumar K.V
  2009-12-11  5:34       ` Aneesh Kumar K. V
  2010-02-05 19:55       ` Carl Worth
  0 siblings, 2 replies; 10+ messages in thread
From: Aneesh Kumar K.V @ 2009-12-02 12:49 UTC (permalink / raw)
  To: cworth, aneesh.kumar; +Cc: Aneesh Kumar K.V, notmuch

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.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---

Changes from V1:
	tags can be specified any where in the result format.
	Dropped notmuch-tag-face-alist which implies we cannot
	fontify select list of tag names.

 notmuch.el |   56 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 1e5bf5b..bd8a6ce 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -119,6 +119,14 @@ 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: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
+					\(\"subject\" . \"%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
@@ -1060,11 +1068,6 @@ thread from that buffer can be show when done with this one)."
   "Notmuch search mode face used to highligh tags."
   :group 'notmuch)
 
-(defvar notmuch-tag-face-alist nil
-  "List containing the tag list that need to be highlighed")
-
-(defvar notmuch-search-font-lock-keywords  nil)
-
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode displaying results of a notmuch search.
@@ -1100,17 +1103,7 @@ Complete list of currently available key bindings:
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t)
-  (if (not notmuch-tag-face-alist)
-      (add-to-list 'notmuch-search-font-lock-keywords (list
-		"(\\([^)]*\\))$" '(1  'notmuch-tag-face)))
-    (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))
-      (loop for notmuch-search-tag  in notmuch-search-tags
-	    do (add-to-list 'notmuch-search-font-lock-keywords (list
-			(concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
-			`(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
-  (set (make-local-variable 'font-lock-defaults)
-         '(notmuch-search-font-lock-keywords t)))
+  (setq buffer-read-only t))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
@@ -1217,6 +1210,30 @@ This function advances the next thread when finished."
 			    (insert (format " (process returned %d)" exit-status)))
 			(insert "\n"))))))))))
 
+(defun insert-tags (tags)
+  (insert (concat "(" (propertize tags
+        'font-lock-face 'notmuch-tag-face) ")")))
+
+(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-tags (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)))
@@ -1239,7 +1256,12 @@ This function advances the next thread 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)
+			    (progn (insert (format "%s %-7s %-40s %s" date count authors subject))
+				   ;; insert the fontified tag
+				   (insert-tags (format "%s" tags))
+				   (insert "\n"))
+			  (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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] Use default face for the button types so that the underlines go away
  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-03 21:04 ` Carl Worth
  1 sibling, 0 replies; 10+ messages in thread
From: Carl Worth @ 2009-12-03 21:04 UTC (permalink / raw)
  To: aneesh.kumar, aneesh.kumar; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

On Tue,  1 Dec 2009 21:45:47 +0530, aneesh.kumar@gmail.com wrote:
> From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>
> 
> Since we know what these buttons do it seems like the underlines are
> unnecessary. This also backs out the attempt at fixing the button
> alignment on the message row, which is broken because of some
> interaction with indent-rigidly in some threads

Thanks, Alexander (and Aneesh).

By the time I was ready to apply this patch, I had fixed the "also"
portion of the commit independently in a different way, (which actually
does give reliable first-column usage of the buttons).

But I've now committed the removal of the underlines from these buttons.

And Aneesh, for the following patch which removes the reverse-video, I
also implemented a different version of that.

Take a look, emacs users, and let me know what you think of the new
presentation of messages. I find it much more pleasant to look at
myself.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -v2] notmuch.el: Support for customizing search result display
  2009-12-02 12:49     ` [PATCH -v2] " Aneesh Kumar K.V
@ 2009-12-11  5:34       ` Aneesh Kumar K. V
  2010-02-05 19:55       ` Carl Worth
  1 sibling, 0 replies; 10+ messages in thread
From: Aneesh Kumar K. V @ 2009-12-11  5:34 UTC (permalink / raw)
  To: cworth; +Cc: Aneesh Kumar K.V, notmuch

On Wed,  2 Dec 2009 18:19:38 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> 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.
> 

Any update on this patch . I would like to get this merged as well

-aneesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -V2] notmuch.el: Support for customizing search result display
@ 2010-01-23 10:09 Aneesh Kumar K.V
  0 siblings, 0 replies; 10+ messages in thread
From: Aneesh Kumar K.V @ 2010-01-23 10:09 UTC (permalink / raw)
  To: cworth; +Cc: Aneesh Kumar K.V, notmuch

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.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
 notmuch.el |   56 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 97914f2..89dc32a 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -119,6 +119,14 @@ 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: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
+					\(\"subject\" . \"%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
@@ -1065,11 +1073,6 @@ matching this search term are shown if non-nil. "
   "Notmuch search mode face used to highligh tags."
   :group 'notmuch)
 
-(defvar notmuch-tag-face-alist nil
-  "List containing the tag list that need to be highlighed")
-
-(defvar notmuch-search-font-lock-keywords  nil)
-
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode displaying results of a notmuch search.
@@ -1105,17 +1108,7 @@ Complete list of currently available key bindings:
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t)
-  (if (not notmuch-tag-face-alist)
-      (add-to-list 'notmuch-search-font-lock-keywords (list
-		"(\\([^)]*\\))$" '(1  'notmuch-tag-face)))
-    (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))
-      (loop for notmuch-search-tag  in notmuch-search-tags
-	    do (add-to-list 'notmuch-search-font-lock-keywords (list
-			(concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
-			`(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
-  (set (make-local-variable 'font-lock-defaults)
-         '(notmuch-search-font-lock-keywords t)))
+  (setq buffer-read-only t))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
@@ -1230,6 +1223,30 @@ This function advances the next thread when finished."
 			    (insert (format " (process returned %d)" exit-status)))
 			(insert "\n"))))))))))
 
+(defun insert-tags (tags)
+  (insert (concat "(" (propertize tags
+        'font-lock-face 'notmuch-tag-face) ")")))
+
+(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-tags (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)))
@@ -1252,7 +1269,12 @@ This function advances the next thread 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)
+			    (progn (insert (format "%s %-7s %-40s %s" date count authors subject))
+				   ;; insert the fontified tag
+				   (insert-tags (format "%s" tags))
+				   (insert "\n"))
+			  (notmuch-search-show-result date count authors subject tags))
 			(put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
 			(put-text-property beg (point-marker) 'notmuch-search-authors authors)
 			(put-text-property beg (point-marker) 'notmuch-search-subject subject))
-- 
1.6.6.1.394.gdedc0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH -v2] notmuch.el: Support for customizing search result display
  2009-12-02 12:49     ` [PATCH -v2] " 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
  1 sibling, 1 reply; 10+ messages in thread
From: Carl Worth @ 2010-02-05 19:55 UTC (permalink / raw)
  To: Aneesh Kumar K.V, aneesh.kumar; +Cc: Aneesh Kumar K.V, notmuch

[-- Attachment #1: Type: text/plain, Size: 2064 bytes --]

On Wed,  2 Dec 2009 18:19:38 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> 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.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

Hi Aneesh,

I'm sorry this patch has lingered so long without comment. There's
really only one problem I see with it:

> +(defcustom notmuch-search-result-format nil
> +  "Search result formating. Supported fields are
> +	date, count, authors, subject, tags
> +ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
> +					\(\"subject\" . \"%s\"\)\)\)"
> +:type '(alist :key-type (string) :value-type (string))
> +:group 'notmuch)

...

> -			(insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
> +			(if (not notmuch-search-result-format)
> +			    (progn (insert (format "%s %-7s %-40s %s" date count authors subject))
> +				   ;; insert the fontified tag
> +				   (insert-tags (format "%s" tags))
> +				   (insert "\n"))
> +			  (notmuch-search-show-result date count authors subject tags))

I don't like that the new format variable is nil by default and then
there's an open-coded implementation of the default formatting. This has
a couple of problems:

1. The new code is not being exercised by default, so it would be easy
   to break it without realizing.

2. The system is not very self-documenting.

   If a new user wants to tweak the default format, that will be a lot
   easier if they find a customizable variable that describes the
   current format. *That* will be a lot easier to modify rather than
   trying to learn what should be used instead of "nil".

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -V3] notmuch.el: Support for customizing search result display
  2010-02-05 19:55       ` Carl Worth
@ 2010-02-11 16:41         ` Aneesh Kumar K.V
  2010-02-11 17:17           ` Aneesh Kumar K. V
  0 siblings, 1 reply; 10+ messages in thread
From: Aneesh Kumar K.V @ 2010-02-11 16:41 UTC (permalink / raw)
  To: cworth; +Cc: Aneesh Kumar K.V, notmuch

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.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
 notmuch.el |   56 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 040997e..a4a89ac 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -141,6 +141,19 @@ remaining lines into a button.")
 (defvar notmuch-show-body-read-visible nil)
 (defvar notmuch-show-citations-visible nil)
 (defvar notmuch-show-signatures-visible nil)
+(defcustom notmuch-search-result-format
+  '(("date" . "%s")
+    ("count" . "%-7s")
+    ("authors" . "%-40s")
+    ("subject" . "%s")
+    ("tags" . "%s"))
+  "Search result formating. Supported fields are
+	date, count, authors, subject, tags
+ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
+					\(\"subject\" . \"%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
@@ -1175,11 +1188,6 @@ matching this search term are shown if non-nil. "
   "Notmuch search mode face used to highligh tags."
   :group 'notmuch)
 
-(defvar notmuch-tag-face-alist nil
-  "List containing the tag list that need to be highlighed")
-
-(defvar notmuch-search-font-lock-keywords  nil)
-
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode displaying results of a notmuch search.
@@ -1215,17 +1223,7 @@ Complete list of currently available key bindings:
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t)
-  (if (not notmuch-tag-face-alist)
-      (add-to-list 'notmuch-search-font-lock-keywords (list
-		"(\\([^)]*\\))$" '(1  'notmuch-tag-face)))
-    (let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist)))
-      (loop for notmuch-search-tag  in notmuch-search-tags
-	    do (add-to-list 'notmuch-search-font-lock-keywords (list
-			(concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
-			`(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
-  (set (make-local-variable 'font-lock-defaults)
-         '(notmuch-search-font-lock-keywords t)))
+  (setq buffer-read-only t))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
@@ -1340,6 +1338,30 @@ This function advances the next thread when finished."
 			    (insert (format " (process returned %d)" exit-status)))
 			(insert "\n"))))))))))
 
+(defun insert-tags (tags)
+  (insert (concat "(" (propertize tags
+        'font-lock-face 'notmuch-tag-face) ")")))
+
+(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-tags (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)))
@@ -1362,7 +1384,7 @@ This function advances the next thread 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))
+			(notmuch-search-show-result date count authors subject tags)
 			(put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
 			(put-text-property beg (point-marker) 'notmuch-search-authors authors)
 			(put-text-property beg (point-marker) 'notmuch-search-subject subject))
-- 
1.7.0.rc2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH -V3] notmuch.el: Support for customizing search result display
  2010-02-11 16:41         ` [PATCH -V3] " Aneesh Kumar K.V
@ 2010-02-11 17:17           ` Aneesh Kumar K. V
  0 siblings, 0 replies; 10+ messages in thread
From: Aneesh Kumar K. V @ 2010-02-11 17:17 UTC (permalink / raw)
  To: cworth; +Cc: Aneesh Kumar K.V, notmuch

On Thu, 11 Feb 2010 22:11:46 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> 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.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
> ---
>  notmuch.el |   56 +++++++++++++++++++++++++++++++++++++++-----------------
>  1 files changed, 39 insertions(+), 17 deletions(-)
> 
> diff --git a/notmuch.el b/notmuch.el
> index 040997e..a4a89ac 100644
> --- a/notmuch.el
> +++ b/notmuch.el
> @@ -141,6 +141,19 @@ remaining lines into a button.")
>  (defvar notmuch-show-body-read-visible nil)
>  (defvar notmuch-show-citations-visible nil)
>  (defvar notmuch-show-signatures-visible nil)
> +(defcustom notmuch-search-result-format
> +  '(("date" . "%s")
> +    ("count" . "%-7s")
> +    ("authors" . "%-40s")
> +    ("subject" . "%s")
> +    ("tags" . "%s"))

I missed a '(' around tags. So the last line should be

    ("tags" . "(%s)"))

-aneesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-02-11 17:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [PATCH 3/3] notmuch.el: Support for customizing search result display aneesh.kumar
2009-12-02 12:49     ` [PATCH -v2] " 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
  -- strict thread matches above, loose matches on Subject: below --
2010-01-23 10:09 [PATCH -V2] notmuch.el: Support for customizing search result display Aneesh Kumar K.V

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).