From 24a9e422eb811224d4340905e68867181cb26861 Mon Sep 17 00:00:00 2001 From: Rémi Vanicat Date: Wed, 13 Feb 2013 15:54:01 +0100 Subject: In ledger-do-reconcile, don't act on windows when reconcile hasn't one Ledger-do-reconcile might be called indirectly (in the after-save-hook for example) and one might not want this buffer she has buried to show up again when she is saving another (even related) buffer. --- lisp/ldg-reconcile.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lisp/ldg-reconcile.el') diff --git a/lisp/ldg-reconcile.el b/lisp/ldg-reconcile.el index 25d2e981..03663b6b 100644 --- a/lisp/ldg-reconcile.el +++ b/lisp/ldg-reconcile.el @@ -276,17 +276,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 -- cgit v1.2.3 From 69673748017fdc9cfe99740d80a3184eef7ca163 Mon Sep 17 00:00:00 2001 From: Rémi Vanicat Date: Wed, 13 Feb 2013 17:03:48 +0100 Subject: Ensure that the reconcile buffer is shown when ledger-reconcile is called. --- lisp/ldg-reconcile.el | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lisp/ldg-reconcile.el') diff --git a/lisp/ldg-reconcile.el b/lisp/ldg-reconcile.el index 03663b6b..d295fd81 100644 --- a/lisp/ldg-reconcile.el +++ b/lisp/ldg-reconcile.el @@ -297,6 +297,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)) @@ -315,6 +324,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. @@ -322,19 +333,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) -- cgit v1.2.3