* Adding a font-lock face to a major mode
@ 2006-01-04 17:16 Tim Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Tim Johnson @ 2006-01-04 17:16 UTC (permalink / raw)
Hi:
I would like to be able to add a font-lock face to a major mode at load
time.
I've written the following code in a file called lisp-mode++.
I need some help in adding the face properly.
FYI: *If possible*, I'd like this to be cross-compatible to Xemacs.
but is not a critical need.
;; code follows:
(defconst tj-word-end "\\)\\b")
(defconst tj-word-begin "\\b\\(")
(defconst tj-lisp-user-keywords
(concat tj-word-begin ;; test some symbols not highlighted
(regexp-opt '( "and" "apply" "concatenate" "format" "funcall" "list" "lambda"
"mapcar" "not" "print" "push" "return-from " "setf" "setq"))
tj-word-end))
(add-hook 'lisp-mode-hook
'(lambda ()
(require 'extra-faces) ;; font-lock-user-keyword-face defined here
'turn-on-font-lock
(cons font-lock-defaults ;; this is wrong, I know!
(list tj-lisp-user-keywords '1 'font-lock-user-keyword-face))
(message "lisp-mode++ loaded"))) ;; test!
(provide 'lisp-mode++) ;; .emacs has (require 'lisp-mode++)
;;
TIA
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Adding a font-lock face to a major mode
[not found] <mailman.21393.1136395091.20277.help-gnu-emacs@gnu.org>
@ 2006-01-05 17:58 ` Stefan Monnier
2006-01-05 20:44 ` Tim Johnson
2006-01-05 21:01 ` Stefan Monnier
0 siblings, 2 replies; 4+ messages in thread
From: Stefan Monnier @ 2006-01-05 17:58 UTC (permalink / raw)
> I would like to be able to add a font-lock face to a major mode at load
> time.
Try font-lock-add-keywords.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Adding a font-lock face to a major mode
2006-01-05 17:58 ` Adding a font-lock face to a major mode Stefan Monnier
@ 2006-01-05 20:44 ` Tim Johnson
2006-01-05 21:01 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: Tim Johnson @ 2006-01-05 20:44 UTC (permalink / raw)
* Stefan Monnier <monnier@iro.umontreal.ca> [060105 10:19]:
> > I would like to be able to add a font-lock face to a major mode at load
> > time.
>
> Try font-lock-add-keywords.
<grin> Works like a charm</grin> the kicker, however, is that
<sigh> I'm tasked with solutions that can be applied to both
gnu and X emacs. Xemacs does not have that function and
furthermore, simply exploiting the code doesn't work
either, because Xemacs apparently has a significantly different
structure for syntax highlighting.
Thanks for the tip Stefan.
For now it will be a gnu-only solution. Later I can use an 'cond
form to test the Xemacs and provide an alternate code.
cheers
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Adding a font-lock face to a major mode
2006-01-05 17:58 ` Adding a font-lock face to a major mode Stefan Monnier
2006-01-05 20:44 ` Tim Johnson
@ 2006-01-05 21:01 ` Stefan Monnier
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2006-01-05 21:01 UTC (permalink / raw)
>> I would like to be able to add a font-lock face to a major mode at load
>> time.
> Try font-lock-add-keywords.
Don't listen to what he says: font-lock-add-keywords is not for use by
derived modes, so it's OK to use it if you put it in lisp-mode-hook, but if
you end up creating your own major mode by deriving from lisp-mode, you
should create your own font-lock-defaults value and your own
font-lock-keywords value (built from lisp-font-lock-keywords, of course).
Stefan "the other one"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-01-05 21:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.21393.1136395091.20277.help-gnu-emacs@gnu.org>
2006-01-05 17:58 ` Adding a font-lock face to a major mode Stefan Monnier
2006-01-05 20:44 ` Tim Johnson
2006-01-05 21:01 ` Stefan Monnier
2006-01-04 17:16 Tim Johnson
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).