help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding a font-lock face to a major mode


From: Tim Johnson
Subject: Adding a font-lock face to a major mode
Date: Wed, 4 Jan 2006 08:16:25 -0900
User-agent: Mutt/1.4.2.1i

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]