From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lee Newsgroups: gmane.emacs.help Subject: Re: overlays? Date: Wed, 19 Mar 2014 08:38:51 +0100 Organization: my virtual residence Message-ID: <878us6y6wk.fsf@yun.yagibdah.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1395216691 12786 80.91.229.3 (19 Mar 2014 08:11:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Mar 2014 08:11:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 19 09:11:39 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WQBb8-0005IR-08 for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Mar 2014 09:11:38 +0100 Original-Received: from localhost ([::1]:39152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQBb7-0004Je-Hd for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Mar 2014 04:11:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQBan-0004AM-Fy for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 04:11:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQBac-0004W2-EY for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 04:11:17 -0400 Original-Received: from client-194-42-186-216.muenet.net ([194.42.186.216]:38645 helo=yun.yagibdah.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQBac-0004Vm-5b for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 04:11:06 -0400 Original-Received: from lee by yun.yagibdah.de with local (Exim 4.80.1) (envelope-from ) id 1WQBaa-0007U0-I5 for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 09:11:04 +0100 In-Reply-To: (Joost Kremers's message of "18 Mar 2014 10:05:37 GMT") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Mail-Followup-To: help-gnu-emacs@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.42.186.216 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96613 Archived-At: Joost Kremers 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.