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

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

bug#41002: Undo breaks inhibit-read-only text property


From: Filipp Gunbin
Subject: bug#41002: Undo breaks inhibit-read-only text property
Date: Sat, 09 May 2020 19:55:24 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin)

On 09/05/2020 16:49 +0300, Eli Zaretskii wrote:

>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> Cc: egnartsms@gmail.com,  41002@debbugs.gnu.org,  larsi@gnus.org
>> Date: Sat, 09 May 2020 16:34:43 +0300
>>
>> > I think you are right: we need to augment this with something that
>> > pays attention to the inhibit-read-only property.  Would you like to
>> > suggest a patch?
>>
>> That property is checked in INTERVAL_WRITABLE_P just above, it looks
>> fine.
>
> That tests if the interval is _not_ writable.  But the problem is not
> triggered by the interval, it is triggered by characters after the
> interval, is it not?

The buffer is read-only, and all characters have inhibit-read-only
property set (it's in the recipe).  Undo properly restores characters as
well as their properties.  But now, after undo, we don't have one single
interval any more, we have 3 intervals instead: before killed region,
killed (and restored) region, and the rest.  And this is where our
problematic (?) "if" triggers.  So I wouldn't talk about characters
after the interval, no.

>> > Btw, how is this related to undo?
>>
>> Before undo, we seem to have one interval spanning all the text.  After
>> undo, there appears a short interval on which "i->position + LENGTH (i)
>> < end" triggers.
>
> Right, thanks.  So this situation could be recreated without any undo
> in the recipe, right?

Yes, just put-text-property on separate (and adjacent) intervals instead
of the full buffer at once, and try to kill a region which crosses 
any interval boundary:

(with-temp-buffer
  (insert "ab")
  (put-text-property 1 2 'inhibit-read-only t)
  (put-text-property 2 3 'inhibit-read-only t)
  (setq buffer-read-only t)
  (kill-region 1 3))                    ;(kill-region 1 2) works

Thanks,
Filipp





reply via email to

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