From: Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl>
Subject: Re: font-lock-add-keywords
Date: Fri, 06 Aug 2004 00:35:55 +0200 [thread overview]
Message-ID: <ceucoa$co5$1@reader13.wxs.nl> (raw)
In-Reply-To: <mailman.0.1091718744.2011.help-gnu-emacs@gnu.org>
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
next prev parent reply other threads:[~2004-08-05 22:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
2004-08-05 15:08 font-lock-add-keywords Randy Haddox
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='ceucoa$co5$1@reader13.wxs.nl' \
--to=arjan.bos@nospam.iseeyou.nl \
--cc=Arjan.Bos@ISeeYou.nl \
/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.
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.