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

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

font lock


From: Shiyuan
Subject: font lock
Date: Tue, 11 Mar 2014 12:32:51 -0700

Hi all,
    I want to write a major mode which is derived from c++-mode.  I need to
add keywords for color highlighting. It works but I don't want to the
keyword to be highlighted if the keyword is in the comments. How can I do
that?  According to the Elisp manual, It seems doable by changing the
number in the font-lock-add-keywords, however I couldn't find the
documentation.  I tried 0 and 1 but neither works.

(define-derived-mode my-mode c++-mode "MY-MODE"
  "Major mode for editing XXX files")

(add-hook 'ion-mode-hook
  (lambda()
(font-lock-add-keywords nil
'(("\\<\\(\\(?:null\\| decimal \\| list\\)\\)\\>" 1 'font-lock-type-face t)
  ("\\<\\(define\\|override\\|exist\\|andp\\|and\\|or\\|not\\|if\\)\\>" 1
'font-lock-keyword-face t)))))
(provide 'ion-mode)

Also, Is there a variable which holds the complete list of the
keyword--face pairs for highlighting? The variable font-lock-defaults seems
not complete---the new keywords I added using the code below is not shown
in the value of font-lock-defaults.

Thanks.


reply via email to

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