help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: overlays?


From: Joost Kremers
Subject: Re: overlays?
Date: 19 Mar 2014 09:53:43 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

lee wrote:
> 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
"foo".

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
explanation.)

> 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                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]