diff options
author | Craig Earls <enderw88@gmail.com> | 2015-09-28 19:00:01 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2015-09-28 19:00:01 -0700 |
commit | 1cf83c6f5f5d005fb143f34b32b86bb838cd9674 (patch) | |
tree | e63e21895b68c44f7672569a32cf8324cc0ab70f /lisp | |
parent | 5905c21ded741a9d17f67999a7e4c33da6c886c8 (diff) | |
parent | 64426842a34f0517e43a47a404cd15c764f1c7f2 (diff) | |
download | fork-ledger-1cf83c6f5f5d005fb143f34b32b86bb838cd9674.tar.gz fork-ledger-1cf83c6f5f5d005fb143f34b32b86bb838cd9674.tar.bz2 fork-ledger-1cf83c6f5f5d005fb143f34b32b86bb838cd9674.zip |
Merge commit '64426842a34f0517e43a47a404cd15c764f1c7f2' into next
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ledger-mode.el | 1 | ||||
-rw-r--r-- | lisp/ledger-post.el | 16 | ||||
-rw-r--r-- | lisp/ledger-regex.el | 10 |
3 files changed, 23 insertions, 4 deletions
diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index f2eb4b21..30f25dfc 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -285,6 +285,7 @@ With a prefix argument, remove the effective date." (define-key map [(meta ?p)] 'ledger-navigate-prev-xact-or-directive) (define-key map [(meta ?n)] 'ledger-navigate-next-xact-or-directive) + (define-key map [(meta ?q)] 'ledger-post-align-dwim) map) "Keymap for `ledger-mode'.") diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el index 21e856db..d741442a 100644 --- a/lisp/ledger-post.el +++ b/lisp/ledger-post.el @@ -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. @@ -146,6 +145,19 @@ at beginning of account" (setq lines-left (not (eobp))))) (setq inhibit-modification-hooks nil)))) +(defun ledger-post-align-dwim () + "Align all the posting of the current xact or the current region. + +If the point is in a comment, fill the comment paragraph as +regular text." + (interactive) + (cond + ((nth 4 (syntax-ppss)) + (call-interactively 'ledger-post-align-postings) + (fill-paragraph)) + ((use-region-p) (call-interactively 'ledger-post-align-postings)) + (t (call-interactively 'ledger-post-align-xact)))) + (defun ledger-post-edit-amount () "Call 'calc-mode' and push the amount in the posting to the top of stack." (interactive) diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el index 5d525d95..6ced0223 100644 --- a/lisp/ledger-regex.el +++ b/lisp/ledger-regex.el @@ -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]*\\)?$")) |