Created
February 26, 2011 14:02
-
-
Save hyagni/845220 to your computer and use it in GitHub Desktop.
logging all the commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq my-log-key-counter 0) | |
(defun my-log-key (&optional acmd) | |
(let | |
((cmd (symbol-name (or acmd this-command))) | |
(file "~/logging")) | |
(save-current-buffer | |
(set-buffer (get-buffer-create "logging")) | |
(when (= 0 my-log-key-counter) | |
(insert-file-contents-literally file)) | |
(goto-char (point-max)) | |
(insert "\n") | |
(insert cmd) | |
(setq my-log-key-counter (1+ my-log-key-counter)) | |
(when (= 1 (mod my-log-key-counter 1000)) | |
; (write-file file) | |
(with-temp-message "" | |
(write-region (point-min) (point-max) file)) | |
);; write without message | |
))) | |
(defun save-keylog-on-exit () | |
(set-buffer (get-buffer "logging")) | |
(with-temp-message "" | |
(write-region (point-min) (point-max) "~/logging")) | |
) | |
(add-hook 'kill-emacs-hook 'save-keylog-on-exit) | |
(add-hook 'pre-command-hook 'my-log-key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment