summaryrefslogtreecommitdiff
path: root/lisp/ledger-xact.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2014-04-23 11:26:20 -0500
committerJohn Wiegley <johnw@newartisans.com>2014-04-23 11:26:20 -0500
commitd752bef547fb696cd1c9151c1c3d00e9a945eadd (patch)
tree1c6cec183c17da41e6f8e27833bb70cb8df80555 /lisp/ledger-xact.el
parent51b335111e02dec052588e1f9a8fdd4025f548a0 (diff)
parent9c3535823a8e9ba60a886f7f75532245da993c70 (diff)
downloadfork-ledger-d752bef547fb696cd1c9151c1c3d00e9a945eadd.tar.gz
fork-ledger-d752bef547fb696cd1c9151c1c3d00e9a945eadd.tar.bz2
fork-ledger-d752bef547fb696cd1c9151c1c3d00e9a945eadd.zip
Merge pull request #279 from csrhodes/fix-ledger-xact-add-transaction
improve C-c C-a (ledger-xact-insert-transaction) behaviour
Diffstat (limited to 'lisp/ledger-xact.el')
-rw-r--r--lisp/ledger-xact.el20
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."