From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?S=C3=A9bastien_Vauban?= Newsgroups: gmane.emacs.help Subject: Adding keywords for font-lock experts Date: Mon, 09 Mar 2009 14:45:39 +0100 Organization: Sebastien Vauban Message-ID: <87eix6n724.fsf@mundaneum.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1236636900 23393 80.91.229.12 (9 Mar 2009 22:15:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Mar 2009 22:15:00 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Mon Mar 09 23:16:16 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lgnld-0004rE-3q for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Mar 2009 23:16:13 +0100 Original-Received: from localhost ([127.0.0.1]:39311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LgnkH-0008LP-8h for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Mar 2009 18:14:49 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!news.motzarella.org!motzarella.org!news.motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 87 Original-X-Trace: news.eternal-september.org U2FsdGVkX19wEdftkuPhXGVWQgWeGr2Dl8xbcazQ3FG3rAr4s1MkGWBvu2kUhGnAyMPdM/OC9N6F8KqbPml0F11Q1d5T1RDw6E27NOQ28XoAP7hLQG3T91eNBM1joUjvpmrNnzwmeDM= Original-X-Complaints-To: Please send complaints to abuse-xVLBGngCCsvFKiuWU8UaTg@public.gmane.org with full headers Original-NNTP-Posting-Date: Mon, 9 Mar 2009 13:45:40 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18vBsc52WOLdcRUMB/we1gS4Djz+7F3C3I= X-Archive: encrypt Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoBAMAAAB+0KVeAAAAElBMVEUAAAAAAP+LRRP0pGC+vr7///+7mT1iAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9cBBwMODhglKe4AAAEsSURBVCjPbZNBboQwDEV/Cd4X9QJRThApmn0XYW+Jyf2v0m+HhqDBgiAe9rcTG7QHw/1Vn2Ar8gBb/ocywSN3qK9T3z4eFDB4eApocBpeBs1RSykoJd8gQcm8pGmHXFso3ajnmsqV0TnYDQkOfXUfN5NwaI7AWTVOyEhcu1aHmdWItHddUVUcUgUBCkitu8V6ditHVOVdqzl2EQ1ZVGTbdK0V7cqn8vWzoU5Q/bF9Y/Y0cRU1xwkys5dJ+Dt6pBDWifcNQml8Gh2JVmPSoQzo7en0grswkxrUGYJ70hSxxAGr7ZMwYcHIzprpi7TENEE1xtiYxixRlCfPBsUUrwHD7uGIwATrbnODJcVrPpVn3hxiGloem/S+z3CtuzUSMo83N4DPH+F0evwR3P4A2k+75838OKQAAAAASUVORK5CYII= X-Www-site: Under construction... Cancel-Lock: sha1:goUGPBGerDtuDB70uik4Ywfkabk= sha1:y7MnQ+ie2IzqAj9y8ITL6OKgQ0s= User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:167487 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:62789 Archived-At: Hello, This question has already been answered several times, but never in a fully satisfactory way. So, I ask it now, once again, but in a much more detailed way. My goal is to highlight some words in (almost) all modes. As an example, I would like to see the word `Warning' highlighted in the following buffers: o any text buffer or programming buffer, o the Gnus article buffer (`gnus-article-mode'), o the LaTeX log buffer (`fundamental-mode'?). To do such a thing, I've found on the Web 3 slightly different solutions, displayed below: --8<---------------cut here---------------start------------->8--- (make-face 'special-words) (set-face-attribute 'special-words nil :foreground "White" :background "Fir= ebrick") ;; solution 1 (dolist (mode '(fundamental-mode gnus-article-mode org-mode shell-mode muse= -mode)) (font-lock-add-keywords mode '(("\\<\\(BUGS\\|FIXME\\|TODO\\)" 0 'font-lock-warning-face t) ("\\<\\(Firefox\\|Warning\\|WARNING\\)" 0 'special-words t)))) ;; solution 2 (defun highlighting-install () (interactive) (font-lock-mode -1) (font-lock-mode 1) (font-lock-add-keywords nil `(("\\(BUGS\\|FIXME\\|Firefox\\|TODO\\|Warning\\|WARNING\\)" (1 'font-lock-warning-face prepend))))) (dolist (hook '(fundamental-mode-hook gnus-article-mode-hook org-mode-hook shell-mode-hook muse-mode-hook)) (add-hook hook 'highlighting-install)) ;; solution 3 (let ((pattern "\\<\\(BUGS\\|FIXME\\|Firefox\\|TODO\\|Warning\\|WARNING\\)"= )) (mapc (lambda (mode) (font-lock-add-keywords mode `((,pattern 1 'special-words prepend)))) '(fundamental-mode gnus-article-mode org-mode shell-mode muse-mode))) --8<---------------cut here---------------end--------------->8--- 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.)? Though, I have 2 problems: o solution 2 is different from solutions 1 and 3 for the Gnus article buffer: - in solution 2, the word `Warning' is highlighted but the re= st of the buffer isn't anymore (mail headers); - with solutions 1 and 3, the article buffer is highlighted l= ike always, but the word `Warning' is not. o none of the solutions highlights the word `Warning' in the LaTeX log (`C-c C-c LaTeX' from AUCTeX), though I've included `fundamental-mo= de' in the above codes. Can someone help me/us getting this working? Thanks a lot in advance! Best regards, Seb --=20 S=C3=A9bastien=C2=A0Vauban