diff options
-rw-r--r-- | doc/ledger3.texi | 17 | ||||
-rw-r--r-- | lisp/ledger-mode.el | 1 | ||||
-rw-r--r-- | lisp/ledger-post.el | 16 | ||||
-rw-r--r-- | lisp/ledger-regex.el | 10 |
4 files changed, 32 insertions, 12 deletions
diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a3794050..5d8ab55c 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -5902,6 +5902,7 @@ or testing small journal files not associated with your main financial database. @item --debug @var{CODE} +@value{FIXME:UNDOCUMENTED} If ledger has been built with debug options this will provide extra data during the run. @@ -6756,8 +6757,8 @@ week. @item --subtotal @itemx -s -Group all postings together. This is very similar to the totals shown by -the balance report. +Cause all transactions in a @command{register} report to be collapsed +into a single, subtotaled transaction. @item --tail @var{INT} @itemx --last @var{INT} @@ -8246,8 +8247,8 @@ Evaluate @var{string} as format just like the @option{--format} option. @end defun @defun format_date date format -Return the @var{date} as a string using @var{format}. See strftime (3) -for format string details. +Return the @var{date} as a string using @var{format}. See +@code{strftime (3)} for format string details. @smallexample @c command:9605B13,with_input:3406FC1 $ ledger -f expr.dat --format "%(format_date(date, '%A, %B %d. %Y'))\n" reg assets @end smallexample @@ -8257,8 +8258,8 @@ Friday, January 16. 2015 @end defun @defun format_datetime datetime format -Return the @var{datetime} as a string using @var{format}. Refer to strftime (3) -for format string details. +Return the @var{datetime} as a string using @var{format}. Refer to +@code{strftime (3)} for format string details. @end defun @defun get_at sequence index @@ -8599,8 +8600,8 @@ $ ledger -f expr.dat --format "%12(5*O)\n" reg assets @end smallexample @item [DATEFMT] -Inserts the result of formatting a posting's date with a date -format string, exactly like those supported by strftime (3). For +Inserts the result of formatting a posting's date with a date format +string, exactly like those supported by @code{strftime (3)}. For example: @samp{%[%Y/%m/%d %H:%M:%S]}. @item S 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]*\\)?$")) |