Io non credo che si possa configurare Emacs in modo che lo fa che per tutti i comandi. Tuttavia, è possibile implementare questa funzionalità nei comandi stessi. Questo è ciò che viene fatto per C-xe. Ecco una macro che ho appena scritto (guidato dalla definizione standard di kmacro-call-macro
in GNU Emacs 23.1.1) che lo rende facile per aggiungere questa funzionalità per i propri comandi:
(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))))))
Ecco come si usa iT:
(defun hello-world()
(interactive)
(with-easy-repeat
(insert "Hello, World!\n")))
(global-set-key (kbd "C-c x y z") 'hello-world)
Ora è possibile digitare Cc xyzzz inserire Hello, World!
tre volte.
fonte
2011-09-26 19:43:12
Funziona perfettamente. Grazie! – TheEzEzz
Vedi anche il pacchetto 'repeat' di Emacs. –
@event_jr Bello !! Grazie per il consiglio. –