Emacs ha repeate repeat-complex-command, che disegnano comandi diversi dalla cronologia dei comandi e sono associati a chiavi diverse. Come si ripete ogni ultimo comando - se era complessa o meno - con una sola chiave? In altre parole, un tale comando ripetuto si comporterebbe come repeat-complex-commandse l'ultimo comando richiedesse un input, altrimenti si comporterebbe come repeat.
EDIT : In altre parole, sto cercando un modo per leggere l'ultimo comando, complesso o no, e quindi chiamare uno repeat-complex-commando repeatsu di esso, a seconda di quale sia appropriato. Ad esempio, supponiamo che sia associato un comando così nuovo <f8>. Poi:
(mimando
C-x M-: (repeat-complex-command)conM-z (zap-to-char)):C-u M-z a <f8> <f8>sarà equivalente aC-u M-z a C-x M-: RET C-x M-: RET(mimando
C-x z (repeat)conC-f (forward-char)):C-u C-f <f8> <f8>sarà equivalente aC-u C-f C-x z z
Ora, repeat-complex-commandrichiede di confermare il modulo Lisp che verrà eseguito. Per consentire di ripetere un comando complesso senza conferma, ho scritto una versione alternativa di repeat-complex-command, chiamata repeat-complex-command-no-confirm(vedi sotto per l'implementazione). Il problema è che non riesco a capire come determinare se devo chiamare repeato repeat-complex-command-no-confirmquando premo <f8>.
-
(defun repeat-complex-command-no-confirm (arg)
"Like `repeat-complex-command' but does not require confirmation."
;; Adapted from `repeat-complex-command' of Emacs 24.5.1.
(interactive "p")
(let ((elt (nth (1- arg) command-history))
newcmd)
(if elt
(progn
(setq newcmd elt)
;; If command to be redone does not match front of history,
;; add it to the history.
(or (equal newcmd (car command-history))
(setq command-history (cons newcmd command-history)))
(unwind-protect
(progn
;; Trick called-interactively-p into thinking that `newcmd' is
;; an interactive call (bug#14136).
(add-hook 'called-interactively-p-functions
#'repeat-complex-command--called-interactively-skip)
(eval newcmd))
(remove-hook 'called-interactively-p-functions
#'repeat-complex-command--called-interactively-skip)))
(if command-history
(error "Argument %d is beyond length of command history" arg)
(error "There are no previous complex commands to repeat")))))