                      vimgolf-pause
                      vimgolf-quit)))))
 
+(defun vimgolf-capturable-dangling-keystroke-p ()
+  (member this-command
+          '(calc-dispatch)))
+
 (defun vimgolf-capture-keystroke ()
   (vimgolf-with-saved-command-environment
    (when (vimgolf-capturable-keystroke-p)

(defvar vimgolf-start-buffer-name "*vimgolf-start*")
(defvar vimgolf-end-buffer-name "*vimgolf-end*")
(defvar vimgolf-keystrokes-buffer-name "*vimgolf-keystrokes*")

(defun point-min-in-buffer (buffer)
  (with-current-buffer buffer

       (insert (key-description (this-command-keys)))
       (insert " ")))))

(defun vimgolf-capture-dangling-keystroke ()
  (vimgolf-with-saved-command-environment
   (when (vimgolf-capturable-dangling-keystroke-p)
     (with-current-buffer (get-buffer-create vimgolf-keystrokes-buffer-name)
       (end-of-buffer)
       (insert (key-description (this-command-keys)))
       (insert " ")))))

;; (setq vimgolf-logging-enabled t)
;; (setq vimgolf-logging-enable)
(defvar vimgolf-logging-enabled)

(defun vimgolf-log-keystroke ()
  (when vimgolf-logging-enabled
    (vimgolf-with-saved-command-environment
     (with-current-buffer (get-buffer-create vimgolf-keystrokes-log-buffer-name)
       (end-of-buffer)
       (insert (key-description (this-command-keys)))
       (insert " ")
       (princ this-command (get-buffer-create vimgolf-keystrokes-log-buffer-name))
       (insert "
")))))

(defun vimgolf-capture-keystrokes ()
  (add-hook 'pre-command-hook 'vimgolf-capture-keystroke)
  (add-hook 'post-command-hook 'vimgolf-capture-dangling-keystroke)
  (add-hook 'pre-command-hook 'vimgolf-log-keystroke)
  (add-hook 'post-command-hook 'vimgolf-log-keystroke))

(defun vimgolf-stop-capture-keystrokes ()
  (remove-hook 'pre-command-hook 'vimgolf-capture-keystroke)
  (remove-hook 'post-command-hook 'vimgolf-capture-dangling-keystroke)
  (remove-hook 'pre-command-hook 'vimgolf-log-keystroke)
  (remove-hook 'post-command-hook 'vimgolf-log-keystroke))

(defun vimgolf-right-solution ()
  (message "Hurray!")
