help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: overlays vs text properties


From: Eric Abrahamsen
Subject: Re: overlays vs text properties
Date: Wed, 13 Jul 2011 00:23:23 -0700
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux)

On Tue, Jul 12 2011, Eli Zaretskii wrote:

>> From: Eric Abrahamsen <address@hidden>
>> Date: Tue, 12 Jul 2011 23:12:20 -0700
>> 
>> 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?
>
> You didn't give enough information to help you with this issue.  For
> example: how many properties/overlays will exist in a given buffer
> simultaneously?  Text properties scale much better than overlays, so
> this information is important.
>
> Also, text properties by default are copied with text, while overlays
> are not.  Will this be an issue in your application?
>
> Overlays can overlap, while text properties cannot (for the same
> property).  Is this a possible issue for you?
>
> Etc. etc.  IOW, tell more about your application to get any advice
> beyond a list of abstract cons and pros.

Can do! So:

1. I'll have a buffer and an indirect buffer on the same file. Each
   buffer will have a single "active" paragraph at any one time, but
   only one. So I don't think scaling is too much of an issue. I'm
   trying to create a "follow" situation, where a paragraph in the
   source buffer is matched to a paragraph in the indirect buffer, and
   these two paragraphs have (different) properties. But only the two
   paragraphs at one time, moving in unison.
2. This is mostly a visual effect (hence my leaning towards overlays),
   and copying text properties is not necessary. In fact, it would be
   annoying.
3. Overlapping would not be an issue -- within the "active" paragraphs
   there might be other properties present, but they would be separate
   from the overall paragraph property.

I am trying to create a translation environment, by modifying an org-mode
file so that I can move through one subtree while the indirect buffer
displays mirror paragraphs in another subtree. I want to link
source-language paragraphs with target-language paragraphs, so it's
pretty crucial that movement be covered: wherever point goes in the main
buffer, it should be tracked and mirrored in the indirect buffer.

Having different keymaps available within the "active" paragraphs is
key!

Thanks a lot for considering this issue…

Eric



reply via email to

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