* font-lock problems
@ 2005-09-18 10:50 Mads Jensen
2005-09-19 14:09 ` Stefan Monnier
2005-09-19 22:39 ` rgb
0 siblings, 2 replies; 6+ messages in thread
From: Mads Jensen @ 2005-09-18 10:50 UTC (permalink / raw)
Hi NG,
I am trying to get font-lock to color some words, but I am not having
very much luck doing it. I am using regexp-opt for creating a list of
words to colorize. The code, that I am using is this:
<code>
(defface inducks-keyword-face
'((t (:foreground "green"))) "face for inducks fields")
(defvar inducks-keywords (regexp-opt '("aka" "altcode" "anim" "app"
"art" "artdir" "background" "brokpg" "cast" "changes"
"chardesign" "code" "col" "collecting" "comment"
"country" "date" "desc" "desc" "dir" "distrib" "edit"
"effectsanim" "enddate" "entrycode" "equiv" "fly"
"genre" "hero" "hiddencomm" "idc" "includedin"
"includes" "ink" "internal" "inx" "issdate" "isslang"
"issuecode" "issueseriescode" "issuevolumecode" "lang"
"layout" "let" "level" "max" "missing" "music" "names"
"orderer" "origpg" "owner" "pagel" "pages" "part" "plot"
"price" "prod" "pscode" "pubdate" "publ" "re" "rp-de"
"rp-dk" "rp-fi" "rp-se" "ser" "size" "source"
"story-comm" "storycode" "storyitem" "superref"
"superrefd" "tim" "title" "titlepref" "trans" "voices"
"westernl" "writ" "xapp" "xref" "xrefd" "desc-fi"
"desc-da" "desc-se" "desc-no" "desc-it" "desc-ru"
"desc-nl" "desc-de") 'words) "inducks keywords to
colorize")
(font-lock-add-keywords 'inducks-mode
'(("slam" . 'font-lock-comment-face)))
(font-lock-add-keywords 'inducks-mode
'(((concat
"\\<\\(" inducks-keywords "\\)\\>")
. 'inducks-keyword-face)))
</code>
The "slam" is not being colorized either. This is part of a major mode,
I am writing. Thank you very much in advance,
--
Mads Jensen - mail sent to address ends in /dev/null
s/spam/madsj for emailing me
gpg: 7E775BDA
It is impossible to make anything foolproof because fools are so
ingenious.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock problems
2005-09-18 10:50 font-lock problems Mads Jensen
@ 2005-09-19 14:09 ` Stefan Monnier
2005-09-19 16:07 ` Mads Jensen
2005-09-19 22:39 ` rgb
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-09-19 14:09 UTC (permalink / raw)
> (font-lock-add-keywords
Major modes shouldn't use font-lock-add-keywords for keywords that are
always highlighted. It would only make sense for things which change
dynamically (i.e. very rare).
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock problems
2005-09-19 14:09 ` Stefan Monnier
@ 2005-09-19 16:07 ` Mads Jensen
2005-09-20 9:25 ` Tim X
2005-09-21 2:34 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Mads Jensen @ 2005-09-19 16:07 UTC (permalink / raw)
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > (font-lock-add-keywords
>
> Major modes shouldn't use font-lock-add-keywords for keywords that are
> always highlighted. It would only make sense for things which change
> dynamically (i.e. very rare).
How am I supposed to get the words colored ? I have more things to
colorize, but I hope that it'll be easier to make that after learning
how to colorize something in the first place. Someone once pointed me to
(info "(elisp)Face foreground") (or something like that), which wasn't
of any help to me, as I see it.
--
Mads Jensen - mail sent to address ends in /dev/null
s/spam/madsj for emailing me
gpg: 7E775BDA
It is impossible to make anything foolproof because fools are so
ingenious.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock problems
2005-09-18 10:50 font-lock problems Mads Jensen
2005-09-19 14:09 ` Stefan Monnier
@ 2005-09-19 22:39 ` rgb
1 sibling, 0 replies; 6+ messages in thread
From: rgb @ 2005-09-19 22:39 UTC (permalink / raw)
> I am trying to get font-lock to color some words
> ...
> This is part of a major mode, I am writing.
Generally in a major mode you would use something like
(setq font-lock-defaults
'((inducks-keywords 0 'inducks-keyword-face)
...))
rather than font-lock-add-keywords.
I usually only see font-lock-add-keywords used in in
customzation functions such as something put on a mode
hook or in a derived mode.
I didn't look too close at your syntax though.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock problems
2005-09-19 16:07 ` Mads Jensen
@ 2005-09-20 9:25 ` Tim X
2005-09-21 2:34 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Tim X @ 2005-09-20 9:25 UTC (permalink / raw)
Mads Jensen <spam@raptus.dk> writes:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > > (font-lock-add-keywords
> >
> > Major modes shouldn't use font-lock-add-keywords for keywords that are
> > always highlighted. It would only make sense for things which change
> > dynamically (i.e. very rare).
>
> How am I supposed to get the words colored ? I have more things to
> colorize, but I hope that it'll be easier to make that after learning
> how to colorize something in the first place. Someone once pointed me to
> (info "(elisp)Face foreground") (or something like that), which wasn't
> of any help to me, as I see it.
> --
Use the source Luke!
Have a look at a simple mode to get the best way to do it. I found
sql.el (part of the emacs distribution) to be very straight forward
and gave me everything I needed in creating a very basic
mode. Unfortunately that was a few years backa nd I've since stopped
using the mode I created and cannot find its original source. However,
I do remember sql.el put me in the right direction on things like
font-locking, the use of the syntax table, handling of comments and
different comment styles etc.
Tim
--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: font-lock problems
2005-09-19 16:07 ` Mads Jensen
2005-09-20 9:25 ` Tim X
@ 2005-09-21 2:34 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-09-21 2:34 UTC (permalink / raw)
> How am I supposed to get the words colored ? I have more things to
> colorize, but I hope that it'll be easier to make that after learning
> how to colorize something in the first place. Someone once pointed me to
> (info "(elisp)Face foreground") (or something like that), which wasn't
> of any help to me, as I see it.
Take a look at
http://www.emacswiki.org/cgi-bin/wiki?id=SampleMode
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-09-21 2:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-18 10:50 font-lock problems Mads Jensen
2005-09-19 14:09 ` Stefan Monnier
2005-09-19 16:07 ` Mads Jensen
2005-09-20 9:25 ` Tim X
2005-09-21 2:34 ` Stefan Monnier
2005-09-19 22:39 ` rgb
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).