Codebase list ledger-mode / 9d4c817
Merge tag 'v4.0.0' David Bremner 1 year, 7 months ago
18 changed file(s) with 269 addition(s) and 106 deletion(s). Raw diff Collapse all Expand all
0 sudo: required
1 language: generic
2 dist: xenial
0 language: nix
1
2 os:
3 - linux
4 # - osx # Travis is saturated; see https://www.traviscistatus.com/
35
46 env:
5 matrix:
6 - EVM_EMACS=emacs-24.3-travis
7 - EVM_EMACS=emacs-25.1-travis
8 # EVM doesn't support xenial yet, which we need since it has ledger version 3.
9 # See https://github.com/rejeep/evm/issues/125
10 # - EVM_EMACS=emacs-26.1-travis
11 # - EVM_EMACS=emacs-26.2-travis
12 # - EVM_EMACS=emacs-git-snapshot-travis
7 - EMACS_CI=emacs-24-3 LEDGER_VERSION=stable
8 - EMACS_CI=emacs-24-4 LEDGER_VERSION=stable
9 - EMACS_CI=emacs-24-5 LEDGER_VERSION=stable
10 - EMACS_CI=emacs-25-1 LEDGER_VERSION=stable
11 - EMACS_CI=emacs-25-2 LEDGER_VERSION=stable
12 - EMACS_CI=emacs-25-3 LEDGER_VERSION=stable
13 - EMACS_CI=emacs-26-1 LEDGER_VERSION=stable
14 - EMACS_CI=emacs-26-2 LEDGER_VERSION=stable
15 - EMACS_CI=emacs-26-3 LEDGER_VERSION=stable
16 - EMACS_CI=emacs-snapshot LEDGER_VERSION=snapshot
1317
14 before_install:
15 - sudo apt-get install -y ledger
16 - git clone https://github.com/rejeep/evm.git $HOME/.evm
17 - export PATH=$HOME/.evm/bin:$PATH
18 - evm config path /tmp
19 - evm install $EVM_EMACS --use --skip
18 matrix:
19 allow_failures:
20 - env: EMACS_CI=emacs-snapshot LEDGER_VERSION=snapshot
21
22 install:
23 - bash <(curl https://raw.githubusercontent.com/purcell/nix-emacs-ci/master/travis-install)
24 # TODO: cache builds of this using cachix
25 - nix-env -iA $LEDGER_VERSION -f tools
2026
2127 script:
2228 - emacs --version
2329 - ledger --version
24 - emacs --eval "(setq byte-compile-error-on-warn (>= emacs-major-version 25))" -L . --batch -f batch-byte-compile *.el
30 # Byte compilation is known to fail in Emacs < 26.1 due to ledger-flymake.el, which should
31 # be packaged separately
32 - emacs --eval "(setq byte-compile-error-on-warn (>= emacs-major-version 26))" -L . --batch -f batch-byte-compile *.el
2533 - make -C test test-batch
2634
2735 after_script:
0 * Development (v4.1)
1 * Release v4.0.0
2 ** The completion system now respects whatever completion system the user prefers
3 Some users prefer different completion systems such as ivy or helm. To get the
4 old behavior back, see the instructions in the ledger manual under the heading
5 "Adding Transactions."
6
7 Additionally, we now realign transactions after completion, see
8 ledger-post-auto-align.
9 ** New option ledger-post-auto-align controls whether post amounts automatically align
10 ** New options control whether the report name/command get printed in the report buffer
11 New option ledger-report-use-header-line controls this behavior and
12 ledger-report-header-line-fn controls how the information is reported.
13 ** New option ledger-default-date-format is now used consistently
14 Ledger-mode uses this option to insert dates whenever it is needed.
15 ** Report buffers are now highlighted by ledger
16 So, for example, debts are usually red and deposits blue.
17
18 New option ledger-report-use-native-highlighting controls this behavior.
19
20 ** Ledger now matches the width of report buffers
21 Option ledger-report-auto-width controls whether we pass this information to
22 ledger or not.
23 ** Ledger-mode gained support for flymake
24 This supports checking for errors in syntax.
25
26 Two new options ledger-flymake-be-pedantic and ledger-flymake-be-explicit
27 control which flags get passed to ledger during checking.
28 ** Report windows can be automatically resized
29 See new option ledger-report-resize-window
30 ** All faces used by ledger now inherit from other faces.
31 This should make ledger-mode look better when used with various themes that
32 don't provide support for ledger-mode explicitly.
33 ** New option ledger-report-use-strict controls whether --strict gets passed to reports
34 ** The fontification system (syntax highlighting) was completly rewritten
35 ** In report buffers, M-n and M-p move to the next and previous month
36 See the "Expansion Formats" section of the ledger mode manual to see examples on
37 how to use this.
38 ** New hook ledger-report-after-report-hook runs after the report has been created
39 ** In report buffers, $ toggles converting to the default commodity
40 ** Two new commands move between uncleared transactions
41 New commands ledger-navigate-next-uncleared and
42 ledger-navigate-previous-uncleared move to the next and previous uncleared
43 transactions. These don't have default keybindings.
44 ** New option ledger-accounts-exclude-function
45 This allows users to exclude some accounts from being offered during completion.
46 This is useful if, for example, you have a lot of accounts but only use some of
47 them rarely.
109109 (kill-buffer (get-buffer ledger-check-buffer-name)))
110110
111111 (defun ledger-check-buffer ()
112 "Run ledge with --explicit and --strict report errors and assist with fixing them.
112 "Check the current buffer for errors.
113
114 Runs ledger with --explicit and --strict report errors and assist
115 with fixing them.
113116
114117 The output buffer will be in `ledger-check-mode', which defines
115118 commands for navigating the buffer to the errors found, etc."
135138
136139
137140 (provide 'ledger-check)
141
142 ;;; ledger-check.el ends here
109109 (replace-regexp-in-string char "" str))
110110
111111 (defun ledger-string-to-number (str &optional decimal-comma)
112 "improve builtin string-to-number by handling internationalization, and return nil if number can't be parsed"
112 "Parse STR as a number and return that number.
113
114 Improves builtin `string-to-number' by handling
115 internationalization, and return nil if number can't be parsed.
116 See `ledger-environment-alist' for DECIMAL-COMMA."
113117 (let ((nstr (if (or decimal-comma
114118 (assoc "decimal-comma" ledger-environment-alist))
115119 (ledger-strip str "[.]")
119123 (string-to-number nstr)))
120124
121125 (defun ledger-number-to-string (n &optional decimal-comma)
122 "number-to-string that handles comma as decimal."
126 "See `number-to-string' for N.
127 DECIMAL-COMMA is as documented in `ledger-environment-alist'."
123128 (let ((str (number-to-string n)))
124129 (when (or decimal-comma
125130 (assoc "decimal-comma" ledger-environment-alist))
3636 :type 'file
3737 :group 'ledger)
3838
39 (defcustom ledger-accounts-exclude-function nil
40 "Function to exclude accounts from completion.
41 Should be a predicate function that accepts one argument, an
42 element of `ledger-accounts-list-in-buffer'."
43 :type 'function
44 :group 'ledger
45 :package-version '(ledger-mode . "2019-08-14"))
46
3947 (defcustom ledger-complete-in-steps nil
4048 "When non-nil, `ledger-complete-at-point' completes account names in steps.
4149 If nil, full account names are offered for completion."
4250 :type 'boolean
4351 :group 'ledger
44 :package-version '(ledger-mode . "2019-05-27"))
52 :package-version '(ledger-mode . "4.0.0"))
4553
4654 (defun ledger-parse-arguments ()
4755 "Parse whitespace separated arguments in the current region."
8997 ;; to the list
9098 (sort (delete-dups payees-list) #'string-lessp)))
9199
100 (defun ledger-accounts-in-buffer ()
101 "Return an alist of accounts in the current buffer.
102 The `car' of each element is the account name and the `cdr' is an
103 alist where the key is a subdirective such as \"assert\" and the
104 value (if any) is the associated data. In other words, if you've
105 declared an account like so:
106
107 account Assets:Checking
108 assert commodity == \"$\"
109 default
110
111 Then one of the elements this function returns will be
112 \(\"Assets:Checking\"
113 (\"default\")
114 (\"assert\" . \"commodity == \"$\"\"))"
115 (save-excursion
116 (goto-char (point-min))
117 (let (account-list)
118 ;; First, consider accounts declared with "account" directives, which may or
119 ;; may not have associated data. The data is on the following lines up to a
120 ;; line not starting with whitespace.
121 (while (re-search-forward ledger-account-directive-regex nil t)
122 (let ((account (match-string-no-properties 1))
123 (lines (buffer-substring-no-properties
124 (point)
125 (progn (ledger-navigate-next-xact-or-directive)
126 (point))))
127 data)
128 (dolist (d (split-string lines "\n"))
129 (setq d
130 ;; TODO: This is basically (string-trim d) but string-trim
131 ;; doesn't exist in Emacs 24. Replace once we drop Emacs 24.
132 (if (string-match "[[:space:]]+" d)
133 (substring d (match-end 0))
134 d))
135 (unless (string= d "")
136 (if (string-match " " d)
137 (push (cons (substring d 0 (match-beginning 0))
138 (substring d (match-end 0) nil))
139 data)
140 (push (cons d nil) data))))
141 (push (cons account data) account-list)))
142 ;; Next, gather all accounts declared in postings
143 (unless
144 ;; FIXME: People who have set `ledger-flymake-be-pedantic' to non-nil
145 ;; probably don't want accounts from postings, just those declared
146 ;; with directives. But the name is a little misleading. Should we
147 ;; make a ledger-mode-be-pedantic and use that instead?
148 (bound-and-true-p ledger-flymake-be-pedantic)
149 (goto-char (point-min))
150 (while (re-search-forward ledger-account-name-or-directive-regex nil t)
151 (let ((account (match-string-no-properties 1)))
152 (unless (member account (mapcar #'car account-list))
153 (push (cons account nil) account-list)))))
154 (sort account-list (lambda (a b) (string-lessp (car a) (car b)))))))
155
92156 (defun ledger-accounts-list-in-buffer ()
93157 "Return a list of all known account names in the current buffer as strings.
94158 Considers both accounts listed in postings and those declared with \"account\" directives."
95 (save-excursion
96 (goto-char (point-min))
97 (let (results)
98 (while (re-search-forward ledger-account-name-or-directive-regex nil t)
99 (setq results (cons (match-string-no-properties 1) results)))
100 (sort (delete-dups results) #'string-lessp))))
159 (let ((accounts (ledger-accounts-in-buffer)))
160 (when ledger-accounts-exclude-function
161 (setq accounts (cl-remove-if ledger-accounts-exclude-function accounts)))
162 (mapcar #'car accounts)))
101163
102164 (defun ledger-accounts-list ()
103165 "Return a list of all known account names as strings.
232294 (eq (save-excursion (ledger-thing-at-point)) 'transaction)
233295 (setq start (save-excursion (backward-word) (point)))
234296 (setq collection #'ledger-payees-in-buffer))
235 ((looking-back (rx-to-string `(seq bol (one-or-more space) (group (zero-or-more (not space))))) (line-beginning-position))
297 (;; Accounts
298 (looking-back (rx-to-string `(seq bol (one-or-more space) (group (zero-or-more (not space))))) (line-beginning-position))
236299 (setq start (match-beginning 1)
237300 delete-suffix (save-excursion
238301 (when (search-forward-regexp (rx (or eol (repeat 2 space))) (line-end-position) t)
260323 (replace-regexp-in-string "[ \t]*$" "" str))
261324
262325 (defun ledger-fully-complete-xact ()
263 "Completes a transaction if there is another matching payee in the buffer.
264 Does not use ledger xact"
326 "Completes a transaction if there is another matching payee in the buffer."
265327 (interactive)
328 (unless (looking-back ledger-payee-any-status-regex (line-beginning-position))
329 (user-error "Point is not after payee"))
266330 (let* ((name (ledger-trim-trailing-whitespace (caar (ledger-parse-arguments))))
267331 (rest-of-name name)
268332 xacts)
276340 (setq rest-of-name (match-string 3))
277341 ;; Start copying the postings
278342 (forward-line)
279 (while (looking-at ledger-account-any-status-regex)
280 (setq xacts (cons (buffer-substring-no-properties
281 (line-beginning-position)
282 (line-end-position))
283 xacts))
284 (forward-line))
285 (setq xacts (nreverse xacts)))))
343 (setq xacts (buffer-substring-no-properties (point) (ledger-navigate-end-of-xact))))))
286344 ;; Insert rest-of-name and the postings
287 (when xacts
288 (save-excursion
289 (insert rest-of-name ?\n)
290 (while xacts
291 (insert (car xacts) ?\n)
292 (setq xacts (cdr xacts))))
293 (forward-line)
294 (goto-char (line-end-position))
295 (if (re-search-backward "\\(\t\\| [ \t]\\)" nil t)
296 (goto-char (match-end 0))))))
345 (save-excursion
346 (insert rest-of-name ?\n)
347 (insert xacts)
348 (insert ?\n))
349 (forward-line)
350 (goto-char (line-end-position))
351 (when (re-search-backward "\\(\t\\| [ \t]\\)" nil t)
352 (goto-char (match-end 0)))))
297353
298354 (provide 'ledger-complete)
299355
5252 (concat (apply 'concat (mapcar 'ledger-get-regex-str elements)) "[ \t]*$"))
5353
5454 (defmacro ledger-single-line-config (&rest elements)
55 "Take list of ELEMENTS and return regex and element list for use in context-at-point"
55 "Take list of ELEMENTS and return regex and element list for use in context-at-point."
5656 `(list (ledger-line-regex (quote ,elements)) (quote ,elements)))
5757
5858 (defconst ledger-line-config
3939 If --pedantic is in your ledgerrc file, then --pedantic gets
4040 passed regardless of the value."
4141 :type 'boolean
42 :package-version '(ledger-mode . "4.0.0")
4243 :group 'ledger)
4344
4445 (defcustom ledger-flymake-be-explicit nil
4647 If --explicit is in your ledgerrc file, then --explicit gets
4748 passed regardless of the value."
4849 :type 'boolean
50 :package-version '(ledger-mode . "4.0.0")
4951 :group 'ledger)
5052
5153 ;; Based on the example from Flymake's info:
456456 "Construct anchored highlighters for subdirectives.
457457
458458 Each element of SUBDIRECTIVES should have the form (MATCHER
459 SUBEXP-HIGHLIGHTERS…). The result will be a list of elements of
459 SUBEXP-HIGHLIGHTERS…). The result will be a list of elements of
460460 the form (MATCHER PRE-FORM POST-FORM SUBEXP-HIGHLIGHTERS) with
461461 PRE-FORM and POST-FORM set to appropriate values.
462462
4141 Set this to the value of `ledger-iso-date-format' if you prefer
4242 ISO 8601 dates."
4343 :type 'string
44 :package-version '(ledger-mode . "4.0.0")
4445 :group 'ledger)
4546
4647 (defconst ledger-iso-date-format "%Y-%m-%d"
100100 (org-read-date nil t nil prompt))))
101101
102102 (defun ledger-get-minibuffer-prompt (prompt default)
103 "Return a string composing of PROMPT and DEFAULT appropriate
104 for a minibuffer prompt."
103 "Return a string composing of PROMPT and DEFAULT appropriate for a minibuffer prompt."
105104 (concat prompt
106105 (if default
107106 (concat " (" default "): ")
108107 ": ")))
109108
110109 (defun ledger-completing-read-with-default (prompt default collection)
111 "Return a user supplied string after PROMPT, or DEFAULT while
112 providing completions from COLLECTION."
110 "Return a user supplied string after PROMPT, or DEFAULT while providing completions from COLLECTION."
113111 (completing-read (ledger-get-minibuffer-prompt prompt default)
114112 collection nil nil nil 'ledger-minibuffer-history default))
115113
122120 "Display the cleared-or-pending balance.
123121 And calculate the target-delta of the account being reconciled.
124122
125 With prefix argument \\[universal-argument] ask for the target commodity and convert
123 With ARG (\\[universal-argument]) ask for the target commodity and convert
126124 the balance into that."
127125 (interactive "P")
128126 (let* ((account (ledger-read-account-with-prompt "Account balance to show"))
5555 "When non-nil, realign post amounts when indenting or completing."
5656 :type 'boolean
5757 :group 'ledger-post
58 :package-version '(ledger-mode . "4.0.0")
5859 :safe 'booleanp)
5960
6061 (defun ledger-next-amount (&optional end)
128129 (defun ledger-indent-line ()
129130 "Indent the current line."
130131 ;; Ensure indent if the previous line was indented
131 (let ((indent-level (save-excursion (if (progn (when (zerop (forward-line -1))
132 (memq (ledger-thing-at-point) '(transaction posting))))
132 (let ((indent-level (save-excursion (if (and (zerop (forward-line -1))
133 (memq (ledger-thing-at-point) '(transaction posting)))
133134 ledger-post-account-alignment-column
134135 0))))
135136 (unless (= (current-indentation) indent-level)
5858 :group 'ledger-reconcile)
5959
6060 (defcustom ledger-buffer-tracks-reconcile-buffer t
61 "If t, then when the cursor is moved to a new transaction in the reconcile buffer.
62 Then that transaction will be shown in its source buffer."
61 "If t, move point in the ledger buffer when it moves in the reconcile buffer.
62 When the cursor is moved to a new transaction in the reconcile
63 buffer then that transaction will be shown in its source buffer."
6364 :type 'boolean
6465 :group 'ledger-reconcile)
6566
7677
7778 (defcustom ledger-reconcile-default-date-format ledger-default-date-format
7879 "Date format for the reconcile buffer.
79 Default is ledger-default-date-format."
80 Default is `ledger-default-date-format'."
8081 :type 'string
8182 :group 'ledger-reconcile)
8283
100101 preced by a minus sign which mean to left justify and pad the
101102 field. WIDTH is the minimum number of characters to display;
102103 if string is longer, it is not truncated unless
103 ledger-reconcile-buffer-payee-max-chars or
104 ledger-reconcile-buffer-account-max-chars is defined."
104 `ledger-reconcile-buffer-payee-max-chars' or
105 `ledger-reconcile-buffer-account-max-chars' is defined."
105106 :type 'string
106107 :group 'ledger-reconcile)
107108
510511 (pop-to-buffer rbuf)))
511512
512513 (defun ledger-reconcile-check-valid-account (account)
513 "Check to see if ACCOUNT exists in the ledger file"
514 "Check to see if ACCOUNT exists in the ledger file."
514515 (if (> (length account) 0)
515516 (save-excursion
516517 (goto-char (point-min))
517518 (search-forward account nil t))))
518519
519520 (defun ledger-reconcile (&optional account target)
520 "Start reconciling, prompt for account."
521 "Start reconciling, prompt for ACCOUNT."
521522 (interactive)
522523 (let ((account (or account (ledger-read-account-with-prompt "Account to reconcile")))
523524 (buf (current-buffer))
559560 (defvar ledger-reconcile-mode-abbrev-table)
560561
561562 (defun ledger-reconcile-change-target (&optional target)
562 "Change the target amount for the reconciliation process."
563 "Change the TARGET amount for the reconciliation process."
563564 (interactive)
564565 (setq ledger-target (or target (ledger-read-commodity-string ledger-reconcile-target-prompt-string))))
565566
1717 ;; along with GNU Emacs; see the file COPYING. If not, write to the
1818 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
1919 ;; MA 02110-1301 USA.
20
21
22 ;;; Commentary:
23 ;; Regular expressions used by ledger-mode.
24
25 ;;; Code:
2026
2127 (require 'rx)
2228 (require 'cl-lib)
403409
404410
405411 (provide 'ledger-regex)
412
413 ;;; ledger-regex.el ends here
9797 (defcustom ledger-report-use-native-highlighting t
9898 "When non-nil, use ledger's native highlighting in reports."
9999 :type 'boolean
100 :package-version '(ledger-mode . "4.0.0")
100101 :group 'ledger-report)
101102
102103 (defcustom ledger-report-auto-width t
103104 "When non-nil, tell ledger about the width of the report window."
104105 :type 'boolean
106 :package-version '(ledger-mode . "4.0.0")
105107 :group 'ledger-report)
106108
107109 (defcustom ledger-report-use-header-line nil
110112 `ledger-report-header-line-fn' for how to customize the
111113 information reported."
112114 :type 'boolean
115 :package-version '(ledger-mode . "4.0.0")
113116 :group 'ledger-report)
114117
115118 (defcustom ledger-report-header-line-fn #'ledger-report--header-function
116119 "Evaluate this function in the `header-line' of the report buffer.
117120 `ledger-report-use-header-line' must be non-nil for this to have any effect."
118121 :type 'function
122 :package-version '(ledger-mode . "4.0.0")
119123 :group 'ledger-report)
120124
121125 (defcustom ledger-report-resize-window t
122126 "If non-nil, resize the report window.
123127 Calls `shrink-window-if-larger-than-buffer'."
124128 :type 'boolean
129 :package-version '(ledger-mode . "4.0.0")
125130 :group 'ledger-report)
126131
127132 (defcustom ledger-report-use-strict nil
128 "Should Ledger-mode pass --strict as a command line parameter
129 when running reports?"
130 :type 'boolean
133 "When non-nil, `ledger-mode' will use --strict when running reports?"
134 :type 'boolean
135 :package-version '(ledger-mode . "4.0.0")
131136 :group 'ledger-report)
132137
133138 (defcustom ledger-report-after-report-hook nil
134139 "Hook run after `ledger-report' has created the buffer and report."
135140 :type 'boolean
141 :package-version '(ledger-mode . "4.0.0")
136142 :group 'ledger-report)
137143
138144 (defvar ledger-report-buffer-name "*Ledger Report*")
179185 (define-key map [?r] #'ledger-report-redo)
180186 (define-key map [(shift ?r)] #'ledger-report-reverse-report)
181187 (define-key map [?s] #'ledger-report-save)
182 (define-key map [(shift ?s)] #'ledger-report-select-report)
188 (define-key map [(shift ?s)] #'ledger-report)
183189 (define-key map [?e] #'ledger-report-edit-report)
184190 (define-key map [( shift ?e)] #'ledger-report-edit-reports)
185191 (define-key map [?q] #'ledger-report-quit)
200206 (easy-menu-define ledger-report-mode-menu ledger-report-mode-map
201207 "Ledger report menu"
202208 '("Reports"
203 ["Select Report" ledger-report-select-report]
209 ["Select Report" ledger-report]
204210 ["Save Report" ledger-report-save]
205211 ["Edit Current Report" ledger-report-edit-report]
206212 ["Edit All Reports" ledger-report-edit-reports]
216222 ))
217223
218224 (define-derived-mode ledger-report-mode special-mode "Ledger-Report"
219 "A mode for viewing ledger reports.")
225 "A mode for viewing ledger reports."
226 (hack-dir-local-variables-non-file-buffer))
220227
221228 (defconst ledger-report--extra-args-marker "[[ledger-mode-flags]]")
222229
467474 'action (lambda (_button) (ledger-report-visit-source)))
468475
469476 (defun ledger-report--change-month (shift)
470 "Rebuild report with transactions from current month + shift."
477 "Rebuild report with transactions from current month + SHIFT."
471478 (let* ((current-month (or ledger-report-current-month (ledger-report--current-month)))
472479 (previous-month (ledger-report--shift-month current-month shift)))
473480 (set (make-local-variable 'ledger-report-current-month) previous-month)
480487 (let ((file (match-string 1))
481488 (line (string-to-number (match-string 2))))
482489 (delete-region (match-beginning 0) (match-end 0))
483 (when file
490 (when (and file line)
484491 (add-text-properties (line-beginning-position) (line-end-position)
485 (list 'ledger-source (cons file (save-window-excursion
486 (save-excursion
487 (find-file file)
488 (widen)
489 (ledger-navigate-to-line line)
490 (point-marker))))))
492 (list 'ledger-source (cons file line)))
491493 (make-text-button
492494 (line-beginning-position) (line-end-position)
493495 'type 'ledger-report-register-entry
536538 "Visit the transaction under point in the report window."
537539 (interactive)
538540 (let* ((prop (get-text-property (point) 'ledger-source))
539 (file (if prop (car prop)))
540 (line-or-marker (if prop (cdr prop))))
541 (when (and file line-or-marker)
541 (file (car prop))
542 (line (cdr prop)))
543 (when (and file line)
542544 (find-file-other-window file)
543545 (widen)
544 (if (markerp line-or-marker)
545 (goto-char line-or-marker)
546 (goto-char (point-min))
547 (forward-line (1- line-or-marker))
548 (re-search-backward "^[0-9]+")
549 (beginning-of-line)
550 (let ((start-of-txn (point)))
551 (forward-paragraph)
552 (narrow-to-region start-of-txn (point))
553 (backward-paragraph))))))
546 (goto-char (point-min))
547 (forward-line (1- line))
548 (ledger-navigate-beginning-of-xact))))
554549
555550 (defun ledger-report-goto ()
556551 "Goto the ledger report buffer."
601596 (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd))
602597 (ledger-report-redo))
603598
604 (defun ledger-report-select-report ()
605 "Select and run one of the named reports."
606 (interactive)
607 (setq ledger-report-name (ledger-report-read-name)
608 ledger-report-cmd (ledger-report-cmd ledger-report-name nil))
609 (ledger-report-redo))
599 (define-obsolete-function-alias 'ledger-report-select-report #'ledger-report "ledger 4.0.0")
610600
611601 (defun ledger-report-read-new-name ()
612602 "Read the name for a new report from the minibuffer."
6767 ("Fr" 5)
6868 ("Sa" 6)
6969 ("Su" 0))
70 "List of weekday abbreviations. There must be exactly seven
71 entries each with a two character abbreviation for a day and the
72 number of that day in the week. "
70 "List of weekday abbreviations.
71 There must be exactly seven entries each with a two character
72 abbreviation for a day and the number of that day in the week."
7373 :type '(alist :value-type (group integer))
7474 :group 'ledger-schedule)
7575
211211 (defun ledger-schedule-constrain-year (year-desc month-desc day-desc)
212212 "Return a form that constrains the year.
213213
214 YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
214 YEAR-DESC, MONTH-DESC, and DAY-DESC are the string portions of the
215215 date descriptor."
216216 (cond
217217 ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the year
224224 (defun ledger-schedule-constrain-month (year-desc month-desc day-desc)
225225 "Return a form that constrains the month.
226226
227 YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
227 YEAR-DESC, MONTH-DESC, and DAY-DESC are the string portions of the
228228 date descriptor."
229229 (cond
230230 ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the month
242242 (defun ledger-schedule-constrain-day (year-desc month-desc day-desc)
243243 "Return a form that constrains the day.
244244
245 YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
245 YEAR-DESC, MONTH-DESC, and DAY-DESC are the string portions of the
246246 date descriptor."
247247 (cond ((string= day-desc "*")
248248 t)
1717 ;; along with GNU Emacs; see the file COPYING. If not, write to the
1818 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
1919 ;; MA 02110-1301 USA.
20
21 ;;; Commentary:
22 ;;
23
2024 ;;; Code:
2125 (defvar ledger-binary-path)
2226
2529 :group 'ledger)
2630
2731 (defcustom ledger-texi-sample-doc-path "~/ledger/doc/sample.dat"
28 "Location for sample data to be used in texi tests"
32 "Location for sample data to be used in texi tests."
2933 :type 'file
3034 :group 'ledger-texi)
3135
3236 (defcustom ledger-texi-normalization-args "--args-only --columns 80"
33 "texi normalization for producing ledger output"
37 "Texi normalization for producing ledger output."
3438 :type 'string
3539 :group 'ledger-texi)
3640
170174 "../test/manual")))))
171175
172176 (provide 'ledger-texi)
177
178 ;;; ledger-texi.el ends here
163163 (list
164164 "Expenses:The Bakery"))))))
165165
166 (ert-deftest ledger-complete/test-ledger-accounts-exclude-function ()
167 ;; TODO: Why doesn't this work in batch?
168 :tags '(interactive)
169 (with-temp-buffer
170 (insert "account Assets:Checking:Bank A
171 assert date<=[1990-01-01]
172 account Assets:Checking:Bank B")
173 (let ((ledger-accounts-exclude-function
174 (lambda (i) "Exclude all entries with a subdirective."
175 (cdr i))))
176 (should (equal (ledger-accounts-list-in-buffer)
177 (list "Assets:Checking:Bank B"))))
178 (let ((ledger-accounts-exclude-function (lambda (_) t)))
179 (should (equal (ledger-accounts-list-in-buffer)
180 nil)))
181 (let ((ledger-accounts-exclude-function (lambda (_) nil)))
182 (should (equal (ledger-accounts-list-in-buffer)
183 (list "Assets:Checking:Bank A"
184 "Assets:Checking:Bank B"))))))
185
166186 (provide 'complete-test)
167187
168188 ;;; complete-test.el ends here
0 { pkgs ? import <nixpkgs> {} }:
1
2 let
3 ledgerFromGit = builtins.fetchGit { url = git://github.com/ledger/ledger; };
4 in
5 {
6 stable = pkgs.ledger;
7
8 snapshot = (pkgs.callPackage ledgerFromGit {})
9 .overrideAttrs(a: {
10 doCheck = false;
11 cmakeFlags = a.cmakeFlags ++ [ "-DCMAKE_INSTALL_MANDIR=share/man" ];
12 });
13 }