summaryrefslogtreecommitdiff
path: root/lisp/ldg-reconcile.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-13 09:03:58 -0800
committerCraig Earls <enderw88@gmail.com>2013-02-13 09:03:58 -0800
commit822970a7ae3d38216b84fc33bcbfc3178e9639bc (patch)
tree6199e9271ce42198f71fd30307fdeb04cff8078e /lisp/ldg-reconcile.el
parentdb9ae7dd042ecc49c2390b19a0670029cdb4e5fe (diff)
parent69673748017fdc9cfe99740d80a3184eef7ca163 (diff)
downloadfork-ledger-822970a7ae3d38216b84fc33bcbfc3178e9639bc.tar.gz
fork-ledger-822970a7ae3d38216b84fc33bcbfc3178e9639bc.tar.bz2
fork-ledger-822970a7ae3d38216b84fc33bcbfc3178e9639bc.zip
Merge pull request #155 from vanicat/t/reconcile_and_windows
T/reconcile and windows
Diffstat (limited to 'lisp/ldg-reconcile.el')
-rw-r--r--lisp/ldg-reconcile.el46
1 files changed, 25 insertions, 21 deletions
diff --git a/lisp/ldg-reconcile.el b/lisp/ldg-reconcile.el
index cae27a01..822597f7 100644
--- a/lisp/ldg-reconcile.el
+++ b/lisp/ldg-reconcile.el
@@ -277,17 +277,17 @@
;; when the buffer point is moved and recentered. If they aren't
;; strange things happen.
- (let
- ((recon-window (get-buffer-window (get-buffer ledger-recon-buffer-name))))
- (fit-window-to-buffer recon-window)
- (with-current-buffer buf
- (select-window (get-buffer-window buf))
- (goto-char (point-max))
- (recenter -1))
-
- (select-window recon-window)
- (add-hook 'post-command-hook 'ledger-reconcile-track-xact nil t)
- (ledger-reconcile-visit t))))
+ (let ((recon-window (get-buffer-window (get-buffer ledger-recon-buffer-name))))
+ (when recon-window
+ (fit-window-to-buffer recon-window)
+ (with-current-buffer buf
+ (select-window (get-buffer-window buf))
+ (goto-char (point-max))
+ (recenter -1))
+
+ (select-window recon-window)
+ (ledger-reconcile-visit t))
+ (add-hook 'post-command-hook 'ledger-reconcile-track-xact nil t))))
(defun ledger-reconcile-track-xact ()
(if (member this-command (list 'next-line
@@ -298,6 +298,15 @@
(save-excursion
(ledger-reconcile-visit t)))))
+(defun ledger-reconcile-open-windows (buf rbuf)
+ "Ensure that the reconcile buffer has its windows
+
+Spliting the windows of BUF if needed"
+ (if ledger-reconcile-force-window-bottom
+ ;;create the *Reconcile* window directly below the ledger buffer.
+ (set-window-buffer (split-window (get-buffer-window buf) nil nil) rbuf)
+ (pop-to-buffer rbuf)))
+
(defun ledger-reconcile (account)
(interactive "sAccount to reconcile: ")
(let ((buf (current-buffer))
@@ -316,6 +325,8 @@
(if ledger-fold-on-reconcile
(ledger-occur-change-regex account ledger-buf))
(set-buffer (get-buffer ledger-recon-buffer-name))
+ (unless (get-buffer-window rbuf)
+ (ledger-reconcile-open-windows buf rbuf))
(ledger-reconcile-refresh))
(progn ;; no recon-buffer, starting from scratch.
@@ -323,19 +334,12 @@
(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)))
+ (with-current-buffer (get-buffer-create ledger-recon-buffer-name)
+ (ledger-reconcile-open-windows buf (current-buffer))
(ledger-reconcile-mode)
(set (make-local-variable 'ledger-buf) buf)
(set (make-local-variable 'ledger-acct) account)
- (ledger-do-reconcile))))))
+ (ledger-do-reconcile))))))
(defvar ledger-reconcile-mode-abbrev-table)