all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: phillip.lord@russet.org.uk (Phillip Lord)
Cc: 23871@debbugs.gnu.org, triska@metalevel.at
Subject: bug#23871: 25.1.50; Undo unexpectedly leads to blank buffer
Date: Mon, 04 Jul 2016 17:32:45 -0400	[thread overview]
Message-ID: <jwv60sl85nl.fsf-monnier+Inbox@gnu.org> (raw)
In-Reply-To: <87vb0lta67.fsf@russet.org.uk> (Phillip Lord's message of "Mon, 04 Jul 2016 21:34:08 +0100")

>> BTW, I notice that in the current code (emacs-25), there's one other
>> call to record_first_change (in record_property_change), and it could be
>> replaced with a call to prepare_record, so it begs the question whether
>> the above hunk should also apply to record_property_change as well.

> Don't understand.

In record_property_change we have (among other things) the exact same
code as in prepare_record (i.e. there's code duplication).  So we
could/should replace those 4 lines of code with a call to
prepare_record.  But if we do, then your (previous) patch changes the
behavior of record_property_change, whereas if we don't, your (previous)
patch doesn't change its behavior.
Anyway, your new patch addresses this.

> That's a possibility, but it appears more complex than re-ordering the
> methods.
[...]
> However, we must bring back the conditional statement because this is no
> longer called in prepare_record, as in this case, it must be called after the
> `at_boundary` check. The alternative, which is making the `at_boundary` check
> accept "nil" then a timestamp as a boundary sounds more complex.

More complex but more robust.  I think it'd be worthwhile to put a FIXME
comment in there, at least.  E.g. the above explanation should be put
inside the code.

> +  /* If we are just after an undo boundary, and point was not at start
> +     of deleted range, and the recorded point was in this buffer, then
> +     record where it was.  */
> +  if (at_boundary
> +      && point_before_last_command_or_undo != beg
> +      && buffer_before_last_command_or_undo == current_buffer )
>      bset_undo_list (current_buffer,
> -		    Fcons (make_number (pt),
> +		    Fcons (make_number (point_before_last_command_or_undo),
>  			   BVAR (current_buffer, undo_list)));
>  }

I think the comment should explain the intention better.
It is currently too close to a simple paraphrase of the code.
I suggest "If it's the first change since the last boundary, and the
upcoming undo record wouldn't restore point correctly, then record where
it was".

Other than that it looks good, thank you for the detailed explanation.


        Stefan





  reply	other threads:[~2016-07-04 21:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 21:47 bug#23871: 25.1.50; Undo unexpectedly leads to blank buffer Markus Triska
2016-06-30 16:38 ` Eli Zaretskii
2016-06-30 18:00   ` Markus Triska
2016-06-30 18:21     ` Eli Zaretskii
2016-06-30 18:52       ` Eli Zaretskii
2016-06-30 21:45     ` Phillip Lord
2016-07-01  6:31       ` Markus Triska
2016-07-01  7:25         ` Eli Zaretskii
2016-07-01 14:04           ` Phillip Lord
2016-07-01 20:38             ` Markus Triska
2016-07-01 22:12               ` Phillip Lord
2016-07-01 20:49             ` Markus Triska
2016-07-01 22:21               ` Phillip Lord
2016-07-02  5:35                 ` Markus Triska
2016-07-02  7:35                 ` Eli Zaretskii
2016-07-02 20:21                   ` Phillip Lord
2016-07-02 20:53                     ` Markus Triska
2016-07-03  3:33                       ` Eli Zaretskii
2016-07-03  9:37                       ` Phillip Lord
2016-07-03 10:08                         ` Markus Triska
2016-07-03 12:55                           ` Phillip Lord
2016-07-03 15:30                             ` Eli Zaretskii
2016-07-03 20:21                               ` Phillip Lord
2016-07-03 18:05                             ` Markus Triska
2016-07-03 20:23                               ` Phillip Lord
2016-07-03 22:03                                 ` Markus Triska
2016-07-04 14:38                                   ` Eli Zaretskii
2016-07-05 16:36                                     ` Eli Zaretskii
2016-07-05 19:44                                       ` Phillip Lord
2016-07-05 20:02                                         ` Markus Triska
2016-07-05 19:47                                       ` Markus Triska
2016-07-05 20:00                                         ` Eli Zaretskii
2016-07-03 15:12                           ` Eli Zaretskii
2016-07-03 18:09                             ` Markus Triska
2016-07-03 19:20                               ` Eli Zaretskii
2016-07-03 20:37                             ` Phillip Lord
2016-07-03  3:31                     ` Eli Zaretskii
2016-07-03  9:39                       ` Phillip Lord
2016-07-03 21:33                     ` Stefan Monnier
2016-07-04 20:34                       ` Phillip Lord
2016-07-04 21:32                         ` Stefan Monnier [this message]
2016-07-05  8:43                           ` Phillip Lord
2016-07-05 20:32                             ` Markus Triska
2016-07-05 22:00                               ` Stefan Monnier
2016-07-05 22:17                                 ` Phillip Lord
2016-07-05 22:09                               ` Phillip Lord
2016-07-05 23:03                                 ` Markus Triska
2016-07-06 16:02                                   ` Phillip Lord
2016-07-06 17:59                                     ` Markus Triska
2016-08-12 23:03                                 ` npostavs
2016-08-13  8:02                                   ` Markus Triska
2016-07-05  8:46                           ` undo refactoring Phillip Lord
2016-07-05 21:50                             ` Stefan Monnier
2016-07-05 22:22                               ` Phillip Lord

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv60sl85nl.fsf-monnier+Inbox@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=23871@debbugs.gnu.org \
    --cc=phillip.lord@russet.org.uk \
    --cc=triska@metalevel.at \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.