[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
font-lock
From: |
Florian Kaufmann |
Subject: |
font-lock |
Date: |
Tue, 15 Sep 2009 03:03:28 -0700 (PDT) |
User-agent: |
G2/1.0 |
I want to configure font-lock for my own mode. I still have troubles
to understand what I have to do so font-lock understands what to do
when matches overlap. Say my comments start with 2 hashes and go until
the end of the line, and strings are in between double quotes:
(defconst adoc-font-lock-keywords
(eval-when-compile
(list
(cons "##.*$" 'font-lock-comment-face)
(cons "\".*?\"" 'font-lock-string-face)
)))
Now in my test buffer
"foo##bar"
##foo"bar"
The first line is not correctly fontified. I expect that the while
line has the string face, but "foo has no face, and ##bar" has comment
face. If I reverse the two (cons ...) lines, then the 2nd line in the
test buffer is ill formated: ##foo has no face, and "bar" has comment
face; I expect the whole 2nd line to be in comment face.
I think I can't make use of syntax tables, because actually my
comments/strings are more complex (and even that is a bit simplified
for this post):
comments
##.*$
#\w+
#\*.*?\*#
strings
".*?"
'\w+
'\[.*?\]
`\W+
- font-lock,
Florian Kaufmann <=