Emacs键盘记录

Ben*_*Ben 6 emacs elisp

我正在尝试在Emacs中实现一个键盘记录器(为了我自己的,非邪恶的目的).

看来,我可以可靠地通过拍摄的最后一个命令real-last-command的pre-command-hook

所以,我可以这样做:

(setq keylog-list nil)

(defun my-keylogger-function ()
  (setq keylog-list (cons real-last-command keylog-list)))

(add-hook 'pre-command-hook 'my-keylogger-function)
Run Code Online (Sandbox Code Playgroud)

经过一些运动命令后,我们得到了

keylog-list's value is
(describe-variable left-char left-char previous-line previous-line left-char eval-last-sexp)
Run Code Online (Sandbox Code Playgroud)

但是,我也有兴趣捕获这些命令的参数(例如,参数left-char,默认情况下,1如果使用前缀参数,可能会有所不同).

有没有办法访问args?有点像real-last-command-arglist?

Ian*_*ing 5

emacs中还内置了一个键盘记录器:(open-dribble-file)。


Lin*_*cer 3

为什么要记录最后一个(即上一个)命令?如果您this-command改为记录,则可以记录current-prefix-arg,它对应于所使用的前缀参数。