Permalink
Browse files

Merge remote-tracking branch 'refs/remotes/purcell/prettify-keystrokes'

  • Loading branch information...
2 parents 71a97dc + 77165fb commit b62188118c02dc28c8d2ebca246186b9e9af199d @timvisher committed Nov 24, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 emacs/vimgolf.el
View
@@ -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 ()

0 comments on commit b621881

Please sign in to comment.