Fixed ledger-post-edit-amount so that it can be called from the and of an account with a null amount.
It automagically determines if the account has two spaces after and if not inserts them.
This commit is contained in:
parent
595a8afa44
commit
c4c088b55b
1 changed files with 17 additions and 10 deletions
|
|
@ -157,15 +157,22 @@ This is done so that the last digit falls in COLUMN, which defaults to 52."
|
||||||
(interactive)
|
(interactive)
|
||||||
(goto-char (line-beginning-position))
|
(goto-char (line-beginning-position))
|
||||||
(when (re-search-forward ledger-post-line-regexp (line-end-position) t)
|
(when (re-search-forward ledger-post-line-regexp (line-end-position) t)
|
||||||
(goto-char (match-end ledger-regex-post-line-group-account))
|
(goto-char (match-end ledger-regex-post-line-group-account)) ;go to the and of the account
|
||||||
(when (re-search-forward "[-.,0-9]+" (line-end-position) t)
|
(let ((end-of-amount (re-search-forward "[-.,0-9]+" (line-end-position) t))) ;determine if the is an amount to edit
|
||||||
|
(if end-of-amount
|
||||||
(let ((val (match-string 0)))
|
(let ((val (match-string 0)))
|
||||||
(goto-char (match-beginning 0))
|
(goto-char (match-beginning 0))
|
||||||
(delete-region (match-beginning 0) (match-end 0))
|
(delete-region (match-beginning 0) (match-end 0))
|
||||||
(calc)
|
(calc)
|
||||||
(while (string-match "," val)
|
(while (string-match "," val)
|
||||||
(setq val (replace-match "" nil nil val)))
|
(setq val (replace-match "" nil nil val))) ;gets rid of commas
|
||||||
(calc-eval val 'push)))))
|
(calc-eval val 'push)) ;edit the amount
|
||||||
|
(progn ;make sure there are two spaces after the account name and go to calc
|
||||||
|
(if (search-backward " " (- (point) 3) t)
|
||||||
|
(goto-char (line-end-position))
|
||||||
|
(insert " "))
|
||||||
|
(calc))
|
||||||
|
))))
|
||||||
|
|
||||||
(defun ledger-post-prev-xact ()
|
(defun ledger-post-prev-xact ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue