From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: overlays? Date: 18 Mar 2014 10:05:37 GMT Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1395137414 29407 80.91.229.3 (18 Mar 2014 10:10:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Mar 2014 10:10:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 18 11:10:25 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 1WPqyW-0007Dt-Iw for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Mar 2014 11:10:24 +0100 Original-Received: from localhost ([::1]:34332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPqyV-0007lA-VU for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Mar 2014 06:10:23 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-X-Trace: individual.net ugJHJSM5kqiIsJcfsJvqiQbhFZ3zwYJs5JxUfJ0GmFrdg9fL3t Cancel-Lock: sha1:R3qDxfTJ/ZxVs3jr25QpkTbuVJ8= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/pre1.0.0-18 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:204308 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:96579 Archived-At: 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). 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. 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. Also, overlays can be moved around the buffer by assigning new buffer positions to them. That makes it easy to use them for navigating the list of keys. And overlays can be made temporarily invisible, something I use in the lower of the two buffers (where the fields of the current entry are shown): it has an overlay as well, to highlight the current field, but it's only visible when focus is in the buffer (i.e., when the user is editing the fields). All of that would be nigh impossible with font lock. > 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. -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9)