emacs-devel
[Top][All Lists]
Advanced

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

Re: A question about overlays and performance.


From: Jeff Norden
Subject: Re: A question about overlays and performance.
Date: Thu, 30 Jul 2020 13:21:45 -0500

>> ... inclined to agree with Stefan's opinion about indirect buffers.
> Another common use is narrowing to subtrees, so that you have two
> buffers with different narrowing for the same org file. It is not
> possible within a single buffer, as far I as know.

So the org case for indirect buffers is messier than I had imagined, which
shouldn't surprise me.  I'm a very casual user of org - just as an
alternative to outline-mode for the cycling and the intuitive use of the
tab key.

> What do you mean by "exactly the opposite"?

I was working on changing some text-property based code to use overlays
instead, but I'm having second thoughts.  Overlays simplified some things,
but not as much as I thought they would.  I also ran into a couple of snags:

1) There don't seem to be 'char-property' versions of text-property-any or
text-property-not-all.  I guess you could do this in lisp with a loop using
next-char-property-change, but that works against my original goal of
simplifying things.

2) A simple option that you have for protecting hidden text when using
text-properties is to temporarily mark it as read-only, e.g.:

  (add-text-properties beg end '(invisible t read-only t))

Of course, you need to make sure you remove both properties when you
un-hide (and take into account that you are now changing read-only text).
It also means that you can't kill or delete a region that contains hidden
text without un-hiding it first.  That may or may not be a good thing,
depending on your perspective.  There might also be other side-effects that
I'm not thinking of right now.

---

I just looked at org a bit more and discovered org-catch-invisible-edits.
It works, in part, because org re-binds the keys that usually call
delete-char and delete-backward-char.  I tried it, and found that even with
catch-invisible-edits set to 'error, if you put the cursor right before an
ellipsis and type M-d, the first word in the hidden text is silently
deleted.  I wouldn't say this is a bug or problem, since it is hard to
imagine someone doing that accidentally.  I just thought it was interesting.

Best regards,
-Jeff



reply via email to

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