Skip to content

Instantly share code, notes, and snippets.

@hyagni
Created February 26, 2011 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyagni/845220 to your computer and use it in GitHub Desktop.
Save hyagni/845220 to your computer and use it in GitHub Desktop.
logging all the commands
(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