unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 41002@debbugs.gnu.org, egnartsms@gmail.com, larsi@gnus.org
Subject: bug#41002: Undo breaks inhibit-read-only text property
Date: Sat, 09 May 2020 19:55:24 +0300	[thread overview]
Message-ID: <m2imh559qb.fsf@fastmail.fm> (raw)
In-Reply-To: <838si1fcbb.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 May 2020 16:49:28 +0300")

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	other threads:[~2020-05-09 16:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 10:38 bug#41002: Undo breaks inhibit-read-only text property Serhii Mozghovyi
2020-05-02 17:33 ` Filipp Gunbin
2020-05-02 19:09   ` Serhii Mozghovyi
2020-05-03  3:22     ` Filipp Gunbin
2020-05-09  7:37       ` Eli Zaretskii
2020-05-09 13:34         ` Filipp Gunbin
2020-05-09 13:49           ` Eli Zaretskii
2020-05-09 16:55             ` Filipp Gunbin [this message]
2020-05-19 12:12       ` Lars Ingebrigtsen

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=m2imh559qb.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=41002@debbugs.gnu.org \
    --cc=egnartsms@gmail.com \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).