* font-lock-add-keywords
@ 2004-08-05 15:08 Randy Haddox
0 siblings, 0 replies; 3+ messages in thread
From: Randy Haddox @ 2004-08-05 15:08 UTC (permalink / raw)
I am using code in .emacs to find and color code various keywords. I
haven't had any luck handling the "if" keyword when it doesn't starting
in column 1 (ie, has leading whitespace). Most of the time the "if"
will start at the beginning.
(defface test-keyword6-face
'((t (:foreground "gold")))
"Keyword face.")
(font-lock-add-keywords 'latex-mode
'(("^if\\|then\\|else\\|endif" . 'test-keyword6-face))
)
Any help would be much appreciated.
Thanks,
Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: font-lock-add-keywords
[not found] <mailman.0.1091718744.2011.help-gnu-emacs@gnu.org>
@ 2004-08-05 15:39 ` Kevin Rodgers
2004-08-05 22:35 ` font-lock-add-keywords Arjan Bos
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2004-08-05 15:39 UTC (permalink / raw)
Randy Haddox wrote:
> I am using code in .emacs to find and color code various keywords. I
> haven't had any luck handling the "if" keyword when it doesn't starting
> in column 1 (ie, has leading whitespace). Most of the time the "if"
> will start at the beginning.
>
> (defface test-keyword6-face
> '((t (:foreground "gold")))
> "Keyword face.")
> (font-lock-add-keywords 'latex-mode
> '(("^if\\|then\\|else\\|endif" . 'test-keyword6-face))
> )
Well you've explicitly anchored "if" to the beginning of the line with
"^". (None of the other keywords are anchored, due to the low
precedence of "\\|"). Getting rid of the "^" should fix it.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: font-lock-add-keywords
[not found] <mailman.0.1091718744.2011.help-gnu-emacs@gnu.org>
2004-08-05 15:39 ` font-lock-add-keywords Kevin Rodgers
@ 2004-08-05 22:35 ` Arjan Bos
1 sibling, 0 replies; 3+ messages in thread
From: Arjan Bos @ 2004-08-05 22:35 UTC (permalink / raw)
Randy Haddox wrote:
> I am using code in .emacs to find and color code various keywords. I
> haven't had any luck handling the "if" keyword when it doesn't starting
> in column 1 (ie, has leading whitespace). Most of the time the "if"
> will start at the beginning.
>
> (defface test-keyword6-face
> '((t (:foreground "gold")))
> "Keyword face.")
> (font-lock-add-keywords 'latex-mode
> '(("^if\\|then\\|else\\|endif" . 'test-keyword6-face))
> )
>
>
> Any help would be much appreciated.
>
>
So `if' can have zero or more whitespaces in front of it. And perhaps
there might even be a tab character in front of it too. So you might
want to consider matching
"^[ \t]*if\\|then\\|else\\|endif"
"^" will match the beginning of a line (as you know)
"[ \t]" will match a whitespace or a tab character
"*" will match zero or more of the thing before it.
So "[ \t]*" will match zero or more of either whitespace or tab and
"^[ \t]*if" will match `if' starting on a line with zero or more
whitespace and / or tab characters in front of it.
HTH,
Arjan
--
--
If you really want to contact me, then replace the "I see you" text by
its three letter accronym, hetnet.
Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-08-05 22:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-05 15:08 font-lock-add-keywords Randy Haddox
[not found] <mailman.0.1091718744.2011.help-gnu-emacs@gnu.org>
2004-08-05 15:39 ` font-lock-add-keywords Kevin Rodgers
2004-08-05 22:35 ` font-lock-add-keywords Arjan Bos
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.