all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: lee <lee@yun.yagibdah.de>
To: help-gnu-emacs@gnu.org
Subject: Re: overlays?
Date: Wed, 19 Mar 2014 08:38:51 +0100	[thread overview]
Message-ID: <878us6y6wk.fsf@yun.yagibdah.de> (raw)
In-Reply-To: <slrnlig6jh.9nq.joost.m.kremers@j.kremers4.news.arnhem.chello.nl> (Joost Kremers's message of "18 Mar 2014 10:05:37 GMT")

Joost Kremers <joost.m.kremers@gmail.com> 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:
>
> <http://joostkremers.github.io/ebib/#screenshots>.
>
> 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	other threads:[~2014-03-19  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.17396.1395106856.10748.help-gnu-emacs@gnu.org>
2014-03-18 10:05 ` overlays? Joost Kremers
2014-03-19  7:38   ` lee [this message]
2014-03-19  8:21     ` overlays? Jambunathan K
     [not found]   ` <mailman.17502.1395216683.10748.help-gnu-emacs@gnu.org>
2014-03-19  9:53     ` overlays? Joost Kremers
2014-03-19 12:29       ` overlays? Stefan
2014-03-18  1:40 overlays? lee
2014-03-18  6:17 ` overlays? Marcin Borkowski
2014-03-19  7:22   ` overlays? lee

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878us6y6wk.fsf@yun.yagibdah.de \
    --to=lee@yun.yagibdah.de \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.