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/revisited


From: Tim Johnson
Subject: Adding a font-lock face to a major mode/revisited
Date: Wed, 4 Jan 2006 17:07:47 -0900
User-agent: Mutt/1.4.2.1i

After studying documentation, I have taken a different approach.
Code for lisp-mode++.el is not as follows:
;;
(defconst tj-word-end "\\)\\b")
(defconst tj-lisp-user-keywords 
          (concat tj-word-begin 
                  (regexp-opt '("and" "apply" "concatenate" "format" "funcall" 
"list" "lambda" 
                                "mapcar" "not" "print" "push" "return-from " 
"setf" "setq") 
                  ) tj-word-end))
(make-local-variable 'lisp-font-lock-keywords-tj)
(defvar lisp-font-lock-keywords-tj  
  (list
    (list tj-lisp-user-keywords '1 'font-lock-user-keyword-face))
  "Additional keywords and groups for lisp-mode")
(add-hook 'lisp-mode-hook
          '(lambda ()
             (require 'extra-faces) ;; font-lock-user-keyword-face defined here
             'turn-on-font-lock
             ;; I have tried both of the lines below, with no good effect
             (put 'lisp-mode 'font-lock-defaults '(lisp-font-lock-keywords-tj))
             ;(cons font-lock-defaults lisp-font-lock-keywords-tj)
             (message "lisp-mode++ loaded")))
(provide 'lisp-mode++) ;; .emacs has (require 'lisp-mode++)
;;
What works:  
  'add hook is being executed. 
     I see the message 
     Even with "debug on error" turned on, there are no errors.
  the 'require form is being evaluated as 
    'font-lock-user-keyword-face appears as a defined variable.
  lisp-font-lock-keywords-tj appears as a defined variable.
    The regex part of the variable seems to work as tested with
      re-builder
What doesn't work:
  No syntax highlighting appears for the keywords.
  c-h v font-lock-defaults => provides a printed representation
    that does not show lisp-font-lock-keywords-tj as a component of
    that variable.

Unfortunately I have not yet found any examples to work from. I suspect 
that neither the 'put nor the 'cons calls are wrong.

Any help would be appreciated.
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]