diff options
author | David Bremner <david@tethera.net> | 2022-09-04 08:39:24 -0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2022-09-04 08:39:24 -0300 |
commit | 9d4c8172c9ecd894ee03aac107779626e173203c (patch) | |
tree | 395a19c37a6957836c892310e066d539d52049dc | |
parent | 87d6a5e6d96a969e5737f91dc1392a94384dbcd0 (diff) | |
parent | 964630f80e0e80dad83134a3660f56948390173a (diff) |
Merge tag 'v4.0.0'
-rw-r--r-- | .travis.yml | 44 | ||||
-rw-r--r-- | NEWS.org | 48 | ||||
-rw-r--r-- | ledger-check.el | 7 | ||||
-rw-r--r-- | ledger-commodities.el | 9 | ||||
-rw-r--r-- | ledger-complete.el | 110 | ||||
-rw-r--r-- | ledger-context.el | 2 | ||||
-rw-r--r-- | ledger-flymake.el | 2 | ||||
-rw-r--r-- | ledger-fonts.el | 2 | ||||
-rw-r--r-- | ledger-init.el | 1 | ||||
-rw-r--r-- | ledger-mode.el | 8 | ||||
-rw-r--r-- | ledger-post.el | 5 | ||||
-rw-r--r-- | ledger-reconcile.el | 17 | ||||
-rw-r--r-- | ledger-regex.el | 8 | ||||
-rw-r--r-- | ledger-report.el | 54 | ||||
-rw-r--r-- | ledger-schedule.el | 12 | ||||
-rw-r--r-- | ledger-texi.el | 10 | ||||
-rw-r--r-- | test/complete-test.el | 20 | ||||
-rw-r--r-- | tools/default.nix | 14 |
18 files changed, 268 insertions, 105 deletions
diff --git a/.travis.yml b/.travis.yml index 9209c46..4ac3df2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,36 @@ -sudo: required -language: generic -dist: xenial +language: nix + +os: + - linux + # - osx # Travis is saturated; see https://www.traviscistatus.com/ env: - matrix: - - EVM_EMACS=emacs-24.3-travis - - EVM_EMACS=emacs-25.1-travis - # EVM doesn't support xenial yet, which we need since it has ledger version 3. - # See https://github.com/rejeep/evm/issues/125 - # - EVM_EMACS=emacs-26.1-travis - # - EVM_EMACS=emacs-26.2-travis - # - EVM_EMACS=emacs-git-snapshot-travis + - EMACS_CI=emacs-24-3 LEDGER_VERSION=stable + - EMACS_CI=emacs-24-4 LEDGER_VERSION=stable + - EMACS_CI=emacs-24-5 LEDGER_VERSION=stable + - EMACS_CI=emacs-25-1 LEDGER_VERSION=stable + - EMACS_CI=emacs-25-2 LEDGER_VERSION=stable + - EMACS_CI=emacs-25-3 LEDGER_VERSION=stable + - EMACS_CI=emacs-26-1 LEDGER_VERSION=stable + - EMACS_CI=emacs-26-2 LEDGER_VERSION=stable + - EMACS_CI=emacs-26-3 LEDGER_VERSION=stable + - EMACS_CI=emacs-snapshot LEDGER_VERSION=snapshot + +matrix: + allow_failures: + - env: EMACS_CI=emacs-snapshot LEDGER_VERSION=snapshot -before_install: - - sudo apt-get install -y ledger - - git clone https://github.com/rejeep/evm.git $HOME/.evm - - export PATH=$HOME/.evm/bin:$PATH - - evm config path /tmp - - evm install $EVM_EMACS --use --skip +install: + - bash <(curl https://raw.githubusercontent.com/purcell/nix-emacs-ci/master/travis-install) + # TODO: cache builds of this using cachix + - nix-env -iA $LEDGER_VERSION -f tools script: - emacs --version - ledger --version - - emacs --eval "(setq byte-compile-error-on-warn (>= emacs-major-version 25))" -L . --batch -f batch-byte-compile *.el + # Byte compilation is known to fail in Emacs < 26.1 due to ledger-flymake.el, which should + # be packaged separately + - emacs --eval "(setq byte-compile-error-on-warn (>= emacs-major-version 26))" -L . --batch -f batch-byte-compile *.el - make -C test test-batch after_script: diff --git a/NEWS.org b/NEWS.org new file mode 100644 index 0000000..0b5b469 --- /dev/null +++ b/NEWS.org @@ -0,0 +1,48 @@ +* Development (v4.1) +* Release v4.0.0 +** The completion system now respects whatever completion system the user prefers +Some users prefer different completion systems such as ivy or helm. To get the +old behavior back, see the instructions in the ledger manual under the heading +"Adding Transactions." + +Additionally, we now realign transactions after completion, see +ledger-post-auto-align. +** New option ledger-post-auto-align controls whether post amounts automatically align +** New options control whether the report name/command get printed in the report buffer +New option ledger-report-use-header-line controls this behavior and +ledger-report-header-line-fn controls how the information is reported. +** New option ledger-default-date-format is now used consistently +Ledger-mode uses this option to insert dates whenever it is needed. +** Report buffers are now highlighted by ledger +So, for example, debts are usually red and deposits blue. + +New option ledger-report-use-native-highlighting controls this behavior. + +** Ledger now matches the width of report buffers +Option ledger-report-auto-width controls whether we pass this information to +ledger or not. +** Ledger-mode gained support for flymake +This supports checking for errors in syntax. + +Two new options ledger-flymake-be-pedantic and ledger-flymake-be-explicit +control which flags get passed to ledger during checking. +** Report windows can be automatically resized +See new option ledger-report-resize-window +** All faces used by ledger now inherit from other faces. +This should make ledger-mode look better when used with various themes that +don't provide support for ledger-mode explicitly. +** New option ledger-report-use-strict controls whether --strict gets passed to reports +** The fontification system (syntax highlighting) was completly rewritten +** In report buffers, M-n and M-p move to the next and previous month +See the "Expansion Formats" section of the ledger mode manual to see examples on +how to use this. +** New hook ledger-report-after-report-hook runs after the report has been created +** In report buffers, $ toggles converting to the default commodity +** Two new commands move between uncleared transactions +New commands ledger-navigate-next-uncleared and +ledger-navigate-previous-uncleared move to the next and previous uncleared +transactions. These don't have default keybindings. +** New option ledger-accounts-exclude-function +This allows users to exclude some accounts from being offered during completion. +This is useful if, for example, you have a lot of accounts but only use some of +them rarely. diff --git a/ledger-check.el b/ledger-check.el index e20ac51..a0c3305 100644 --- a/ledger-check.el +++ b/ledger-check.el @@ -110,7 +110,10 @@ (kill-buffer (get-buffer ledger-check-buffer-name))) (defun ledger-check-buffer () - "Run ledge with --explicit and --strict report errors and assist with fixing them. + "Check the current buffer for errors. + +Runs ledger with --explicit and --strict report errors and assist +with fixing them. The output buffer will be in `ledger-check-mode', which defines commands for navigating the buffer to the errors found, etc." @@ -136,3 +139,5 @@ commands for navigating the buffer to the errors found, etc." (provide 'ledger-check) + +;;; ledger-check.el ends here diff --git a/ledger-commodities.el b/ledger-commodities.el index beb4759..50453dc 100644 --- a/ledger-commodities.el +++ b/ledger-commodities.el @@ -110,7 +110,11 @@ Returns a list with (value commodity)." (replace-regexp-in-string char "" str)) (defun ledger-string-to-number (str &optional decimal-comma) - "improve builtin string-to-number by handling internationalization, and return nil if number can't be parsed" + "Parse STR as a number and return that number. + +Improves builtin `string-to-number' by handling +internationalization, and return nil if number can't be parsed. +See `ledger-environment-alist' for DECIMAL-COMMA." (let ((nstr (if (or decimal-comma (assoc "decimal-comma" ledger-environment-alist)) (ledger-strip str "[.]") @@ -120,7 +124,8 @@ Returns a list with (value commodity)." (string-to-number nstr))) (defun ledger-number-to-string (n &optional decimal-comma) - "number-to-string that handles comma as decimal." + "See `number-to-string' for N. +DECIMAL-COMMA is as documented in `ledger-environment-alist'." (let ((str (number-to-string n))) (when (or decimal-comma (assoc "decimal-comma" ledger-environment-alist)) diff --git a/ledger-complete.el b/ledger-complete.el index 569031e..d700abe 100644 --- a/ledger-complete.el +++ b/ledger-complete.el @@ -37,12 +37,20 @@ This file will then be used as a source for account name completions." :type 'file :group 'ledger) +(defcustom ledger-accounts-exclude-function nil + "Function to exclude accounts from completion. +Should be a predicate function that accepts one argument, an +element of `ledger-accounts-list-in-buffer'." + :type 'function + :group 'ledger + :package-version '(ledger-mode . "2019-08-14")) + (defcustom ledger-complete-in-steps nil "When non-nil, `ledger-complete-at-point' completes account names in steps. If nil, full account names are offered for completion." :type 'boolean :group 'ledger - :package-version '(ledger-mode . "2019-05-27")) + :package-version '(ledger-mode . "4.0.0")) (defun ledger-parse-arguments () "Parse whitespace separated arguments in the current region." @@ -90,15 +98,69 @@ If nil, full account names are offered for completion." ;; to the list (sort (delete-dups payees-list) #'string-lessp))) +(defun ledger-accounts-in-buffer () + "Return an alist of accounts in the current buffer. +The `car' of each element is the account name and the `cdr' is an +alist where the key is a subdirective such as \"assert\" and the +value (if any) is the associated data. In other words, if you've +declared an account like so: + +account Assets:Checking + assert commodity == \"$\" + default + +Then one of the elements this function returns will be +\(\"Assets:Checking\" + (\"default\") + (\"assert\" . \"commodity == \"$\"\"))" + (save-excursion + (goto-char (point-min)) + (let (account-list) + ;; First, consider accounts declared with "account" directives, which may or + ;; may not have associated data. The data is on the following lines up to a + ;; line not starting with whitespace. + (while (re-search-forward ledger-account-directive-regex nil t) + (let ((account (match-string-no-properties 1)) + (lines (buffer-substring-no-properties + (point) + (progn (ledger-navigate-next-xact-or-directive) + (point)))) + data) + (dolist (d (split-string lines "\n")) + (setq d + ;; TODO: This is basically (string-trim d) but string-trim + ;; doesn't exist in Emacs 24. Replace once we drop Emacs 24. + (if (string-match "[[:space:]]+" d) + (substring d (match-end 0)) + d)) + (unless (string= d "") + (if (string-match " " d) + (push (cons (substring d 0 (match-beginning 0)) + (substring d (match-end 0) nil)) + data) + (push (cons d nil) data)))) + (push (cons account data) account-list))) + ;; Next, gather all accounts declared in postings + (unless + ;; FIXME: People who have set `ledger-flymake-be-pedantic' to non-nil + ;; probably don't want accounts from postings, just those declared + ;; with directives. But the name is a little misleading. Should we + ;; make a ledger-mode-be-pedantic and use that instead? + (bound-and-true-p ledger-flymake-be-pedantic) + (goto-char (point-min)) + (while (re-search-forward ledger-account-name-or-directive-regex nil t) + (let ((account (match-string-no-properties 1))) + (unless (member account (mapcar #'car account-list)) + (push (cons account nil) account-list))))) + (sort account-list (lambda (a b) (string-lessp (car a) (car b))))))) + (defun ledger-accounts-list-in-buffer () "Return a list of all known account names in the current buffer as strings. Considers both accounts listed in postings and those declared with \"account\" directives." - (save-excursion - (goto-char (point-min)) - (let (results) - (while (re-search-forward ledger-account-name-or-directive-regex nil t) - (setq results (cons (match-string-no-properties 1) results))) - (sort (delete-dups results) #'string-lessp)))) + (let ((accounts (ledger-accounts-in-buffer))) + (when ledger-accounts-exclude-function + (setq accounts (cl-remove-if ledger-accounts-exclude-function accounts))) + (mapcar #'car accounts))) (defun ledger-accounts-list () "Return a list of all known account names as strings. @@ -233,7 +295,8 @@ Looks in `ledger-accounts-file' if set, otherwise the current buffer." (eq (save-excursion (ledger-thing-at-point)) 'transaction) (setq start (save-excursion (backward-word) (point))) (setq collection #'ledger-payees-in-buffer)) - ((looking-back (rx-to-string `(seq bol (one-or-more space) (group (zero-or-more (not space))))) (line-beginning-position)) + (;; Accounts + (looking-back (rx-to-string `(seq bol (one-or-more space) (group (zero-or-more (not space))))) (line-beginning-position)) (setq start (match-beginning 1) delete-suffix (save-excursion (when (search-forward-regexp (rx (or eol (repeat 2 space))) (line-end-position) t) @@ -261,9 +324,10 @@ Looks in `ledger-accounts-file' if set, otherwise the current buffer." (replace-regexp-in-string "[ \t]*$" "" str)) (defun ledger-fully-complete-xact () - "Completes a transaction if there is another matching payee in the buffer. -Does not use ledger xact" + "Completes a transaction if there is another matching payee in the buffer." (interactive) + (unless (looking-back ledger-payee-any-status-regex (line-beginning-position)) + (user-error "Point is not after payee")) (let* ((name (ledger-trim-trailing-whitespace (caar (ledger-parse-arguments)))) (rest-of-name name) xacts) @@ -277,24 +341,16 @@ Does not use ledger xact" (setq rest-of-name (match-string 3)) ;; Start copying the postings (forward-line) - (while (looking-at ledger-account-any-status-regex) - (setq xacts (cons (buffer-substring-no-properties - (line-beginning-position) - (line-end-position)) - xacts)) - (forward-line)) - (setq xacts (nreverse xacts))))) + (setq xacts (buffer-substring-no-properties (point) (ledger-navigate-end-of-xact)))))) ;; Insert rest-of-name and the postings - (when xacts - (save-excursion - (insert rest-of-name ?\n) - (while xacts - (insert (car xacts) ?\n) - (setq xacts (cdr xacts)))) - (forward-line) - (goto-char (line-end-position)) - (if (re-search-backward "\\(\t\\| [ \t]\\)" nil t) - (goto-char (match-end 0)))))) + (save-excursion + (insert rest-of-name ?\n) + (insert xacts) + (insert ?\n)) + (forward-line) + (goto-char (line-end-position)) + (when (re-search-backward "\\(\t\\| [ \t]\\)" nil t) + (goto-char (match-end 0))))) (provide 'ledger-complete) diff --git a/ledger-context.el b/ledger-context.el index 0a225c5..5400727 100644 --- a/ledger-context.el +++ b/ledger-context.el @@ -53,7 +53,7 @@ (concat (apply 'concat (mapcar 'ledger-get-regex-str elements)) "[ \t]*$")) (defmacro ledger-single-line-config (&rest elements) - "Take list of ELEMENTS and return regex and element list for use in context-at-point" + "Take list of ELEMENTS and return regex and element list for use in context-at-point." `(list (ledger-line-regex (quote ,elements)) (quote ,elements))) (defconst ledger-line-config diff --git a/ledger-flymake.el b/ledger-flymake.el index 182efd7..f4ad5dd 100644 --- a/ledger-flymake.el +++ b/ledger-flymake.el @@ -40,6 +40,7 @@ If --pedantic is in your ledgerrc file, then --pedantic gets passed regardless of the value." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger) (defcustom ledger-flymake-be-explicit nil @@ -47,6 +48,7 @@ passed regardless of the value." If --explicit is in your ledgerrc file, then --explicit gets passed regardless of the value." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger) ;; Based on the example from Flymake's info: diff --git a/ledger-fonts.el b/ledger-fonts.el index 4963e17..b4f9a7b 100644 --- a/ledger-fonts.el +++ b/ledger-fonts.el @@ -457,7 +457,7 @@ UNCLEARED otherwise." "Construct anchored highlighters for subdirectives. Each element of SUBDIRECTIVES should have the form (MATCHER -SUBEXP-HIGHLIGHTERS…). The result will be a list of elements of +SUBEXP-HIGHLIGHTERS…). The result will be a list of elements of the form (MATCHER PRE-FORM POST-FORM SUBEXP-HIGHLIGHTERS) with PRE-FORM and POST-FORM set to appropriate values. diff --git a/ledger-init.el b/ledger-init.el index f5d4c3f..8ce9921 100644 --- a/ledger-init.el +++ b/ledger-init.el @@ -42,6 +42,7 @@ to treat commas as decimal separator.") Set this to the value of `ledger-iso-date-format' if you prefer ISO 8601 dates." :type 'string + :package-version '(ledger-mode . "4.0.0") :group 'ledger) (defconst ledger-iso-date-format "%Y-%m-%d" diff --git a/ledger-mode.el b/ledger-mode.el index bdd1b5e..0e3a305 100644 --- a/ledger-mode.el +++ b/ledger-mode.el @@ -101,16 +101,14 @@ (org-read-date nil t nil prompt)))) (defun ledger-get-minibuffer-prompt (prompt default) - "Return a string composing of PROMPT and DEFAULT appropriate -for a minibuffer prompt." + "Return a string composing of PROMPT and DEFAULT appropriate for a minibuffer prompt." (concat prompt (if default (concat " (" default "): ") ": "))) (defun ledger-completing-read-with-default (prompt default collection) - "Return a user supplied string after PROMPT, or DEFAULT while - providing completions from COLLECTION." + "Return a user supplied string after PROMPT, or DEFAULT while providing completions from COLLECTION." (completing-read (ledger-get-minibuffer-prompt prompt default) collection nil nil nil 'ledger-minibuffer-history default)) @@ -123,7 +121,7 @@ for a minibuffer prompt." "Display the cleared-or-pending balance. And calculate the target-delta of the account being reconciled. -With prefix argument \\[universal-argument] ask for the target commodity and convert +With ARG (\\[universal-argument]) ask for the target commodity and convert the balance into that." (interactive "P") (let* ((account (ledger-read-account-with-prompt "Account balance to show")) diff --git a/ledger-post.el b/ledger-post.el index 982863d..6cfaa7a 100644 --- a/ledger-post.el +++ b/ledger-post.el @@ -56,6 +56,7 @@ decimal separator." "When non-nil, realign post amounts when indenting or completing." :type 'boolean :group 'ledger-post + :package-version '(ledger-mode . "4.0.0") :safe 'booleanp) (defun ledger-next-amount (&optional end) @@ -129,8 +130,8 @@ Looks only as far as END, if supplied, otherwise `point-max'." (defun ledger-indent-line () "Indent the current line." ;; Ensure indent if the previous line was indented - (let ((indent-level (save-excursion (if (progn (when (zerop (forward-line -1)) - (memq (ledger-thing-at-point) '(transaction posting)))) + (let ((indent-level (save-excursion (if (and (zerop (forward-line -1)) + (memq (ledger-thing-at-point) '(transaction posting))) ledger-post-account-alignment-column 0)))) (unless (= (current-indentation) indent-level) diff --git a/ledger-reconcile.el b/ledger-reconcile.el index 4522b21..2b25b91 100644 --- a/ledger-reconcile.el +++ b/ledger-reconcile.el @@ -59,8 +59,9 @@ :group 'ledger-reconcile) (defcustom ledger-buffer-tracks-reconcile-buffer t - "If t, then when the cursor is moved to a new transaction in the reconcile buffer. -Then that transaction will be shown in its source buffer." + "If t, move point in the ledger buffer when it moves in the reconcile buffer. +When the cursor is moved to a new transaction in the reconcile +buffer then that transaction will be shown in its source buffer." :type 'boolean :group 'ledger-reconcile) @@ -77,7 +78,7 @@ reconcile-finish will mark all pending posting cleared." (defcustom ledger-reconcile-default-date-format ledger-default-date-format "Date format for the reconcile buffer. -Default is ledger-default-date-format." +Default is `ledger-default-date-format'." :type 'string :group 'ledger-reconcile) @@ -101,8 +102,8 @@ amount. The format for each field is %WIDTH(FIELD), WIDTH can be preced by a minus sign which mean to left justify and pad the field. WIDTH is the minimum number of characters to display; if string is longer, it is not truncated unless -ledger-reconcile-buffer-payee-max-chars or -ledger-reconcile-buffer-account-max-chars is defined." +`ledger-reconcile-buffer-payee-max-chars' or +`ledger-reconcile-buffer-account-max-chars' is defined." :type 'string :group 'ledger-reconcile) @@ -511,14 +512,14 @@ moved and recentered. If they aren't strange things happen." (pop-to-buffer rbuf))) (defun ledger-reconcile-check-valid-account (account) - "Check to see if ACCOUNT exists in the ledger file" + "Check to see if ACCOUNT exists in the ledger file." (if (> (length account) 0) (save-excursion (goto-char (point-min)) (search-forward account nil t)))) (defun ledger-reconcile (&optional account target) - "Start reconciling, prompt for account." + "Start reconciling, prompt for ACCOUNT." (interactive) (let ((account (or account (ledger-read-account-with-prompt "Account to reconcile"))) (buf (current-buffer)) @@ -560,7 +561,7 @@ moved and recentered. If they aren't strange things happen." (defvar ledger-reconcile-mode-abbrev-table) (defun ledger-reconcile-change-target (&optional target) - "Change the target amount for the reconciliation process." + "Change the TARGET amount for the reconciliation process." (interactive) (setq ledger-target (or target (ledger-read-commodity-string ledger-reconcile-target-prompt-string)))) diff --git a/ledger-regex.el b/ledger-regex.el index 8ac3002..ab8f752 100644 --- a/ledger-regex.el +++ b/ledger-regex.el @@ -19,6 +19,12 @@ ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, ;; MA 02110-1301 USA. + +;;; Commentary: +;; Regular expressions used by ledger-mode. + +;;; Code: + (require 'rx) (require 'cl-lib) @@ -404,3 +410,5 @@ (provide 'ledger-regex) + +;;; ledger-regex.el ends here diff --git a/ledger-report.el b/ledger-report.el index 25f22d9..ed06d8f 100644 --- a/ledger-report.el +++ b/ledger-report.el @@ -98,11 +98,13 @@ simply concatenated (no quoting)." (defcustom ledger-report-use-native-highlighting t "When non-nil, use ledger's native highlighting in reports." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defcustom ledger-report-auto-width t "When non-nil, tell ledger about the width of the report window." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defcustom ledger-report-use-header-line nil @@ -111,29 +113,33 @@ The report name/command won't be printed in the buffer. See `ledger-report-header-line-fn' for how to customize the information reported." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defcustom ledger-report-header-line-fn #'ledger-report--header-function "Evaluate this function in the `header-line' of the report buffer. `ledger-report-use-header-line' must be non-nil for this to have any effect." :type 'function + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defcustom ledger-report-resize-window t "If non-nil, resize the report window. Calls `shrink-window-if-larger-than-buffer'." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defcustom ledger-report-use-strict nil - "Should Ledger-mode pass --strict as a command line parameter -when running reports?" + "When non-nil, `ledger-mode' will use --strict when running reports?" :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defcustom ledger-report-after-report-hook nil "Hook run after `ledger-report' has created the buffer and report." :type 'boolean + :package-version '(ledger-mode . "4.0.0") :group 'ledger-report) (defvar ledger-report-buffer-name "*Ledger Report*") @@ -180,7 +186,7 @@ See documentation for the function `ledger-master-file'") (define-key map [?r] #'ledger-report-redo) (define-key map [(shift ?r)] #'ledger-report-reverse-report) (define-key map [?s] #'ledger-report-save) - (define-key map [(shift ?s)] #'ledger-report-select-report) + (define-key map [(shift ?s)] #'ledger-report) (define-key map [?e] #'ledger-report-edit-report) (define-key map [( shift ?e)] #'ledger-report-edit-reports) (define-key map [?q] #'ledger-report-quit) @@ -201,7 +207,7 @@ See documentation for the function `ledger-master-file'") (easy-menu-define ledger-report-mode-menu ledger-report-mode-map "Ledger report menu" '("Reports" - ["Select Report" ledger-report-select-report] + ["Select Report" ledger-report] ["Save Report" ledger-report-save] ["Edit Current Report" ledger-report-edit-report] ["Edit All Reports" ledger-report-edit-reports] @@ -217,7 +223,8 @@ See documentation for the function `ledger-master-file'") )) (define-derived-mode ledger-report-mode special-mode "Ledger-Report" - "A mode for viewing ledger reports.") + "A mode for viewing ledger reports." + (hack-dir-local-variables-non-file-buffer)) (defconst ledger-report--extra-args-marker "[[ledger-mode-flags]]") @@ -468,7 +475,7 @@ Optionally EDIT the command." 'action (lambda (_button) (ledger-report-visit-source))) (defun ledger-report--change-month (shift) - "Rebuild report with transactions from current month + shift." + "Rebuild report with transactions from current month + SHIFT." (let* ((current-month (or ledger-report-current-month (ledger-report--current-month))) (previous-month (ledger-report--shift-month current-month shift))) (set (make-local-variable 'ledger-report-current-month) previous-month) @@ -481,14 +488,9 @@ Optionally EDIT the command." (let ((file (match-string 1)) (line (string-to-number (match-string 2)))) (delete-region (match-beginning 0) (match-end 0)) - (when file + (when (and file line) (add-text-properties (line-beginning-position) (line-end-position) - (list 'ledger-source (cons file (save-window-excursion - (save-excursion - (find-file file) - (widen) - (ledger-navigate-to-line line) - (point-marker)))))) + (list 'ledger-source (cons file line))) (make-text-button (line-beginning-position) (line-end-position) 'type 'ledger-report-register-entry @@ -537,21 +539,14 @@ arguments returned by `ledger-report--compute-extra-args'." "Visit the transaction under point in the report window." (interactive) (let* ((prop (get-text-property (point) 'ledger-source)) - (file (if prop (car prop))) - (line-or-marker (if prop (cdr prop)))) - (when (and file line-or-marker) + (file (car prop)) + (line (cdr prop))) + (when (and file line) (find-file-other-window file) (widen) - (if (markerp line-or-marker) - (goto-char line-or-marker) - (goto-char (point-min)) - (forward-line (1- line-or-marker)) - (re-search-backward "^[0-9]+") - (beginning-of-line) - (let ((start-of-txn (point))) - (forward-paragraph) - (narrow-to-region start-of-txn (point)) - (backward-paragraph)))))) + (goto-char (point-min)) + (forward-line (1- line)) + (ledger-navigate-beginning-of-xact)))) (defun ledger-report-goto () "Goto the ledger report buffer." @@ -602,12 +597,7 @@ arguments returned by `ledger-report--compute-extra-args'." (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd)) (ledger-report-redo)) -(defun ledger-report-select-report () - "Select and run one of the named reports." - (interactive) - (setq ledger-report-name (ledger-report-read-name) - ledger-report-cmd (ledger-report-cmd ledger-report-name nil)) - (ledger-report-redo)) +(define-obsolete-function-alias 'ledger-report-select-report #'ledger-report "ledger 4.0.0") (defun ledger-report-read-new-name () "Read the name for a new report from the minibuffer." diff --git a/ledger-schedule.el b/ledger-schedule.el index 3a3e0ef..786df0c 100644 --- a/ledger-schedule.el +++ b/ledger-schedule.el @@ -68,9 +68,9 @@ ("Fr" 5) ("Sa" 6) ("Su" 0)) - "List of weekday abbreviations. There must be exactly seven -entries each with a two character abbreviation for a day and the -number of that day in the week. " + "List of weekday abbreviations. +There must be exactly seven entries each with a two character +abbreviation for a day and the number of that day in the week." :type '(alist :value-type (group integer)) :group 'ledger-schedule) @@ -212,7 +212,7 @@ the transaction should be logged for that day." (defun ledger-schedule-constrain-year (year-desc month-desc day-desc) "Return a form that constrains the year. -YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the +YEAR-DESC, MONTH-DESC, and DAY-DESC are the string portions of the date descriptor." (cond ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the year @@ -225,7 +225,7 @@ date descriptor." (defun ledger-schedule-constrain-month (year-desc month-desc day-desc) "Return a form that constrains the month. -YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the +YEAR-DESC, MONTH-DESC, and DAY-DESC are the string portions of the date descriptor." (cond ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the month @@ -243,7 +243,7 @@ date descriptor." (defun ledger-schedule-constrain-day (year-desc month-desc day-desc) "Return a form that constrains the day. -YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the +YEAR-DESC, MONTH-DESC, and DAY-DESC are the string portions of the date descriptor." (cond ((string= day-desc "*") t) diff --git a/ledger-texi.el b/ledger-texi.el index 7661d91..45eb281 100644 --- a/ledger-texi.el +++ b/ledger-texi.el @@ -18,6 +18,10 @@ ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, ;; MA 02110-1301 USA. + +;;; Commentary: +;; + ;;; Code: (defvar ledger-binary-path) @@ -26,12 +30,12 @@ :group 'ledger) (defcustom ledger-texi-sample-doc-path "~/ledger/doc/sample.dat" - "Location for sample data to be used in texi tests" + "Location for sample data to be used in texi tests." :type 'file :group 'ledger-texi) (defcustom ledger-texi-normalization-args "--args-only --columns 80" - "texi normalization for producing ledger output" + "Texi normalization for producing ledger output." :type 'string :group 'ledger-texi) @@ -171,3 +175,5 @@ "../test/manual"))))) (provide 'ledger-texi) + +;;; ledger-texi.el ends here diff --git a/test/complete-test.el b/test/complete-test.el index d5082ce..c02f4ca 100644 --- a/test/complete-test.el +++ b/test/complete-test.el @@ -164,6 +164,26 @@ account Expenses:The Bakery (list "Expenses:The Bakery")))))) +(ert-deftest ledger-complete/test-ledger-accounts-exclude-function () + ;; TODO: Why doesn't this work in batch? + :tags '(interactive) + (with-temp-buffer + (insert "account Assets:Checking:Bank A + assert date<=[1990-01-01] +account Assets:Checking:Bank B") + (let ((ledger-accounts-exclude-function + (lambda (i) "Exclude all entries with a subdirective." + (cdr i)))) + (should (equal (ledger-accounts-list-in-buffer) + (list "Assets:Checking:Bank B")))) + (let ((ledger-accounts-exclude-function (lambda (_) t))) + (should (equal (ledger-accounts-list-in-buffer) + nil))) + (let ((ledger-accounts-exclude-function (lambda (_) nil))) + (should (equal (ledger-accounts-list-in-buffer) + (list "Assets:Checking:Bank A" + "Assets:Checking:Bank B")))))) + (provide 'complete-test) ;;; complete-test.el ends here diff --git a/tools/default.nix b/tools/default.nix new file mode 100644 index 0000000..68fec02 --- /dev/null +++ b/tools/default.nix @@ -0,0 +1,14 @@ +{ pkgs ? import <nixpkgs> {} }: + +let + ledgerFromGit = builtins.fetchGit { url = git://github.com/ledger/ledger; }; +in +{ + stable = pkgs.ledger; + + snapshot = (pkgs.callPackage ledgerFromGit {}) + .overrideAttrs(a: { + doCheck = false; + cmakeFlags = a.cmakeFlags ++ [ "-DCMAKE_INSTALL_MANDIR=share/man" ]; + }); +} |