[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-28 Thread David Edmondson
On Wed, 28 Dec 2011 13:34:31 +0100, Xavier Maillard  
wrote:
> On Tue, 27 Dec 2011 17:13:23 +, David Edmondson  wrote:
> > Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
> > allows the header line in `notmuch-show-mode' buffers to be coloured
> > according to the tags of the message.
> 
> I have not tested this feature (yet). What would be useful when such
> /theming feature/ is proposed is to show a before/after patch aka a
> screenshot. Do you have some for this one for example ?

Well, to be honest, I don't plan to use it. Maybe j4ni could provide an
example?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-28 Thread David Edmondson
On Tue, 27 Dec 2011 21:57:33 +0200, Jani Nikula  wrote:
> The patch failed to apply cleanly without "emacs: Don't attempt to
> colour tags in `notmuch-show-mode'." Is there a dependency, or was this
> accidental?

There's no dependency, they're just ordered that way in my
repository. (Maintaining lots of topic branches is just too much hard
work.)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: [PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-28 Thread David Edmondson
On Tue, 27 Dec 2011 21:57:33 +0200, Jani Nikula j...@nikula.org wrote:
 The patch failed to apply cleanly without emacs: Don't attempt to
 colour tags in `notmuch-show-mode'. Is there a dependency, or was this
 accidental?

There's no dependency, they're just ordered that way in my
repository. (Maintaining lots of topic branches is just too much hard
work.)


pgpJQ7NgAhYnJ.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-28 Thread David Edmondson
On Wed, 28 Dec 2011 13:34:31 +0100, Xavier Maillard xav...@maillard.im wrote:
 On Tue, 27 Dec 2011 17:13:23 +, David Edmondson d...@dme.org wrote:
  Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
  allows the header line in `notmuch-show-mode' buffers to be coloured
  according to the tags of the message.
 
 I have not tested this feature (yet). What would be useful when such
 /theming feature/ is proposed is to show a before/after patch aka a
 screenshot. Do you have some for this one for example ?

Well, to be honest, I don't plan to use it. Maybe j4ni could provide an
example?


pgpC0PWlTbuq3.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 17:13:23 +, David Edmondson  wrote:
> Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
> allows the header line in `notmuch-show-mode' buffers to be coloured
> according to the tags of the message.

Hi David, I've only given this a quick test drive, but so far it seems
to work as expected. I think this would be a useful feature to have.

The patch failed to apply cleanly without "emacs: Don't attempt to
colour tags in `notmuch-show-mode'." Is there a dependency, or was this
accidental?


BR,
Jani.


> ---
>  emacs/notmuch-lib.el  |   18 ++
>  emacs/notmuch-show.el |   32 
>  emacs/notmuch.el  |   17 ++---
>  3 files changed, 48 insertions(+), 19 deletions(-)
> 
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 0f856bf..1f00fe0 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new 
> value."
>(interactive)
>(kill-buffer (current-buffer)))
>  
> +(defun notmuch-color-line (start end line-tag-list spec)
> +  "Colorize a line based on tags."
> +  ;; Create the overlay only if the message has tags which match one
> +  ;; of those specified in `spec'.
> +  (let (overlay)
> +(mapc (lambda (elem)
> + (let ((tag (car elem))
> +   (attributes (cdr elem)))
> +   (when (member tag line-tag-list)
> + (when (not overlay)
> +   (setq overlay (make-overlay start end))
> +   (overlay-put overlay 'priority 5))
> + ;; Merge the specified properties with any already
> + ;; applied from an earlier match.
> + (overlay-put overlay 'face
> +  (append (overlay-get overlay 'face) attributes)
> +   spec)))
> +
>  ;;
>  
>  (defun notmuch-common-do-stash (text)
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 24f0b40..0885bd5 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -88,6 +88,23 @@ any given message."
>notmuch-wash-elide-blank-lines
>notmuch-wash-excerpt-citations))
>  
> +(defcustom notmuch-show-line-faces nil
> +  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.
> +
> +Here is an example of how to color search results based on tags.
> + (the following text would be placed in your ~/.emacs file):
> +
> + (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"
> +   :background \"blue\"))
> +   (\"unread\" . (:foreground \"green\"
> +
> +The attributes defined for matching tags are merged, with later
> +attributes overriding earlier. A message having both \"delete\"
> +and \"unread\" tags with the above settings would have a green
> +foreground and blue background."
> +  :type '(alist :key-type (string) :value-type (custom-face-edit))
> +  :group 'notmuch)
> +
>  ;; Mostly useful for debugging.
>  (defcustom notmuch-show-all-multipart/alternative-parts t
>"Should all parts of multipart/alternative parts be shown?"
> @@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails."
>  (defun notmuch-show-insert-headerline (headers date tags depth)
>"Insert a notmuch style headerline based on HEADERS for a
>  message at DEPTH in the current thread."
> -  (let ((start (point)))
> +  (let ((start (point))
> + overlay)
>  (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
>   (notmuch-show-clean-address (plist-get headers :From))
>   " ("
> @@ -277,7 +295,9 @@ message at DEPTH in the current thread."
>   ") ("
>   (mapconcat 'identity tags " ")
>   ")\n")
> -(overlay-put (make-overlay start (point)) 'face 
> 'notmuch-message-summary-face)))
> +(setq overlay (make-overlay start (point)))
> +(overlay-put overlay 'face 'notmuch-message-summary-face)
> +(overlay-put overlay 'priority 2)))
>  
>  (defun notmuch-show-insert-header (header header-value)
>"Insert a single header."
> @@ -712,7 +732,8 @@ current buffer, if possible."
>body-start body-end
>(headers-invis-spec (notmuch-show-make-symbol "header"))
>(message-invis-spec (notmuch-show-make-symbol "message"))
> -  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject
> +  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
> +  (tags (plist-get msg :tags)))
>  
>  ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
>  ;; removing items from `buffer-invisibility-spec' (which is what
> @@ -737,10 +758,13 @@ current buffer, if possible."
>   (plist-get msg :date_relative)
> nil)
>   (plist-get headers :Date))
> - (plist-get msg :tags) 

[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread David Edmondson
Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
allows the header line in `notmuch-show-mode' buffers to be coloured
according to the tags of the message.
---
 emacs/notmuch-lib.el  |   18 ++
 emacs/notmuch-show.el |   32 
 emacs/notmuch.el  |   17 ++---
 3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..1f00fe0 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new value."
   (interactive)
   (kill-buffer (current-buffer)))

+(defun notmuch-color-line (start end line-tag-list spec)
+  "Colorize a line based on tags."
+  ;; Create the overlay only if the message has tags which match one
+  ;; of those specified in `spec'.
+  (let (overlay)
+(mapc (lambda (elem)
+   (let ((tag (car elem))
+ (attributes (cdr elem)))
+ (when (member tag line-tag-list)
+   (when (not overlay)
+ (setq overlay (make-overlay start end))
+ (overlay-put overlay 'priority 5))
+   ;; Merge the specified properties with any already
+   ;; applied from an earlier match.
+   (overlay-put overlay 'face
+(append (overlay-get overlay 'face) attributes)
+ spec)))
+
 ;;

 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 24f0b40..0885bd5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -88,6 +88,23 @@ any given message."
 notmuch-wash-elide-blank-lines
 notmuch-wash-excerpt-citations))

+(defcustom notmuch-show-line-faces nil
+  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.
+
+Here is an example of how to color search results based on tags.
+ (the following text would be placed in your ~/.emacs file):
+
+ (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"
+ :background \"blue\"))
+   (\"unread\" . (:foreground \"green\"
+
+The attributes defined for matching tags are merged, with later
+attributes overriding earlier. A message having both \"delete\"
+and \"unread\" tags with the above settings would have a green
+foreground and blue background."
+  :type '(alist :key-type (string) :value-type (custom-face-edit))
+  :group 'notmuch)
+
 ;; Mostly useful for debugging.
 (defcustom notmuch-show-all-multipart/alternative-parts t
   "Should all parts of multipart/alternative parts be shown?"
@@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails."
 (defun notmuch-show-insert-headerline (headers date tags depth)
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
-  (let ((start (point)))
+  (let ((start (point))
+   overlay)
 (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
(notmuch-show-clean-address (plist-get headers :From))
" ("
@@ -277,7 +295,9 @@ message at DEPTH in the current thread."
") ("
(mapconcat 'identity tags " ")
")\n")
-(overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
+(setq overlay (make-overlay start (point)))
+(overlay-put overlay 'face 'notmuch-message-summary-face)
+(overlay-put overlay 'priority 2)))

 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -712,7 +732,8 @@ current buffer, if possible."
 body-start body-end
 (headers-invis-spec (notmuch-show-make-symbol "header"))
 (message-invis-spec (notmuch-show-make-symbol "message"))
-(bare-subject (notmuch-show-strip-re (plist-get headers :Subject
+(bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
+(tags (plist-get msg :tags)))

 ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
 ;; removing items from `buffer-invisibility-spec' (which is what
@@ -737,10 +758,13 @@ current buffer, if possible."
(plist-get msg :date_relative)
  nil)
(plist-get headers :Date))
-   (plist-get msg :tags) depth)
+   tags depth)

 (setq content-start (point-marker))

+;; Colour the header line according to the tags of the message.
+(notmuch-color-line message-start content-start tags 
notmuch-show-line-faces)
+
 (plist-put msg :headers-invis-spec headers-invis-spec)
 (plist-put msg :message-invis-spec message-invis-spec)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 4844385..56d35d0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -641,7 +641,7 @@ This 

[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread David Edmondson
Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
allows the header line in `notmuch-show-mode' buffers to be coloured
according to the tags of the message.
---
 emacs/notmuch-lib.el  |   18 ++
 emacs/notmuch-show.el |   32 
 emacs/notmuch.el  |   17 ++---
 3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..1f00fe0 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new value.
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defun notmuch-color-line (start end line-tag-list spec)
+  Colorize a line based on tags.
+  ;; Create the overlay only if the message has tags which match one
+  ;; of those specified in `spec'.
+  (let (overlay)
+(mapc (lambda (elem)
+   (let ((tag (car elem))
+ (attributes (cdr elem)))
+ (when (member tag line-tag-list)
+   (when (not overlay)
+ (setq overlay (make-overlay start end))
+ (overlay-put overlay 'priority 5))
+   ;; Merge the specified properties with any already
+   ;; applied from an earlier match.
+   (overlay-put overlay 'face
+(append (overlay-get overlay 'face) attributes)
+ spec)))
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 24f0b40..0885bd5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -88,6 +88,23 @@ any given message.
 notmuch-wash-elide-blank-lines
 notmuch-wash-excerpt-citations))
 
+(defcustom notmuch-show-line-faces nil
+  Tag to face mapping for header line highlighting in `notmuch-show-mode'.
+
+Here is an example of how to color search results based on tags.
+ (the following text would be placed in your ~/.emacs file):
+
+ (setq notmuch-search-line-faces '((\delete\ . (:foreground \red\
+ :background \blue\))
+   (\unread\ . (:foreground \green\
+
+The attributes defined for matching tags are merged, with later
+attributes overriding earlier. A message having both \delete\
+and \unread\ tags with the above settings would have a green
+foreground and blue background.
+  :type '(alist :key-type (string) :value-type (custom-face-edit))
+  :group 'notmuch)
+
 ;; Mostly useful for debugging.
 (defcustom notmuch-show-all-multipart/alternative-parts t
   Should all parts of multipart/alternative parts be shown?
@@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails.
 (defun notmuch-show-insert-headerline (headers date tags depth)
   Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread.
-  (let ((start (point)))
+  (let ((start (point))
+   overlay)
 (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
(notmuch-show-clean-address (plist-get headers :From))
 (
@@ -277,7 +295,9 @@ message at DEPTH in the current thread.
) (
(mapconcat 'identity tags  )
)\n)
-(overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
+(setq overlay (make-overlay start (point)))
+(overlay-put overlay 'face 'notmuch-message-summary-face)
+(overlay-put overlay 'priority 2)))
 
 (defun notmuch-show-insert-header (header header-value)
   Insert a single header.
@@ -712,7 +732,8 @@ current buffer, if possible.
 body-start body-end
 (headers-invis-spec (notmuch-show-make-symbol header))
 (message-invis-spec (notmuch-show-make-symbol message))
-(bare-subject (notmuch-show-strip-re (plist-get headers :Subject
+(bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
+(tags (plist-get msg :tags)))
 
 ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
 ;; removing items from `buffer-invisibility-spec' (which is what
@@ -737,10 +758,13 @@ current buffer, if possible.
(plist-get msg :date_relative)
  nil)
(plist-get headers :Date))
-   (plist-get msg :tags) depth)
+   tags depth)
 
 (setq content-start (point-marker))
 
+;; Colour the header line according to the tags of the message.
+(notmuch-color-line message-start content-start tags 
notmuch-show-line-faces)
+
 (plist-put msg :headers-invis-spec headers-invis-spec)
 (plist-put msg :message-invis-spec message-invis-spec)
 
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 4844385..56d35d0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -641,7 +641,7 @@ This function advances the next thread 

Re: [PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 17:13:23 +, David Edmondson d...@dme.org wrote:
 Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
 allows the header line in `notmuch-show-mode' buffers to be coloured
 according to the tags of the message.

Hi David, I've only given this a quick test drive, but so far it seems
to work as expected. I think this would be a useful feature to have.

The patch failed to apply cleanly without emacs: Don't attempt to
colour tags in `notmuch-show-mode'. Is there a dependency, or was this
accidental?


BR,
Jani.


 ---
  emacs/notmuch-lib.el  |   18 ++
  emacs/notmuch-show.el |   32 
  emacs/notmuch.el  |   17 ++---
  3 files changed, 48 insertions(+), 19 deletions(-)
 
 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
 index 0f856bf..1f00fe0 100644
 --- a/emacs/notmuch-lib.el
 +++ b/emacs/notmuch-lib.el
 @@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new 
 value.
(interactive)
(kill-buffer (current-buffer)))
  
 +(defun notmuch-color-line (start end line-tag-list spec)
 +  Colorize a line based on tags.
 +  ;; Create the overlay only if the message has tags which match one
 +  ;; of those specified in `spec'.
 +  (let (overlay)
 +(mapc (lambda (elem)
 + (let ((tag (car elem))
 +   (attributes (cdr elem)))
 +   (when (member tag line-tag-list)
 + (when (not overlay)
 +   (setq overlay (make-overlay start end))
 +   (overlay-put overlay 'priority 5))
 + ;; Merge the specified properties with any already
 + ;; applied from an earlier match.
 + (overlay-put overlay 'face
 +  (append (overlay-get overlay 'face) attributes)
 +   spec)))
 +
  ;;
  
  (defun notmuch-common-do-stash (text)
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 24f0b40..0885bd5 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -88,6 +88,23 @@ any given message.
notmuch-wash-elide-blank-lines
notmuch-wash-excerpt-citations))
  
 +(defcustom notmuch-show-line-faces nil
 +  Tag to face mapping for header line highlighting in `notmuch-show-mode'.
 +
 +Here is an example of how to color search results based on tags.
 + (the following text would be placed in your ~/.emacs file):
 +
 + (setq notmuch-search-line-faces '((\delete\ . (:foreground \red\
 +   :background \blue\))
 +   (\unread\ . (:foreground \green\
 +
 +The attributes defined for matching tags are merged, with later
 +attributes overriding earlier. A message having both \delete\
 +and \unread\ tags with the above settings would have a green
 +foreground and blue background.
 +  :type '(alist :key-type (string) :value-type (custom-face-edit))
 +  :group 'notmuch)
 +
  ;; Mostly useful for debugging.
  (defcustom notmuch-show-all-multipart/alternative-parts t
Should all parts of multipart/alternative parts be shown?
 @@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails.
  (defun notmuch-show-insert-headerline (headers date tags depth)
Insert a notmuch style headerline based on HEADERS for a
  message at DEPTH in the current thread.
 -  (let ((start (point)))
 +  (let ((start (point))
 + overlay)
  (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
   (notmuch-show-clean-address (plist-get headers :From))
(
 @@ -277,7 +295,9 @@ message at DEPTH in the current thread.
   ) (
   (mapconcat 'identity tags  )
   )\n)
 -(overlay-put (make-overlay start (point)) 'face 
 'notmuch-message-summary-face)))
 +(setq overlay (make-overlay start (point)))
 +(overlay-put overlay 'face 'notmuch-message-summary-face)
 +(overlay-put overlay 'priority 2)))
  
  (defun notmuch-show-insert-header (header header-value)
Insert a single header.
 @@ -712,7 +732,8 @@ current buffer, if possible.
body-start body-end
(headers-invis-spec (notmuch-show-make-symbol header))
(message-invis-spec (notmuch-show-make-symbol message))
 -  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject
 +  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
 +  (tags (plist-get msg :tags)))
  
  ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
  ;; removing items from `buffer-invisibility-spec' (which is what
 @@ -737,10 +758,13 @@ current buffer, if possible.
   (plist-get msg :date_relative)
 nil)
   (plist-get headers :Date))
 - (plist-get msg :tags) depth)
 + tags depth)
  
  (setq content-start (point-marker))
  
 +;; Colour the header line