Skip to content

Commit 6851325

Browse files
authored
Merge pull request #454 from ledger/fix-emacs-30.1-bytecomp-when-let
Fix deprecated use of when-let, and drop Emacs 25 support
2 parents d9b6648 + 9440bab commit 6851325

File tree

9 files changed

+26
-34
lines changed

9 files changed

+26
-34
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest]
18-
emacs_version: [25.1, 25.2, 25.3, 26.1, 26.2, 26.3, 27.1, 27.2, 28.1, 28.2, 29.1, 29.3, 30.1, snapshot]
18+
emacs_version: [26.1, 26.2, 26.3, 27.1, 27.2, 28.1, 28.2, 29.1, 29.3, 30.1, snapshot]
1919
experimental: [false]
2020

2121
# Exclude Emacs versions that are unavailable on Apple Silicon
2222
exclude:
23-
- emacs_version: 25.1
24-
os: macos-latest
25-
- emacs_version: 25.2
26-
os: macos-latest
27-
- emacs_version: 25.3
28-
os: macos-latest
2923
- emacs_version: 26.1
3024
os: macos-latest
3125
- emacs_version: 26.2
@@ -53,10 +47,8 @@ jobs:
5347
version: ${{ matrix.emacs_version }}
5448

5549
- uses: actions/checkout@v4
56-
# Byte compilation is known to fail in Emacs < 26.1 due to ledger-flymake.el, which should
57-
# be packaged separately
5850
- name: Byte compilation
59-
run: emacs --eval "(setq byte-compile-error-on-warn (>= emacs-major-version 26))" -L . --batch -f batch-byte-compile ./*.el
51+
run: emacs --eval "(setq byte-compile-error-on-warn t)" -L . --batch -f batch-byte-compile ./*.el
6052
- name: Tests
6153
run: nix shell ${{ matrix.ledger_version || 'nixpkgs#ledger' }} --print-build-logs -c make -C test
6254
# This is currently for information only, since a lot of docstrings need fixing up

ledger-mode.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
;; This file is not part of GNU Emacs.
66

7-
;; Package-Requires: ((emacs "25.1"))
7+
;; Package-Requires: ((emacs "26.1"))
88

99
;; This is free software; you can redistribute it and/or modify it under
1010
;; the terms of the GNU General Public License as published by the Free
@@ -99,7 +99,7 @@
9999
(defun ledger-read-payee-with-prompt (prompt)
100100
"Read a payee from the minibuffer with PROMPT."
101101
(ledger-completing-read-with-default prompt
102-
(when-let ((payee (ledger-xact-payee)))
102+
(when-let* ((payee (ledger-xact-payee)))
103103
(regexp-quote payee))
104104
(ledger-payees-list)))
105105

ledger-occur.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ Argument OVL-BOUNDS contains bounds for the transactions to be left visible."
150150
;; Search loop
151151
(while (not (eobp))
152152
;; if something found
153-
(when-let ((endpoint (re-search-forward regex nil 'end))
154-
(bounds (ledger-navigate-find-element-extents endpoint)))
153+
(when-let* ((endpoint (re-search-forward regex nil 'end))
154+
(bounds (ledger-navigate-find-element-extents endpoint)))
155155
(push bounds lines)
156156
;; move to the end of the xact, no need to search inside it more
157157
(goto-char (cadr bounds))))

ledger-post.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Error if the commodities do not match."
210210
(cl-loop
211211
while (re-search-forward ledger-post-line-regexp end t)
212212
for account-end = (match-end ledger-regex-post-line-group-account)
213-
for amount-string = (when-let ((amount-string (match-string ledger-regex-post-line-group-amount)))
213+
for amount-string = (when-let* ((amount-string (match-string ledger-regex-post-line-group-amount)))
214214
(unless (string-empty-p (string-trim amount-string))
215215
amount-string))
216216
if (not amount-string)

ledger-reconcile.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ described above."
221221
"Display the cleared-or-pending balance.
222222
And calculate the target-delta of the account being reconciled."
223223
(interactive)
224-
(when-let (pending (ledger-reconcile-get-cleared-or-pending-balance ledger-reconcile-ledger-buf ledger-reconcile-account))
224+
(when-let* ((pending (ledger-reconcile-get-cleared-or-pending-balance ledger-reconcile-ledger-buf ledger-reconcile-account)))
225225
(let ((message
226-
(if-let (diff (and ledger-reconcile-target (ledger-subtract-commodity ledger-reconcile-target pending)))
226+
(if-let* ((diff (and ledger-reconcile-target (ledger-subtract-commodity ledger-reconcile-target pending))))
227227
(progn
228228
(setq ledger-reconcile-last-balance-equals-target (zerop (car diff)))
229229
(format-message "Cleared and Pending balance: %s, Difference from target: %s"

ledger-report.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ called in the ledger buffer for which the report is being run."
432432
(with-temp-buffer
433433
(save-excursion (insert report-cmd))
434434
(while (re-search-forward "%(\\([^)]*\\))" nil t)
435-
(when-let ((specifier (match-string 1))
436-
(f (cdr (assoc specifier ledger-report-format-specifiers))))
435+
(when-let* ((specifier (match-string 1))
436+
(f (cdr (assoc specifier ledger-report-format-specifiers))))
437437
(let* ((arg (save-match-data
438438
(with-current-buffer ledger-buf
439439
(funcall f))))
@@ -442,7 +442,7 @@ called in the ledger buffer for which the report is being run."
442442
(string-join arg " ")
443443
(shell-quote-argument arg)))))
444444
(replace-match quoted 'fixedcase 'literal))))
445-
(buffer-string))))
445+
(buffer-string))))
446446

447447
(defun ledger-report--cmd-needs-links-p (cmd)
448448
"Check links should be added to the report produced by CMD."
@@ -632,7 +632,7 @@ IGNORE-AUTO and NOCONFIRM are for compatibility with
632632
(when (string-empty-p ledger-report-name)
633633
(setq ledger-report-name (ledger-report-read-new-name)))
634634

635-
(when-let ((existing-name (ledger-report-name-exists ledger-report-name)))
635+
(when-let* ((existing-name (ledger-report-name-exists ledger-report-name)))
636636
(cond ((y-or-n-p (format "Overwrite existing report named '%s'? "
637637
ledger-report-name))
638638
(if (string-equal

ledger-schedule.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ COUNT 0) means EVERY day-of-week (eg. every Saturday)"
103103
(cond ((zerop count) ;; Return true if day-of-week matches
104104
`(eq (nth 6 (decode-time date)) ,day-of-week))
105105
((> count 0) ;; Positive count
106-
(let ((decoded (cl-gensym)))
106+
(let ((decoded (gensym)))
107107
`(let ((,decoded (decode-time date)))
108108
(and (eq (nth 6 ,decoded) ,day-of-week)
109109
(<= ,(* (1- count) 7)
110110
(nth 3 ,decoded)
111111
,(* count 7))))))
112112
((< count 0)
113-
(let ((days-in-month (cl-gensym))
114-
(decoded (cl-gensym)))
113+
(let ((days-in-month (gensym))
114+
(decoded (gensym)))
115115
`(let* ((,decoded (decode-time date))
116116
(,days-in-month (ledger-schedule-days-in-month
117117
(nth 4 ,decoded)
@@ -138,9 +138,9 @@ For example every second Friday, regardless of month."
138138
(defun ledger-schedule-constrain-date-range (month1 day1 month2 day2)
139139
"Return a form of DATE that is true if DATE falls between two dates.
140140
The dates are given by the pairs MONTH1 DAY1 and MONTH2 DAY2."
141-
(let ((decoded (cl-gensym))
142-
(target-month (cl-gensym))
143-
(target-day (cl-gensym)))
141+
(let ((decoded (gensym))
142+
(target-month (gensym))
143+
(target-day (gensym)))
144144
`(let* ((,decoded (decode-time date))
145145
(,target-month (nth 4 decoded))
146146
(,target-day (nth 3 decoded)))

ledger-xact.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ When nil, `ledger-add-transaction' will not prompt twice."
8585

8686
(defun ledger-xact-payee ()
8787
"Return the payee of the transaction containing point or nil."
88-
(when-let ((xact-context (ledger-xact-context)))
88+
(when-let* ((xact-context (ledger-xact-context)))
8989
(ledger-context-field-value xact-context 'payee)))
9090

9191
(defun ledger-xact-date ()
9292
"Return the date of the transaction containing point or nil."
93-
(when-let ((xact-context (ledger-xact-context)))
93+
(when-let* ((xact-context (ledger-xact-context)))
9494
(ledger-context-field-value xact-context 'date)))
9595

9696
(defun ledger-xact-find-slot (moment)
@@ -117,7 +117,7 @@ MOMENT is an encoded date"
117117
(current-year (nth 5 (decode-time now))))
118118
(while (not (eobp))
119119
(when (looking-at ledger-iterate-regexp)
120-
(if-let ((year (match-string 1)))
120+
(if-let* ((year (match-string 1)))
121121
(setq current-year (string-to-number year)) ;a Y directive was found
122122
(let ((start (match-beginning 0))
123123
(year (match-string (+ ledger-regex-iterate-group-actual-date 1)))

test/regex-test.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
;; Add symbols in reverse so they are sorted in the correct order as we
8080
;; prepend them.
8181
(dolist (symbol (reverse regex-test--all-ledger-regex-symbols))
82-
(when-let (name (seq-find (lambda (name)
83-
(string-prefix-p (concat "ledger-regex-" name "-")
84-
(symbol-name symbol)))
85-
reverse-names))
82+
(when-let* ((name (seq-find (lambda (name)
83+
(string-prefix-p (concat "ledger-regex-" name "-")
84+
(symbol-name symbol)))
85+
reverse-names)))
8686
(puthash name
8787
(cons symbol (gethash name hash-table)) hash-table)))
8888
hash-table)

0 commit comments

Comments
 (0)