[notmuch] [PATCH 1/3] Use default face for the button types so that the underlines go away

2009-12-01 Thread aneesh.ku...@gmail.com
From: Alexander Botero-Lowry 

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



[notmuch] [PATCH 2/3] notmuch.el: Fix the message summary button to be active even on first column

2009-12-01 Thread aneesh.ku...@gmail.com
From: Aneesh Kumar K.V 

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



[notmuch] [PATCH 3/3] notmuch.el: Support for customizing search result display

2009-12-01 Thread aneesh.ku...@gmail.com
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