[Top][All Lists]

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

Re: overlays?

From: lee
Subject: Re: overlays?
Date: Wed, 19 Mar 2014 08:38:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Joost Kremers <address@hidden> writes:

> lee wrote:
>> could someone please shed a light on the purpose of overlays?  I`m
>> wondering under what circumstances they are used, or need to be used.
>> Are they a feature that has been obsoleted by font-lock, or are they
>> still needed?
> Well, one difference with regard to font lock is that overlays do not
> depend on the textual content of the buffer. Font lock is used for
> highlighting parts of the buffer that match certain regexes (optionally
> in specific contexts).

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")?

> Overlays are Lisp objects that are attached to
> specific positions in the buffer, regardless of the text in those
> positions. Because of that you can use them for things that you couldn't
> use font lock for.

So an overlay could possibly be better for "the first five lines of the
buffer" than font-lock.

> A simple example: in a program of mine, I use an overlay to navigate a
> list of (BibTeX) keys. See the screenshots here:
> <>.
> The selected key ("Booij2009" in the first screenshot) is highlighted
> using an overlay. Since the key can be anything, there isn't really a
> regexp you can come up with that highlights one single entry.

I see :)  And the overlay will be at the wrong position, or even
off-screen, when the size of the display changes?

>> The background is that I`ve made an extension to hi-lock.el, and hi-lock
>> features alternatively using overlays or font-lock.  My extension does
>> not support overlays, and I`m wondering if support for overlays needs to
>> be added or not.
> That of course is another question. Overlays certainly do have their
> uses, they're not obsoleted by font lock. But whether those uses are
> relevant for you is something you'll have to decide.

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.

Knowledge is volatile and fluid.  Software is power.

reply via email to

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