[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: prevent part of user var highlighted as keyword in new lang mode
From: |
Xah |
Subject: |
Re: prevent part of user var highlighted as keyword in new lang mode |
Date: |
Wed, 19 Nov 2008 05:53:13 -0800 (PST) |
User-agent: |
G2/1.0 |
On Nov 19, 5:31 am, Scott Frazer <frazer.sc...@gmail.com> wrote:
> Xah wrote:
> > in writing a new language mode, how do i prevent part of variable that
> > gets highlighted as keyword? e.g. the “for” in “inform”.
>
> > i'm using
> > (setq font-lock-defaults '((xlsl-font-lock-keywords) nil nil))
>
> You need to wrap your regexp with markers that indicate the beginning/end
> of the empty string or symbol, e.g. these are the symbol ones:
>
> (concat "\\_<\\(" (regexp-opt '("form" "foo" "bar")) "\\)\\_>")
>
> See the "Backslash constructs in regular expressions" section in the
> Elisp manual.
>
> Scott
i'm not sure what's wrong.
Here's my code:
(defvar xlsl-keywords-regexp (regexp-opt xlsl-keywords 'word))
(defvar xlsl-type-regexp (regexp-opt xlsl-types 'words))
(defvar xlsl-constant-regexp (regexp-opt xlsl-constants 'words))
(defvar xlsl-event-regexp (regexp-opt xlsl-events 'words))
(defvar xlsl-functions-regexp (regexp-opt xlsl-functions 'words))
(setq xlsl-font-lock-keywords
`(
(,xlsl-type-regexp . font-lock-type-face)
(,xlsl-constant-regexp . font-lock-constant-face)
(,xlsl-event-regexp . font-lock-builtin-face)
(,xlsl-functions-regexp . font-lock-function-name-face)
(,xlsl-keywords-regexp . font-lock-keyword-face)
))
but still, when i type for example “information”, the “for” is
highlighted.
Any other idea?
Xah
∑ http://xahlee.org/
☄