unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH -v2] notmuch.el: Add face support to search and show mode
@ 2009-11-22  8:37 Aneesh Kumar K.V
  2009-11-22 12:02 ` Carl Worth
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-22  8:37 UTC (permalink / raw)
  To: notmuch

This add two faces, notmuch-show-subject-face and
notmuch-tag-unread-face. The first face is used to show the subject
line in the notmuch-show-mode and the second one to show the unread
tag in the notmuch-search-mode. We can set additional tags by setting
notmuch-tag-face-alist as below

(defface notmuch-tag-unread-face
 '((((class color) (background light)) (:foreground "goldenrod" :bold t))
    (((class color) (background dark)) (:foreground "goldenrod" :bold t)))
  "Notmuch search mode face used to highligh tags.")

(defface notmuch-tag-inbox-face
 '((((class color) (background light)) (:foreground "red" :bold t))
    (((class color) (background dark)) (:foreground "red" :bold t)))
  "Notmuch search mode face used to highligh tags.")

(setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
				 ("inbox" . 'notmuch-tag-inbox-face)))
(require 'notmuch)

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 notmuch.el |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 0144b61..a0f5aaa 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -637,6 +637,18 @@ which this thread was originally shown."
   (force-window-update)
   (redisplay t))
 
+(defface notmuch-show-subject-face
+ '((((class color) (background light)) (:foreground "yellow" :bold t))
+    (((class color) (background dark)) (:foreground "yellow" :bold t)))
+  "Notmuch show mode face used to highligh subject line."
+  :group 'notmuch)
+
+(defvar notmuch-show-font-lock-keywords
+  (list ;; header in font-lock-type-face
+   (list "\\(Subject:.*$\\)"
+	 '(1  'notmuch-show-subject-face)))
+  "Additonal expression to hightlight in notmuch-show-mode")
+
 ;;;###autoload
 (defun notmuch-show-mode ()
   "Major mode for viewing a thread with notmuch.
@@ -677,7 +689,9 @@ view, (remove the \"inbox\" tag from each), with
   (use-local-map notmuch-show-mode-map)
   (setq major-mode 'notmuch-show-mode
 	mode-name "notmuch-show")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (set (make-local-variable 'font-lock-defaults)
+         '(notmuch-show-font-lock-keywords t)))
 
 ;;;###autoload
 
@@ -806,6 +820,17 @@ thread from that buffer can be show when done with this one)."
   (goto-char (point-max))
   (forward-line -1))
 
+(defface notmuch-tag-unread-face
+ '((((class color) (background light)) (:foreground "goldenrod" :bold t))
+    (((class color) (background dark)) (:foreground "goldenrod" :bold t)))
+  "Notmuch search mode face used to highligh tags."
+  :group 'notmuch)
+
+(defvar notmuch-tag-face-alist `(("unread" . 'notmuch-tag-unread-face))
+  "List containing the tag list that need to be highlighed")
+
+(defvar notmuch-search-font-lock-keywords  nil)
+
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode for searching mail with notmuch.
@@ -836,7 +861,14 @@ global search.
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (setq 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)))
 
 (defun notmuch-search-find-thread-id ()
   (save-excursion
-- 
1.6.5.2.74.g610f9

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

* Re: [PATCH -v2] notmuch.el: Add face support to search and show mode
  2009-11-22  8:37 [PATCH -v2] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
@ 2009-11-22 12:02 ` Carl Worth
  2009-11-22 12:21   ` Aneesh Kumar K.V
  0 siblings, 1 reply; 4+ messages in thread
From: Carl Worth @ 2009-11-22 12:02 UTC (permalink / raw)
  To: Aneesh Kumar K.V, notmuch

On Sun, 22 Nov 2009 14:07:56 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> This add two faces, notmuch-show-subject-face and
> notmuch-tag-unread-face. The first face is used to show the subject
> line in the notmuch-show-mode and the second one to show the unread
> tag in the notmuch-search-mode. We can set additional tags by setting
> notmuch-tag-face-alist as below

Hi Aneesh,

I've been meaning to follow-up with you on this since I did get it
working.

> (setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
> 				 ("inbox" . 'notmuch-tag-inbox-face)))

It's interesting to be able to highlight specific tags like this. But I
think that first I'd like to have a single 'notmuch-tag face to make it
easier to see all the tag names, since they're hard to see among the
subject. And then maybe after that have s 'notmuch-tag-important-face or
something. I'm guessing that just that much would cover most people's
needs, before needing to choose custom colors for each tag name.

> +(defface notmuch-show-subject-face
> + '((((class color) (background light)) (:foreground "yellow" :bold t))
> +    (((class color) (background dark)) (:foreground "yellow" :bold t)))
> +  "Notmuch show mode face used to highligh subject line."
> +  :group 'notmuch)

Color selection can be pretty difficult, and I don't think we're ever
all going to agree on things. But I can at least say that I can't read
yellow on white at all, (maybe yellow on black works out a bit better, I
don't know).

So I'd definitely like to hear people's ideas on what the presentation
should look like here.

First, the current reverse-video is definitely not something I really
like. That was just a placeholder since I didn't know how to configure
other faces, (and I needed _something_ to distinguish one message from
another).

Second, from the time I spent with sup, I found that it was hard for me
to read entire lines of bold text. So I think I'd rather just have the
header name ("Subject:", for example) in bold and the rest of the
subject not bold. Hmm... maybe we could use a "From:" at the beginning
of the one line summary.

Finally, for separating one message from the other, I think I'd really
just like a one-pixel line drawn between the last line of text of one
message and the first line of text of the next message. Does anybody
know how to achieve that?

Back to the patch, I think I'll be able to push it as soon as I can
apply it and still _see_ the subject lines. ;-)

-Carl

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

* Re: [PATCH -v2] notmuch.el: Add face support to search and show mode
  2009-11-22 12:02 ` Carl Worth
@ 2009-11-22 12:21   ` Aneesh Kumar K.V
  2009-11-22 22:48     ` Carl Worth
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-22 12:21 UTC (permalink / raw)
  To: Carl Worth; +Cc: notmuch

On Sun, Nov 22, 2009 at 01:02:21PM +0100, Carl Worth wrote:
> On Sun, 22 Nov 2009 14:07:56 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> > This add two faces, notmuch-show-subject-face and
> > notmuch-tag-unread-face. The first face is used to show the subject
> > line in the notmuch-show-mode and the second one to show the unread
> > tag in the notmuch-search-mode. We can set additional tags by setting
> > notmuch-tag-face-alist as below
> 
> Hi Aneesh,
> 
> I've been meaning to follow-up with you on this since I did get it
> working.
> 
> > (setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
> > 				 ("inbox" . 'notmuch-tag-inbox-face)))
> 
> It's interesting to be able to highlight specific tags like this. But I
> think that first I'd like to have a single 'notmuch-tag face to make it
> easier to see all the tag names, since they're hard to see among the
> subject. And then maybe after that have s 'notmuch-tag-important-face or
> something. I'm guessing that just that much would cover most people's
> needs, before needing to choose custom colors for each tag name.

The default search pattern for notmuch is inbox and unread right. So adding
both of them to the notmuch-tag-face-alist should color the tags properly.

> 
> > +(defface notmuch-show-subject-face
> > + '((((class color) (background light)) (:foreground "yellow" :bold t))
> > +    (((class color) (background dark)) (:foreground "yellow" :bold t)))
> > +  "Notmuch show mode face used to highligh subject line."
> > +  :group 'notmuch)
> 
> Color selection can be pretty difficult, and I don't think we're ever
> all going to agree on things. But I can at least say that I can't read
> yellow on white at all, (maybe yellow on black works out a bit better, I
> don't know).
> 
> So I'd definitely like to hear people's ideas on what the presentation
> should look like here.
> 
> First, the current reverse-video is definitely not something I really
> like. That was just a placeholder since I didn't know how to configure
> other faces, (and I needed _something_ to distinguish one message from
> another).
> 
> Second, from the time I spent with sup, I found that it was hard for me
> to read entire lines of bold text. So I think I'd rather just have the
> header name ("Subject:", for example) in bold and the rest of the
> subject not bold. Hmm... maybe we could use a "From:" at the beginning
> of the one line summary.
> 
> Finally, for separating one message from the other, I think I'd really
> just like a one-pixel line drawn between the last line of text of one
> message and the first line of text of the next message. Does anybody
> know how to achieve that?
> 
> Back to the patch, I think I'll be able to push it as soon as I can
> apply it and still _see_ the subject lines. ;-)

One of the easy part with emacs is we can use customize-face and select 
notmuch-show-subject-face to select what ever suites your configuration.
For me with black background i found yellow with bold to be nice.

-aneesh

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

* Re: [PATCH -v2] notmuch.el: Add face support to search and show mode
  2009-11-22 12:21   ` Aneesh Kumar K.V
@ 2009-11-22 22:48     ` Carl Worth
  0 siblings, 0 replies; 4+ messages in thread
From: Carl Worth @ 2009-11-22 22:48 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: notmuch

On Sun, 22 Nov 2009 17:51:06 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> > It's interesting to be able to highlight specific tags like this. But I
> > think that first I'd like to have a single 'notmuch-tag face to make it
> > easier to see all the tag names, since they're hard to see among the
> > subject. And then maybe after that have s 'notmuch-tag-important-face or
> > something. I'm guessing that just that much would cover most people's
> > needs, before needing to choose custom colors for each tag name.
> 
> The default search pattern for notmuch is inbox and unread right. So adding
> both of them to the notmuch-tag-face-alist should color the tags
> properly.

Well, actually the default search pattern for notmuch is just "inbox".

But it's really about *all* the tags I have on the messages. I would
like all of my tags to stand out from the subject line, (and I don't
want to keep adjusting notmuch-tag-face-alist every time I add a new
tag).

I'd prefer instead to just be able to choose a color that would
highlight everyhing between the final set of parentheses in the search
results.

> One of the easy part with emacs is we can use customize-face and select 
> notmuch-show-subject-face to select what ever suites your configuration.
> For me with black background i found yellow with bold to be nice.

OK. I'll experiment and look for a reasonable color for a white
background.

-Carl

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

end of thread, other threads:[~2009-11-22 22:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-22  8:37 [PATCH -v2] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
2009-11-22 12:02 ` Carl Worth
2009-11-22 12:21   ` Aneesh Kumar K.V
2009-11-22 22:48     ` Carl Worth

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