   (if (bufferp (car where))
       (car where)
       (error "buffer not set")))
-
 
 (defun ledger-reconcile-toggle ()
   (interactive)

	    (unless (eobp)
	      (unless (looking-at "(")
		(error (buffer-string)))
	      (read (current-buffer))))))
    (if (> (length xacts) 0)
	(progn
	  (dolist (xact xacts)
	    (let ((index 1))
	      (dolist (posting (nthcdr 5 xact))
		(let ((beg (point))  
		      (where (ledger-marker-where-xact-is xact posting)))

(defun ledger-reconcile (account)
  (interactive "sAccount to reconcile: ")
  (let ((buf (current-buffer))
        (rbuf (get-buffer ledger-recon-buffer-name)))  ;this means only one *Reconcile* buffer, ever
    (if rbuf  ; *Reconcile* already exists
	(with-current-buffer rbuf
	  (set 'ledger-acct account)  ; already buffer local
	  (if (not (eq buf rbuf)) 
	      (progn ; called from some other ledger-mode buffer
		(ledger-reconcile-quit-cleanup)
		(set 'ledger-buf buf)))  ; should already be buffer-local
	  (if ledger-fold-on-reconcile
	      (ledger-occur-change-regex account ledger-buf))
	  (set-buffer (get-buffer ledger-recon-buffer-name))
	  (ledger-reconcile-refresh))

	  (progn  ; no recon-buffer, starting from scratch.
	    (add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t)
	    (if ledger-fold-on-reconcile
		(ledger-occur-mode account buf))
	    
	    (with-current-buffer
		(if ledger-reconcile-force-window-bottom
		    ;create the *Reconcile* window directly below the ledger buffer.
		    (progn
		      (set-window-buffer
		       (split-window (get-buffer-window buf) nil nil) 
		       (get-buffer-create ledger-recon-buffer-name))
		      (get-buffer ledger-recon-buffer-name))
		    (pop-to-buffer (get-buffer-create ledger-recon-buffer-name)))
	      (ledger-reconcile-mode)
	      (set (make-local-variable 'ledger-buf) buf)
	      (set (make-local-variable 'ledger-acct) account)
	      (ledger-do-reconcile))))))  

(defvar ledger-reconcile-mode-abbrev-table)

(defun ledger-reconcile-display-internals ()
  (interactive)
  (message "%S %S" ledger-acct ledger-buf))

(define-derived-mode ledger-reconcile-mode text-mode "Reconcile"
   "A mode for reconciling ledger entries."
