More armor plating on ledger-post-align-postings

This commit is contained in:
Craig Earls 2013-03-23 21:51:27 -07:00
parent 0bcef93e29
commit 53778317cb

View file

@ -138,24 +138,28 @@ Return the column of the beginning of the account"
"Align all accounts and amounts within region, if there is no
region alight the posting on the current line."
(interactive)
(save-excursion
(let ((region-boundaries-verified nil)) (save-excursion
;; If there is no region set
(when (or (not (mark))
(= (point) (mark)))
(beginning-of-line)
(set-mark (point))
(goto-char (1+ (line-end-position))))
(goto-char (line-end-position))
(setq region-boundaries-verified t))
(let* ((mark-first (< (mark) (point)))
(begin (if mark-first (mark) (point)))
(end (if mark-first (point-marker) (mark-marker)))
acc-col amt-offset)
(if (not region-boundaries-verified)
(progn
(goto-char end)
(end-of-line)
(setq end (point-marker))
(goto-char begin)
(beginning-of-line)
(setq begin (point-marker))
(setq begin (point-marker)))
(goto-char begin))
(while (setq acc-col (ledger-next-account end))
;; Adjust account position if necessary
(let ((acc-adjust (- ledger-post-account-alignment-column acc-col)))
@ -179,7 +183,7 @@ region alight the posting on the current line."
(skip-chars-forward "^ \t")
(delete-horizontal-space)
(insert " "))))))
(forward-line)))))
(forward-line))))))
(defun ledger-post-maybe-align (beg end len)
"Align amounts only if point is in a posting.