* please help with font-lock-add-keywords
@ 2009-12-31 1:06 bufie
2009-12-31 13:08 ` Tassilo Horn
[not found] ` <mailman.477.1262264969.18930.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 5+ messages in thread
From: bufie @ 2009-12-31 1:06 UTC (permalink / raw)
To: help-gnu-emacs
(originally posted to comp.emacs, but moved here since it seems more
appropriate...)
Hi all,
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).
Almost all of the functions start with the same prefix "qbb-" so that
shouldn't be too hard (though for the examples I've just tried to use
some actual function names to get it to work). I've done a bunch of web
searching, and haven't figured out a way to make this work.
I've tried all of the following, and none of them work for me... I
don't claim to be a wizard at this stuff, but thought I had followed the
examples correctly
(font-lock-add-keywords
'lisp-mode
'(("\\<\\(qbb-create-image\\|qbb-destroy-image\\)\\>" .
font-lock-keyword-face)))
(font-lock-add-keywords
'lisp-mode
'(("\\<\\qbb-create-image\\)" 2 font-lock-keyword-face t)))
(add-hook 'lisp-mode-hook
(lambda ()
(font-lock-add-keywords
nil
'(("\\<\\(qbb-create-image\\|qbb-destroy-image\\)\\>" .
font-lock-keyword-face)))))
I'm sure this can't be as hard as I'm making it -- help, please!
Thanks in advance!
b
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: please help with font-lock-add-keywords
2009-12-31 1:06 please help with font-lock-add-keywords bufie
@ 2009-12-31 13:08 ` Tassilo Horn
[not found] ` <mailman.477.1262264969.18930.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 5+ messages in thread
From: Tassilo Horn @ 2009-12-31 13:08 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: please help with font-lock-add-keywords
[not found] ` <mailman.477.1262264969.18930.help-gnu-emacs@gnu.org>
@ 2009-12-31 23:14 ` bufie
2010-01-07 0:39 ` David Combs
1 sibling, 0 replies; 5+ messages in thread
From: bufie @ 2009-12-31 23:14 UTC (permalink / raw)
To: help-gnu-emacs
Tassilo Horn wrote:
> 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---
Thanks! This is perfect -- it seems to do exactly what I needed! (and
thanks for the help on the other possibilities as well -- that's great
and may come in handy in the future!)
Thanks again, and Happy New Year!
-b
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: please help with font-lock-add-keywords
[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
1 sibling, 1 reply; 5+ messages in thread
From: David Combs @ 2010-01-07 0:39 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.477.1262264969.18930.help-gnu-emacs@gnu.org>,
Tassilo Horn <tassilo@member.fsf.org> wrote:
>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
Please, what is a "shy group"? Some math thing?
Thanks,
David
>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
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: please help with font-lock-add-keywords
2010-01-07 0:39 ` David Combs
@ 2010-01-07 1:01 ` Lennart Borgman
0 siblings, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2010-01-07 1:01 UTC (permalink / raw)
To: David Combs; +Cc: help-gnu-emacs
On Thu, Jan 7, 2010 at 1:39 AM, David Combs <dkcombs@panix.com> wrote:
>>> (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
>
> Please, what is a "shy group"? Some math thing?
It is a group that does not record sub expressions in the match.
Written with (?: ...) like
'(("\\<\\(?:qbb-create-image\\|qbb-destroy-image\\)\\>" .
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-07 1:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-31 1:06 please help with font-lock-add-keywords bufie
2009-12-31 13:08 ` Tassilo Horn
[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
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.