unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch.el: Add face support to search and show mode
@ 2009-11-20 15:27 Aneesh Kumar K.V
  2009-11-21  2:59 ` Carl Worth
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-20 15:27 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 the unread tag in
the notmuch-search-mode.

The changes are done looking at message.el in emacs source

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

diff --git a/notmuch.el b/notmuch.el
index 4b2936a..71e9dea 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -603,9 +603,37 @@ which this thread was originally shown."
   (force-window-update)
   (redisplay t))
 
+(defun notmuch-font-lock-matcher (regexp)
+  (let ((form
+         `(lambda (limit)
+            (let ((start (point)))
+              (save-restriction
+                (widen)
+                (goto-char (point-min))
+		(setq limit (min limit (point-max)))
+                (goto-char start))
+              (and (< start limit)
+                   (re-search-forward ,regexp limit t))))))
+    (if (featurep 'bytecomp)
+        (byte-compile form)
+      form)))
+
+(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
+  (let ((content ""))
+    `((,(notmuch-font-lock-matcher
+	 (concat "\\(Subject:.*$\\)" content))
+	 (1 'notmuch-show-subject-face nil t))))
+  "Additonal expression to hightlight in notmuch-search-mode")
+
 ;;;###autoload
-(defun notmuch-show-mode ()
-  "Major mode for viewing a thread with notmuch.
+(define-derived-mode notmuch-show-mode text-mode "notmuch-show"
+"Major mode for viewing a thread with notmuch.
 
 This buffer contains the results of the \"notmuch show\" command
 for displaying a single thread of email from your email archives.
@@ -643,7 +671,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
 
@@ -769,8 +799,21 @@ thread from that buffer can be show when done with this one)."
   (end-of-buffer arg)
   (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 inbox tags."
+  :group 'notmuch)
+
+(defvar notmuch-search-font-lock-keywords
+  (let ((content ""))
+    `((,(notmuch-font-lock-matcher
+	 (concat "\\(unread\\)" content))
+	 (1 'notmuch-tag-unread-face nil t))))
+  "Additonal expression to hightlight in notmuch-search-mode")
+
 ;;;###autoload
-(defun notmuch-search-mode ()
+(define-derived-mode notmuch-search-mode text-mode "notmuch-search"
   "Major mode for searching mail with notmuch.
 
 This buffer contains the results of a \"notmuch search\" of your
@@ -799,7 +842,9 @@ 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)
+  (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] notmuch.el: Add face support to search and show mode
  2009-11-20 15:27 [PATCH] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
@ 2009-11-21  2:59 ` Carl Worth
  2009-11-21  4:07   ` Aneesh Kumar K.V
  0 siblings, 1 reply; 4+ messages in thread
From: Carl Worth @ 2009-11-21  2:59 UTC (permalink / raw)
  To: Aneesh Kumar K.V, notmuch

On Fri, 20 Nov 2009 20:57:24 +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 the unread tag in
> the notmuch-search-mode.
> 
> The changes are done looking at message.el in emacs source

Hi Aneesh,

This looks like very interesting stuff, but I wasn't able to get it to
work. Initially I was running emacs within a terminal (emacs -nw) so I
thought that might be preventing me from seeing the face differences or
so.

But I can't seem to see anything in graphical emacs either.

Is there something more I need to do to make this work?

-Carl

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

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

On Sat, Nov 21, 2009 at 03:59:12AM +0100, Carl Worth wrote:
> On Fri, 20 Nov 2009 20:57:24 +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 the unread tag in
> > the notmuch-search-mode.
> > 
> > The changes are done looking at message.el in emacs source
> 
> Hi Aneesh,
> 
> This looks like very interesting stuff, but I wasn't able to get it to
> work. Initially I was running emacs within a terminal (emacs -nw) so I
> thought that might be preventing me from seeing the face differences or
> so.
> 
> But I can't seem to see anything in graphical emacs either.
> 
> Is there something more I need to do to make this work?

To verify whether i have some setting in .emacs i ran emacs -q and still
i am able see the colors. So not sure what extra is needed. I also tried
emacs23 and that also worked. Are you able to see this faces via customize-face
command ? And what is the color they display in customize-face ?

-aneesh

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

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

On Sat, 21 Nov 2009 09:37:30 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> To verify whether i have some setting in .emacs i ran emacs -q and still
> i am able see the colors. So not sure what extra is needed. I also tried
> emacs23 and that also worked. Are you able to see this faces via customize-face
> command ? And what is the color they display in customize-face ?

I think this was user-error on my part. So sorry about the noise.

For one thing, I recently broke the Makefiles to install
notmuch.el/notmuch.elc into the wrong directory.

Fixes shortly...

-Carl

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

end of thread, other threads:[~2009-11-21 10:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20 15:27 [PATCH] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
2009-11-21  2:59 ` Carl Worth
2009-11-21  4:07   ` Aneesh Kumar K.V
2009-11-21 10:31     ` 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).