[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: font-lock and fontifying the few first nonempty lines in a buffer
From: |
Stefan Monnier |
Subject: |
Re: font-lock and fontifying the few first nonempty lines in a buffer |
Date: |
27 Jun 2003 12:54:17 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> "\\`\\(\\(.+\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