Mercurial > emacs
comparison lisp/simple.el @ 59782:ec7c04e04f71
(undo): Fix the test for continuing a series of undos.
(undo-more): Set pending-undo-list to t when we reach end.
(pending-undo-list): defvar moved up.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 29 Jan 2005 17:24:41 +0000 |
parents | 5f125540565b |
children | 85fb49e8bc60 |
comparison
equal
deleted
inserted
replaced
59781:b302445f7b00 | 59782:ec7c04e04f71 |
---|---|
1233 "Non-nil if `pending-undo-list' is not just a tail of `buffer-undo-list'.") | 1233 "Non-nil if `pending-undo-list' is not just a tail of `buffer-undo-list'.") |
1234 | 1234 |
1235 (defvar undo-no-redo nil | 1235 (defvar undo-no-redo nil |
1236 "If t, `undo' doesn't go through redo entries.") | 1236 "If t, `undo' doesn't go through redo entries.") |
1237 | 1237 |
1238 (defvar pending-undo-list nil | |
1239 "Within a run of consecutive undo commands, list remaining to be undone. | |
1240 t if we undid all the way to the end of it.") | |
1241 | |
1238 (defun undo (&optional arg) | 1242 (defun undo (&optional arg) |
1239 "Undo some previous changes. | 1243 "Undo some previous changes. |
1240 Repeat this command to undo more changes. | 1244 Repeat this command to undo more changes. |
1241 A numeric argument serves as a repeat count. | 1245 A numeric argument serves as a repeat count. |
1242 | 1246 |
1256 ;; the next command should not be a "consecutive undo". | 1260 ;; the next command should not be a "consecutive undo". |
1257 ;; So set `this-command' to something other than `undo'. | 1261 ;; So set `this-command' to something other than `undo'. |
1258 (setq this-command 'undo-start) | 1262 (setq this-command 'undo-start) |
1259 | 1263 |
1260 (unless (and (eq last-command 'undo) | 1264 (unless (and (eq last-command 'undo) |
1261 ;; If something (a timer or filter?) changed the buffer | 1265 (or (eq pending-undo-list t) |
1262 ;; since the previous command, don't continue the undo seq. | 1266 ;; If something (a timer or filter?) changed the buffer |
1263 (let ((list buffer-undo-list)) | 1267 ;; since the previous command, don't continue the undo seq. |
1264 (while (eq (car list) nil) | 1268 (let ((list buffer-undo-list)) |
1265 (setq list (cdr list))) | 1269 (while (eq (car list) nil) |
1266 ;; If the last undo record made was made by undo | 1270 (setq list (cdr list))) |
1267 ;; it shows nothing else happened in between. | 1271 ;; If the last undo record made was made by undo |
1268 (gethash list undo-equiv-table))) | 1272 ;; it shows nothing else happened in between. |
1273 (gethash list undo-equiv-table)))) | |
1269 (setq undo-in-region | 1274 (setq undo-in-region |
1270 (if transient-mark-mode mark-active (and arg (not (numberp arg))))) | 1275 (if transient-mark-mode mark-active (and arg (not (numberp arg))))) |
1271 (if undo-in-region | 1276 (if undo-in-region |
1272 (undo-start (region-beginning) (region-end)) | 1277 (undo-start (region-beginning) (region-end)) |
1273 (undo-start)) | 1278 (undo-start)) |
1338 (let ((undo-no-redo t)) (undo arg))) | 1343 (let ((undo-no-redo t)) (undo arg))) |
1339 ;; Richard said that we should not use C-x <uppercase letter> and I have | 1344 ;; Richard said that we should not use C-x <uppercase letter> and I have |
1340 ;; no idea whereas to bind it. Any suggestion welcome. -stef | 1345 ;; no idea whereas to bind it. Any suggestion welcome. -stef |
1341 ;; (define-key ctl-x-map "U" 'undo-only) | 1346 ;; (define-key ctl-x-map "U" 'undo-only) |
1342 | 1347 |
1343 (defvar pending-undo-list nil | |
1344 "Within a run of consecutive undo commands, list remaining to be undone.") | |
1345 | |
1346 (defvar undo-in-progress nil | 1348 (defvar undo-in-progress nil |
1347 "Non-nil while performing an undo. | 1349 "Non-nil while performing an undo. |
1348 Some change-hooks test this variable to do something different.") | 1350 Some change-hooks test this variable to do something different.") |
1349 | 1351 |
1350 (defun undo-more (count) | 1352 (defun undo-more (count) |
1351 "Undo back N undo-boundaries beyond what was already undone recently. | 1353 "Undo back N undo-boundaries beyond what was already undone recently. |
1352 Call `undo-start' to get ready to undo recent changes, | 1354 Call `undo-start' to get ready to undo recent changes, |
1353 then call `undo-more' one or more times to undo them." | 1355 then call `undo-more' one or more times to undo them." |
1354 (or pending-undo-list | 1356 (or (listp pending-undo-list) |
1355 (error (format "No further undo information%s" | 1357 (error (format "No further undo information%s" |
1356 (if (and transient-mark-mode mark-active) | 1358 (if (and transient-mark-mode mark-active) |
1357 " for region" "")))) | 1359 " for region" "")))) |
1358 (let ((undo-in-progress t)) | 1360 (let ((undo-in-progress t)) |
1359 (setq pending-undo-list (primitive-undo count pending-undo-list)))) | 1361 (setq pending-undo-list (primitive-undo count pending-undo-list)) |
1362 (if (null pending-undo-list) | |
1363 (setq pending-undo-list t)))) | |
1360 | 1364 |
1361 ;; Deep copy of a list | 1365 ;; Deep copy of a list |
1362 (defun undo-copy-list (list) | 1366 (defun undo-copy-list (list) |
1363 "Make a copy of undo list LIST." | 1367 "Make a copy of undo list LIST." |
1364 (mapcar 'undo-copy-list-1 list)) | 1368 (mapcar 'undo-copy-list-1 list)) |