Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/purcell/prettify-keystrokes'
Browse files Browse the repository at this point in the history
  • Loading branch information
timvisher committed Nov 24, 2011
2 parents 71a97dc + 77165fb commit b621881
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions emacs/vimgolf.el
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,19 @@ unknown key sequence was entered).")
(insert (format "Keystrokes (%d):\n\n" (vimgolf-count-keystrokes))
(mapconcat 'key-description (mapcar 'car vimgolf-keystrokes) " ")
"\n\nFull command log:\n\n")
(dolist (entry vimgolf-keystrokes)
(insert (key-description (car entry)))
(insert " ")
(princ (cdr entry) (current-buffer))
(insert "\n")))))
(when vimgolf-keystrokes
(let* ((descrs-and-commands
(mapcar (lambda (entry) (cons (key-description (car entry)) (cdr entry))) vimgolf-keystrokes))
(maxlen (apply 'max (mapcar 'length (mapcar 'car descrs-and-commands))))
(fmt (format "%%-%ds %%s" maxlen)))
(dolist (entry descrs-and-commands)
(insert (format fmt (car entry) (prin1-to-string (cdr entry) t)) "\n")))))))

(defun vimgolf-enable-capture (enable)
"Enable keystroke logging if `ENABLE' is non-nil otherwise disable it."
(let ((f (if enable 'add-hook 'remove-hook)))
(funcall f 'pre-command-hook 'vimgolf-capture-keystroke)
(funcall f 'post-command-hook 'vimgolf-capture-dangling-keystroke)
(funcall f 'pre-command-hook 'vimgolf-refresh-keystroke-log)
(funcall f 'post-command-hook 'vimgolf-refresh-keystroke-log)))

(defun vimgolf-count-keystrokes ()
Expand Down

0 comments on commit b621881

Please sign in to comment.