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