diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ldg-post.el | 13 | ||||
-rw-r--r-- | lisp/ldg-state.el | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el index 75efb83c..5ac97893 100644 --- a/lisp/ldg-post.el +++ b/lisp/ldg-post.el @@ -158,10 +158,10 @@ position, whichever is closer." (copy-marker end) end))) -(defun ledger-post-adjust (adjust-by) +(defsubst ledger-post-adjust (adjust-by) (if (> adjust-by 0) (insert (make-string adjust-by ? )) - (if (looking-back " " (- (point) 3)) + (if (looking-back " " (- (point) 1)) (delete-char adjust-by) (skip-chars-forward "^ \t") (delete-horizontal-space) @@ -176,7 +176,10 @@ region align the posting on the current line." (not (use-region-p))) (set-mark (point))) - (let* ((mark-first (< (mark) (point))) + (let* ((has-align-hook (remove-hook + 'after-change-functions + 'ledger-post-maybe-align t)) + (mark-first (< (mark) (point))) (begin-region (if beg beg (if mark-first (mark) (point)))) @@ -204,7 +207,9 @@ region align the posting on the current line." (current-column)))) (if (/= amt-adjust 0) (ledger-post-adjust amt-adjust))))) - (forward-line))))) + (forward-line)) + (if has-align-hook + (add-hook 'after-change-functions 'ledger-post-maybe-align t t))))) (defun ledger-post-maybe-align (beg end len) "Align amounts only if point is in a posting. diff --git a/lisp/ldg-state.el b/lisp/ldg-state.el index c1027f5c..88891aff 100644 --- a/lisp/ldg-state.el +++ b/lisp/ldg-state.el @@ -163,7 +163,7 @@ dropped." (delete-char 1)))) (setq new-status inserted)))) (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)))) ;; This excursion cleans up the entry so that it displays ;; minimally. This means that if all posts are cleared, remove |