Fix bug 935, very long account names can get stomped on.

This works, but hammers performance
This commit is contained in:
Craig Earls 2013-03-27 15:37:52 -07:00
parent ad07d28427
commit 4ca0e8916b

View file

@ -136,17 +136,16 @@ point at beginning of the commodity."
(match-end 3)) (point)))) (match-end 3)) (point))))
(defvar ledger-post-account-regex (defvar ledger-post-account-regex
(concat "\\(^[ \t]+\\)" "\\(^[ \t]+\\)\\([\\[(;!*A-Za-z0-9]\\)\\(.+?\\)\\( \\|\n\\)")
"\\([\\[(*!;a-zA-Z0-9]\\)"))
(defsubst ledger-next-account (&optional end) (defun ledger-next-account (&optional end)
"Move point to the beginning of the next account, or status marker (!*), as long as it is not past END. "Move point to the beginning of the next account, or status marker (!*), as long as it is not past END.
Return the column of the beginning of the account and leave point Return the column of the beginning of the account and leave point
at beginning of account" at beginning of account"
(if (> end (point)) (if (> end (point))
(when (re-search-forward ledger-post-account-regex end t) (when (re-search-forward ledger-post-account-regex (1+ end) t)
(goto-char (match-beginning 2)) (goto-char (match-beginning 2))
(current-column)))) (list (current-column) (length (match-string-no-properties 3))))))
(defsubst ledger-post-adjust (adjust-by) (defsubst ledger-post-adjust (adjust-by)
(if (> adjust-by 0) (if (> adjust-by 0)
@ -185,10 +184,12 @@ region align the posting on the current line."
lines-left) lines-left)
(< (point) end-region)) (< (point) end-region))
(when acc-col (when acc-col
(if (/= (setq acc-adjust (- ledger-post-account-alignment-column acc-col)) 0) (if (/= (setq acc-adjust (- ledger-post-account-alignment-column (car acc-col))) 0)
(ledger-post-adjust acc-adjust)) (ledger-post-adjust acc-adjust))
(when (setq amt-offset (ledger-next-amount (line-end-position))) (when (and
(> ledger-post-amount-alignment-column (+ ledger-post-account-alignment-column (cadr acc-col)))
(setq amt-offset (ledger-next-amount (line-end-position))))
(let* ((amt-adjust (- ledger-post-amount-alignment-column (let* ((amt-adjust (- ledger-post-amount-alignment-column
amt-offset amt-offset
(current-column)))) (current-column))))