[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generic mode -- keywords
From: |
Stefan Monnier |
Subject: |
Re: Generic mode -- keywords |
Date: |
Wed, 28 Mar 2012 19:22:03 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> When editing, if a defined keyword like "and" is contained in a "*;"
> type comment, the mode doesn't highlight the *; comment, but as long
> as there is no keyword, it works fine.
You're already stepping outside the scope of define-generic-mode (which
I find too limited to be of any real use anyway).
So you'll want to use define-derived-mode and mark those *...; such that
they're recognized not just by font-lock highlighting but by the syntax
primitives (at which point font-lock highlighting will "just work").
Something like the code below (beware, untested code using Emacs-24 features).
Stefan
(defvar simple-sas-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?/ ". 14" st)
(modify-syntax-entry ?* ". 23" st)
(modify-syntax-entry ?\" "\"" st)
st))
;; The *...; syntax is outside the scope of syntax-tables, so we need to use
;; the syntax-table text-property via syntax-propertize.
(defconst simple-sas-syntax-propertize-function
(syntax-propertize-rules
("\\(\\*\\)[^;\\*/]*\\(;\\)" (1 "<") (2 ">"))))
(defvar simple-sas-font-lock-keywords
'(("and")))
(define-derived-mode simple-sas-mode prog-mode "SAS"
"Simple mode for SAS editing."
(set (make-local-variable 'comment-start) "/* ")
(set (make-local-variable 'comment-end) " */")
(set (make-local-variable 'font-lock-keywords)
simple-sas-font-lock-keywords)
(set (make-local-variable 'syntax-propertize-function)
simple-sas-syntax-propertize-function))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Generic mode -- keywords,
Stefan Monnier <=