   (if (get-buffer vimgolf-start-buffer-name) (kill-buffer vimgolf-start-buffer-name))
   (if (get-buffer vimgolf-work-buffer-name) (kill-buffer vimgolf-work-buffer-name))
   (if (get-buffer vimgolf-end-buffer-name) (kill-buffer vimgolf-end-buffer-name))
-  (vimgolf-stop-capture-keystrokes)
+  (vimgolf-enable-capture nil)
   (set-window-configuration vimgolf-prior-window-configuration)
   (message "I declare you, n00b!"))
 

        (switch-to-buffer vimgolf-work-buffer)
        (setq vimgolf-working-window-configuration (current-window-configuration))

        (vimgolf-capture-keystrokes)))))

;;; vimgolf.el ends here

       (insert "
")))))

(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-log-keystroke)
    (funcall f 'post-command-hook 'vimgolf-log-keystroke)))

(defun vimgolf-count-keystrokes ()
  (with-current-buffer (get-buffer vimgolf-keystrokes-buffer-name)
