Subject: bug#45054: 27.1; Can get point into the middle of a run of characters with a replacing display spec

From: Zack Weinberg <[email-masked]>
Date: Sat, 5 Dec 2020 15:00:30 -0500

On Sat, Dec 5, 2020 at 11:18 AM Eli Zaretskii <[email-masked]> wrote:
> > 1. Is this indeed a bug in Emacs?
>
> Probably a bug in adjust_point_for_property.  Try your recipe after
> setting global-disable-point-adjustment non-nil.

No change, but set-variable doesn't recognize that variable (so I used
setq instead)  Is this variable possibly only available in development
trunk and/or in an Emacs compiled with internal debugging enabled?
I'm using 27.1 as packaged by Debian, right now.

> > 2. Assuming it is, can you suggest a workaround?  I’m hoping for a
> >    viable solution within my code that’s compatible at least as far back
> >    as Emacs 24.
>
> A workaround in Lisp?  Try making the affected text, or some of it,
> invisible, i.e. give it the 'invisible' text property as well.  (I
> didn't try to test this solution, so I cannot promise it will work.)

That makes the situation worse: with the mode enabled, I can separate
point from the visible cursor just by attempting to move the visible
cursor over the displayed ¶.  Also, if the ¶ is at the beginning of a
line and point is at the end of that line, C-a moves only to after the
(invisible) 6.  And redisplay gets screwed up if I delete one of the
invisible characters.

> > 3. I think it would be better UI if the C-d in the recipe deleted the
> >    entire run of text that’s getting hidden (more generally, deletion
> >    commands should behave as if the ¶ is really what’s in the buffer).
> >    I can’t figure out how to implement that, can you suggest anything?
>
> Why can't you delete every character around point that has this
> special property?

I don't know how to do that.  My best guess is this would be done in a
change hook, but I'm not sure of that, and I don't understand how to
write change hooks, either.  Is there a good example or guide-level
documentation you could point me at?

zw