comparison lisp/repeat.el @ 23098:7fd17414e625

(repeat): Doc fix. [From rms:] (repeat-previous-repeated-command): New variable. (repeat): Check for real-last-command being null or repeat. Set repeat-previous-repeated-command.
author Dave Love <fx@gnu.org>
date Tue, 25 Aug 1998 13:28:44 +0000
parents 9c6f6af7919f
children f47c04fb4aab
comparison
equal deleted inserted replaced
23097:86a92272892c 23098:7fd17414e625
199 ;; available in <http://www.eskimo.com/~seldon/dotemacs.el>; search for 199 ;; available in <http://www.eskimo.com/~seldon/dotemacs.el>; search for
200 ;; "defun wm-switch-buffer". 200 ;; "defun wm-switch-buffer".
201 201
202 ;;;;; ******************* THE REPEAT COMMAND ITSELF ******************* ;;;;; 202 ;;;;; ******************* THE REPEAT COMMAND ITSELF ******************* ;;;;;
203 203
204 (defvar repeat-previous-repeated-command nil
205 "The previous repeated command.")
206
204 ;;;###autoload 207 ;;;###autoload
205 (defun repeat (repeat-arg) 208 (defun repeat (repeat-arg)
206 "Repeat most recently executed command. 209 "Repeat most recently executed command.
207 With prefix arg, apply new prefix arg to that command; otherwise, maintain 210 With prefix arg, apply new prefix arg to that command; otherwise, maintain
208 prefix arg of most recently executed command if it had one. 211 prefix arg of most recently executed command if it had one.
209 This command is named after the `.' command in the vi editor. 212 This command is like the `.' command in the vi editor.
210 213
211 If this command is invoked by a multi-character key sequence, it can then 214 If this command is invoked by a multi-character key sequence, it can then
212 be repeated by repeating the final character of that sequence. This behavior 215 be repeated by repeating the final character of that sequence. This behavior
213 can be modified by the global variable `repeat-on-final-keystroke'." 216 can be modified by the global variable `repeat-on-final-keystroke'."
214 ;; The most recently executed command could be anything, so surprises could 217 ;; The most recently executed command could be anything, so surprises could
218 ;; To avoid that, I tried the `lexical-let' of the Common Lisp extensions, 221 ;; To avoid that, I tried the `lexical-let' of the Common Lisp extensions,
219 ;; but that entails a very noticeable performance hit, so instead I use the 222 ;; but that entails a very noticeable performance hit, so instead I use the
220 ;; "repeat-" prefix, reserved by this package, for *local* variables that 223 ;; "repeat-" prefix, reserved by this package, for *local* variables that
221 ;; might be visible to re-executed commands, including this function's arg. 224 ;; might be visible to re-executed commands, including this function's arg.
222 (interactive "P") 225 (interactive "P")
223 (setq this-command real-last-command 226 (when (eq real-last-command 'repeat)
224 repeat-num-input-keys-at-repeat num-input-keys) 227 (setq real-last-command repeat-previous-repeated-command))
228 (when (null real-last-command)
229 (error "There is nothing to repeat"))
225 (when (eq real-last-command 'mode-exit) 230 (when (eq real-last-command 'mode-exit)
226 (error "real-last-command is mode-exit & can't be repeated")) 231 (error "real-last-command is mode-exit & can't be repeated"))
227 (when (memq real-last-command repeat-too-dangerous) 232 (when (memq real-last-command repeat-too-dangerous)
228 (error "Command %S too dangerous to repeat automatically" real-last-command)) 233 (error "Command %S too dangerous to repeat automatically" real-last-command))
234 (setq this-command real-last-command
235 repeat-num-input-keys-at-repeat num-input-keys)
236 (setq repeat-previous-repeated-command this-command)
229 (when (null repeat-arg) 237 (when (null repeat-arg)
230 (setq repeat-arg last-prefix-arg)) 238 (setq repeat-arg last-prefix-arg))
231 ;; Now determine whether to loop on repeated taps of the final character 239 ;; Now determine whether to loop on repeated taps of the final character
232 ;; of the key sequence that invoked repeat. The Emacs global 240 ;; of the key sequence that invoked repeat. The Emacs global
233 ;; last-command-char contains the final character now, but may not still 241 ;; last-command-char contains the final character now, but may not still