summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-03-25 18:48:28 -0400
committerCraig Earls <enderw88@gmail.com>2013-03-25 18:48:28 -0400
commit48266d110758e54716177e5c87e33103247414a0 (patch)
treecdbcc569193ec9adb5aca4bcc5e3ed54153d1ace
parent862a83e7927ed0d18e5d297801d28f82595bb2a5 (diff)
downloadfork-ledger-48266d110758e54716177e5c87e33103247414a0.tar.gz
fork-ledger-48266d110758e54716177e5c87e33103247414a0.tar.bz2
fork-ledger-48266d110758e54716177e5c87e33103247414a0.zip
Fix bug 928 Refix slow indent-region behavior.
Need to bing ledger-post-align-postings to indent-region-function, not indent-line-function, others it tries to align the entire region once for every line in the region.
-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)