Skip to content

Commit ba24131

Browse files
committed
Pacify Emacs 31 compiler warnings
* doom-modeline-core.el (doom-modeline-set-modeline) (doom-modeline-propertize-icon, doom-modeline--project-root) (doom-modeline--buffer-file-name): * doom-modeline-env.el (doom-modeline-env--get): * doom-modeline-segments.el (doom-modeline--buffer-mode-icon) (doom-modeline--buffer-state-icon, doom-modeline--buffer-name) (calc, remote-host, check, workspace-name, input-method, repl) (lsp, doom-modeline--debug-dap): Use `when-let*' instead of in Emacs 31 deprecated `when-let'.
1 parent ec6bc00 commit ba24131

File tree

3 files changed

+60
-60
lines changed

3 files changed

+60
-60
lines changed

doom-modeline-core.el

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ Throws an error if it doesn't exist."
13091309
(defun doom-modeline-set-modeline (key &optional default)
13101310
"Set the modeline format. Does nothing if the modeline KEY doesn't exist.
13111311
If DEFAULT is non-nil, set the default mode-line for all buffers."
1312-
(when-let ((modeline (doom-modeline key)))
1312+
(when-let* ((modeline (doom-modeline key)))
13131313
(setf (if default
13141314
(default-value 'mode-line-format)
13151315
mode-line-format)
@@ -1391,12 +1391,12 @@ So convert the face \":family XXX :height XXX :inherit XXX\" to
13911391
See https://github.com/seagle0128/doom-modeline/issues/301."
13921392
(when icon
13931393
(if (doom-modeline-icon-displayable-p)
1394-
(when-let ((props (get-text-property 0 'face icon)))
1394+
(when-let* ((props (get-text-property 0 'face icon)))
13951395
(when (listp props)
13961396
(cl-destructuring-bind (&key family height inherit &allow-other-keys) props
13971397
(propertize icon 'face `(:inherit (doom-modeline ,(or face inherit props))
1398-
:family ,(or family "")
1399-
:height ,(or height 1.0))))))
1398+
:family ,(or family "")
1399+
:height ,(or height 1.0))))))
14001400
(propertize icon 'face `(:inherit (doom-modeline ,face))))))
14011401

14021402
(defun doom-modeline-icon (icon-set icon-name unicode text &rest args)
@@ -1529,7 +1529,7 @@ Return nil if no project was found."
15291529
(projectile-project-root))
15301530
((and (memq doom-modeline-project-detection '(auto project))
15311531
(fboundp 'project-current))
1532-
(when-let ((project (project-current)))
1532+
(when-let* ((project (project-current)))
15331533
(expand-file-name
15341534
(if (fboundp 'project-root)
15351535
(project-root project)
@@ -1681,8 +1681,8 @@ Example:
16811681
(concat
16821682
;; Project root parent
16831683
(unless hide-project-root-parent
1684-
(when-let (root-path-parent
1685-
(file-name-directory (directory-file-name project-root)))
1684+
(when-let* ((root-path-parent
1685+
(file-name-directory (directory-file-name project-root))))
16861686
(propertize
16871687
(if (and truncate-project-root-parent
16881688
(not (string-empty-p root-path-parent))
@@ -1696,12 +1696,12 @@ Example:
16961696
'face 'doom-modeline-project-dir)
16971697
;; relative path
16981698
(propertize
1699-
(when-let (relative-path (file-relative-name
1700-
(or (file-name-directory
1701-
(if doom-modeline-buffer-file-true-name
1702-
true-file-path file-path))
1703-
"./")
1704-
project-root))
1699+
(when-let* ((relative-path (file-relative-name
1700+
(or (file-name-directory
1701+
(if doom-modeline-buffer-file-true-name
1702+
true-file-path file-path))
1703+
"./")
1704+
project-root)))
17051705
(if (string= relative-path "./")
17061706
""
17071707
(if truncate-project-relative-path

doom-modeline-env.el

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ Example:
119119
\\='(\"--version\")
120120
(lambda (line)
121121
(message (doom-modeline-parser--ruby line)))"
122-
(when-let ((proc (ignore-errors
123-
(apply 'start-process
124-
;; Flaten process-args into a single list so we can handle
125-
;; variadic length args
126-
(append
127-
(list "doom-modeline-env" nil prog)
128-
args))))
129-
(parser callback))
122+
(when-let* ((proc (ignore-errors
123+
(apply 'start-process
124+
;; Flaten process-args into a single list so we can handle
125+
;; variadic length args
126+
(append
127+
(list "doom-modeline-env" nil prog)
128+
args))))
129+
(parser callback))
130130
(set-process-filter proc
131131
(lambda (_proc line)
132132
(ignore-errors

doom-modeline-segments.el

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ mouse-1: Previous buffer\nmouse-3: Next buffer"
373373
(defsubst doom-modeline--buffer-mode-icon ()
374374
"The icon of the current major mode."
375375
(when (and doom-modeline-icon doom-modeline-major-mode-icon)
376-
(when-let ((icon (or doom-modeline--buffer-file-icon
377-
(doom-modeline-update-buffer-file-icon))))
376+
(when-let* ((icon (or doom-modeline--buffer-file-icon
377+
(doom-modeline-update-buffer-file-icon))))
378378
(unless (string-empty-p icon)
379379
(concat
380380
(if doom-modeline-major-mode-color-icon
@@ -387,7 +387,7 @@ mouse-1: Previous buffer\nmouse-3: Next buffer"
387387
(defsubst doom-modeline--buffer-state-icon ()
388388
"The icon of the current buffer state."
389389
(when doom-modeline-buffer-state-icon
390-
(when-let ((icon (doom-modeline-update-buffer-file-state-icon)))
390+
(when-let* ((icon (doom-modeline-update-buffer-file-state-icon)))
391391
(unless (string-empty-p icon)
392392
(concat
393393
(doom-modeline-display-icon icon)
@@ -414,8 +414,8 @@ mouse-1: Previous buffer\nmouse-3: Next buffer"
414414
;; Only display the buffer name if the window is small, and doesn't
415415
;; need to respect file-name style.
416416
(doom-modeline--buffer-simple-name)
417-
(when-let ((name (or doom-modeline--buffer-file-name
418-
(doom-modeline-update-buffer-file-name))))
417+
(when-let* ((name (or doom-modeline--buffer-file-name
418+
(doom-modeline-update-buffer-file-name))))
419419
;; Check if the buffer is modified
420420
(if (and doom-modeline-highlight-modified-buffer-name
421421
(buffer-modified-p))
@@ -445,7 +445,7 @@ read-only or non-existent)."
445445
"Display calculator icons and info."
446446
(concat
447447
(doom-modeline-spc)
448-
(when-let ((icon (doom-modeline-icon 'faicon "nf-fa-calculator" "🖩" "")))
448+
(when-let* ((icon (doom-modeline-icon 'faicon "nf-fa-calculator" "🖩" "")))
449449
(concat
450450
(doom-modeline-display-icon icon)
451451
(doom-modeline-vspc)))
@@ -573,7 +573,7 @@ project directory is important."
573573
(doom-modeline-def-segment remote-host
574574
"Hostname for remote buffers."
575575
(when default-directory
576-
(when-let ((host (file-remote-p default-directory 'host)))
576+
(when-let* ((host (file-remote-p default-directory 'host)))
577577
(propertize
578578
(concat "@" host)
579579
'face (doom-modeline-face 'doom-modeline-host)))))
@@ -1029,15 +1029,15 @@ level."
10291029

10301030
(doom-modeline-def-segment check
10311031
"Displays color-coded error status in the current buffer with pretty icons."
1032-
(when-let ((sep (doom-modeline-spc))
1033-
(vsep (doom-modeline-vspc))
1034-
(seg (cond
1035-
((and (bound-and-true-p flymake-mode)
1036-
(bound-and-true-p flymake--state)) ; only support 26+
1037-
doom-modeline--flymake)
1038-
((and (bound-and-true-p flycheck-mode)
1039-
(bound-and-true-p flycheck--automatically-enabled-checkers))
1040-
doom-modeline--flycheck))))
1032+
(when-let* ((sep (doom-modeline-spc))
1033+
(vsep (doom-modeline-vspc))
1034+
(seg (cond
1035+
((and (bound-and-true-p flymake-mode)
1036+
(bound-and-true-p flymake--state)) ; only support 26+
1037+
doom-modeline--flymake)
1038+
((and (bound-and-true-p flycheck-mode)
1039+
(bound-and-true-p flycheck--automatically-enabled-checkers))
1040+
doom-modeline--flycheck))))
10411041
(concat
10421042
sep
10431043
(let ((str))
@@ -1525,7 +1525,7 @@ one. The ignored buffers are excluded unless `aw-ignore-on' is nil."
15251525
"The current workspace name or number.
15261526
Requires `eyebrowse-mode' to be enabled or `tab-bar-mode' tabs to be created."
15271527
(when doom-modeline-workspace-name
1528-
(when-let
1528+
(when-let*
15291529
((name (cond
15301530
((and (bound-and-true-p eyebrowse-mode)
15311531
(length> (eyebrowse--get 'window-configs) 1))
@@ -1873,14 +1873,14 @@ Including `evil', `overwrite', `god', `ryo' and `xha-fly-kyes', etc."
18731873

18741874
(doom-modeline-def-segment input-method
18751875
"The current input method."
1876-
(when-let ((im (cond
1877-
(current-input-method
1878-
current-input-method-title)
1879-
((and (bound-and-true-p evil-local-mode)
1880-
(bound-and-true-p evil-input-method))
1881-
(nth 3 (assoc default-input-method input-method-alist)))
1882-
(t nil)))
1883-
(sep (doom-modeline-spc)))
1876+
(when-let* ((im (cond
1877+
(current-input-method
1878+
current-input-method-title)
1879+
((and (bound-and-true-p evil-local-mode)
1880+
(bound-and-true-p evil-input-method))
1881+
(nth 3 (assoc default-input-method input-method-alist)))
1882+
(t nil)))
1883+
(sep (doom-modeline-spc)))
18841884
(concat
18851885
sep
18861886
(propertize im
@@ -1971,9 +1971,9 @@ mouse-3: Describe current input method")
19711971
(doom-modeline-def-segment repl
19721972
"The REPL state."
19731973
(when doom-modeline-repl
1974-
(when-let ((icon (when (bound-and-true-p cider-mode)
1975-
doom-modeline--cider))
1976-
(sep (doom-modeline-spc)))
1974+
(when-let* ((icon (when (bound-and-true-p cider-mode)
1975+
doom-modeline--cider))
1976+
(sep (doom-modeline-spc)))
19771977
(concat
19781978
sep
19791979
(doom-modeline-display-icon icon)
@@ -2121,13 +2121,13 @@ mouse-1: Toggle citre mode"
21212121
(doom-modeline-def-segment lsp
21222122
"The LSP server state."
21232123
(when doom-modeline-lsp
2124-
(when-let ((icon (cond ((bound-and-true-p lsp-mode)
2125-
doom-modeline--lsp)
2126-
((bound-and-true-p eglot--managed-mode)
2127-
doom-modeline--eglot)
2128-
((bound-and-true-p citre-mode)
2129-
doom-modeline--tags)))
2130-
(sep (doom-modeline-spc)))
2124+
(when-let* ((icon (cond ((bound-and-true-p lsp-mode)
2125+
doom-modeline--lsp)
2126+
((bound-and-true-p eglot--managed-mode)
2127+
doom-modeline--eglot)
2128+
((bound-and-true-p citre-mode)
2129+
doom-modeline--tags)))
2130+
(sep (doom-modeline-spc)))
21312131
(concat
21322132
sep
21332133
(doom-modeline-display-icon icon)
@@ -2289,7 +2289,7 @@ mouse-3: Fetch notifications"
22892289
"The current `dap-mode' state."
22902290
(when (and (bound-and-true-p dap-mode)
22912291
(bound-and-true-p lsp-mode))
2292-
(when-let ((session (dap--cur-session)))
2292+
(when-let* ((session (dap--cur-session)))
22932293
(when (dap--session-running session)
22942294
(propertize (doom-modeline-debug-icon 'doom-modeline-info)
22952295
'help-echo (format "DAP (%s - %s)
@@ -2301,11 +2301,11 @@ mouse-3: Disconnect session"
23012301
'mouse-face 'doom-modeline-highlight
23022302
'local-map (let ((map (make-sparse-keymap)))
23032303
(define-key map [mode-line mouse-1]
2304-
#'dap-hydra)
2304+
#'dap-hydra)
23052305
(define-key map [mode-line mouse-2]
2306-
#'dap-debug-recent)
2306+
#'dap-debug-recent)
23072307
(define-key map [mode-line mouse-3]
2308-
#'dap-disconnect)
2308+
#'dap-disconnect)
23092309
map))))))
23102310

23112311
(defvar-local doom-modeline--debug-dap nil)

0 commit comments

Comments
 (0)