     (setq then (time-subtract then (seconds-to-time (* 45 24 60 60))))
     (while (not (eobp))
       (when (looking-at
-	     (concat "\\(Y\\s-+\\([0-9]+\\)\\|\\([0-9]{4}+\\)?[./]?"
+	     (concat "\\(Y\\s-+\\([0-9]+\\)\\|"
+		     "\\([0-9]\\{4\\}+\\)?[./]?"
 		     "\\([0-9]+\\)[./]\\([0-9]+\\)\\s-+"
 		     "\\(\\*\\s-+\\)?\\(.+\\)\\)"))
 	(let ((found (match-string 2))
-	      when)
+	      total when)
 	  (if found
 	      (setq current-year (string-to-number found))
 	    (let ((start (match-beginning 0))

(define-derived-mode ledger-reconcile-mode text-mode "Reconcile"
  "A mode for reconciling ledger entries."
  (let ((map (make-sparse-keymap)))
    (define-key map [space] 'ledger-reconcile-toggle)
    (use-local-map map)))

(defvar ledger-buf nil)

				      (or year current-year)))
	      (when (or (not mark) (time-less-p then when))
		(forward-line)
		(setq total 0.0)
		(while (looking-at
			(concat "\\s-+\\([A-Za-z_].+?\\)\\(\\s-*$\\|  \\s-*"
				"\\([^0-9]+\\)\\s-*\\([0-9.]+\\)\\)"))
		  (let ((acct (match-string 1))
			(amt (match-string 4)))
		    (if amt
			(setq amt (string-to-number amt)
			      total (+ total amt)))
		    (if (string= account acct)
			(setq entries
			      (cons (list (copy-marker start)
					  mark when desc (or amt total))
				    entries))))
		  (forward-line)))))))
      (forward-line))
