GNU bug report logs -
#810
23.0.60; atomic-change-group narrowing problem
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 810 in the body.
You can then email your comments to 810 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
When using atomic-change-group I got the message
undo-more: Changes to be undone are outside visible portion of buffer
The changes are also not undone. This seems wrong to me.
If I put (widen) before the end of my code in the atomic-change-group
the message above disappears and the change is undone.
In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
of 2008-08-10
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags
-Ic:/g/include -fno-crossjumping'
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #10 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
> When using atomic-change-group I got the message
>
> undo-more: Changes to be undone are outside visible portion of buffer
This message is usually a consequence of narrowing the buffer within the
body of `atomic-change-group' or afterwards.
> The changes are also not undone. This seems wrong to me.
If you did narrow the buffer this is normal and not specific to
`atomic-change-group'.
martin
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #15 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
martin rudalics wrote:
>> When using atomic-change-group I got the message
>>
>> undo-more: Changes to be undone are outside visible portion of buffer
>
> This message is usually a consequence of narrowing the buffer within the
> body of `atomic-change-group' or afterwards.
>
>> The changes are also not undone. This seems wrong to me.
>
> If you did narrow the buffer this is normal and not specific to
> `atomic-change-group'.
Maybe, but what is specific to atomic-change-group is that the doc
string says
Perform body as an atomic change group.
This means that if body exits abnormally,
all of its changes to the current buffer are undone.
AFAICS there is something wrong either in the doc string or in the function.
I would suggest that this is a bug in the function. Think for example of
the case that you want to test something during narrowing and be sure
that the buffer is not changed.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #20 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
> I would suggest that this is a bug in the function. Think for example of
> the case that you want to test something during narrowing and be sure
> that the buffer is not changed.
Does the attached patch do what you want?
martin
[810.diff (text/plain, inline)]
*** subr.el.~1.602.~ 2008-07-31 07:33:45.000000000 +0200
--- subr.el 2008-08-29 11:15:34.765625000 +0200
***************
*** 1991,2016 ****
(dolist (elt handle)
(with-current-buffer (car elt)
(setq elt (cdr elt))
! (let ((old-car
! (if (consp elt) (car elt)))
! (old-cdr
! (if (consp elt) (cdr elt))))
! ;; Temporarily truncate the undo log at ELT.
! (when (consp elt)
! (setcar elt nil) (setcdr elt nil))
! (unless (eq last-command 'undo) (undo-start))
! ;; Make sure there's no confusion.
! (when (and (consp elt) (not (eq elt (last pending-undo-list))))
! (error "Undoing to some unrelated state"))
! ;; Undo it all.
! (save-excursion
! (while (listp pending-undo-list) (undo-more 1)))
! ;; Reset the modified cons cell ELT to its original content.
! (when (consp elt)
! (setcar elt old-car)
! (setcdr elt old-cdr))
! ;; Revert the undo info to what it was when we grabbed the state.
! (setq buffer-undo-list elt)))))
;;;; Display-related functions.
--- 1991,2018 ----
(dolist (elt handle)
(with-current-buffer (car elt)
(setq elt (cdr elt))
! (save-restriction
! (widen)
! (let ((old-car
! (if (consp elt) (car elt)))
! (old-cdr
! (if (consp elt) (cdr elt))))
! ;; Temporarily truncate the undo log at ELT.
! (when (consp elt)
! (setcar elt nil) (setcdr elt nil))
! (unless (eq last-command 'undo) (undo-start))
! ;; Make sure there's no confusion.
! (when (and (consp elt) (not (eq elt (last pending-undo-list))))
! (error "Undoing to some unrelated state"))
! ;; Undo it all.
! (save-excursion
! (while (listp pending-undo-list) (undo-more 1)))
! ;; Reset the modified cons cell ELT to its original content.
! (when (consp elt)
! (setcar elt old-car)
! (setcdr elt old-cdr))
! ;; Revert the undo info to what it was when we grabbed the state.
! (setq buffer-undo-list elt))))))
;;;; Display-related functions.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #25 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
> When using atomic-change-group I got the message
>
> undo-more: Changes to be undone are outside visible portion of buffer
>
> The changes are also not undone. This seems wrong to me.
The attached patch now also tries to restore any narrowing in force
before the atomic change.
martin
[810.diff (text/plain, inline)]
*** subr.el.~1.604.~ 2008-08-31 09:48:50.531250000 +0200
--- subr.el 2008-09-01 19:52:32.843750000 +0200
***************
*** 1907,1912 ****
--- 1907,1917 ----
;;; Atomic change groups.
+ (defvar atomic-change-point-min nil
+ "Value returned by `point-min' before an atomic change.")
+ (defvar atomic-change-point-max nil
+ "Value returned by `point-max' before an atomic change.")
+
(defmacro atomic-change-group (&rest body)
"Perform BODY as an atomic change group.
This means that if BODY exits abnormally,
***************
*** 1920,1925 ****
--- 1925,1932 ----
(let ((handle (make-symbol "--change-group-handle--"))
(success (make-symbol "--change-group-success--")))
`(let ((,handle (prepare-change-group))
+ (atomic-change-point-min (point-min))
+ (atomic-change-point-max (point-max))
;; Don't truncate any undo data in the middle of this.
(undo-outer-limit nil)
(undo-limit most-positive-fixnum)
***************
*** 1992,2017 ****
(dolist (elt handle)
(with-current-buffer (car elt)
(setq elt (cdr elt))
! (let ((old-car
! (if (consp elt) (car elt)))
! (old-cdr
! (if (consp elt) (cdr elt))))
! ;; Temporarily truncate the undo log at ELT.
! (when (consp elt)
! (setcar elt nil) (setcdr elt nil))
! (unless (eq last-command 'undo) (undo-start))
! ;; Make sure there's no confusion.
! (when (and (consp elt) (not (eq elt (last pending-undo-list))))
! (error "Undoing to some unrelated state"))
! ;; Undo it all.
! (save-excursion
! (while (listp pending-undo-list) (undo-more 1)))
! ;; Reset the modified cons cell ELT to its original content.
! (when (consp elt)
! (setcar elt old-car)
! (setcdr elt old-cdr))
! ;; Revert the undo info to what it was when we grabbed the state.
! (setq buffer-undo-list elt)))))
;;;; Display-related functions.
--- 1999,2030 ----
(dolist (elt handle)
(with-current-buffer (car elt)
(setq elt (cdr elt))
! (save-restriction
! (widen)
! (let ((old-car
! (if (consp elt) (car elt)))
! (old-cdr
! (if (consp elt) (cdr elt))))
! ;; Temporarily truncate the undo log at ELT.
! (when (consp elt)
! (setcar elt nil) (setcdr elt nil))
! (unless (eq last-command 'undo) (undo-start))
! ;; Make sure there's no confusion.
! (when (and (consp elt) (not (eq elt (last pending-undo-list))))
! (error "Undoing to some unrelated state"))
! ;; Undo it all.
! (save-excursion
! (while (listp pending-undo-list) (undo-more 1)))
! ;; Reset the modified cons cell ELT to its original content.
! (when (consp elt)
! (setcar elt old-car)
! (setcdr elt old-cdr))
! ;; Revert the undo info to what it was when we grabbed the state.
! (setq buffer-undo-list elt)))
! (unless (and (= (point-min) atomic-change-point-min)
! (= (point-max) atomic-change-point-max))
! ;; Try to restore narrowing in force before atomic change.
! (narrow-to-region atomic-change-point-min atomic-change-point-max)))))
;;;; Display-related functions.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #30 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> When using atomic-change-group I got the message
>> undo-more: Changes to be undone are outside visible portion of buffer
>> The changes are also not undone. This seems wrong to me.
> The attached patch now also tries to restore any narrowing in force
> before the atomic change.
I'm not sure we should do that. Currently, narrowing operations are not
saved to the undo-log, so making atomic-change-group save&restore the
narrowing makes it behave differently from the undo.
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #35 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
>>> When using atomic-change-group I got the message
>>> undo-more: Changes to be undone are outside visible portion of buffer
>>> The changes are also not undone. This seems wrong to me.
>
>> The attached patch now also tries to restore any narrowing in force
>> before the atomic change.
>
> I'm not sure we should do that. Currently, narrowing operations are not
> saved to the undo-log, so making atomic-change-group save&restore the
> narrowing makes it behave differently from the undo.
I know what you mean but the present case is different. When someone
uses narrowing within the atomic change group and we really want to undo
the changes (we still can decide that we won't fix the bug ;-)) we have
to widen the buffer. If the buffer was narrowed _before_ entering the
atomic change group, it would be incorrect not to restore that. Or am I
missing something?
martin
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #40 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
martin rudalics wrote:
>>>> When using atomic-change-group I got the message
>>>> undo-more: Changes to be undone are outside visible portion of buffer
>>>> The changes are also not undone. This seems wrong to me.
>>
>>> The attached patch now also tries to restore any narrowing in force
>>> before the atomic change.
>>
>> I'm not sure we should do that. Currently, narrowing operations are not
>> saved to the undo-log, so making atomic-change-group save&restore the
>> narrowing makes it behave differently from the undo.
>
> I know what you mean but the present case is different. When someone
> uses narrowing within the atomic change group and we really want to undo
> the changes (we still can decide that we won't fix the bug ;-)) we have
> to widen the buffer. If the buffer was narrowed _before_ entering the
> atomic change group, it would be incorrect not to restore that. Or am I
> missing something?
I agree. It would be very surprising if narrowing was not restored.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #45 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
>>>>> When using atomic-change-group I got the message
>>>>> undo-more: Changes to be undone are outside visible portion of buffer
>>>>> The changes are also not undone. This seems wrong to me.
>>>
>>>> The attached patch now also tries to restore any narrowing in force
>>>> before the atomic change.
>>>
>>> I'm not sure we should do that. Currently, narrowing operations are not
>>> saved to the undo-log, so making atomic-change-group save&restore the
>>> narrowing makes it behave differently from the undo.
>>
>> I know what you mean but the present case is different. When someone
>> uses narrowing within the atomic change group and we really want to undo
>> the changes (we still can decide that we won't fix the bug ;-)) we have
>> to widen the buffer. If the buffer was narrowed _before_ entering the
>> atomic change group, it would be incorrect not to restore that. Or am I
>> missing something?
The widening needs to be temporary around the call to undo, but that
doesn't seem to imply that atomic-change-group will preserve narrowing.
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
rms <at> gnu.org
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #50 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
I know what you mean but the present case is different. When someone
uses narrowing within the atomic change group and we really want to undo
the changes (we still can decide that we won't fix the bug ;-)) we have
to widen the buffer.
We could say that if the body of the atomic-change-group does
narrowing, then it has the responsibility to widen again.
That seems logical.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
rms <at> gnu.org
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#810
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #60 received at 810 <at> emacsbugs.donarmstrong.com (full text, mbox):
> The widening needs to be temporary around the call to undo, but that
> doesn't seem to imply that atomic-change-group will preserve narrowing.
OK. Installed without restoring the initial narrowing state. Any
narrowing within the group will remain effective when the change is
canceled.
martin
Reply sent to
martin rudalics <rudalics <at> gmx.at>
:
You have taken responsibility.
Full text and
rfc822 format available.
Notification sent to
"Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
:
bug acknowledged by developer.
Full text and
rfc822 format available.
Message #65 received at 810-done <at> emacsbugs.donarmstrong.com (full text, mbox):
Fixed as
2008-09-07 Martin Rudalics <rudalics <at> gmx.at>
* subr.el (cancel-change-group): Widen buffer temporarily when
undoing changes. (Bug#810)
Thanks
bug archived.
Request was from
Debbugs Internal Request <don <at> donarmstrong.com>
to
internal_control <at> emacsbugs.donarmstrong.com
.
(Sun, 05 Oct 2008 14:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 16 years and 258 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.