unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: overlays vs text properties
Date: Tue, 12 Jul 2011 23:12:20 -0700	[thread overview]
Message-ID: <87k4bmk8u3.fsf@ericabrahamsen.net> (raw)

Hi,

I'm learning about overlays and text properties, and am looking for some
pointers on which to use. I'm building a medium-sized package, and one
function I need is that as the user moves point through paragraphs of
text in a buffer, each paragraph should be given a certain
property/overlay. As point leaves a paragraph its properties are
deleted, and as it enters a different paragraph (either by typing or
simple movement), that new paragraph gets the properties.

I can't decide whether to use overlays or regular properties. The
advantages of using overlays seem to be:

1. I can make a single named overlay, and move it around the buffer with
   move-overlay. Nice and clean, no searching for boundaries of things
   and suchlike.
2. I can attach multiple properties to a single overlay -- saves time
   and effort, and seems like good programming.

The disadvantage seems to be the practical issue that overlays don't
come with point-entered/point-left special properties -- ie, there's no
good way of keeping track of when point is going in and out of a
paragraph with the overlay, and then moving the overlay to the
next/previous/other paragraph.

Does anyone have any experience they'd like to share on this point?
Should I just use fundamental text properties?

Thanks,
Eric




             reply	other threads:[~2011-07-13  6:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13  6:12 Eric Abrahamsen [this message]
2011-07-13  6:59 ` overlays vs text properties Eli Zaretskii
2011-07-13  7:23   ` Eric Abrahamsen
2011-07-13  7:28     ` Eli Zaretskii
2011-07-13  7:32       ` Eric Abrahamsen
2011-07-13  8:07         ` PJ Weisberg
2011-07-13 22:21           ` Eric Abrahamsen
2011-07-13  9:57         ` Eli Zaretskii
2011-07-13 14:55     ` Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87k4bmk8u3.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).