From: "Sébastien Vauban" <zthjwsqqafhv-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org
Subject: Re: Adding keywords for font-lock experts
Date: Thu, 12 Mar 2009 11:14:42 +0100 [thread overview]
Message-ID: <87skljkpyl.fsf@mundaneum.com> (raw)
In-Reply-To: 87eix6n724.fsf@mundaneum.com
Hello,
> My goal is to highlight some words [like `Warning'] in (almost) all modes.
>
> To do such a thing, I've found on the Web [...] different solutions.
>
> (font-lock-add-keywords nil
> `(("\\(BUGS\\|FIXME\\|Firefox\\|TODO\\|Warning\\|WARNING\\)"
> 1 'font-lock-warning-face prepend))))
>
> [...]
>
> (font-lock-add-keywords mode
> `((,pattern
> 1 'special-words prepend))))
>
> They almost behave the same from a user perspective, but is one of them
> superior to the others from a technical perspective (better coding regarding
> different versions of Emacs, portability, etc.)?
I've found good documentation
(http://www.gnu.org/software/emacs/elisp/html_node/Customizing-Keywords.html#Customizing-Keywords)
explaining the differences between the exposed solutions:
o one is to add fontification patterns for _one major mode only_;
o the other affects _all derived modes_ as well.
I've now rewritten the codes as follows:
--8<---------------cut here---------------start------------->8---
;; special words
(setq keywords-level-1-pattern "\\(BUGS\\|FIXME\\|TODO\\)")
(make-face 'keywords-level-1)
(set-face-attribute 'keywords-level-1 nil :foreground "red")
(setq keywords-level-2-pattern "\\(WARNING\\)")
(make-face 'keywords-level-2)
(set-face-attribute 'keywords-level-2 nil :foreground "purple")
;; set up highlighting of special words for proper selected major modes only
(dolist (mode '(fundamental-mode
gnus-article-mode
message-mode
text-mode)) ; no interference with org-mode (which derives
; from text-mode)
(font-lock-add-keywords mode
`((,keywords-level-1-pattern 1 'keywords-level-1 prepend)
(,keywords-level-2-pattern 1 'keywords-level-2 prepend))))
--8<---------------cut here---------------end--------------->8---
Though:
o it still does not work with _LaTeX logs_ (generated on the fly in
buffers that are *not* associated with a file), such as `*test output'
-- whose major mode is `fundamental-mode';
o it still does not work with Gnus (for messages that I'm _reading_ as
well as for messages that I'm _composing_).
Can some expert please help me on this? I'm now totally blocked at this
stage...
Best regards,
Seb
--
Sébastien Vauban
prev parent reply other threads:[~2009-03-12 10:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-09 13:45 Adding keywords for font-lock experts Sébastien Vauban
2009-03-12 10:14 ` Sébastien Vauban [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87skljkpyl.fsf@mundaneum.com \
--to=zthjwsqqafhv-genee64ty+gs+fvcfc7uqw@public.gmane.org \
--cc=help-gnu-emacs-mXXj517/zsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.