GNU bug report logs -
#810
23.0.60; atomic-change-group narrowing problem
Previous Next
Full log
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.
This bug report was last modified 16 years and 259 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.