      (define-key map [menu-bar ldg-recon-menu ref] '("Refresh" . ledger-reconcile-refresh))
      (define-key map [menu-bar ldg-recon-menu sav] '("Save" . ledger-reconcile-save))
      
-     (use-local-map map)
-     
-     (add-hook 'kill-buffer-hook 'ledger-reconcile-quit-cleanup nil t)))
+     (use-local-map map)))
 
 (provide 'ldg-reconcile)
 (provide 'ldg-reconcile)



(defun ledger-reconcile-quit ()
  "Quite the reconcile window without saving ledger buffer."
  (interactive)
  (ledger-reconcile-quit-cleanup)
  (let ((buf ledger-buf)
	(recon-buf  (get-buffer ledger-recon-buffer-name)))
    ;; Make sure you delete the window before you delete the buffer,
    ;; otherwise, madness ensues
    (with-current-buffer recon-buf
      (delete-window (get-buffer-window recon-buf))
      (kill-buffer recon-buf))
    (set-window-buffer (selected-window) buf)))

(defun ledger-reconcile-quit-cleanup ()
  "Cleanup all hooks established by reconcile mode."
  (interactive)
  (let ((buf ledger-buf)
	(reconcile-buf (get-buffer ledger-recon-buffer-name)))
    (with-current-buffer buf
      (remove-hook 'after-save-hook 'ledger-reconcile-refresh-after-save t)
      (if ledger-fold-on-reconcile

      (when recon-window
	(fit-window-to-buffer recon-window)
	(with-current-buffer buf
	  (add-hook 'kill-buffer-hook 'ledger-reconcile-quit nil t)
	  (select-window (get-buffer-window buf))
	  (goto-char (point-max))
	  (recenter -1))
