From 61f45b7d29f21a12600771a78b294e6912d033f2 Mon Sep 17 00:00:00 2001 From: "Aaron L. Zeng" Date: Tue, 9 Jun 2026 23:34:43 -0400 Subject: [PATCH 1/2] Replace ledger-get-minibuffer-prompt with built-in format-prompt --- README.md | 3 +++ flake.nix | 1 + ledger-mode.el | 14 ++++---------- tools/lint.el | 4 ++++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c0641ae5..ea61ab78 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ packages in [MELPA][melpa] or [MELPA Stable][melpa-stable], you'll need to add the directory containing `ledger-mode.el` to your `load-path`, and then `(require 'ledger-mode)`. +You will also need to have the `compat` package installed, at version 28.1 or +newer. + Configuring completion ====================== diff --git a/flake.nix b/flake.nix index 6159adcd..a59103b8 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,7 @@ package-lint elisp-autofmt undercover + compat ] ); diff --git a/ledger-mode.el b/ledger-mode.el index ee77f1d2..0997ecda 100644 --- a/ledger-mode.el +++ b/ledger-mode.el @@ -5,7 +5,7 @@ ;; This file is not part of GNU Emacs. ;; Version: 4.1.0 -;; Package-Requires: ((emacs "26.1")) +;; Package-Requires: ((emacs "26.1") (compat "28.1")) ;; URL: https://github.com/ledger/ledger-mode ;; This is free software; you can redistribute it and/or modify it under @@ -32,6 +32,7 @@ ;;; Code: +(require 'compat) (require 'ledger-regex) (require 'org) (require 'ledger-commodities) @@ -111,22 +112,15 @@ This uses `org-read-date', which see." (ledger-format-date (let ((org-read-date-prefer-future nil)) (org-read-date nil t nil prompt)))) -(defun ledger-get-minibuffer-prompt (prompt default) - "Return a minibuffer prompt string composing PROMPT and DEFAULT." - (concat prompt - (if default - (concat " (" default "): ") - ": "))) - (defun ledger-completing-read-with-default (prompt default collection) "Return a user-supplied string after PROMPT. Use the given DEFAULT, while providing completions from COLLECTION." - (completing-read (ledger-get-minibuffer-prompt prompt default) + (completing-read (format-prompt prompt default) collection nil nil nil 'ledger-minibuffer-history default)) (defun ledger-read-string-with-default (prompt default) "Return user supplied string after PROMPT, or DEFAULT." - (read-string (ledger-get-minibuffer-prompt prompt default) + (read-string (format-prompt prompt default) nil 'ledger-minibuffer-history default)) (defun ledger-display-balance-at-point (&optional arg) diff --git a/tools/lint.el b/tools/lint.el index 76bad1be..c9aef17b 100644 --- a/tools/lint.el +++ b/tools/lint.el @@ -18,6 +18,10 @@ ;;; Code: +;; Required for `package-lint' to find installed `compat' package and not warn +;; about the dependency. +(package-activate-all) + (require 'package-lint nil t) (require 'checkdoc) From 0f6fddabed998b17b4e8e40c76e804343fab8287 Mon Sep 17 00:00:00 2001 From: "Aaron L. Zeng" Date: Fri, 12 Jun 2026 15:07:14 -0400 Subject: [PATCH 2/2] Install compat package in CI workflow --- .github/workflows/test.yml | 5 ++++- test/Makefile | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5081e3d4..91940532 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,10 +45,13 @@ jobs: - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} + - name: Install compat + run: emacs --batch -f package-initialize -f package-refresh-contents --eval "(package-install 'compat)" - uses: actions/checkout@v6 - name: Byte compilation - run: emacs --eval "(setq byte-compile-error-on-warn t)" -L . --batch -f batch-byte-compile ./*.el + # package-activate-all is not available until Emacs 27 + run: emacs --eval "(setq byte-compile-error-on-warn t)" -L . --batch -f package-initialize -f batch-byte-compile ./*.el - name: Tests run: nix shell ${{ matrix.ledger_version || 'nixpkgs#ledger' }} --print-build-logs -c make -C test # This is currently for information only, since a lot of docstrings need fixing up diff --git a/test/Makefile b/test/Makefile index cc722f66..30d13c17 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,6 @@ EMACS ?= emacs -EMACS_FLAGS = --quick --directory . --directory .. +# package-activate-all is not available until Emacs 27 +EMACS_FLAGS = --quick --directory . --directory .. -f package-initialize EMACS_BATCH = "$(EMACS)" --batch $(EMACS_FLAGS) EMACS_INTERACTIVE = "$(EMACS)" $(EMACS_FLAGS)