diff options
| author | Stefan Monnier | 2008-02-04 15:31:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-02-04 15:31:09 +0000 |
| commit | cb11476b222555583a5afe3f61d08fc8191d0ccc (patch) | |
| tree | 4eead23989b4d3aa9e8c54f2012b5c60c1bf2eea | |
| parent | d9090cc15a6ec3039fc0dc9ef4c826b8541d78f1 (diff) | |
| download | emacs-cb11476b222555583a5afe3f61d08fc8191d0ccc.tar.gz emacs-cb11476b222555583a5afe3f61d08fc8191d0ccc.zip | |
(cancel-change-group): Improve last fix.
| -rw-r--r-- | lisp/subr.el | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index ef908c0a7cb..8420c8553dd 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1871,29 +1871,29 @@ This finishes the change group by accepting its changes as final." | |||
| 1871 | (defun cancel-change-group (handle) | 1871 | (defun cancel-change-group (handle) |
| 1872 | "Finish a change group made with `prepare-change-group' (which see). | 1872 | "Finish a change group made with `prepare-change-group' (which see). |
| 1873 | This finishes the change group by reverting all of its changes." | 1873 | This finishes the change group by reverting all of its changes." |
| 1874 | (save-excursion | 1874 | (dolist (elt handle) |
| 1875 | (dolist (elt handle) | 1875 | (with-current-buffer (car elt) |
| 1876 | (with-current-buffer (car elt) | 1876 | (setq elt (cdr elt)) |
| 1877 | (setq elt (cdr elt)) | 1877 | (let ((old-car |
| 1878 | (let ((old-car | 1878 | (if (consp elt) (car elt))) |
| 1879 | (if (consp elt) (car elt))) | 1879 | (old-cdr |
| 1880 | (old-cdr | 1880 | (if (consp elt) (cdr elt)))) |
| 1881 | (if (consp elt) (cdr elt)))) | 1881 | ;; Temporarily truncate the undo log at ELT. |
| 1882 | ;; Temporarily truncate the undo log at ELT. | 1882 | (when (consp elt) |
| 1883 | (when (consp elt) | 1883 | (setcar elt nil) (setcdr elt nil)) |
| 1884 | (setcar elt nil) (setcdr elt nil)) | 1884 | (unless (eq last-command 'undo) (undo-start)) |
| 1885 | (unless (eq last-command 'undo) (undo-start)) | 1885 | ;; Make sure there's no confusion. |
| 1886 | ;; Make sure there's no confusion. | 1886 | (when (and (consp elt) (not (eq elt (last pending-undo-list)))) |
| 1887 | (when (and (consp elt) (not (eq elt (last pending-undo-list)))) | 1887 | (error "Undoing to some unrelated state")) |
| 1888 | (error "Undoing to some unrelated state")) | 1888 | ;; Undo it all. |
| 1889 | ;; Undo it all. | 1889 | (save-excursion |
| 1890 | (while (listp pending-undo-list) (undo-more 1)) | 1890 | (while (listp pending-undo-list) (undo-more 1))) |
| 1891 | ;; Reset the modified cons cell ELT to its original content. | 1891 | ;; Reset the modified cons cell ELT to its original content. |
| 1892 | (when (consp elt) | 1892 | (when (consp elt) |
| 1893 | (setcar elt old-car) | 1893 | (setcar elt old-car) |
| 1894 | (setcdr elt old-cdr)) | 1894 | (setcdr elt old-cdr)) |
| 1895 | ;; Revert the undo info to what it was when we grabbed the state. | 1895 | ;; Revert the undo info to what it was when we grabbed the state. |
| 1896 | (setq buffer-undo-list elt)))))) | 1896 | (setq buffer-undo-list elt))))) |
| 1897 | 1897 | ||
| 1898 | ;;;; Display-related functions. | 1898 | ;;;; Display-related functions. |
| 1899 | 1899 | ||