* generic-mode: Keywords also highlight with an underscore
@ 2005-08-24 7:51 "O. Wölfelschneider"
2005-08-24 22:52 ` rgb
0 siblings, 1 reply; 4+ messages in thread
From: "O. Wölfelschneider" @ 2005-08-24 7:51 UTC (permalink / raw)
Hi group!
Say I did:
(define-generic-mode 'fnord-mode
nil
(list "fnord" "foobar")
nil
(list "\\.fnord")
(list 'turn-on-font-lock))
This mode will then highlight the keywords fnord and foobar.
However, it will also highlight _fnord, foobar_ and so on.
I do not want the keyword to highlight if it has an
underscore attached to it.
How can I get rid of this behaviour?
(Emacs 21.4 that comes with debian sarge, also an older
20.7.1 on windows)
Thanks!
Olav
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: generic-mode: Keywords also highlight with an underscore
2005-08-24 7:51 generic-mode: Keywords also highlight with an underscore "O. Wölfelschneider"
@ 2005-08-24 22:52 ` rgb
2005-08-25 5:54 ` "O. Wölfelschneider"
0 siblings, 1 reply; 4+ messages in thread
From: rgb @ 2005-08-24 22:52 UTC (permalink / raw)
> Say I did:
>
> (define-generic-mode 'fnord-mode
> nil
> (list "fnord" "foobar")
> nil
> (list "\\.fnord")
> (list 'turn-on-font-lock))
>
> This mode will then highlight the keywords fnord and foobar.
>
> However, it will also highlight _fnord, foobar_ and so on.
>
> I do not want the keyword to highlight if it has an
> underscore attached to it.
>
> How can I get rid of this behaviour?
>
By far the easiest way is to give the underscore character
word syntax. Which is exactly how I avoid the problem in
tacl-mode.
(modify-syntax-entry ?\_ "w" st)
Other than that you probably need to use font-lock-list
rather than keyword-list so you can build your own
regexp that excludes the characters that shouldn't
be allowed to touch the keywords.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: generic-mode: Keywords also highlight with an underscore
2005-08-24 22:52 ` rgb
@ 2005-08-25 5:54 ` "O. Wölfelschneider"
2005-08-25 17:55 ` rgb
0 siblings, 1 reply; 4+ messages in thread
From: "O. Wölfelschneider" @ 2005-08-25 5:54 UTC (permalink / raw)
rgb wrote:
> (modify-syntax-entry ?\_ "w" st)
Great, that works.
Since I didn't know what to put in for st, I defined
(defun syntax-table-for-fnord() (modify-syntax-entry ?\_ "w"))
and have this called on start of fnord-mode.
However, I'd rather have this fix globally. Is there
a global syntax table that I can use for st in my .emacs?
Thanks a lot!
Olav
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: generic-mode: Keywords also highlight with an underscore
2005-08-25 5:54 ` "O. Wölfelschneider"
@ 2005-08-25 17:55 ` rgb
0 siblings, 0 replies; 4+ messages in thread
From: rgb @ 2005-08-25 17:55 UTC (permalink / raw)
> > (modify-syntax-entry ?\_ "w" st)
>
> Great, that works.
> Since I didn't know what to put in for st, I defined
>
> (defun syntax-table-for-fnord() (modify-syntax-entry ?\_ "w"))
>
I believe that you would use this to modify a modes table
from a mode hook.
(modify-syntax-entry ?\_ "w" (syntax-table))
When writing a mode I usually see it done like this:
(defvar tal-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?\n ">" st)
... <zillion other lines snipped>
(modify-syntax-entry ?\_ "w" st)
(modify-syntax-entry ?\{ "." st)
(modify-syntax-entry ?\| "." st)
(modify-syntax-entry ?\} "." st)
st)
"Syntax table for `tal-mode'.")
Then this is in the tal-mode function:
(set-syntax-table tal-mode-syntax-table)
> However, I'd rather have this fix globally. Is there
> a global syntax table that I can use for st in my .emacs?
>
I've never tried to modify the global map so I'm not
sure this is correct but looks to me like it should be.
(modify-syntax-entry ?\_ "w" (standard-syntax-table))
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-08-25 17:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-24 7:51 generic-mode: Keywords also highlight with an underscore "O. Wölfelschneider"
2005-08-24 22:52 ` rgb
2005-08-25 5:54 ` "O. Wölfelschneider"
2005-08-25 17:55 ` 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).