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