Align amounts on the decimal separator.

That is:
  A   $10.00
  B    $5
  C  -$15.00

Before the numbers aligned at the end of the last digit.
This commit is contained in:
Matus Goljer 2015-09-28 18:03:32 +02:00
parent 4dec0e3829
commit 767ab3e39c
2 changed files with 9 additions and 4 deletions

View file

@ -79,8 +79,7 @@ point at beginning of the commodity."
(when (re-search-forward ledger-amount-regex end t)
(goto-char (match-beginning 0))
(skip-syntax-forward " ")
(- (or (match-end 4)
(match-end 3)) (point)))))
(- (match-end 3) (point)))))
(defun ledger-next-account (&optional end)
"Move to the beginning of the posting, or status marker, limit to END.

View file

@ -27,8 +27,14 @@
(defconst ledger-amount-regex
(concat "\\( \\|\t\\| \t\\)[ \t]*-?"
"\\([A-Z$€£₹_(]+ *\\)?"
"\\(-?[0-9,]+\\)"
"\\(\\.[0-9)]+\\)?"
;; We either match just a number after the commodity with no
;; decimal or thousand separators or a number with thousand
;; separators. If we have a decimal part starting with `,'
;; or `.', because the match is non-greedy, it must leave at
;; least one of those symbols for the following capture
;; group, which then finishes the decimal part.
"\\(-?\\(?:[0-9]+\\|[0-9,.]+?\\)\\)"
"\\([,.][0-9)]+\\)?"
"\\( *[[:word:]€£₹_\"]+\\)?"
"\\([ \t]*[@={]@?[^\n;]+?\\)?"
"\\([ \t]+;.+?\\|[ \t]*\\)?$"))