Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs keylogger

Tags:

emacs

elisp

I'm trying to implement a keylogger in Emacs (for my own, non-nefarious purposes).

It seems that I can reliably capture the last command through real-last-command in the pre-command-hook

So, I can do something like:

(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)

After a few movement commands, we get

keylog-list's value is
(describe-variable left-char left-char previous-line previous-line left-char eval-last-sexp)

However, I'm interested in capturing the arguments to these commands as well (e.g. the arguments to left-char, which will by default be 1 but may be different if prefix arguments are used.

Is there a way to access the args as well? Something like real-last-command-arglist?

like image 673
Ben Avatar asked Jun 04 '13 05:06

Ben


2 Answers

A keylogger is also built into emacs: (open-dribble-file).

like image 54
Ian Kelling Avatar answered Sep 21 '22 16:09

Ian Kelling


Why do you log the last (i.e. previous) command? If you log this-command instead, you can log current-prefix-arg, which corresponds to the prefix argument used.

like image 41
Lindydancer Avatar answered Sep 18 '22 16:09

Lindydancer