From: Martin Rudalics Date: Sun, 7 Sep 2008 09:16:56 +0000 (+0000) Subject: (cancel-change-group): Widen buffer temporarily when X-Git-Tag: emacs-pretest-23.0.90~2975 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d21cba62f0b647ad7ec7ac298f0dae59e06bc381;p=emacs.git (cancel-change-group): Widen buffer temporarily when undoing changes. (Bug#810) --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1bb4e7721cf..46404ef3c09 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-09-07 Martin Rudalics + + * subr.el (cancel-change-group): Widen buffer temporarily when + undoing changes. (Bug#810) + 2008-09-07 Nick Roberts * progmodes/gud.el (gud-stop-subjob): Using jdb, suspend threads diff --git a/lisp/subr.el b/lisp/subr.el index b7b6b2c38de..2aa802cd03e 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1993,26 +1993,30 @@ This finishes the change group by reverting all of its changes." (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))))) + (save-restriction + ;; Widen buffer temporarily so if the buffer was narrowed within + ;; the body of `atomic-change-group' all changes can be undone. + (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.