all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Shiyuan <gshy2014@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: font lock
Date: Tue, 11 Mar 2014 12:32:51 -0700	[thread overview]
Message-ID: <CAOm4EMuKNgP6iKvLi66tCKW9xB0g4LQ4Tw09JGOL8zD_kuLjKQ@mail.gmail.com> (raw)

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	other threads:[~2014-03-11 19:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11 19:32 Shiyuan [this message]
2014-03-11 19:44 ` font lock Shiyuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOm4EMuKNgP6iKvLi66tCKW9xB0g4LQ4Tw09JGOL8zD_kuLjKQ@mail.gmail.com \
    --to=gshy2014@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.