all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Florian Kaufmann <sensorflo@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: font-lock
Date: Tue, 15 Sep 2009 03:03:28 -0700 (PDT)	[thread overview]
Message-ID: <3026515d-2b01-40a9-9f03-9cd7babc55e0@p9g2000vbl.googlegroups.com> (raw)

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+




             reply	other threads:[~2009-09-15 10:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 10:03 Florian Kaufmann [this message]
2009-09-17  0:57 ` font-lock Andreas Politz

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=3026515d-2b01-40a9-9f03-9cd7babc55e0@p9g2000vbl.googlegroups.com \
    --to=sensorflo@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.