Revert "Merge pull request #147 from vanicat/t/where-are-transaction"

This reverts commit 9a411e898a, reversing
changes made to bdf404112e.
This commit is contained in:
Craig Earls 2013-02-08 15:24:00 -07:00
parent 9a411e898a
commit 8f214f3830

View file

@ -22,7 +22,6 @@
;; Reconcile mode ;; Reconcile mode
(defvar ledger-buf nil) (defvar ledger-buf nil)
(defvar ledger-bufs nil)
(defvar ledger-acct nil) (defvar ledger-acct nil)
(defcustom ledger-recon-buffer-name "*Reconcile*" (defcustom ledger-recon-buffer-name "*Reconcile*"
"Name to use for reconciliation window" "Name to use for reconciliation window"
@ -54,18 +53,14 @@
(equal file "<stdin>") (equal file "<stdin>")
(equal file "/dev/stdin"))) (equal file "/dev/stdin")))
(defun ledger-reconcile-get-buffer (where)
(when (bufferp (car where))
(car where)))
(defun ledger-reconcile-toggle () (defun ledger-reconcile-toggle ()
(interactive) (interactive)
(let ((where (get-text-property (point) 'where)) (let ((where (get-text-property (point) 'where))
(account ledger-acct) (account ledger-acct)
(inhibit-read-only t) (inhibit-read-only t)
cleared) cleared)
(when (ledger-reconcile-get-buffer where) (when (is-stdin (car where))
(with-current-buffer (ledger-reconcile-get-buffer where) (with-current-buffer ledger-buf
(goto-char (cdr where)) (goto-char (cdr where))
(setq cleared (ledger-toggle-current-entry))) (setq cleared (ledger-toggle-current-entry)))
;remove the existing face and add the new face ;remove the existing face and add the new face
@ -117,8 +112,8 @@
(defun ledger-reconcile-delete () (defun ledger-reconcile-delete ()
(interactive) (interactive)
(let ((where (get-text-property (point) 'where))) (let ((where (get-text-property (point) 'where)))
(when (ledger-reconcile-get-buffer where) (when (is-stdin (car where))
(with-current-buffer (ledger-reconcile-get-buffer where) (with-current-buffer ledger-buf
(goto-char (cdr where)) (goto-char (cdr where))
(ledger-delete-current-entry)) (ledger-delete-current-entry))
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
@ -129,16 +124,15 @@
(defun ledger-reconcile-visit () (defun ledger-reconcile-visit ()
(interactive) (interactive)
(let ((where (get-text-property (point) 'where))) (let ((where (get-text-property (point) 'where)))
(when (ledger-reconcile-get-buffer where) (when (is-stdin (car where))
(switch-to-buffer-other-window (ledger-reconcile-get-buffer where)) (switch-to-buffer-other-window ledger-buf)
(goto-char (cdr where)) (goto-char (cdr where))
(recenter)))) (recenter))))
(defun ledger-reconcile-save () (defun ledger-reconcile-save ()
(interactive) (interactive)
(dolist (buf (cons ledger-buf ledger-bufs)) (with-current-buffer ledger-buf
(with-current-buffer buf (save-buffer))
(save-buffer)))
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(ledger-display-balance)) (ledger-display-balance))
@ -160,8 +154,8 @@
(let ((where (get-text-property (point) 'where)) (let ((where (get-text-property (point) 'where))
(face (get-text-property (point) 'face))) (face (get-text-property (point) 'face)))
(if (and (eq face 'bold) (if (and (eq face 'bold)
(ledger-reconcile-get-buffer where)) (when (is-stdin (car where))))
(with-current-buffer (ledger-reconcile-get-buffer where) (with-current-buffer ledger-buf
(goto-char (cdr where)) (goto-char (cdr where))
(ledger-toggle-current 'cleared)))) (ledger-toggle-current 'cleared))))
(forward-line 1))) (forward-line 1)))
@ -171,12 +165,10 @@
"find the position of the xact in the ledger-buf buffer using "find the position of the xact in the ledger-buf buffer using
the emacs output from ledger, return a marker to the beginning the emacs output from ledger, return a marker to the beginning
of the xact in the buffer" of the xact in the buffer"
(let ((buf (if (is-stdin emacs-xact) (let ((buf ledger-buf))
ledger-buf
(find-file-noselect (nth 0 item)))))
(with-current-buffer buf ;use the ledger-buf buffer (with-current-buffer buf ;use the ledger-buf buffer
(cons (cons
buf (nth 0 item)
(if ledger-clear-whole-entries ;determines whether to (if ledger-clear-whole-entries ;determines whether to
;clear on the payee line ;clear on the payee line
;or posting line ;or posting line
@ -201,14 +193,12 @@
(unless (looking-at "(") (unless (looking-at "(")
(error (buffer-string))) (error (buffer-string)))
(read (current-buffer)))))) (read (current-buffer))))))
(setq ledger-bufs ())
(if (> (length items) 0) (if (> (length items) 0)
(dolist (item items) (dolist (item items)
(let ((index 1)) (let ((index 1))
(dolist (xact (nthcdr 5 item)) (dolist (xact (nthcdr 5 item))
(let ((beg (point)) (let ((beg (point))
(where (ledger-marker-where-xact-is item))) (where (ledger-marker-where-xact-is item)))
(add-to-list 'ledger-bufs (car where))
(insert (format "%s %-4s %-30s %-30s %15s\n" (insert (format "%s %-4s %-30s %-30s %15s\n"
(format-time-string "%Y/%m/%d" (nth 2 item)) (format-time-string "%Y/%m/%d" (nth 2 item))
(if (nth 3 item) (if (nth 3 item)
@ -308,4 +298,4 @@
(use-local-map map))) (use-local-map map)))
(provide 'ldg-reconcile) (provide 'ldg-reconcile)