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: Re: Adding keywords for font-lock experts Date: Thu, 12 Mar 2009 11:14:42 +0100 Organization: Sebastien Vauban Message-ID: <87skljkpyl.fsf@mundaneum.com> References: <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 1236854493 20582 80.91.229.12 (12 Mar 2009 10:41:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Mar 2009 10:41:33 +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 Thu Mar 12 11:42:50 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 1LhiMR-0001Ck-S2 for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Mar 2009 11:42:00 +0100 Original-Received: from localhost ([127.0.0.1]:35350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LhiL5-0000Zd-U5 for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Mar 2009 06:40:35 -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: 71 Original-X-Trace: news.eternal-september.org U2FsdGVkX1/L/+ywNm0pYxfpACNUOAU6n3vhCTpNDe5etgwFFTBySk4XtkoiXFfff6Sm/mvKssHEZTWFBI/DS7Y6u034FHGqAwbNattBtHI45+9CP1ShudKGGko7sENYHCkyMq3UiN0= Original-X-Complaints-To: Please send complaints to abuse-xVLBGngCCsvFKiuWU8UaTg@public.gmane.org with full headers Original-NNTP-Posting-Date: Thu, 12 Mar 2009 10:14:43 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18j7V5dFtlo4XuhxItupP9Lrl7cGL2INqU= X-Archive: encrypt X-Www-site: Under construction... Cancel-Lock: sha1:yAO4uV/g9XUbhF7v+Kd5sKjsDsM= sha1:ErXHO30xTc9MSFTJz2uJEl4FcWQ= User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:167522 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:62845 Archived-At: 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 regard= ing > different versions of Emacs, portability, etc.)? I've found good documentation (http://www.gnu.org/software/emacs/elisp/html_node/Customizing-Keywords.htm= l#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 outp= ut' -- 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 --=20 S=C3=A9bastien=C2=A0Vauban