diff options
author | Christophe Rhodes <csr21@cantab.net> | 2014-04-23 17:07:23 +0100 |
---|---|---|
committer | Christophe Rhodes <csr21@cantab.net> | 2014-04-23 17:07:23 +0100 |
commit | 9c3535823a8e9ba60a886f7f75532245da993c70 (patch) | |
tree | 5f1993a49d06d17229bb41346f68f1dcf76ec3c3 /lisp | |
parent | 4707122eede9746b36bbaa0dab0b419e11b0433b (diff) | |
download | fork-ledger-9c3535823a8e9ba60a886f7f75532245da993c70.tar.gz fork-ledger-9c3535823a8e9ba60a886f7f75532245da993c70.tar.bz2 fork-ledger-9c3535823a8e9ba60a886f7f75532245da993c70.zip |
improve C-c C-a (ledger-xact-insert-transaction) behaviour
When the right place to add a transaction is after all existing
transactions, add it just after the last transaction rather than at the
end of the buffer. (Otherwise the transactions get added after Local
Variables blocks and any other endmatter.)
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ledger-xact.el | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el index 35b0d62c..4eb88749 100644 --- a/lisp/ledger-xact.el +++ b/lisp/ledger-xact.el @@ -89,12 +89,20 @@ within the transaction." (defun ledger-xact-find-slot (moment) "Find the right place in the buffer for a transaction at MOMENT. MOMENT is an encoded date" - (catch 'found - (ledger-xact-iterate-transactions - (function - (lambda (start date mark desc) - (if (ledger-time-less-p moment date) - (throw 'found t))))))) + (let (last-xact-start) + (catch 'found + (ledger-xact-iterate-transactions + (function + (lambda (start date mark desc) + (setq last-xact-start start) + (if (ledger-time-less-p moment date) + (throw 'found t)))))) + (when (and (eobp) last-xact-start) + (let ((end (cadr (ledger-find-xact-extents last-xact-start)))) + (goto-char end) + (if (eobp) + (insert "\n") + (forward-line)))))) (defun ledger-xact-iterate-transactions (callback) "Iterate through each transaction call CALLBACK for each." |