summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/ldg-mode.el2
-rw-r--r--lisp/ldg-post.el13
2 files changed, 10 insertions, 5 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el
index b435ada2..1d587d63 100644
--- a/lisp/ldg-mode.el
+++ b/lisp/ldg-mode.el
@@ -92,7 +92,7 @@ Can be pcomplete, or align-posting"
(ledger-init-load-init-file)
- (setq indent-line-function 'ledger-post-align-postings)
+ (setq indent-region-function 'ledger-post-align-postings)
(let ((map (current-local-map)))
(define-key map [(control ?c) (control ?a)] 'ledger-add-transaction)
diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el
index c831f01a..75efb83c 100644
--- a/lisp/ldg-post.el
+++ b/lisp/ldg-post.el
@@ -167,17 +167,22 @@ position, whichever is closer."
(delete-horizontal-space)
(insert " "))))
-(defun ledger-post-align-postings ()
+(defun ledger-post-align-postings (&optional beg end)
"Align all accounts and amounts within region, if there is no
-region alight the posting on the current line."
+region align the posting on the current line."
(interactive)
(save-excursion
(if (or (not (mark))
(not (use-region-p)))
(set-mark (point)))
+
(let* ((mark-first (< (mark) (point)))
- (begin-region (if mark-first (mark) (point)))
- (end-region (if mark-first (point-marker) (mark-marker)))
+ (begin-region (if beg
+ beg
+ (if mark-first (mark) (point))))
+ (end-region (if end
+ end
+ (if mark-first (point-marker) (mark-marker))))
acc-col amt-offset acc-adjust)
;; Condition point and mark to the beginning and end of lines
(goto-char end-region)