all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* font-lock
@ 2009-09-15 10:03 Florian Kaufmann
  2009-09-17  0:57 ` font-lock Andreas Politz
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Kaufmann @ 2009-09-15 10:03 UTC (permalink / raw)
  To: help-gnu-emacs

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+




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

end of thread, other threads:[~2009-09-17  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-15 10:03 font-lock Florian Kaufmann
2009-09-17  0:57 ` font-lock Andreas Politz

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.