From: Tassilo Horn <tassilo@member.fsf.org>
To: help-gnu-emacs@gnu.org
Subject: Re: please help with font-lock-add-keywords
Date: Thu, 31 Dec 2009 14:08:46 +0100 [thread overview]
Message-ID: <87pr5vcmu9.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: hhgteb$uki$1@news.eternal-september.org
bufie <bufie@spamneggs.com> writes:
Hi!
> I'd like to fontify a whole bunch of function names for a project I'm
> working on (which uses lisp mode, not emacs-lisp-mode -- for
> reference, I'm using GNU emacs 23.1.1).
This works for me and highlights any symbol starting with qbb- in the
keyword face.
--8<---------------cut here---------------start------------->8---
(font-lock-add-keywords
'lisp-mode
'(("\\<qbb-[[:alnum:]-]+\\>" . font-lock-keyword-face)))
--8<---------------cut here---------------end--------------->8---
> (font-lock-add-keywords
> 'lisp-mode
> '(("\\<\\(qbb-create-image\\|qbb-destroy-image\\)\\>" .
> font-lock-keyword-face)))
Looks ok to me.
> (font-lock-add-keywords
> 'lisp-mode
> '(("\\<\\qbb-create-image\\)" 2 font-lock-keyword-face t)))
^
I think a paren is missing there. And if there was one, you would like
to highlight the first group, so the 2 has to be replaced with 1.
> (add-hook 'lisp-mode-hook
> (lambda ()
> (font-lock-add-keywords
> nil
> '(("\\<\\(qbb-create-image\\|qbb-destroy-image\\)\\>" .
> font-lock-keyword-face)))))
Looks correct. But when using the ("regexp" . face) form, you can use
shy groups for performance reasons, because here you refer to the whole
match anyway and not to a group by number.
Hm, if your first and last solutions don't work, I'd guess you are not
in lisp-mode...
Bye,
Tassilo
next prev parent reply other threads:[~2009-12-31 13:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-31 1:06 please help with font-lock-add-keywords bufie
2009-12-31 13:08 ` Tassilo Horn [this message]
[not found] ` <mailman.477.1262264969.18930.help-gnu-emacs@gnu.org>
2009-12-31 23:14 ` bufie
2010-01-07 0:39 ` David Combs
2010-01-07 1:01 ` Lennart Borgman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pr5vcmu9.fsf@thinkpad.tsdh.de \
--to=tassilo@member.fsf.org \
--cc=help-gnu-emacs@gnu.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.
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).