From: "Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
Subject: Re: font-lock and fontifying the few first nonempty lines in a buffer
Date: 27 Jun 2003 12:54:17 -0400 [thread overview]
Message-ID: <5lisqr5ume.fsf@rum.cs.yale.edu> (raw)
In-Reply-To: mdVKa.17879$dP1.33296@newsc.telia.net
> "\\`\\(\\(.+\n\\)\\{1,7\\}\\)\n"
You can also try "\\`\\(\\(.+\n\\)*?\\)\n".
> And it does indeed color the header correctly some times, but not always.
> The documentation for font-lock also says that "keywords", i.e. regexps
> in the `font-lock-keywords' variable, should not span several lines, as
> this is "unreliable", to use the Elisp manual's word.
In Emacs-21, there's a hack to try and get it to work. It's not
100% but you might want to try it (setq font-lock-multiline t).
> This lead us back to square one, I'm afraid.
Another approach is to use font-lock-syntactic-keywords:
(defvar foo-font-lock-syntactic-keywords
'(("\\`." (0 "<"))
("\n\\(\n\\)" (1 ">"))))
This will mark the header as being a comment. If you don't like
to color/appearance of font-lock-comment-face, you can set
`font-lock-syntactic-face-function' to something else that will
return a different face.
Stefan
next prev parent reply other threads:[~2003-06-27 16:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-26 20:47 font-lock and fontifying the few first nonempty lines in a buffer Ulf Andersson
2003-06-26 23:26 ` Kevin Rodgers
2003-06-27 10:43 ` Ulf Andersson
2003-06-27 12:44 ` Kai Großjohann
2003-06-27 14:41 ` Ulf Andersson
2003-06-27 15:15 ` Kai Großjohann
2003-06-27 16:54 ` Stefan Monnier [this message]
2003-06-28 1:01 ` Sandip Chitale
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5lisqr5ume.fsf@rum.cs.yale.edu \
--to=monnier+gnu.emacs.help/news/@flint.cs.yale.edu \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).