Mercurial > emacs
comparison lisp/simple.el @ 5935:a2b7fc4645d9
(undo, yank): Set this-command to t at start,
and set it correctly at the end.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 13 Feb 1994 00:16:23 +0000 |
parents | 57c1061d77ff |
children | 022fbe742832 |
comparison
equal
deleted
inserted
replaced
5934:9699f3d409e5 | 5935:a2b7fc4645d9 |
---|---|
602 (defun undo (&optional arg) | 602 (defun undo (&optional arg) |
603 "Undo some previous changes. | 603 "Undo some previous changes. |
604 Repeat this command to undo more changes. | 604 Repeat this command to undo more changes. |
605 A numeric argument serves as a repeat count." | 605 A numeric argument serves as a repeat count." |
606 (interactive "*p") | 606 (interactive "*p") |
607 ;; If we don't get all the way thru, make last-command indicate that | |
608 ;; for the following command. | |
609 (setq this-command t) | |
607 (let ((modified (buffer-modified-p)) | 610 (let ((modified (buffer-modified-p)) |
608 (recent-save (recent-auto-save-p))) | 611 (recent-save (recent-auto-save-p))) |
609 (or (eq (selected-window) (minibuffer-window)) | 612 (or (eq (selected-window) (minibuffer-window)) |
610 (message "Undo!")) | 613 (message "Undo!")) |
611 (or (eq last-command 'undo) | 614 (or (eq last-command 'undo) |
612 (progn (undo-start) | 615 (progn (undo-start) |
613 (undo-more 1))) | 616 (undo-more 1))) |
614 (setq this-command 'undo) | |
615 (undo-more (or arg 1)) | 617 (undo-more (or arg 1)) |
616 (and modified (not (buffer-modified-p)) | 618 (and modified (not (buffer-modified-p)) |
617 (delete-auto-save-file-if-necessary recent-save)))) | 619 (delete-auto-save-file-if-necessary recent-save))) |
620 ;; If we do get all the way thru, make this-command indicate that. | |
621 (setq this-command 'undo)) | |
618 | 622 |
619 (defvar pending-undo-list nil | 623 (defvar pending-undo-list nil |
620 "Within a run of consecutive undo commands, list remaining to be undone.") | 624 "Within a run of consecutive undo commands, list remaining to be undone.") |
621 | 625 |
622 (defun undo-start () | 626 (defun undo-start () |
1163 With just C-u as argument, same but put point at beginning (and mark at end). | 1167 With just C-u as argument, same but put point at beginning (and mark at end). |
1164 With argument N, reinsert the Nth most recently killed stretch of killed | 1168 With argument N, reinsert the Nth most recently killed stretch of killed |
1165 text. | 1169 text. |
1166 See also the command \\[yank-pop]." | 1170 See also the command \\[yank-pop]." |
1167 (interactive "*P") | 1171 (interactive "*P") |
1172 ;; If we don't get all the way thru, make last-command indicate that | |
1173 ;; for the following command. | |
1174 (setq this-command t) | |
1168 (push-mark (point)) | 1175 (push-mark (point)) |
1169 (insert (current-kill (cond | 1176 (insert (current-kill (cond |
1170 ((listp arg) 0) | 1177 ((listp arg) 0) |
1171 ((eq arg '-) -1) | 1178 ((eq arg '-) -1) |
1172 (t (1- arg))))) | 1179 (t (1- arg))))) |
1174 ;; This is like exchange-point-and-mark, but doesn't activate the mark. | 1181 ;; This is like exchange-point-and-mark, but doesn't activate the mark. |
1175 ;; It is cleaner to avoid activation, even though the command | 1182 ;; It is cleaner to avoid activation, even though the command |
1176 ;; loop would deactivate the mark because we inserted text. | 1183 ;; loop would deactivate the mark because we inserted text. |
1177 (goto-char (prog1 (mark t) | 1184 (goto-char (prog1 (mark t) |
1178 (set-marker (mark-marker) (point) (current-buffer))))) | 1185 (set-marker (mark-marker) (point) (current-buffer))))) |
1186 ;; If we do get all the way thru, make this-command indicate that. | |
1187 (setq this-command 'yank) | |
1179 nil) | 1188 nil) |
1180 | 1189 |
1181 (defun rotate-yank-pointer (arg) | 1190 (defun rotate-yank-pointer (arg) |
1182 "Rotate the yanking point in the kill ring. | 1191 "Rotate the yanking point in the kill ring. |
1183 With argument, rotate that many kills forward (or backward, if negative)." | 1192 With argument, rotate that many kills forward (or backward, if negative)." |