Fix bug 1052 ledger-mode mangles transactions with tabs.

This commit is contained in:
Craig Earls 2014-06-25 20:50:07 -07:00
parent 10bdcbb876
commit 3a2eb94bef
3 changed files with 14 additions and 4 deletions

View file

@ -222,6 +222,7 @@ With a prefix argument, remove the effective date. "
(defun ledger-mode-clean-buffer () (defun ledger-mode-clean-buffer ()
"indent, remove multiple linfe feeds and sort the buffer" "indent, remove multiple linfe feeds and sort the buffer"
(interactive) (interactive)
(untabify (point-min) (point-max))
(ledger-sort-buffer) (ledger-sort-buffer)
(ledger-post-align-postings (point-min) (point-max)) (ledger-post-align-postings (point-min) (point-max))
(ledger-mode-remove-extra-lines)) (ledger-mode-remove-extra-lines))

View file

@ -163,7 +163,16 @@ region align the posting on the current line."
(if mark-first (point) (mark)))) (if mark-first (point) (mark))))
acct-start-column acct-end-column acct-adjust amt-width acct-start-column acct-end-column acct-adjust amt-width
(lines-left 1)) (lines-left 1))
;; Condition point and mark to the beginning and end of lines ;; Condition point and mark to the beginning and end of lines
(goto-char end-region)
(setq end-region (line-end-position))
(goto-char begin-region)
(goto-char
(setq begin-region
(line-beginning-position)))
(untabify begin-region end-region)
(goto-char end-region) (goto-char end-region)
(setq end-region (line-end-position)) (setq end-region (line-end-position))
(goto-char begin-region) (goto-char begin-region)

View file

@ -103,9 +103,9 @@ dropped."
(skip-chars-forward " \t") (skip-chars-forward " \t")
(when (not (eq (ledger-state-from-char (char-after)) 'comment)) (when (not (eq (ledger-state-from-char (char-after)) 'comment))
(insert (ledger-char-from-state cur-status) " ") (insert (ledger-char-from-state cur-status) " ")
(if (search-forward " " (line-end-position) t) (if (and (search-forward " " (line-end-position) t)
(if (looking-at " ") (looking-at " "))
(delete-char 2)))) (delete-char 2)))
(forward-line)) (forward-line))
(setq new-status nil))) (setq new-status nil)))