[notmuch] [PATCH -v4] notmuch.el: Add face support to search and show mode
Aneesh Kumar K. V
aneesh.kumar at linux.vnet.ibm.com
Wed Nov 25 07:47:46 PST 2009
On Tue, 24 Nov 2009 21:24:07 -0800, Alexander Botero-Lowry <alex.boterolowry at gmail.com> wrote:
> On Wed, 25 Nov 2009 10:28:00 +0530, "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com> wrote:
> > This add two faces, notmuch-show-subject-face and
> > notmuch-tag-face. The first face is used to show the subject
> > line in the notmuch-show-mode and the second one to show tags
> > in the notmuch-search-mode.
> First, I definetly think fontification is the way to go instead of
> the adhoc/crappy way that cworth and I have been doing this in the
> > +(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")
> > +
> So what happens if I have Subject: xxxx in my message?
It will highlight them too. I initially tried to highlight it only
in the header fields. But then my elisp is not good to find out
how to do it for the full message. That is we need to search the
header area of each message and highlight specific fields. And all
the message fall in the same buffer.
> We already ran
> into a problem where a patch sent the list that included notmuch control
> character caused it to go into an infinite loop, I'd prefer our
> fontification code be a bit more resilient. At the very least this
> should use the font-lock syntax tables stuff to only do header
> fontification when inside the header block. This would probably require
> that fontification occur before the message is post-processed by
> notmuch-show to remove the section markers etc.
Highlighting specific part of the email should not get any trouble
like infinite loop. Unless somebody figure out how to make elisp
highlight specific area, it would be nice to have the patch applied.
I really found it to help me when reading mails.
> Also +1 for more subduded colors than red. :) Possibly consider copying
> the message-mode colors, so that there is a bit of consistency between
> sending and viewing mail? Might even be able to steal the message-mode
> faces by importing their symbols.
I use yellow with black background. It is difficult to find a color that
everybody likes. Infact once of the reason the patch was not applied
till now was yellow may the subject line not readable. So i went for
read which kind of looked fine with white background.
> > (defun notmuch-search-mode ()
> > "Major mode for searching mail with notmuch.
> > @@ -865,7 +888,18 @@ 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)
> > + (if (not notmuch-tag-face-alist)
> > + (add-to-list 'notmuch-search-font-lock-keywords (list
> > + "\\(([^)]*)$\\)" '(1 'notmuch-tag-face)))
> This way of detecting the tags seems ok, but I think it would be nicer
> if it could be done even more deterministically. :) One idea that be
> neat is to have a --format=sexp for notmuch search, which exports sexps
> (probably alists, but could be some other format) for the search results
> that can just be eval'd and processed in a cleaner way (and would also
> make for nicer APIs in emacs for querying notmuch itself). Actually I
> really like the idea of a sexp output mode for show too, instead of the
> markers.... *plots*
> > + (progn
> > + (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)))
> I don't really see the point of fontifying all tags the same way if no
> tag-faces have been set, especially if none of the rest of the search
> results are fontified.
This was done as per Carl's request. The idea was to make tags stand out
from rest of the subject.
More information about the notmuch