I do not think that you can configure Emacs to execute this for all commands. However, you can implement this functionality in the commands themselves. It is made for Cx e . Here is the macro I just wrote (guided by the standard definition of kmacro-call-macro in GNU Emacs 23.1.1) , which makes it easy to add this function to your own commands:
(defmacro with-easy-repeat (&rest body) "Execute BODY and repeat while the user presses the last key." (declare (indent 0)) `(let* ((repeat-key (and (> (length (this-single-command-keys)) 1) last-input-event)) (repeat-key-str (format-kbd-macro (vector repeat-key) nil))) ,@body (while repeat-key (message "(Type %s to repeat)" repeat-key-str) (let ((event (read-event))) (clear-this-command-keys t) (if (equal event repeat-key) (progn ,@body (setq last-input-event nil)) (setq repeat-key nil) (push last-input-event unread-command-events))))))
Here's how you use it:
(defun hello-world () (interactive) (with-easy-repeat (insert "Hello, World!\n"))) (global-set-key (kbd "Cc xyz") 'hello-world)
Now you can enter Cc xyzzz three times to paste Hello, World! .
Daniel Brockman
source share