- (repeat-message "Repeating command %S" real-last-command)
- (setq current-prefix-arg repeat-arg)
- (repeat-message "Repeating command %S %S" repeat-arg real-last-command))
- (if (eq real-last-command 'self-insert-command)
- (let ((insertion
- (if (<= (- num-input-keys
- repeat-num-input-keys-at-self-insert)
- 1)
- repeat-last-self-insert
- (let ((range (nth 1 buffer-undo-list)))
- (condition-case nil
- (setq repeat-last-self-insert
- (buffer-substring (car range)
- (cdr range)))
- (error (error "%s %s %s" ;Danger, Will Robinson!
- "repeat can't intuit what you"
- "inserted before auto-fill"
- "clobbered it, sorry")))))))
- (setq repeat-num-input-keys-at-self-insert num-input-keys)
- ;; If the self-insert had a repeat count, INSERTION
- ;; includes that many copies of the same character.
- ;; So use just the first character
- ;; and repeat it the right number of times.
- (setq insertion (substring insertion -1))
- (let ((count (prefix-numeric-value repeat-arg))
- (i 0))
- (while (< i count)
- (repeat-self-insert insertion)
- (setq i (1+ i)))))
- (let ((indirect (indirect-function real-last-command)))
- (if (or (stringp indirect)
- (vectorp indirect))
- ;; Bind real-last-command so that executing the macro
- ;; does not alter it.
- (let ((real-last-command real-last-command))
- (execute-kbd-macro real-last-command))
- (run-hooks 'pre-command-hook)
- (call-interactively real-last-command)
- (run-hooks 'post-command-hook)))))
+ (repeat-message "Repeating command %S" last-repeatable-command)
+ (setq current-prefix-arg repeat-arg)
+ (repeat-message
+ "Repeating command %S %S" repeat-arg last-repeatable-command))
+ (when (eq last-repeatable-command 'self-insert-command)
+ ;; We used to use a much more complex code to try and figure out
+ ;; what key was used to run that self-insert-command:
+ ;; (if (<= (- num-input-keys
+ ;; repeat-num-input-keys-at-self-insert)
+ ;; 1)
+ ;; repeat-last-self-insert
+ ;; (let ((range (nth 1 buffer-undo-list)))
+ ;; (condition-case nil
+ ;; (setq repeat-last-self-insert
+ ;; (buffer-substring (car range)
+ ;; (cdr range)))
+ ;; (error (error "%s %s %s" ;Danger, Will Robinson!
+ ;; "repeat can't intuit what you"
+ ;; "inserted before auto-fill"
+ ;; "clobbered it, sorry")))))
+ (setq last-command-event (char-before)))
+ (let ((indirect (indirect-function last-repeatable-command)))
+ (if (or (stringp indirect)
+ (vectorp indirect))
+ ;; Bind last-repeatable-command so that executing the macro does
+ ;; not alter it.
+ (let ((last-repeatable-command last-repeatable-command))
+ (execute-kbd-macro last-repeatable-command))
+ (call-interactively last-repeatable-command))))