[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
19 Mar 2014 09:53:43 GMT
> How am I to imagine "specific contexts"? Like within a function
> definition (i. e. a syntactical context) and/or something else (like
> "the first five lines of the buffer")?
With "specific contexts", I meant that you can highlight text matching
some regexp if it occurs on the same line as some other regexp. So you
can highlight all occurrences of "bar" that occur on the same line as
"foo", and leave occurrences of "bar" that do not occur together with
In Elisp code, for example, a function name is highlighted with
`font-lock-function-name-face' if it is preceded by the string "(defun",
but not in other contexts.
See the Elisp manual for details:
(info "(elisp) Search-based Fontification") <=== Position the cursor here and
press `C-x C-e'
> So an overlay could possibly be better for "the first five lines of the
> buffer" than font-lock.
Yes, but you'll have to find a way to figure out where the first five
lines of the buffer end.
> I see :) And the overlay will be at the wrong position, or even
> off-screen, when the size of the display changes?
No. Overlays are tied to specific buffer positions, so when a display
size change causes those buffer positions to move to another part of the
screen, the overlay changes along with it. In the same way that the
characters at those buffer positions are moved across the screen.
(Actually, I'm not entirely sure I understand your question here.
Perhaps it's caused by confusion over the term "buffer position"? If so,
check out the Elisp manual (info "(elisp) Positions") for an
> Well, the question is whether the extension I made to hi-lock.el needs
> to, or should, support overlays or not. Since now I understand the
> difference between font-lock and overlays, I need to find out what
> hi-lock.el uses them for and what it does with them. That will provide
> an answer.
Yup. Have fun! :-)
Joost Kremers address@hidden
Selbst in die Unterwelt dringt durch Spalten Licht