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.
This commit is contained in:
Craig Earls 2013-03-25 18:48:28 -04:00
parent 862a83e792
commit 48266d1107
2 changed files with 10 additions and 5 deletions

View file

@ -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)

View file

@ -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)