summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-08 17:16:12 -0700
committerCraig Earls <enderw88@gmail.com>2013-02-08 17:16:12 -0700
commit5f67cfbec73863608639a7b8507191236cbac800 (patch)
treed61f8d61d307a8dddf01c317ac425362807d3b93
parente3be9686e4780778fe26124e37151009c8f66446 (diff)
downloadfork-ledger-5f67cfbec73863608639a7b8507191236cbac800.tar.gz
fork-ledger-5f67cfbec73863608639a7b8507191236cbac800.tar.bz2
fork-ledger-5f67cfbec73863608639a7b8507191236cbac800.zip
Added ability to have ledger buffer track the xact under point in recon window
controllable using ledger-buffer-tracks-reconcile-buffer
-rw-r--r--lisp/ldg-reconcile.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/lisp/ldg-reconcile.el b/lisp/ldg-reconcile.el
index ed974a1e..395266e3 100644
--- a/lisp/ldg-reconcile.el
+++ b/lisp/ldg-reconcile.el
@@ -24,6 +24,7 @@
(defvar ledger-buf nil)
(defvar ledger-bufs nil)
(defvar ledger-acct nil)
+
(defcustom ledger-recon-buffer-name "*Reconcile*"
"Name to use for reconciliation window"
:group 'ledger)
@@ -33,6 +34,12 @@
matching the reconcile regex"
:group 'ledger)
+(defcustom ledger-buffer-tracks-reconcile-buffer t
+ "if t, then when the cursor is moved to a new xact in the recon
+ window, then that transaction will be shown in its source
+ buffer."
+ :group 'ledger)
+
(defun ledger-display-balance ()
"Calculate the cleared balance of the account being reconciled"
(interactive)
@@ -231,6 +238,22 @@
(select-window recon-window))))
+(defun ledger-reconcile-track-xact ()
+ (if (or (eq this-command 'next-line)
+ (eq this-command 'previous-line)
+ (eq this-command 'mouse-set-point))
+ (let* ((where (get-text-property (point) 'where))
+ (target-buffer (ledger-reconcile-get-buffer
+ where))
+ (cur-buf (current-buffer)))
+ (when target-buffer
+ (switch-to-buffer-other-window target-buffer)
+ (goto-char (cdr where))
+ (recenter)
+ (switch-to-buffer-other-window cur-buf)
+ ))))
+
+
(defun ledger-reconcile (account)
(interactive "sAccount to reconcile: ")
(let ((buf (current-buffer))
@@ -240,6 +263,7 @@
(quit-window (get-buffer-window rbuf))
(kill-buffer rbuf)))
(add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save)
+ (add-hook 'post-command-hook 'ledger-reconcile-track-xact)
(if ledger-fold-on-reconcile
(ledger-occur-mode account buf))