all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* font lock
@ 2014-03-11 19:32 Shiyuan
  2014-03-11 19:44 ` Shiyuan
  0 siblings, 1 reply; 2+ messages in thread
From: Shiyuan @ 2014-03-11 19:32 UTC (permalink / raw
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: font lock
  2014-03-11 19:32 font lock Shiyuan
@ 2014-03-11 19:44 ` Shiyuan
  0 siblings, 0 replies; 2+ messages in thread
From: Shiyuan @ 2014-03-11 19:44 UTC (permalink / raw
  To: help-gnu-emacs

I found the answers. Taking out the 't' in the list  will make the keywords
not to be highlighted in the comments. Also the variable font-lock-keywords
seems to contains the complete keywords highlighting list.  Thanks.



On Tue, Mar 11, 2014 at 12:32 PM, Shiyuan <gshy2014@gmail.com> wrote:

> 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.
>
>
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-11 19:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 19:32 font lock Shiyuan
2014-03-11 19:44 ` Shiyuan

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.