Fix align-postings to deal with being at end of buffer
This commit is contained in:
parent
bc7a885eb7
commit
b947bae1a8
2 changed files with 7 additions and 6 deletions
|
|
@ -127,10 +127,9 @@ Return tree structure"
|
||||||
(line-end-position))))
|
(line-end-position))))
|
||||||
(delete-region (line-beginning-position)
|
(delete-region (line-beginning-position)
|
||||||
(line-end-position))
|
(line-end-position))
|
||||||
(condition-case err
|
(condition-case nil
|
||||||
(ledger-add-transaction text t)
|
(ledger-add-transaction text t)
|
||||||
((error "ledger-complete-at-point")
|
(error nil)))
|
||||||
(insert text))))
|
|
||||||
(forward-line)
|
(forward-line)
|
||||||
(goto-char (line-end-position))
|
(goto-char (line-end-position))
|
||||||
(search-backward ";" (line-beginning-position) t)
|
(search-backward ";" (line-beginning-position) t)
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,8 @@ region align the posting on the current line."
|
||||||
(end-region (if end
|
(end-region (if end
|
||||||
end
|
end
|
||||||
(if mark-first (point-marker) (mark-marker))))
|
(if mark-first (point-marker) (mark-marker))))
|
||||||
acc-col amt-offset acc-adjust)
|
acc-col amt-offset acc-adjust
|
||||||
|
(lines-left 1))
|
||||||
;; Condition point and mark to the beginning and end of lines
|
;; Condition point and mark to the beginning and end of lines
|
||||||
(goto-char end-region)
|
(goto-char end-region)
|
||||||
(setq end-region (copy-marker (line-end-position)))
|
(setq end-region (copy-marker (line-end-position)))
|
||||||
|
|
@ -195,7 +196,8 @@ region align the posting on the current line."
|
||||||
(setq begin-region
|
(setq begin-region
|
||||||
(copy-marker (line-beginning-position))))
|
(copy-marker (line-beginning-position))))
|
||||||
(while (or (setq acc-col (ledger-next-account (end-of-line-or-region end-region)))
|
(while (or (setq acc-col (ledger-next-account (end-of-line-or-region end-region)))
|
||||||
(< (point) (marker-position end-region)))
|
(and (< (point) (marker-position end-region))
|
||||||
|
(> lines-left 0)))
|
||||||
(when acc-col
|
(when acc-col
|
||||||
(setq acc-adjust (- ledger-post-account-alignment-column acc-col))
|
(setq acc-adjust (- ledger-post-account-alignment-column acc-col))
|
||||||
(if (/= acc-adjust 0)
|
(if (/= acc-adjust 0)
|
||||||
|
|
@ -207,7 +209,7 @@ region align the posting on the current line."
|
||||||
(current-column))))
|
(current-column))))
|
||||||
(if (/= amt-adjust 0)
|
(if (/= amt-adjust 0)
|
||||||
(ledger-post-adjust amt-adjust)))))
|
(ledger-post-adjust amt-adjust)))))
|
||||||
(forward-line))
|
(setq lines-left (forward-line)))
|
||||||
(if has-align-hook
|
(if has-align-hook
|
||||||
(add-hook 'after-change-functions 'ledger-post-maybe-align t t)))))
|
(add-hook 'after-change-functions 'ledger-post-maybe-align t t)))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue