Merge pull request #279 from csrhodes/fix-ledger-xact-add-transaction
improve C-c C-a (ledger-xact-insert-transaction) behaviour
This commit is contained in:
commit
d752bef547
1 changed files with 14 additions and 6 deletions
|
|
@ -89,12 +89,20 @@ within the transaction."
|
||||||
(defun ledger-xact-find-slot (moment)
|
(defun ledger-xact-find-slot (moment)
|
||||||
"Find the right place in the buffer for a transaction at MOMENT.
|
"Find the right place in the buffer for a transaction at MOMENT.
|
||||||
MOMENT is an encoded date"
|
MOMENT is an encoded date"
|
||||||
|
(let (last-xact-start)
|
||||||
(catch 'found
|
(catch 'found
|
||||||
(ledger-xact-iterate-transactions
|
(ledger-xact-iterate-transactions
|
||||||
(function
|
(function
|
||||||
(lambda (start date mark desc)
|
(lambda (start date mark desc)
|
||||||
|
(setq last-xact-start start)
|
||||||
(if (ledger-time-less-p moment date)
|
(if (ledger-time-less-p moment date)
|
||||||
(throw 'found t)))))))
|
(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)
|
(defun ledger-xact-iterate-transactions (callback)
|
||||||
"Iterate through each transaction call CALLBACK for each."
|
"Iterate through each transaction call CALLBACK for each."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue