update packages

This commit is contained in:
2022-01-04 21:35:17 +01:00
parent 1d5275c946
commit 8de00e5202
700 changed files with 42441 additions and 85378 deletions

View File

@@ -119,7 +119,7 @@ See `ledger-environment-alist' for DECIMAL-COMMA."
(assoc "decimal-comma" ledger-environment-alist))
(ledger-strip str "[.]")
(ledger-strip str ","))))
(while (string-match "," nstr) ;if there is a comma now, it is a thousands separator
(while (string-match "," nstr) ;if there is a comma now, it is a decimal point
(setq nstr (replace-match "." nil nil nstr)))
(string-to-number nstr)))

View File

@@ -295,12 +295,11 @@ Looks in `ledger-accounts-file' if set, otherwise the current buffer."
(setq start (save-excursion (backward-word) (point)))
(setq collection #'ledger-payees-in-buffer))
(;; Accounts
(looking-back (rx-to-string `(seq bol (one-or-more space)
(optional (any ?\( ?\[ )) ;; for virtual accounts
(group (zero-or-more (not space)))))
(line-beginning-position))
(setq start (match-beginning 1)
delete-suffix (save-excursion
(save-excursion
(back-to-indentation)
(skip-chars-forward "([") ;; for virtual accounts
(setq start (point)))
(setq delete-suffix (save-excursion
(when (search-forward-regexp (rx (or eol (repeat 2 space))) (line-end-position) t)
(- (match-beginning 0) end)))
realign-after t

View File

@@ -37,11 +37,11 @@
(defconst ledger-amount-string ledger-amount-regexp)
(defconst ledger-commoditized-amount-string ledger-commoditized-amount-regexp)
(defconst ledger-balance-assertion-string ledger-balance-assertion-regexp)
(defconst ledger-comment-string "[ \t]*;[ \t]*\\(.*?\\)")
(defconst ledger-comment-string "\\(?:[ \t]*\n\\)?[ \t]*;[ \t]*\\(.*?\\)")
(defconst ledger-nil-string "\\([ \t]+\\)")
(defconst ledger-date-string "^\\([0-9]\\{4\\}[/-][01]?[0-9][/-][0123]?[0-9]\\)\\(?:=[0-9]\\{4\\}[/-][01]?[0-9][/-][0123]?[0-9]\\)?")
(defconst ledger-code-string "\\((.*)\\)?")
(defconst ledger-payee-string "\\(.*[^[:space:]]\\)")
(defconst ledger-payee-string "\\(.*[^[:space:]\n]\\)")
(defun ledger-get-regex-str (name)

View File

@@ -31,7 +31,7 @@
"The version of ledger executable needed for interactive features.")
(defvar ledger-works nil
"Flag showing whether the ledger binary can support `ledger-mode' interactive features.")
"Non-nil if the ledger binary can support `ledger-mode' interactive features.")
(defgroup ledger-exec nil
"Interface to the Ledger command-line accounting program."
@@ -89,6 +89,7 @@ otherwise the error output is displayed and an error is raised."
(apply #'call-process-region
(append (list (point-min) (point-max)
ledger-binary-path nil (list outbuf errfile) nil "-f" "-")
(list "--date-format" ledger-default-date-format)
args)))))
(if (ledger-exec-success-p exit-code outbuf)
outbuf

View File

@@ -360,7 +360,7 @@
:group 'ledger-faces)
(defface ledger-font-posting-account-face
`((t :inherit ledger-font-default-face))
`((t :inherit ledger-font-default-directive-face))
"Face for Ledger accounts"
:group 'ledger-faces)
@@ -599,7 +599,7 @@ See `font-lock-keywords' for the full description."
(,(concat "^\\(P\\)"
"\\(?:[[:blank:]]+\\([^[:blank:]\n]+"
"\\(?:[[:blank:]]+[[:digit:]][^[:blank:]\n]*\\)?\\)"
"\\(?:[[:blank:]]+\\([^[:blank:]\n]+\\)"
"\\(?:[[:blank:]]+\\(\".*?\"\\|[^[:blank:]\n]+\\)"
"\\(?:[[:blank:]]+\\(.*\\)\\)?\\)?\\)?$")
(1 'ledger-font-price-directive-face)
(2 'ledger-font-price-date-face nil :lax)
@@ -653,7 +653,7 @@ See `font-lock-keywords' for the full description."
ledger-xact-after-date-regex "\\)") ; mark 4, code 5, desc 6, comment 7
(1 (cond ((equal "=" (match-string 2)) 'ledger-font-auto-xact-face)
((equal "~" (match-string 2)) 'ledger-font-periodic-xact-face)
(t 'ledger-font-default-face))
(t 'ledger-font-default-directive-face))
nil :lax)
(3 'ledger-font-posting-date-face nil :lax)
(5 'ledger-font-code-face nil :lax)

View File

@@ -37,6 +37,9 @@
Adding the dotted pair (\"decimal-comma\" . t) will tell ledger
to treat commas as decimal separator.")
(defconst ledger-iso-date-format "%Y-%m-%d"
"The format for ISO 8601 dates.")
(defcustom ledger-default-date-format "%Y/%m/%d"
"The date format that ledger uses throughout.
Set this to the value of `ledger-iso-date-format' if you prefer
@@ -45,9 +48,6 @@ ISO 8601 dates."
:package-version '(ledger-mode . "4.0.0")
:group 'ledger)
(defconst ledger-iso-date-format "%Y-%m-%d"
"The format for ISO 8601 dates.")
(defun ledger-format-date (&optional date)
"Format DATE according to the current preferred date format.
Returns the current date if DATE is nil or not supplied."
@@ -81,17 +81,17 @@ Returns the current date if DATE is nil or not supplied."
(defun ledger-init-load-init-file ()
"Load and parse the .ledgerrc file."
(interactive)
(let ((init-base-name (file-name-nondirectory ledger-init-file-name)))
(if (get-buffer init-base-name) ;; init file already loaded, parse it and leave it
(setq ledger-environment-alist
(ledger-init-parse-initialization init-base-name))
(when (and ledger-init-file-name
(file-exists-p ledger-init-file-name)
(file-readable-p ledger-init-file-name))
(let ((init-buffer (find-file-noselect ledger-init-file-name)))
(when ledger-init-file-name
(let ((init-base-name (file-name-nondirectory ledger-init-file-name)))
(if (get-buffer init-base-name) ;; init file already loaded, parse it and leave it
(setq ledger-environment-alist
(ledger-init-parse-initialization init-buffer))
(kill-buffer init-buffer))))))
(ledger-init-parse-initialization init-base-name))
(when (and (file-exists-p ledger-init-file-name)
(file-readable-p ledger-init-file-name))
(let ((init-buffer (find-file-noselect ledger-init-file-name)))
(setq ledger-environment-alist
(ledger-init-parse-initialization init-buffer))
(kill-buffer init-buffer)))))))
(provide 'ledger-init)

View File

@@ -1,6 +1,6 @@
(define-package "ledger-mode" "20210106.227" "Helper code for use with the \"ledger\" command-line tool"
(define-package "ledger-mode" "20211214.1449" "Helper code for use with the \"ledger\" command-line tool"
'((emacs "25.1"))
:commit "bcd8cefb720702db88986a52bb66e08e2e451c05")
:commit "3ec65b8931e8989ac590e95921e46f9e2fac6821")
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@@ -1,4 +1,4 @@
This is ledger-mode.info, produced by makeinfo version 6.5 from
This is ledger-mode.info, produced by makeinfo version 6.7 from
ledger-mode.texi.
Copyright © 2013, Craig Earls. All rights reserved.
@@ -147,9 +147,8 @@ entry.
C-c C-a or using Add Transaction menu entry. Then typing a close
match to the payee. Ledger-mode will call ledger xact with the data
you enter and place the transaction in the proper chronological place in
the ledger. Subsequent calls to C-c C-a remember the last date so
entering many dates in the past is easy. The date format can be changed
by modifying ledger-default-date-format.
the ledger. The date format can be changed by modifying
ledger-default-date-format.

File: ledger-mode.info, Node: Reconciliation, Next: Reports, Prev: Quick Add, Up: Quick Demo
@@ -1494,58 +1493,58 @@ Node: Quick Installation2785
Node: Menus3717
Node: Quick Demo4032
Node: Quick Add4462
Node: Reconciliation5662
Node: Reports7346
Node: Narrowing8376
Node: The Ledger Buffer8960
Node: Navigating Transactions9366
Node: Adding Transactions9914
Node: Setting a Transactions Effective Date11413
Node: Quick Balance Display12313
Node: Copying Transactions12845
Node: Editing Amounts13447
Node: Marking Transactions14518
Node: Formatting Transactions16213
Node: Deleting Transactions16811
Node: Sorting Transactions17251
Node: Narrowing Transactions18803
Node: The Reconcile Buffer20653
Node: Basics of Reconciliation21118
Node: Starting a Reconciliation22067
Node: Mark Transactions Pending23916
Node: Edit Transactions During Reconciliation24585
Node: Finalize Reconciliation25228
Node: Adding and Deleting Transactions during Reconciliation25885
Node: Changing Reconciliation Account26469
Node: Changing Reconciliation Target27019
Node: The Report Buffer27337
Node: Running Basic Reports27595
Node: Adding and Editing Reports29028
Node: Expansion Formats30415
Node: Make Report Transactions Active32056
Node: Reversing Report Order32763
Node: Scheduling Transactions33456
Node: Specifying Upcoming Transactions34312
Node: Transactions that occur on specific dates34886
Node: Transactions that occur on specific days35927
Node: Customizing Ledger-mode37056
Node: Ledger-mode Customization37320
Node: Customization Variables38005
Node: Ledger Customization Group38485
Node: Ledger Reconcile Customization Group39125
Node: Ledger Report Customization Group42068
Node: Ledger Faces Customization Group42787
Node: Ledger Post Customization Group44534
Node: Ledger Exec Customization Group45361
Node: Ledger Test Customization Group45860
Node: Ledger Texi Customization Group46262
Node: Generating Ledger Regression Tests46754
Node: Embedding Example results in Ledger Documentation47017
Node: Hacking Ledger-mode47306
Node: Use org-like outlines47531
Node: Concept Index48196
Node: Command & Variable Index53712
Node: Keystroke Index61822
Node: Reconciliation5560
Node: Reports7244
Node: Narrowing8274
Node: The Ledger Buffer8858
Node: Navigating Transactions9264
Node: Adding Transactions9812
Node: Setting a Transactions Effective Date11311
Node: Quick Balance Display12211
Node: Copying Transactions12743
Node: Editing Amounts13345
Node: Marking Transactions14416
Node: Formatting Transactions16111
Node: Deleting Transactions16709
Node: Sorting Transactions17149
Node: Narrowing Transactions18701
Node: The Reconcile Buffer20551
Node: Basics of Reconciliation21016
Node: Starting a Reconciliation21965
Node: Mark Transactions Pending23814
Node: Edit Transactions During Reconciliation24483
Node: Finalize Reconciliation25126
Node: Adding and Deleting Transactions during Reconciliation25783
Node: Changing Reconciliation Account26367
Node: Changing Reconciliation Target26917
Node: The Report Buffer27235
Node: Running Basic Reports27493
Node: Adding and Editing Reports28926
Node: Expansion Formats30313
Node: Make Report Transactions Active31954
Node: Reversing Report Order32661
Node: Scheduling Transactions33354
Node: Specifying Upcoming Transactions34210
Node: Transactions that occur on specific dates34784
Node: Transactions that occur on specific days35825
Node: Customizing Ledger-mode36954
Node: Ledger-mode Customization37218
Node: Customization Variables37903
Node: Ledger Customization Group38383
Node: Ledger Reconcile Customization Group39023
Node: Ledger Report Customization Group41966
Node: Ledger Faces Customization Group42685
Node: Ledger Post Customization Group44432
Node: Ledger Exec Customization Group45259
Node: Ledger Test Customization Group45758
Node: Ledger Texi Customization Group46160
Node: Generating Ledger Regression Tests46652
Node: Embedding Example results in Ledger Documentation46915
Node: Hacking Ledger-mode47204
Node: Use org-like outlines47429
Node: Concept Index48094
Node: Command & Variable Index53610
Node: Keystroke Index61720

End Tag Table

View File

@@ -35,7 +35,8 @@
(defconst ledger-occur-overlay-property-name 'ledger-occur-custom-buffer-grep)
(defcustom ledger-occur-use-face-shown t
"If non-nil, use a custom face for xacts shown in `ledger-occur' mode using ledger-occur-xact-face."
"If non-nil, use a custom face for xacts shown in `ledger-occur' mode.
This uses `ledger-occur-xact-face'."
:type 'boolean
:group 'ledger)
(make-variable-buffer-local 'ledger-occur-use-face-shown)
@@ -52,9 +53,9 @@
(define-minor-mode ledger-occur-mode
"A minor mode which display only transactions matching `ledger-occur-current-regex'."
nil
(:eval (format " Ledger-Narrow(%s)" ledger-occur-current-regex))
ledger-occur-mode-map
:init-value nil
:lighter (:eval (format " Ledger-Narrow(%s)" ledger-occur-current-regex))
:keymap ledger-occur-mode-map
(if (and ledger-occur-current-regex ledger-occur-mode)
(ledger-occur-refresh)
(ledger-occur-remove-overlays)

View File

@@ -26,6 +26,8 @@
(require 'ledger-regex)
(require 'ledger-navigate)
(declare-function ledger-string-to-number "ledger-commodities" (str &optional decimal-comma))
;;; Code:
(defgroup ledger-post nil
@@ -168,7 +170,9 @@ regular text."
(delete-region (match-beginning 0) (match-end 0))
(push-mark)
(calc)
(calc-eval val-string 'push)) ;; edit the amount
;; edit the amount, first removing thousands separators and
;; converting decimal commas to calc's input format
(calc-eval (number-to-string (ledger-string-to-number val-string)) 'push))
(progn ;;make sure there are two spaces after the account name and go to calc
(if (search-backward " " (- (point) 3) t)
(goto-char (line-end-position))

View File

@@ -55,7 +55,7 @@
:group 'ledger-reconcile)
(defcustom ledger-narrow-on-reconcile t
"If t, limit transactions shown in main buffer to those matching the reconcile regex."
"If t, show only transactions matching the reconcile regex in the main buffer."
:type 'boolean
:group 'ledger-reconcile)
@@ -67,7 +67,7 @@ buffer then that transaction will be shown in its source buffer."
:group 'ledger-reconcile)
(defcustom ledger-reconcile-force-window-bottom nil
"If t, make the reconcile window appear along the bottom of the register window and resize."
"If t, show the reconcile window below the register window and resize."
:type 'boolean
:group 'ledger-reconcile)
@@ -121,12 +121,13 @@ if string is longer, it is not truncated unless
(defcustom ledger-reconcile-sort-key "(0)"
"Key for sorting reconcile buffer.
Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e. using ledger file order."
Possible values are '(date)', '(amount)', '(payee)' or '(0)' for
no sorting, i.e. using ledger file order."
:type 'string
:group 'ledger-reconcile)
(defcustom ledger-reconcile-insert-effective-date nil
"If t, prompt for effective date when clearing transactions during reconciliation."
"If t, prompt for effective date when clearing transactions."
:type 'boolean
:group 'ledger-reconcile)
@@ -553,10 +554,10 @@ moved and recentered. If they aren't strange things happen."
(add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t)
;; Narrow the ledger buffer
(if ledger-narrow-on-reconcile
(ledger-occur (regexp-quote account)))
(with-current-buffer rbuf
(save-excursion
(if ledger-narrow-on-reconcile
(ledger-occur account)))
(if (> (ledger-reconcile-refresh) 0)
(ledger-reconcile-change-target target))
(ledger-display-balance)))))

View File

@@ -28,7 +28,7 @@
(require 'rx)
(require 'cl-lib)
(defvar ledger-iso-date-regex)
(defvar ledger-iso-date-regexp)
(defconst ledger-amount-decimal-comma-regex
"-?[1-9][0-9.]*[,]?[0-9]*")
@@ -89,43 +89,49 @@
(defmacro ledger-define-regexp (name regex docs &rest args)
"Simplify the creation of a Ledger regex and helper functions."
(let ((defs
(list
`(defconst
,(intern (concat "ledger-" (symbol-name name) "-regexp"))
,(eval regex)
,docs)))
(addend 0) last-group)
(if (null args)
(progn
(nconc
defs
(let* ((regex (eval regex))
(group-count (regexp-opt-depth regex))
(defs
(list
`(defconst
,(intern
(concat "ledger-regex-" (symbol-name name) "-group"))
1)))
(nconc
defs
(list
,(intern (concat "ledger-" (symbol-name name) "-regexp"))
,regex
,docs)
`(defconst
,(intern (concat "ledger-regex-" (symbol-name name)
"-group--count"))
1)))
(nconc
defs
(list
`(defmacro
,(intern (concat "ledger-regex-" (symbol-name name)))
(&optional string)
,(format "Return the match string for the %s" name)
(match-string
,(intern (concat "ledger-regex-" (symbol-name name)
"-group"))
string)))))
,group-count)))
(addend 0) last-group)
(if (null args)
(progn
(when (cl-plusp group-count)
(nconc
defs
(list
`(defconst
,(intern
(concat "ledger-regex-" (symbol-name name) "-group"))
1)))
(nconc
defs
(list
`(defmacro
,(intern (concat "ledger-regex-" (symbol-name name)))
(&optional string)
,(format "Return the match string for the %s" name)
(match-string
,(intern (concat "ledger-regex-" (symbol-name name)
"-group"))
string))))))
(while args
(let (arg var grouping target force-increment)
(setq arg (pop args))
(when (eq arg :separate)
(setq arg (pop args))
(setq force-increment t))
(dolist (arg args)
(let (var grouping target)
(if (symbolp arg)
(setq var arg target arg)
(cl-assert (listp arg))
@@ -137,7 +143,8 @@
target (cl-caddr arg))))
(if (and last-group
(not (eq last-group (or grouping target))))
(or (not (eq last-group (or grouping target)))
force-increment))
(cl-incf addend
(symbol-value
(intern-soft (concat "ledger-regex-"
@@ -171,189 +178,170 @@
"-group-" (symbol-name var)))
string))))
(setq last-group (or grouping target))))
(nconc defs
(list
`(defconst ,(intern (concat "ledger-regex-" (symbol-name name)
"-group--count"))
,(length args)))))
(setq last-group (or grouping target)))))
(cons 'eval-and-compile defs)))
(put 'ledger-define-regexp 'lisp-indent-function 1)
(ledger-define-regexp iso-date
( let ((sep '(or ?- ?/)))
(rx (group
(and (group (= 4 num))
(eval sep)
(group (and num (? num)))
(eval sep)
(group (and num (? num)))))))
"Match a single date, in its 'written' form.")
(let ((sep '(or ?- ?/)))
(rx (group
(and (group (= 4 num))
(eval sep)
(group (and num (? num)))
(eval sep)
(group (and num (? num)))))))
"Match a single date, in its 'written' form.")
(ledger-define-regexp full-date
(macroexpand
`(rx (and (regexp ,ledger-iso-date-regexp)
(? (and ?= (regexp ,ledger-iso-date-regexp))))))
"Match a compound date, of the form ACTUAL=EFFECTIVE"
(actual iso-date)
(effective iso-date))
(macroexpand
`(rx (and (regexp ,ledger-iso-date-regexp)
(? (and ?= (regexp ,ledger-iso-date-regexp))))))
"Match a compound date, of the form ACTUAL=EFFECTIVE"
(actual iso-date)
:separate
(effective iso-date))
(ledger-define-regexp state
(rx (group (any ?! ?*)))
"Match a transaction or posting's \"state\" character.")
(rx (group (any ?! ?*)))
"Match a transaction or posting's \"state\" character.")
(ledger-define-regexp code
(rx (and ?\( (group (+? (not (any ?\))))) ?\)))
"Match the transaction code.")
(rx (and ?\( (group (+? (not (any ?\))))) ?\)))
"Match the transaction code.")
(ledger-define-regexp long-space
(rx (and (*? blank)
(or (and ? (or ? ?\t)) ?\t)))
"Match a \"long space\".")
(rx (and (*? blank)
(or (and ? (or ? ?\t)) ?\t)))
"Match a \"long space\".")
(ledger-define-regexp note
(rx (group (+ nonl)))
"")
(rx (group (+ nonl)))
"")
(ledger-define-regexp end-note
(macroexpand
`(rx (and (regexp ,ledger-long-space-regexp) ?\;
(regexp ,ledger-note-regexp))))
"")
(macroexpand
`(rx (and (regexp ,ledger-long-space-regexp) ?\;
(regexp ,ledger-note-regexp))))
"")
(ledger-define-regexp full-note
(macroexpand
`(rx (and line-start (+ blank)
?\; (regexp ,ledger-note-regexp))))
"")
(macroexpand
`(rx (and line-start (+ blank)
?\; (regexp ,ledger-note-regexp))))
"")
(ledger-define-regexp xact-line
(macroexpand
`(rx (and line-start
(regexp ,ledger-full-date-regexp)
(? (and (+ blank) (regexp ,ledger-state-regexp)))
(? (and (+ blank) (regexp ,ledger-code-regexp)))
(+ blank) (+? nonl)
(? (regexp ,ledger-end-note-regexp))
line-end)))
"Match a transaction's first line (and optional notes)."
(actual-date full-date actual)
(effective-date full-date effective)
state
code
(note end-note))
(ledger-define-regexp recurring-line
(macroexpand
`(rx (and line-start
(regexp "\\[.+/.+/.+\\]")
(? (and (+ blank) (regexp ,ledger-state-regexp)))
(? (and (+ blank) (regexp ,ledger-code-regexp)))
(+ blank) (+? nonl)
(? (regexp ,ledger-end-note-regexp))
line-end)))
"Match a transaction's first line (and optional notes)."
(actual-date full-date actual)
(effective-date full-date effective)
state
code
(note end-note))
(macroexpand
`(rx (and line-start
(regexp ,ledger-full-date-regexp)
(? (and (+ blank) (regexp ,ledger-state-regexp)))
(? (and (+ blank) (regexp ,ledger-code-regexp)))
(+ blank) (+? nonl)
(? (regexp ,ledger-end-note-regexp))
line-end)))
"Match a transaction's first line (and optional notes)."
(actual-date full-date actual)
(effective-date full-date effective)
state
code
(note end-note))
(ledger-define-regexp account
(rx (group (and (not (any blank ?\[ ?\( ?: ?\;)) (*? nonl))))
"")
(rx (group (and (not (any blank ?\[ ?\( ?: ?\;)) (*? nonl))))
"")
(ledger-define-regexp account-kind
(rx (group (? (any ?\[ ?\())))
"")
(rx (group (? (any ?\[ ?\())))
"")
(ledger-define-regexp full-account
(macroexpand
`(rx (and (regexp ,ledger-account-kind-regexp)
(regexp ,ledger-account-regexp)
(? (any ?\] ?\))))))
""
(kind account-kind)
(name account))
(macroexpand
`(rx (and (regexp ,ledger-account-kind-regexp)
(regexp ,ledger-account-regexp)
(? (any ?\] ?\))))))
""
(kind account-kind)
(name account))
(ledger-define-regexp commodity-no-group
(rx (or (and ?\" (+ (not (any ?\"))) ?\")
(+ (not (any blank ?\n
digit
?- ?\[ ?\]
?. ?, ?\; ?+ ?* ?/ ?^ ?? ?: ?& ?| ?! ?=
?\< ?\> ?\{ ?\} ?\( ?\) ?@)))))
"")
(rx (or (and ?\" (+ (not (any ?\"))) ?\")
(+ (not (any blank ?\n
digit
?- ?\[ ?\]
?. ?, ?\; ?+ ?* ?/ ?^ ?? ?: ?& ?| ?! ?=
?\< ?\> ?\{ ?\} ?\( ?\) ?@)))))
"")
(ledger-define-regexp commodity
(macroexpand
`(rx (group (regexp ,ledger-commodity-no-group-regexp))))
"")
(macroexpand
`(rx (group (regexp ,ledger-commodity-no-group-regexp))))
"")
(ledger-define-regexp amount-no-group
(rx (and (? ?-)
(+ digit)
(*? (and (any ?. ?,) (+ digit)))))
"")
(rx (and (? ?-)
(+ digit)
(*? (and (any ?. ?,) (+ digit)))))
"")
(ledger-define-regexp amount
(macroexpand
`(rx (group (regexp ,ledger-amount-no-group-regexp))))
"")
(macroexpand
`(rx (group (regexp ,ledger-amount-no-group-regexp))))
"")
(ledger-define-regexp commoditized-amount
(macroexpand
`(rx (group
(or (and (regexp ,ledger-commodity-no-group-regexp)
(*? blank)
(regexp ,ledger-amount-no-group-regexp))
(and (regexp ,ledger-amount-no-group-regexp)
(*? blank)
(regexp ,ledger-commodity-no-group-regexp))))))
"")
(macroexpand
`(rx (group
(or (and (regexp ,ledger-commodity-no-group-regexp)
(*? blank)
(regexp ,ledger-amount-no-group-regexp))
(and (regexp ,ledger-amount-no-group-regexp)
(*? blank)
(regexp ,ledger-commodity-no-group-regexp))))))
"")
(ledger-define-regexp commodity-annotations
(macroexpand
`(rx (* (+ blank)
(or (and ?\{ (regexp ,ledger-commoditized-amount-regexp) ?\})
(and ?\[ (regexp ,ledger-iso-date-regexp) ?\])
(and ?\( (not (any ?\))) ?\))))))
"")
(macroexpand
`(rx (* (+ blank)
(or (and ?\{ (regexp ,ledger-commoditized-amount-regexp) ?\})
(and ?\[ (regexp ,ledger-iso-date-regexp) ?\])
(and ?\( (not (any ?\))) ?\))))))
""
commoditized-amount
iso-date)
(ledger-define-regexp cost
(macroexpand
`(rx (and (or "@" "@@") (+ blank)
(regexp ,ledger-commoditized-amount-regexp))))
"")
(macroexpand
`(rx (and (or "@" "@@") (+ blank)
(regexp ,ledger-commoditized-amount-regexp))))
"")
(ledger-define-regexp balance-assertion
(macroexpand
`(rx (and ?= (+ blank)
(regexp ,ledger-commoditized-amount-regexp))))
"")
(macroexpand
`(rx (and ?= (+ blank)
(regexp ,ledger-commoditized-amount-regexp))))
"")
(ledger-define-regexp full-amount
(macroexpand `(rx (group (+? (not (any ?\;))))))
"")
(rx (group (+? (not (any ?\;)))))
"")
(ledger-define-regexp post-line
(macroexpand
`(rx (and line-start (+ blank)
(? (and (regexp ,ledger-state-regexp) (* blank)))
(regexp ,ledger-full-account-regexp)
(? (and (regexp ,ledger-long-space-regexp)
(regexp ,ledger-full-amount-regexp)))
(? (regexp ,ledger-end-note-regexp))
line-end)))
""
state
(account-kind full-account kind)
(account full-account name)
(amount full-amount)
(note end-note))
(macroexpand
`(rx (and line-start (+ blank)
(? (and (regexp ,ledger-state-regexp) (* blank)))
(regexp ,ledger-full-account-regexp)
(? (and (regexp ,ledger-long-space-regexp)
(regexp ,ledger-full-amount-regexp)))
(? (regexp ,ledger-end-note-regexp))
line-end)))
""
state
(account-kind full-account kind)
(account full-account name)
(amount full-amount)
(note end-note))
(defconst ledger-amount-regex
(concat "\\( \\|\t\\| \t\\)[ \t]*-?"
@@ -370,13 +358,32 @@
"\\([ \t]*[@={]@?[^\n;]+?\\)?"
"\\([ \t]+;.+?\\|[ \t]*\\)?$"))
(defconst ledger-iterate-regex
(concat "\\(\\(?:Y\\|year\\)\\s-+\\([0-9]+\\)\\|" ;; Catches a Y/year directive
ledger-iso-date-regexp
"\\([ *!]+\\)" ;; mark
"\\((.*)\\)?" ;; code
"\\([[:word:] ]+\\)" ;; desc
"\\)"))
(ledger-define-regexp year
(rx (group (+ (any "0-9"))))
"")
(ledger-define-regexp payee
(rx (group (+? nonl)))
"")
(ledger-define-regexp iterate
(macroexpand `(rx (or (and (or "Y" "year")
(+ (syntax ?-))
(regexp ,ledger-year-regexp))
(and (regexp ,ledger-full-date-regexp)
(? (and (+ blank) (regexp ,ledger-state-regexp)))
(? (and (+ blank) (regexp ,ledger-code-regexp)))
(+ blank)
(regexp ,ledger-payee-regexp)
(? (regexp ,ledger-end-note-regexp))))))
""
year
(actual-date full-date actual)
(effective-date full-date effective)
state
code
payee
(note end-note))
(defconst ledger-incomplete-date-regexp
"\\(?:\\([0-9]\\{1,2\\}\\)[-/]\\)?\\([0-9]\\{1,2\\}\\)")

View File

@@ -87,7 +87,7 @@ simply concatenated (no quoting)."
:group 'ledger-report)
(defcustom ledger-report-auto-refresh-sticky-cursor nil
"If non-nil, place cursor at same relative position as it was before auto-refresh."
"If non-nil, keep cursor's relative position after auto-refresh."
:type 'boolean
:group 'ledger-report)
@@ -103,7 +103,7 @@ simply concatenated (no quoting)."
:group 'ledger-report)
(defcustom ledger-report-native-highlighting-arguments '("--color" "--force-color")
"List of strings to pass to ledger when `ledger-report-use-native-highlighting' is non-nil.
"List of ledger args needed by `ledger-report-use-native-highlighting'.
If you are using hledger instead of ledger, you might want to set
this variable to `(\"--color=always\")'."

View File

@@ -137,8 +137,7 @@
(let ((section (match-string 1))
(example-name (match-string 2))
(command (match-string 3))
(data-file ledger-texi-sample-doc-path)
input output)
(data-file ledger-texi-sample-doc-path))
(goto-char (match-end 0))
(forward-line)
(when (looking-at "@\\(\\(?:small\\)?example\\)")
@@ -171,7 +170,7 @@
"@end " section-name ?\n))
;; Update the regression test associated with this example
(ledger-texi-write-test example-name command input output
(ledger-texi-write-test example-name command nil nil
"../test/manual")))))
(provide 'ledger-texi)

View File

@@ -40,6 +40,13 @@
:type 'boolean
:group 'ledger)
(defcustom ledger-add-transaction-prompt-for-text t
"When non-nil, use ledger xact to format transaction.
When nil, `ledger-add-transaction' will not prompt twice."
:type 'boolean
:package-version '(ledger-mode . "4.0.1")
:group 'ledger)
(defvar-local ledger-xact-highlight-overlay (list))
(defun ledger-highlight-make-overlay ()
@@ -117,26 +124,26 @@ MOMENT is an encoded date"
(let* ((now (current-time))
(current-year (nth 5 (decode-time now))))
(while (not (eobp))
(when (looking-at ledger-iterate-regex)
(let ((found-y-p (match-string 2)))
(when (looking-at ledger-iterate-regexp)
(let ((found-y-p (match-string 1)))
(if found-y-p
(setq current-year (string-to-number found-y-p)) ;; a Y directive was found
(let ((start (match-beginning 0))
(year (match-string 4))
(month (string-to-number (match-string 5)))
(day (string-to-number (match-string 6)))
(mark (match-string 7))
(desc (match-string 9)))
(year (match-string (+ ledger-regex-iterate-group-actual-date 1)))
(month (string-to-number (match-string (+ ledger-regex-iterate-group-actual-date 2))))
(day (string-to-number (match-string (+ ledger-regex-iterate-group-actual-date 3))))
(state (match-string ledger-regex-iterate-group-state))
(payee (match-string ledger-regex-iterate-group-payee)))
(if (and year (> (length year) 0))
(setq year (string-to-number year)))
(funcall callback start
(encode-time 0 0 0 day month
(or year current-year))
mark desc)))))
state payee)))))
(forward-line))))
(defcustom ledger-copy-transaction-insert-blank-line-after nil
"Non-nil means insert blank line after a transaction inserted with ledger-copy-transaction-at-point."
"When non-nil, insert a blank line after `ledger-copy-transaction-at-point'."
:type 'boolean
:group 'ledger)
@@ -172,14 +179,10 @@ MOMENT is an encoded date"
(defun ledger-read-transaction ()
"Read the text of a transaction, which is at least the current date."
(let* ((reference-date (or ledger-add-transaction-last-date (current-time)))
(full-date-string (ledger-format-date reference-date))
;; Pre-fill year and month, but not day: this assumes DD is the last format arg.
(initial-string (replace-regexp-in-string "[0-9]+$" "" full-date-string))
(entered-string (ledger-read-date "Date: ")))
(if (string= initial-string entered-string)
full-date-string
entered-string)))
(let ((date (ledger-read-date "Date: ")))
(concat date " "
(when ledger-add-transaction-prompt-for-text
(read-string (concat "xact " date ": ") nil 'ledger-minibuffer-history)))))
(defun ledger-parse-iso-date (date)
"Try to parse DATE using `ledger-iso-date-regexp' and return a time value or nil."