refactor: s/when-let/when-let*/

The former is deprecated on Emacs 31 for the latter.
This commit is contained in:
Henrik Lissner 2026-03-09 03:25:16 -04:00
parent 0b1de48daa
commit 4fe1cbeddb
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
70 changed files with 210 additions and 210 deletions

View file

@ -297,7 +297,7 @@ SEE ALSO:
(defcli-group! "Module commands"
(with-doom-context 'module
(dolist (key (doom-module-list))
(when-let (path (doom-module-locate-path key cli-file))
(when-let* ((path (doom-module-locate-path key cli-file)))
(defcli-group! :prefix (if (cdr key) (format "+%s" (cdr key)))
(doom-load (file-name-sans-extension path))))))))

View file

@ -198,7 +198,7 @@ Each element of this list can be one of:
(string-match-p " " value))
(fail! "Found %S, but only one value allowed per trailer"
(truncate-string-to-width (concat key ": " value) 20 nil nil ""))
(when-let (allowed-types (cdr (assoc key doom-ci-commit-trailer-keys)))
(when-let* ((allowed-types (cdr (assoc key doom-ci-commit-trailer-keys))))
(or (cl-loop for type in allowed-types
if (cdr (assq type doom-ci-commit-trailer-types))
if (string-match-p it value)

View file

@ -236,7 +236,7 @@ in."
;; Check for oversized problem files in cache that may cause unusual/tremendous
;; delays or freezing. This shouldn't happen often.
(dolist (file (list "savehist" "projectile.cache"))
(when-let (size (ignore-errors (doom-file-size file doom-cache-dir)))
(when-let* ((size (ignore-errors (doom-file-size file doom-cache-dir))))
(when (> size 1048576) ; larger than 1mb
(warn! "%s is too large (%.02fmb). This may cause freezes or odd startup delays"
file (/ size 1024 1024.0))

View file

@ -87,7 +87,7 @@ libraries. It is the equivalent of the following shell commands:
"Couldn't detect what branch you're on. Is Doom detached?")))
;; We assume that a dirty .emacs.d is intentional and abort
(when-let (dirty (doom-upgrade--working-tree-dirty-p default-directory))
(when-let* ((dirty (doom-upgrade--working-tree-dirty-p default-directory)))
(if (not force-p)
(user-error "%s\n\n%s\n\n %s"
(format "Refusing to upgrade because %S has been modified."

View file

@ -13,7 +13,7 @@
:group 'doom)
(defcustom doom-cli-load-path
(append (when-let ((doompath (getenv "DOOMPATH")))
(append (when-let* ((doompath (getenv "DOOMPATH")))
(cl-loop for dir in (split-string doompath path-separator)
collect (expand-file-name dir)))
(list (file-name-concat (dir!) "cli")))
@ -354,9 +354,9 @@ Returned in the order they will execute. Includes pseudo CLIs."
(push (cons :before path) results))
(push '(:before) results)
(dolist (result results (nreverse clis))
(when-let ((cli (doom-cli-get result t))
((or (not nopartials?)
(doom-cli-type cli))))
(when-let* ((cli (doom-cli-get result t))
((or (not nopartials?)
(doom-cli-type cli))))
(cl-pushnew cli clis
:test #'equal
:key #'doom-cli-key)))))
@ -432,9 +432,9 @@ Return nil if CLI (a `doom-cli') has no explicit documentation."
;; Populate options
(let ((options (doom-cli-context-options context)))
(dolist (opt optspec)
(when-let (option (cl-loop for flag in (doom-cli-option-switches opt)
if (cdr (assoc flag options))
return (cons flag it)))
(when-let* ((option (cl-loop for flag in (doom-cli-option-switches opt)
if (cdr (assoc flag options))
return (cons flag it))))
(unless (member (car option) seen)
(setf (alist-get (doom-cli-option-symbol opt) alist)
(cdr option))
@ -467,7 +467,7 @@ Return nil if CLI (a `doom-cli') has no explicit documentation."
(buffer-string))))
(&rest . ,rest)
(&whole . ,(doom-cli-context-whole context))))
(when-let (var (car (alist-get (car type) argspec)))
(when-let* ((var (car (alist-get (car type) argspec))))
(setf (alist-get var alist) (cdr type)))))
alist))
@ -728,9 +728,9 @@ executable context."
"Restore the last restarted context from FILE into CONTEXT."
(when (and (stringp file)
(file-exists-p file))
(when-let (old-context (with-temp-buffer
(insert-file-contents file)
(read (current-buffer))))
(when-let* ((old-context (with-temp-buffer
(insert-file-contents file)
(read (current-buffer)))))
(unless (doom-cli-context-p old-context)
(error "An invalid context was restored from file: %s" file))
(unless (equal (doom-cli-context-prefix context)
@ -1022,7 +1022,7 @@ considered as well."
doom-print-indent
1)
"..."))))
(when-let (backtrace-file (doom-backtrace-write-to-file backtrace error-file))
(when-let* ((backtrace-file (doom-backtrace-write-to-file backtrace error-file)))
(print! (warn "Wrote extended backtrace to %s")
(path backtrace-file))))))))
(exit! 255)))
@ -2291,7 +2291,7 @@ The alist's CAR are lists of formatted switches plus their arguments, e.g.
else collect (list (format strfmt switch)))
(string-join
(or (delq
nil (cons (when-let (docs (doom-cli-option-docs option))
nil (cons (when-let* ((docs (doom-cli-option-docs option)))
(concat docs "."))
(cl-loop for (flags . docs) in docs
unless (equal (seq-difference flags switches) flags)
@ -2350,7 +2350,7 @@ The alist's CAR are lists of formatted switches plus their arguments, e.g.
(cl-check-type section-name string)
(let (alist)
(dolist (cli cli-list (nreverse alist))
(when-let (section (cdr (assoc section-name (doom-cli-docs cli))))
(when-let* ((section (cdr (assoc section-name (doom-cli-docs cli)))))
(with-temp-buffer
(save-excursion (insert section))
(let ((lead (current-indentation))

View file

@ -396,7 +396,7 @@ files, so this replace calls to `pp' with the much faster `prin1'."
:after-call doom-first-input-hook doom-first-file-hook focus-out-hook
:defer 1
:config
(when-let (name (getenv "EMACS_SERVER_NAME"))
(when-let* ((name (getenv "EMACS_SERVER_NAME")))
(setq server-name name))
(unless (server-running-p)
(server-start)))

View file

@ -63,7 +63,7 @@ and Emacs states, and for non-evil users.")
([C-m] [?\C-m] return kp-return)))
(define-key
input-decode-map fallback
(cmd! (if (when-let ((keys (this-single-command-raw-keys)))
(cmd! (if (when-let* ((keys (this-single-command-raw-keys)))
(and (display-graphic-p)
(not (cl-loop for event in events
if (cl-position event keys)
@ -159,7 +159,7 @@ all hooks after it are ignored.")
(push `(define-key doom-leader-map (general--kbd ,key)
,bdef)
forms))
(when-let (desc (cadr (memq :which-key udef)))
(when-let* ((desc (cadr (memq :which-key udef))))
(cl-callf2 append
`((which-key-add-key-based-replacements
(general--concat t doom-leader-alt-key ,key)

View file

@ -227,7 +227,7 @@ unreadable. Returns the names of envvars that were changed."
(signal 'file-error (list "No envvar file exists" file)))
(with-temp-buffer
(insert-file-contents file)
(when-let (env (read (current-buffer)))
(when-let* ((env (read (current-buffer))))
(let ((tz (getenv-internal "TZ")))
(setq-default
process-environment
@ -238,7 +238,7 @@ unreadable. Returns the names of envvars that were changed."
shell-file-name
(or (getenv "SHELL")
(default-value 'shell-file-name)))
(when-let (newtz (getenv-internal "TZ"))
(when-let* ((newtz (getenv-internal "TZ")))
(unless (equal tz newtz)
(set-time-zone-rule newtz))))
env))))
@ -313,7 +313,7 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
"Queue FNS to be byte/natively-compiled after a brief delay."
(with-memoization (get 'doom-compile-function 'timer)
(run-with-idle-timer
1.5 t (fn! (when-let (fn (pop fns))
1.5 t (fn! (when-let* ((fn (pop fns)))
(doom-log 3 "compile-functions: %s" fn)
(or (if (featurep 'native-compile)
(or (subr-native-elisp-p (indirect-function fn))
@ -345,7 +345,7 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
(if (stringp val)
(if deep? val (purecopy val))
(if deep?
(when-let ((newval (mapcar (doom-rpartial #'doom-copy t) val)))
(when-let* ((newval (mapcar (doom-rpartial #'doom-copy t) val)))
(if (vectorp val)
(apply #'vector newval)
newval))
@ -424,7 +424,7 @@ The def* forms accepted are:
(`defadvice
(if (keywordp (cadr rest))
(cl-destructuring-bind (target where fn) rest
`(when-let (fn ,fn)
`(when-let* ((fn ,fn))
(advice-add ,target ,where fn)
(unwind-protect ,body (advice-remove ,target fn))))
(let* ((fn (pop rest))
@ -1318,7 +1318,7 @@ cell."
Return its PROPERTY, if specified."
(declare (side-effect-free t))
(when-let ((context (get group name)))
(when-let* ((context (get group name)))
(if property
(aref
context
@ -1371,9 +1371,9 @@ duplicates."
(while flags
(let* ((flag (car flags))
(flagstr (symbol-name flag)))
(when-let ((sym (intern-soft
(concat (if (eq ?- (aref flagstr 0)) "+" "-")
(substring flagstr 1)))))
(when-let* ((sym (intern-soft
(concat (if (eq ?- (aref flagstr 0)) "+" "-")
(substring flagstr 1)))))
(setq newflags (delq sym newflags)))
(cl-pushnew flag newflags :test 'eq))
(setq flags (cdr flags)))
@ -1382,7 +1382,7 @@ duplicates."
(defun doom-module-get (key &optional property)
"Returns the plist for GROUP MODULE. Gets PROPERTY, specifically, if set."
(declare (side-effect-free t))
(when-let ((m (gethash key doom-modules)))
(when-let* ((m (gethash key doom-modules)))
(if property
(aref
m (or (plist-get
@ -1398,7 +1398,7 @@ duplicates."
(defun doom-module-active-p (group module &optional flags)
"Return t if GROUP MODULE is active, and with FLAGS (if given)."
(declare (side-effect-free t))
(when-let ((val (doom-module-get (cons group module) (if flags :flags))))
(when-let* ((val (doom-module-get (cons group module) (if flags :flags))))
(or (null flags)
(doom-module--has-flag-p flags val))))
@ -1453,7 +1453,7 @@ If INITORDER? is non-nil, sort modules by the CAR of that module's :depth."
GROUP is a keyword. MODULE is a symbol. FILE is an optional string path.
If the group isn't enabled this returns nil. For finding disabled modules use
`doom-module-locate-path' instead."
(when-let ((path (doom-module-get key :path)))
(when-let* ((path (doom-module-get key :path)))
(if file
(file-name-concat path file)
path)))
@ -1671,7 +1671,7 @@ elsewhere."
do (cl-callf plist-put plist key value))
;; Some basic key validation; throws an error on invalid properties
(condition-case e
(when-let (recipe (plist-get plist :recipe))
(when-let* ((recipe (plist-get plist :recipe)))
(cl-destructuring-bind
(&key local-repo _files _flavor _build _pre-build _post-build
_includes _type _repo _host _branch _protocol _remote

View file

@ -93,8 +93,8 @@
(concat "Alternatively, either update your $PATH environment variable to include the\n"
"path of the desired Emacs executable OR alter the $EMACS environment variable\n"
"to specify the exact path or command needed to invoke Emacs."
(when-let ((script (cadr (member "--load" command-line-args)))
(command (file-name-nondirectory script)))
(when-let* ((script (cadr (member "--load" command-line-args)))
(command (file-name-nondirectory script)))
(concat " For example:\n\n"
" $ EMACS=/path/to/valid/emacs " command " ...\n"
" $ EMACS=\"/Applications/Emacs.app/Contents/MacOS/Emacs\" " command " ...\n"

View file

@ -144,8 +144,8 @@ If BUFFER-OR-NAME is omitted or nil, the current buffer is tested."
(or (bufferp buffer-or-name)
(stringp buffer-or-name)
(signal 'wrong-type-argument (list '(bufferp stringp) buffer-or-name)))
(when-let (buf (get-buffer buffer-or-name))
(when-let (basebuf (buffer-base-buffer buf))
(when-let* ((buf (get-buffer buffer-or-name)))
(when-let* ((basebuf (buffer-base-buffer buf)))
(setq buf basebuf))
(and (buffer-live-p buf)
(not (doom-temp-buffer-p buf))

View file

@ -236,10 +236,10 @@
(when (looking-at-p org-drawer-regexp)
(setq pt (org-element-property :end (org-element-at-point))))
(while (re-search-forward org-drawer-regexp nil t)
(when-let ((el (org-element-at-point))
(beg (max (point-min) (1- (org-element-property :begin el))))
(end (org-element-property :end el))
((memq (org-element-type el) '(drawer property-drawer))))
(when-let* ((el (org-element-at-point))
(beg (max (point-min) (1- (org-element-property :begin el))))
(end (org-element-property :end el))
((memq (org-element-type el) '(drawer property-drawer))))
(when (org-element-property-inherited :level el)
(cl-decf end))
(org-fold-core-region beg end doom-docs-mode 'doom-doc-hidden))))
@ -252,7 +252,7 @@
(org-with-wide-buffer
(goto-char (point-min))
(while (re-search-forward org-heading-regexp nil t)
(when-let (tags (org-get-tags nil t))
(when-let* ((tags (org-get-tags nil t)))
(when (or (member "noorg" tags)
(member "unfold" tags))
;; prevent `org-ellipsis' around hidden regions
@ -406,7 +406,7 @@ This primes `org-mode' for reading."
(unless (< state 0)
(setf (alist-get mode doom-docs--initial-values) nil)
(funcall mode +1)))
(when-let (old-val (assq mode doom-docs--initial-values))
(when-let* ((old-val (assq mode doom-docs--initial-values)))
(funcall mode (if old-val +1 -1)))))
doom-docs-mode-alist)
(unless doom-docs-mode
@ -468,7 +468,7 @@ This primes `org-mode' for reading."
(org-id-locations doom-docs--id-locations)
(org-id-files doom-docs--id-files))
(doom/reload-docs)
(when-let (fname (buffer-file-name (buffer-base-buffer)))
(when-let* ((fname (buffer-file-name (buffer-base-buffer))))
(let ((id (org-id-new)))
(org-id-add-location id fname)
id))))

View file

@ -398,11 +398,11 @@ some optimizations for `binary' IO."
(dolist (file files)
(when (featurep 'vc)
(vc-file-clearprops file)
(when-let (buffer (get-file-buffer file))
(when-let* ((buffer (get-file-buffer file)))
(with-current-buffer buffer
(vc-refresh-state))))
(when (featurep 'magit)
(when-let (default-directory (magit-toplevel (file-name-directory file)))
(when-let* ((default-directory (magit-toplevel (file-name-directory file))))
(cl-pushnew default-directory toplevels)))
(unless (file-readable-p file)
(when (bound-and-true-p recentf-mode)

View file

@ -109,7 +109,7 @@ selection of all minor-modes, active or not."
(list (if current-prefix-arg
(save-window-excursion
(message "Click what to describe...")
(or (when-let ((evt (read--potential-mouse-event)))
(or (when-let* ((evt (read--potential-mouse-event)))
;; Discard mouse release event
(read--potential-mouse-event)
(cadr evt))
@ -383,10 +383,10 @@ without needing to check if they are available."
(when (memq (car-safe sexp) '(featurep! modulep! require!))
(format "%s %s" (nth 1 sexp) (nth 2 sexp)))))))
((when buffer-file-name
(when-let (mod (doom-module-from-path buffer-file-name))
(when-let* ((mod (doom-module-from-path buffer-file-name)))
(unless (memq (car mod) '(:doom :user))
(format "%s %s" (car mod) (cdr mod))))))
((when-let (mod (cdr (assq major-mode doom--help-major-mode-module-alist)))
((when-let* ((mod (cdr (assq major-mode doom--help-major-mode-module-alist))))
(format "%s %s"
(symbol-name (car mod))
(symbol-name (cadr mod)))))))

View file

@ -161,7 +161,7 @@ properties:
((catch 'doom-modules
(let* ((module (if (listp m) (car m) m))
(flags (if (listp m) (cdr m))))
(when-let (new (assq module obsolete))
(when-let* ((new (assq module obsolete)))
(let ((newkeys (cdr new)))
(if (null newkeys)
(print! (warn "%s module was removed"))

View file

@ -148,9 +148,9 @@ package's name as a symbol, and whose CDR is the plist supplied to its
(dolist (package packages)
(let* ((name (car package))
(repo (symbol-name name)))
(when-let (recipe (plist-get (cdr package) :recipe))
(when-let* ((recipe (plist-get (cdr package) :recipe)))
(straight-override-recipe (cons name recipe))
(when-let (local-repo (plist-get recipe :local-repo))
(when-let* ((local-repo (plist-get recipe :local-repo)))
(setq repo local-repo)))
(print-group!
;; Only clone the package, don't build them. Straight hasn't been fully
@ -313,7 +313,7 @@ non-nil."
;;;###autoload
(defun doom-package-in-module-p (package category &optional module)
"Return non-nil if PACKAGE was installed by the user's private config."
(when-let (modules (doom-package-get package :modules))
(when-let* ((modules (doom-package-get package :modules)))
(or (and (not module) (assq :user modules))
(member (cons category module) modules))))
@ -379,8 +379,8 @@ also be a list of module keys."
doom-packages)
(letf! (defun read-packages (key)
(with-doom-module key
(when-let (file (doom-module-locate-path
key doom-module-packages-file))
(when-let* ((file (doom-module-locate-path
key doom-module-packages-file)))
(doom-packages--read file nil 'noerror))))
(with-doom-context 'package
(let ((user? (assq :user module-list)))
@ -430,7 +430,7 @@ also be a list of module keys."
(doom-initialize-packages)
(or (get package 'homepage)
(put package 'homepage
(cond ((when-let (location (locate-library (symbol-name package)))
(cond ((when-let* ((location (locate-library (symbol-name package))))
(with-temp-buffer
(if (string-match-p "\\.gz$" location)
(jka-compr-insert-file-contents location)
@ -439,7 +439,7 @@ also be a list of module keys."
(let ((case-fold-search t))
(when (re-search-forward " \\(?:url\\|homepage\\|website\\): \\(http[^\n]+\\)\n" nil t)
(match-string-no-properties 1))))))
((when-let ((recipe (straight-recipes-retrieve package)))
((when-let* ((recipe (straight-recipes-retrieve package)))
(straight--with-plist (straight--convert-recipe recipe)
(host repo)
(pcase host
@ -528,7 +528,7 @@ also be a list of module keys."
(interactive)
(cl-destructuring-bind (&key package plist beg end)
(doom--package-at-point)
(when-let (str (doom--package-to-bump-string package plist))
(when-let* ((str (doom--package-to-bump-string package plist)))
(goto-char beg)
(delete-region beg end)
(insert str))))
@ -693,11 +693,11 @@ Must be run from a magit diff buffer."
:test #'equal)))
(save-excursion
(while (re-search-forward "^-" nil t)
(when-let (pkg (read-package))
(when-let* ((pkg (read-package)))
(cl-pushnew pkg before :test #'equal))))
(save-excursion
(while (re-search-forward "^+" nil t)
(when-let (pkg (read-package))
(when-let* ((pkg (read-package)))
(cl-pushnew pkg after :test #'equal))))
(unless (= (length before) (length after))
(user-error "Uneven number of packages being bumped"))

View file

@ -457,7 +457,7 @@ All emphasis markers need to be preceded by a backslash."
(let ((end (point))
(iend (1- (point))))
(let ((text (buffer-substring ibeg iend)))
(when-let (style (cdr (assq (string-to-char fence) styles)))
(when-let* ((style (cdr (assq (string-to-char fence) styles))))
(goto-char beg)
(delete-region beg end)
(insert (doom-print--style style "%s" text)))))

View file

@ -79,7 +79,7 @@ file will be created within it so that it will always be treated as one. This
command will throw an error if a parent of DIR is a valid project (which would
mask DIR)."
(interactive "D")
(when-let ((proj-dir (doom-project-root dir)))
(when-let* ((proj-dir (doom-project-root dir)))
(if (file-equal-p proj-dir dir)
(user-error "ERROR: Directory is already a project: %s" proj-dir)
(user-error "ERROR: Directory is already inside another project: %s" proj-dir)))

View file

@ -39,7 +39,7 @@
(with-file-contents! "/etc/os-release"
(when (re-search-forward "^PRETTY_NAME=\"?\\([^\"\n]+\\)\"?" nil t)
(match-string 1)))))
((when-let (files (doom-glob "/etc/*-release"))
((when-let* ((files (doom-glob "/etc/*-release")))
(truncate-string-to-width
(replace-regexp-in-string
"\n" " " (doom-file-read (car files) :end 73) nil t)

View file

@ -74,7 +74,7 @@ PT defaults to the current position."
;; starters and enders, because `syntax-ppss' does not yet know if
;; we are inside a comment or not (e.g. / can be a division or
;; comment starter...).
(when-let ((s (car (syntax-after pt))))
(when-let* ((s (car (syntax-after pt))))
(or (and (/= 0 (logand (ash 1 16) s))
(nth 4 (syntax-ppss (+ pt 2))))
(and (/= 0 (logand (ash 1 17) s))
@ -392,7 +392,7 @@ editorconfig installed."
(let (editorconfig-lisp-use-default-indent)
(editorconfig-set-indentation nil width)))
((require 'dtrt-indent nil t)
(when-let (vars (nth 2 (assq major-mode dtrt-indent-hook-mapping-list)))
(when-let* ((vars (nth 2 (assq major-mode dtrt-indent-hook-mapping-list))))
(dolist (var (ensure-list vars))
(doom-log "Updated %s = %d" var width)
(set var width)))))

View file

@ -177,7 +177,7 @@ playback.")
(add-hook! 'lui-pre-output-hook
(defun +irc-truncate-nicks-h ()
"Truncate long nicknames in chat output non-destructively."
(when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick))
(when-let* ((beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick)))
(goto-char beg)
(let ((end (next-single-property-change beg 'lui-format-argument))
(nick (plist-get (plist-get (text-properties-at beg) 'lui-keywords)

View file

@ -100,7 +100,7 @@
(show-buffers (doom-buffers-in-mode 'elfeed-show-mode))
kill-buffer-query-functions)
(dolist (file (bound-and-true-p rmh-elfeed-org-files))
(when-let (buf (get-file-buffer (expand-file-name file org-directory)))
(when-let* ((buf (get-file-buffer (expand-file-name file org-directory))))
(kill-buffer buf)))
(dolist (b search-buffers)
(with-current-buffer b

View file

@ -17,7 +17,7 @@
;;;###autoload
(defun +spell-init-flyspell-predicate-h ()
"TODO"
(when-let (pred (assq major-mode +spell--flyspell-predicate-alist))
(when-let* ((pred (assq major-mode +spell--flyspell-predicate-alist)))
(setq-local flyspell-generic-check-word-predicate (cdr pred))))
;;;###autoload

View file

@ -141,7 +141,7 @@
(add-hook! 'spell-fu-mode-hook
(defun +spell-init-excluded-faces-h ()
"Set `spell-fu-faces-exclude' according to `+spell-excluded-faces-alist'."
(when-let (excluded (cdr (cl-find-if #'derived-mode-p +spell-excluded-faces-alist :key #'car)))
(when-let* ((excluded (cdr (cl-find-if #'derived-mode-p +spell-excluded-faces-alist :key #'car))))
(setq-local spell-fu-faces-exclude excluded))))
;; TODO: custom `spell-fu-check-range' function to reduce false positives

View file

@ -168,5 +168,5 @@ Uses ivy, helm, vertico, or ido, if available."
(call-interactively #'helm-company))
((not company-candidates)
(user-error "No company candidates available"))
((when-let (cand (completing-read "Candidate: " company-candidates))
((when-let* ((cand (completing-read "Candidate: " company-candidates)))
(company-finish cand)))))

View file

@ -224,7 +224,7 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
(call-interactively
(cond ((or (file-equal-p default-directory "~")
(file-equal-p default-directory "/")
(when-let (proot (doom-project-root))
(when-let* ((proot (doom-project-root)))
(file-equal-p proot "~")))
#'counsel-find-file)

View file

@ -274,7 +274,7 @@ workable results ripgrep produces, despite the error."
"Change `counsel-file-jump' to use fd or ripgrep, if they are available."
:override #'counsel--find-return-list
(cl-destructuring-bind (find-program . args)
(cond ((when-let (fd (executable-find (or doom-fd-executable "fd") t))
(cond ((when-let* ((fd (executable-find (or doom-fd-executable "fd") t)))
(append (list fd "--hidden" "--type" "file" "--type" "symlink" "--follow" "--color=never")
(cl-loop for dir in projectile-globally-ignored-directories
collect "--exclude"

View file

@ -253,12 +253,12 @@ See minad/consult#770."
;; Ignore single dispatcher character
((and (= len 1) (alist-get (aref pattern 0) alist)) #'ignore)
;; Prefix
((when-let ((style (alist-get (aref pattern 0) alist))
((not (char-equal (aref pattern (max (1- len) 1)) ?\\))))
((when-let* ((style (alist-get (aref pattern 0) alist))
((not (char-equal (aref pattern (max (1- len) 1)) ?\\))))
(cons style (substring pattern 1))))
;; Suffix
((when-let ((style (alist-get (aref pattern (1- len)) alist))
((not (char-equal (aref pattern (max 0 (- len 2))) ?\\))))
((when-let* ((style (alist-get (aref pattern (1- len)) alist))
((not (char-equal (aref pattern (max 0 (- len 2))) ?\\))))
(cons style (substring pattern 0 -1))))))))
;;;###autoload

View file

@ -53,7 +53,7 @@
:as #'buffer-name
:predicate
(lambda (buf)
(when-let (workspace (+workspace-get name t))
(when-let* ((workspace (+workspace-get name t)))
(+workspace-contains-buffer-p buf workspace)))))))
(+workspace-list-names))))
@ -67,13 +67,13 @@ buffer list. Selecting a buffer in another workspace will switch to that
workspace instead. If FORCE-SAME-WORKSPACE (the prefix arg) is non-nil, that
buffer will be opened in the current workspace instead."
(interactive "P")
(when-let (buffer (consult--multi (+vertico--workspace-generate-sources)
:require-match
(confirm-nonexistent-file-or-buffer)
:prompt (format "Switch to buffer (%s): "
(+workspace-current-name))
:history 'consult--buffer-history
:sort nil))
(when-let* ((buffer (consult--multi (+vertico--workspace-generate-sources)
:require-match
(confirm-nonexistent-file-or-buffer)
:prompt (format "Switch to buffer (%s): "
(+workspace-current-name))
:history 'consult--buffer-history
:sort nil)))
(let ((origin-workspace (plist-get (cdr buffer) :name)))
;; Switch to the workspace the buffer belongs to, maybe
(if (or (equal origin-workspace (+workspace-current-name))

View file

@ -47,7 +47,7 @@
epa-file-encrypt-to
(or (default-value 'epa-file-encrypt-to)
(unless (string-empty-p user-full-name)
(when-let (context (ignore-errors (epg-make-context)))
(when-let* ((context (ignore-errors (epg-make-context))))
(cl-loop for key in (epg-list-keys context user-full-name 'public)
for subkey = (car (epg-key-sub-key-list key))
if (not (memq 'disabled (epg-sub-key-capability subkey)))
@ -459,12 +459,12 @@ Continues comments if executed from a commented line."
;; A Doom convention where C-s on popups and interactive searches will invoke
;; ivy/helm/vertico for their superior filtering.
(when-let (command (cond ((modulep! :completion ivy)
#'counsel-minibuffer-history)
((modulep! :completion helm)
#'helm-minibuffer-history)
((modulep! :completion vertico)
#'consult-history)))
(when-let* ((command (cond ((modulep! :completion ivy)
#'counsel-minibuffer-history)
((modulep! :completion helm)
#'helm-minibuffer-history)
((modulep! :completion vertico)
#'consult-history))))
(define-key!
:keymaps (append +default-minibuffer-maps
(when (modulep! :editor evil +everywhere)

View file

@ -105,7 +105,7 @@
(require ',name))
((debug error)
(message "Failed to load deferred package %s: %s" ',name e)))
(when-let (deferral-list (assq ',name doom--deferred-packages-alist))
(when-let* ((deferral-list (assq ',name doom--deferred-packages-alist)))
(dolist (hook (cdr deferral-list))
(advice-remove hook #',fn)
(remove-hook hook #',fn))

View file

@ -55,7 +55,7 @@ more information on modifiers."
(file-relative-name parent)))))
("s"
(if (featurep 'evil)
(when-let (args (evil-delimited-arguments (substring modifier 1) 2))
(when-let* ((args (evil-delimited-arguments (substring modifier 1) 2)))
(let ((pattern (evil-transform-vim-style-regexp (car args)))
(replace (cadr args)))
(replace-regexp-in-string

View file

@ -122,7 +122,7 @@ evil is loaded and enabled)."
for uuid = (yas--template-uuid tpl)
if (string-prefix-p "__license-" uuid)
collect (cons (string-remove-prefix "__license-" uuid) tpl)))))
(when-let (uuid (yas-choose-value (mapcar #'car templates)))
(when-let* ((uuid (yas-choose-value (mapcar #'car templates))))
(yas-expand-snippet (cdr (assoc uuid templates))))))
;;;###autoload

View file

@ -91,7 +91,7 @@ Return non-nil if successful in doing so."
(let ((beg (progn (outline-back-to-heading) (point)))
(end (progn (outline-end-of-subtree) (point))))
(list (cons beg end)))))
(when-let ((start (+fold--hideshow-fold-p)))
(when-let* ((start (+fold--hideshow-fold-p)))
;; `start' could be start of the block, or 't' if that wasn't found.
;; In either case, we know the fold is on the same line.
(let* ((start (or (and (numberp start) start)

View file

@ -122,7 +122,7 @@ This is controlled by `+format-on-save-disabled-modes'."
".prettierrc.toml")
if (locate-dominating-file default-directory file)
return t)
(when-let ((pkg (locate-dominating-file default-directory "package.json")))
(when-let* ((pkg (locate-dominating-file default-directory "package.json")))
(require 'json)
(let ((json-key-type 'alist))
(assq 'prettier

View file

@ -114,7 +114,7 @@ Fixes #3939: unsortable dired entries on Windows."
(when (modulep! :ui modeline)
(add-hook! 'dired-mode-hook
(defun +dired-update-mode-line-height-h ()
(when-let (height (bound-and-true-p doom-modeline-height))
(when-let* ((height (bound-and-true-p doom-modeline-height)))
(setq dirvish-mode-line-height height
dirvish-header-line-height height)))))
@ -181,10 +181,10 @@ Fixes #3939: unsortable dired entries on Windows."
persp-before-switch-functions
projectile-before-switch-project-hook)
(defun +dired--cleanup-dirvish-h (&rest _)
(when-let ((dv (cl-loop for w in (window-list)
if (window-dedicated-p w)
if (with-current-buffer (window-buffer w) (dirvish-curr))
return it)))
(when-let* ((dv (cl-loop for w in (window-list)
if (window-dedicated-p w)
if (with-current-buffer (window-buffer w) (dirvish-curr))
return it)))
(let (dirvish-reuse-session)
(with-selected-window (dv-root-window dv)
(dirvish-quit)))))))
@ -212,9 +212,9 @@ Fixes #3939: unsortable dired entries on Windows."
;; deleted directory. Of course I do!
(setq dired-clean-confirm-killing-deleted-buffers nil)
;; Let OS decide how to open certain files
(when-let (cmd (cond ((featurep :system 'macos) "open")
((featurep :system 'linux) "xdg-open")
((featurep :system 'windows) "start")))
(when-let* ((cmd (cond ((featurep :system 'macos) "open")
((featurep :system 'linux) "xdg-open")
((featurep :system 'windows) "start"))))
(setq dired-guess-shell-alist-user
`(("\\.\\(?:docx\\|pdf\\|djvu\\|eps\\)\\'" ,cmd)
("\\.\\(?:jpe?g\\|png\\|gif\\|xpm\\)\\'" ,cmd)

View file

@ -21,7 +21,7 @@ DEFAULT-P is a boolean. If non-nil, it marks that email account as the
default/fallback account."
(after! mu4e
(when (version< mu4e-mu-version "1.4")
(when-let (address (cdr (assq 'user-mail-address letvars)))
(when-let* ((address (cdr (assq 'user-mail-address letvars))))
(add-to-list 'mu4e-user-mail-address-list address)))
;; remove existing context with same label
(setq mu4e-contexts
@ -376,10 +376,10 @@ When otherwise called, open a dired buffer and enable `dired-mu4e-attach-ctrl-c-
within a context, set `user-mail-address' to an alias found in the 'To' or
'From' headers of the parent message if present, or prompt the user for a
preferred alias"
(when-let ((addresses (if (or mu4e-contexts +mu4e-personal-addresses)
(and (> (length +mu4e-personal-addresses) 1)
+mu4e-personal-addresses)
(mu4e-personal-addresses))))
(when-let* ((addresses (if (or mu4e-contexts +mu4e-personal-addresses)
(and (> (length +mu4e-personal-addresses) 1)
+mu4e-personal-addresses)
(mu4e-personal-addresses))))
(setq user-mail-address
(if mu4e-compose-parent-message
(if (version<= "1.8" mu4e-mu-version)

View file

@ -44,7 +44,7 @@
(concat "mbsync --all"
;; XDG support was added to isync 1.5, but this lets
;; users on older benefit from it sooner.
(when-let (file (file-exists-p! "isyncrc" (or (getenv "XDG_CONFIG_HOME") "~/.config")))
(when-let* ((file (file-exists-p! "isyncrc" (or (getenv "XDG_CONFIG_HOME") "~/.config"))))
(format " --config %S" file)))
mu4e-change-filenames-when-moving t))
((or (modulep! +offlineimap)

View file

@ -130,7 +130,7 @@ the children of class at point."
(condition-case _
(progn
(save-window-excursion (cmake-help))
(when-let (buf (get-buffer "*CMake Help*"))
(when-let* ((buf (get-buffer "*CMake Help*")))
(pop-to-buffer buf)
t))
(error nil)))

View file

@ -119,7 +119,7 @@ Intended to replace `lisp-outline-level'."
(defun +emacs-lisp-lookup-documentation (thing)
"Lookup THING with `helpful-variable' if it's a variable, `helpful-callable'
if it's callable, `apropos' otherwise."
(cond ((when-let (module (+emacs-lisp--module-at-point))
(cond ((when-let* ((module (+emacs-lisp--module-at-point)))
(doom/help-modules (car module) (cadr module))
(when (eq major-mode 'org-mode)
(goto-char (point-min))
@ -400,10 +400,10 @@ This generally applies to your private config (`doom-user-dir') or Doom's source
(derived-mode-p 'emacs-lisp-mode)
(not (+emacs-lisp--in-package-buffer-p)))
(setq +emacs-lisp-non-package-mode nil))
(when-let ((modesym (cond ((modulep! :checkers syntax +flymake)
#'+emacs-lisp--flymake-non-package-mode)
((modulep! :checkers syntax)
#'+emacs-lisp--flycheck-non-package-mode))))
(when-let* ((modesym (cond ((modulep! :checkers syntax +flymake)
#'+emacs-lisp--flymake-non-package-mode)
((modulep! :checkers syntax)
#'+emacs-lisp--flycheck-non-package-mode))))
(if (not +emacs-lisp-non-package-mode)
(when (symbol-value modesym)
(funcall modesym -1))
@ -528,8 +528,8 @@ Adapted from URL `https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_
;; Align keywords in plists if each newline begins with
;; a keyword. This is useful for "unquoted plist
;; function" macros, like `map!' and `defhydra'.
(when-let ((first (elt state 1))
(char (char-after (1+ first))))
(when-let* ((first (elt state 1))
(char (char-after (1+ first))))
(and (eq char ?:)
(ignore-errors
(or (save-excursion
@ -554,14 +554,14 @@ Adapted from URL `https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_
(quotep 0))
(while positions
(let ((point (pop positions)))
(or (when-let (char (char-before point))
(or (when-let* ((char (char-before point)))
(cond
((eq char ?\())
((memq char '(?\' ?\`))
(or (save-excursion
(goto-char (1+ point))
(skip-chars-forward "( ")
(when-let (fn (ignore-errors (read (current-buffer))))
(when-let* ((fn (ignore-errors (read (current-buffer)))))
(if (and (symbolp fn)
(fboundp fn)
;; Only special forms and

View file

@ -116,7 +116,7 @@ See `+emacs-lisp-non-package-mode' for details.")
(defadvice! +emacs-lisp-append-value-to-eldoc-a (fn sym)
"Display variable value next to documentation in eldoc."
:around #'elisp-get-var-docstring
(when-let (ret (funcall fn sym))
(when-let* ((ret (funcall fn sym)))
(if (boundp sym)
(concat ret " "
(let* ((truncated " [...]")

View file

@ -47,7 +47,7 @@ root)."
((and (not (eq major-mode 'java-mode))
(not (eq major-mode 'java-ts-mode))
(user-error "Not in java-mode or java-ts-mode")))
((when-let (project-root (doom-project-root))
((when-let* ((project-root (doom-project-root)))
(let* ((project-root (file-truename project-root))
(file-path
(file-name-sans-extension

View file

@ -12,9 +12,9 @@ for the package.json file, and defaults to the current buffer's project root."
(or (and (not refresh-p)
(gethash project-root +javascript-npm-conf))
(let ((package-file (expand-file-name "package.json" project-root)))
(when-let (json (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file)))
(when-let* ((json (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file))))
(puthash project-root json +javascript-npm-conf))))))
;;;###autoload
@ -23,8 +23,8 @@ for the package.json file, and defaults to the current buffer's project root."
This value is cached unless REFRESH-P is non-nil. If PROJECT-ROOT is omitted,
the current buffer's project root is used."
(when-let (data (and (bound-and-true-p +javascript-npm-mode)
(+javascript-npm-conf project-root refresh-p)))
(when-let* ((data (and (bound-and-true-p +javascript-npm-mode)
(+javascript-npm-conf project-root refresh-p))))
(let ((deps (append (cdr (assq 'dependencies data))
(cdr (assq 'devDependencies data)))))
(cond ((listp packages)
@ -40,9 +40,9 @@ the current buffer's project root is used."
;;;###autoload
(defun +javascript-add-npm-path-h ()
"Add node_modules/.bin to `exec-path'."
(when-let ((search-directory (or (doom-project-root) default-directory))
(node-modules-parent (locate-dominating-file search-directory "node_modules/"))
(node-modules-dir (expand-file-name "node_modules/.bin/" node-modules-parent)))
(when-let* ((search-directory (or (doom-project-root) default-directory))
(node-modules-parent (locate-dominating-file search-directory "node_modules/"))
(node-modules-dir (expand-file-name "node_modules/.bin/" node-modules-parent)))
(make-local-variable 'exec-path)
(add-to-list 'exec-path node-modules-dir)
(doom-log ":lang:javascript: add %s to $PATH" (expand-file-name "node_modules/" node-modules-parent))))

View file

@ -22,7 +22,7 @@ lua-language-server.")
(doom-path +lua-lsp-dir "main.lua")))
(defun +lua-love-build-command ()
(when-let (root (+lua-love-project-root))
(when-let* ((root (+lua-love-project-root)))
(format "%s %s"
(if (executable-find "love")
"love"
@ -35,7 +35,7 @@ lua-language-server.")
Returns nil if 'love' executable can't be found."
(when (executable-find "love")
(when-let ((dir (or dir (doom-project-root))))
(when-let* ((dir (or dir (doom-project-root))))
(if (doom-project-p dir)
(file-name-directory
(or (file-exists-p! (or "main.lua" "src/main.lua") dir)
@ -46,11 +46,11 @@ Returns nil if 'love' executable can't be found."
;; well-formed project as far as projecitle is concerned, so we search for
;; main.lua/main.moon up the file tree as a backup.
(or (projectile-locate-dominating-file dir "main.lua")
(when-let (root (projectile-locate-dominating-file dir "src/main.lua"))
(when-let* ((root (projectile-locate-dominating-file dir "src/main.lua")))
(expand-file-name "src" root))
(and (modulep! +moonscript)
(or (projectile-locate-dominating-file dir "main.moon")
(when-let (root (projectile-locate-dominating-file dir "src/main.moon"))
(when-let* ((root (projectile-locate-dominating-file dir "src/main.moon")))
(expand-file-name "src" root)))))))))

View file

@ -80,8 +80,8 @@ exit code."
(defun +markdown-compile-markdown (beg end output-buffer)
"Compiles markdown using the Markdown.pl script (or markdown executable), if
available. Returns its exit code."
(when-let (exe (or (executable-find "Markdown.pl")
(executable-find "markdown")))
(when-let* ((exe (or (executable-find "Markdown.pl")
(executable-find "markdown"))))
(call-process-region beg end exe nil output-buffer nil)))

View file

@ -55,11 +55,11 @@ If there's none, return an empty string."
;;;###autoload (autoload 'org-roam-node-doom-type "lang/org/autoload/contrib-roam" nil t)
(cl-defmethod org-roam-node-doom-type ((node org-roam-node))
"Return the directory relative to `org-roam-directory' as a note's \"type\"."
(when-let (dir (thread-first
node
(org-roam-node-file)
(file-relative-name org-roam-directory)
(file-name-directory)))
(when-let* ((dir (thread-first
node
(org-roam-node-file)
(file-relative-name org-roam-directory)
(file-name-directory))))
(directory-file-name dir)))

View file

@ -52,7 +52,7 @@ If prefix ARG, copy instead of move."
org-refile-targets
current-prefix-arg)
(dolist (buf (delq (current-buffer) (doom-buffers-in-mode 'org-mode)))
(when-let (file (buffer-file-name (buffer-base-buffer buf)))
(when-let* ((file (buffer-file-name (buffer-base-buffer buf))))
(cl-pushnew (cons file (cons :maxlevel 10))
org-refile-targets)))
(call-interactively #'org-refile)))
@ -87,7 +87,7 @@ If prefix ARG, copy instead of move."
(defun +org/refile-to-visible ()
"Refile current heading as first child of visible heading selected with Avy."
(interactive)
(when-let (marker (+org-headline-avy))
(when-let* ((marker (+org-headline-avy)))
(let* ((buffer (marker-buffer marker))
(filename
(buffer-file-name (or (buffer-base-buffer buffer)

View file

@ -292,8 +292,8 @@ Also adds support for a `:sync' parameter to override `:async'."
;; buffer where `buffer-file-name' is nil).
(string-match-p "^ \\*temp" (buffer-name)))
(save-excursion
(when-let ((beg (org-babel-where-is-src-block-result))
(end (progn (goto-char beg) (forward-line) (org-babel-result-end))))
(when-let* ((beg (org-babel-where-is-src-block-result))
(end (progn (goto-char beg) (forward-line) (org-babel-result-end))))
(org-display-inline-images nil nil (min beg end) (max beg end))))))))
@ -747,7 +747,7 @@ up to be fully-fledged org-mode buffers."
vc-handled-backends
enable-local-variables
find-file-hook)
(when-let ((buf (delay-mode-hooks (funcall fn file))))
(when-let* ((buf (delay-mode-hooks (funcall fn file))))
(with-current-buffer buf
(add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
nil 'local))

View file

@ -13,7 +13,7 @@
(defun +org-journal-p ()
"Wrapper around `org-journal-is-journal' to lazy load `org-journal'."
(when-let (buffer-file-name (buffer-file-name (buffer-base-buffer)))
(when-let* ((buffer-file-name (buffer-file-name (buffer-base-buffer))))
(if (or (featurep 'org-journal)
(and (file-in-directory-p
buffer-file-name (expand-file-name org-journal-dir org-directory))

View file

@ -9,9 +9,9 @@ ignore the cache."
(let ((project-root (or project-root (doom-project-root))))
(or (and (not refresh-p) (gethash project-root +php-composer-conf))
(let ((package-file (expand-file-name "composer.json" project-root)))
(when-let (data (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file)))
(when-let* ((data (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file))))
(puthash project-root data +php-composer-conf))))))
;;

View file

@ -11,7 +11,7 @@ can use a remote conda environment, including the corresponding remote python
executable and packages."
(interactive)
(require 'conda)
(when-let (home (read-directory-name "Set conda home: " "~" nil nil conda-anaconda-home))
(when-let* ((home (read-directory-name "Set conda home: " "~" nil nil conda-anaconda-home)))
(setq conda-anaconda-home home)
(message "Successfully changed conda home to: %s" (abbreviate-file-name home))))

View file

@ -18,7 +18,7 @@
;;;###autoload
(defun +python-pyenv-read-version-from-file ()
"Read pyenv version from .python-version file."
(when-let (root-path (projectile-locate-dominating-file default-directory ".python-version"))
(when-let* ((root-path (projectile-locate-dominating-file default-directory ".python-version")))
(let* ((file-path (expand-file-name ".python-version" root-path))
(version
(with-temp-buffer

View file

@ -16,7 +16,7 @@ falling back on searching your PATH."
(let ((bin (expand-file-name (concat conda-env-current-name "/" exe-root)
(conda-env-default-location))))
(if (file-executable-p bin) bin))))
((when-let (bin (projectile-locate-dominating-file default-directory exe-root))
((when-let* ((bin (projectile-locate-dominating-file default-directory exe-root)))
(setq-local doom-modeline-python-executable (expand-file-name exe-root bin))))
((executable-find exe))))))

View file

@ -16,7 +16,7 @@
(ring-remove+insert+extend +eshell-buffers buf 'grow))
(defun +eshell--remove-buffer (buf)
(when-let (idx (ring-member +eshell-buffers buf))
(when-let* ((idx (ring-member +eshell-buffers buf)))
(ring-remove +eshell-buffers idx)
t))
@ -28,7 +28,7 @@
(switch-to-buffer (doom-fallback-buffer)))
(when +eshell-enable-new-shell-on-split
(let ((default-directory directory))
(when-let (win (get-buffer-window (+eshell/here)))
(when-let* ((win (get-buffer-window (+eshell/here))))
(set-window-dedicated-p win dedicated-p))))))
(defun +eshell--setup-window (window &optional flag)
@ -107,7 +107,7 @@
confirm-kill-processes
current-prefix-arg)
(when arg
(when-let (win (get-buffer-window eshell-buffer))
(when-let* ((win (get-buffer-window eshell-buffer)))
(delete-window win))
(when (buffer-live-p eshell-buffer)
(with-current-buffer eshell-buffer
@ -306,7 +306,7 @@ delete."
"Close window (or workspace) on quit."
(let ((buf (current-buffer)))
(when (+eshell--remove-buffer buf)
(when-let (win (get-buffer-window buf))
(when-let* ((win (get-buffer-window buf)))
(+eshell--setup-window win nil)
(cond ((and (one-window-p t)
(window-configuration-p (frame-parameter nil 'saved-wconf)))

View file

@ -79,7 +79,7 @@ If popup is focused, kill it."
(cd dir)
(run-mode-hooks 'shell-mode-hook)))
(pop-to-buffer buffer))
(when-let (process (get-buffer-process buffer))
(when-let* ((process (get-buffer-process buffer)))
(set-process-sentinel process #'+shell--sentinel)
(+shell--send-input buffer command))))

View file

@ -34,9 +34,9 @@ If prefix ARG, recreate the term buffer."
(doom-mark-buffer-as-real-h)
(multi-term-internal))
(unless (window-live-p window)
(when-let (window
(display-buffer-in-side-window
buffer `((window-height . ,multi-term-dedicated-window-height))))
(when-let* ((window
(display-buffer-in-side-window
buffer `((window-height . ,multi-term-dedicated-window-height)))))
(select-window window)))))))
;;;###autoload

View file

@ -18,7 +18,7 @@ buffer rather than an overlay on the line at point or the minibuffer.")
(buffer-local-value '+eval-repl-mode (get-buffer bufname))))
:ttl (lambda (buf)
(unless (plist-get +eval-repl-plist :persist)
(when-let (process (get-buffer-process buf))
(when-let* ((process (get-buffer-process buf)))
(set-process-query-on-exit-flag process nil)
(kill-process process)
(kill-buffer buf))))
@ -49,7 +49,7 @@ buffer rather than an overlay on the line at point or the minibuffer.")
(defadvice! +eval--quickrun-auto-close-a (&rest _)
"Silently re-create the quickrun popup when re-evaluating."
:before '(quickrun quickrun-region)
(when-let (win (get-buffer-window quickrun--buffer-name))
(when-let* ((win (get-buffer-window quickrun--buffer-name)))
(let ((inhibit-message t))
(quickrun--kill-running-process)
(message ""))
@ -58,13 +58,13 @@ buffer rather than an overlay on the line at point or the minibuffer.")
(add-hook! 'quickrun-after-run-hook
(defun +eval-quickrun-shrink-window-h ()
"Shrink the quickrun output window once code evaluation is complete."
(when-let (win (get-buffer-window quickrun--buffer-name))
(when-let* ((win (get-buffer-window quickrun--buffer-name)))
(with-selected-window (get-buffer-window quickrun--buffer-name)
(let ((ignore-window-parameters t))
(shrink-window-if-larger-than-buffer)))))
(defun +eval-quickrun-scroll-to-bof-h ()
"Ensures window is scrolled to BOF on invocation."
(when-let (win (get-buffer-window quickrun--buffer-name))
(when-let* ((win (get-buffer-window quickrun--buffer-name)))
(with-selected-window win
(goto-char (point-min))))))

View file

@ -66,7 +66,7 @@ Docsets must be installed with one of the following commands:
Docsets can be searched directly via `+lookup/in-docsets'."
(when (require 'dash-docs nil t)
(when-let (docsets (cl-remove-if-not #'dash-docs-docset-path (dash-docs-buffer-local-docsets)))
(when-let* ((docsets (cl-remove-if-not #'dash-docs-docset-path (dash-docs-buffer-local-docsets))))
(+lookup/in-docsets nil identifier docsets)
'deferred)))

View file

@ -292,7 +292,7 @@ framework (ivy, helm, vertico, etc), otherwise falling back to
;; Only do this with paths that contain segments, to reduce
;; false positives.
(string-match-p "/" guess)
(when-let ((dir (locate-dominating-file default-directory guess)))
(when-let* ((dir (locate-dominating-file default-directory guess)))
(when (file-in-directory-p dir (doom-project-root))
(find-file (doom-path dir guess))
t))))
@ -321,7 +321,7 @@ the browser."
(bug-reference-fontify (line-beginning-position) (line-end-position))
(dolist (o (overlays-at (point)))
;; It should only be possible to have one URL overlay.
(when-let (url (overlay-get o 'bug-reference-url))
(when-let* ((url (overlay-get o 'bug-reference-url)))
(browse-url url)
(throw 'found t)))))

View file

@ -6,11 +6,11 @@
(let ((key (or namespace major-mode)))
(or (and (not force-p)
(cdr (assq key +lookup--last-provider)))
(when-let (provider
(completing-read
"Search on: "
(mapcar #'car +lookup-provider-url-alist)
nil t))
(when-let* ((provider
(completing-read
"Search on: "
(mapcar #'car +lookup-provider-url-alist)
nil t)))
(setf (alist-get key +lookup--last-provider) provider)
provider))))

View file

@ -56,8 +56,8 @@
(defun +lsp-lookup-definition-handler ()
"Find definition of the symbol at point using LSP."
(interactive)
(when-let (loc (lsp-request "textDocument/definition"
(lsp--text-document-position-params)))
(when-let* ((loc (lsp-request "textDocument/definition"
(lsp--text-document-position-params))))
(lsp-show-xrefs (lsp--locations-to-xref-items loc) nil nil)
'deferred))
@ -65,11 +65,11 @@
(defun +lsp-lookup-references-handler (&optional include-declaration)
"Find project-wide references of the symbol at point using LSP."
(interactive "P")
(when-let
(loc (lsp-request "textDocument/references"
(append (lsp--text-document-position-params)
(list
:context `(:includeDeclaration
,(lsp-json-bool include-declaration))))))
(when-let*
((loc (lsp-request "textDocument/references"
(append (lsp--text-document-position-params)
(list
:context `(:includeDeclaration
,(lsp-json-bool include-declaration)))))))
(lsp-show-xrefs (lsp--locations-to-xref-items loc) nil t)
'deferred))

View file

@ -297,7 +297,7 @@ FUNCTION
(after! git-rebase
(dolist (key '(("M-k" . "gk") ("M-j" . "gj")))
(when-let (desc (assoc (car key) evil-collection-magit-rebase-commands-w-descriptions))
(when-let* ((desc (assoc (car key) evil-collection-magit-rebase-commands-w-descriptions)))
(setcar desc (cdr key))))
(evil-define-key* evil-collection-magit-state git-rebase-mode-map
"gj" #'git-rebase-move-line-down

View file

@ -324,7 +324,7 @@ This and `+dashboard--persp-record-project-h' provides `persp-mode'
integration with the Doom dashboard. It ensures that the dashboard is always in
the correct project (which may be different across perspective)."
(when (bound-and-true-p persp-mode)
(when-let (pwd (persp-parameter 'last-project-root))
(when-let* ((pwd (persp-parameter 'last-project-root)))
(+dashboard-update-pwd-h pwd))))
(defun +dashboard--persp-record-project-h (&optional persp &rest _)

View file

@ -270,7 +270,7 @@ whose dimensions may not be fully initialized by the time this is run."
(let (buffer-list-update-hook
window-configuration-change-hook
window-size-change-functions)
(when-let (windows (get-buffer-window-list (doom-fallback-buffer) nil t))
(when-let* ((windows (get-buffer-window-list (doom-fallback-buffer) nil t)))
(dolist (win windows)
(set-window-start win 0)
(set-window-fringes win 0 0)
@ -297,7 +297,7 @@ This and `+doom-dashboard--persp-record-project-h' provides `persp-mode'
integration with the Doom dashboard. It ensures that the dashboard is always in
the correct project (which may be different across perspective)."
(when (bound-and-true-p persp-mode)
(when-let (pwd (persp-parameter 'last-project-root))
(when-let* ((pwd (persp-parameter 'last-project-root)))
(+doom-dashboard-update-pwd-h pwd))))
(defun +doom-dashboard--persp-record-project-h (&optional persp &rest _)

View file

@ -39,7 +39,7 @@ Note that this will keep all ligatures in `+ligatures-prog-mode-list' active, as
(let ((results))
(while plist
(let ((key (pop plist)))
(when-let (char (plist-get +ligatures-extra-symbols key))
(when-let* ((char (plist-get +ligatures-extra-symbols key)))
(push (cons (pop plist) char) results))))
(dolist (mode (ensure-list modes))
(setf (alist-get mode +ligatures-extra-alist)

View file

@ -382,7 +382,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
(unless (or (null default-directory)
(null file-name)
(file-remote-p file-name))
(when-let (project-root (doom-project-root))
(when-let* ((project-root (doom-project-root)))
(file-relative-name (or buffer-file-truename (file-truename file-name))
(concat project-root "..")))))))))

View file

@ -38,7 +38,7 @@
(defun +neotree/collapse-or-up ()
"Collapse an expanded directory node or go to the parent node."
(interactive)
(when-let (node (neo-buffer--get-filename-current-line))
(when-let* ((node (neo-buffer--get-filename-current-line)))
(if (and (file-directory-p node)
(neo-buffer--expanded-node-p node))
(+neotree/collapse)
@ -48,7 +48,7 @@
(defun +neotree/collapse ()
"Collapse a neotree node."
(interactive)
(when-let (node (neo-buffer--get-filename-current-line))
(when-let* ((node (neo-buffer--get-filename-current-line)))
(when (file-directory-p node)
(neo-buffer--set-expand node nil)
(neo-buffer--refresh t))
@ -59,7 +59,7 @@
(defun +neotree/expand-or-open ()
"Expand or open a neotree node."
(interactive)
(when-let (node (neo-buffer--get-filename-current-line))
(when-let* ((node (neo-buffer--get-filename-current-line)))
(cond ((file-directory-p node)
(neo-buffer--set-expand node t)
(neo-buffer--refresh t)

View file

@ -165,8 +165,8 @@ the command buffer."
origin)
(save-popups!
(find-file path)
(when-let (pos (get-text-property button 'position
(marker-buffer button)))
(when-let* ((pos (get-text-property button 'position
(marker-buffer button))))
(goto-char pos))
(setq origin (selected-window))
(recenter))
@ -182,7 +182,7 @@ the command buffer."
(defadvice! +popup--helm-hide-org-links-popup-a (fn &rest args)
:around #'org-insert-link
(letf! ((defun org-completing-read (&rest args)
(when-let (win (get-buffer-window "*Org Links*"))
(when-let* ((win (get-buffer-window "*Org Links*")))
;; While helm is opened as a popup, it will mistaken the *Org
;; Links* popup for the "originated window", and will target it
;; for actions invoked by the user. However, since *Org Links*
@ -208,7 +208,7 @@ the command buffer."
;;;###package Info
(defadvice! +popup--switch-to-info-window-a (&rest _)
:after #'info-lookup-symbol
(when-let (win (get-buffer-window "*info*"))
(when-let* ((win (get-buffer-window "*info*")))
(when (+popup-window-p win)
(select-window win))))
@ -266,7 +266,7 @@ Ugh, such an ugly hack."
(defun split-window-vertically (&optional _size)
(funcall split-window-vertically (- 0 window-min-height 1)))
(defun org-fit-window-to-buffer (&optional window max-height min-height shrink-only)
(when-let (buf (window-buffer window))
(when-let* ((buf (window-buffer window)))
(with-current-buffer buf
(+popup-buffer-mode)))
(when (> (window-buffer-height window)

View file

@ -20,7 +20,7 @@ the buffer is visible, then set another timer and try again later."
(with-current-buffer buffer
(let ((kill-buffer-hook (remq '+popup-kill-buffer-hook-h kill-buffer-hook))
confirm-kill-processes)
(when-let (process (get-buffer-process buffer))
(when-let* ((process (get-buffer-process buffer)))
(when (eq (process-type process) 'real)
(kill-process process)))
(let (kill-buffer-query-functions)
@ -83,7 +83,7 @@ the buffer is visible, then set another timer and try again later."
(defun +popup--delete-other-windows (window)
"Fixes `delete-other-windows' when used from a popup window."
(when-let (window (ignore-errors (+popup/raise window)))
(when-let* ((window (ignore-errors (+popup/raise window))))
(let ((ignore-window-parameters t))
(delete-other-windows window)))
nil)
@ -203,9 +203,9 @@ and enables `+popup-buffer-mode'."
(when window
(+popup--maybe-select-window window origin)
window))
(when-let (popup (cl-loop for func in actions
if (funcall func buffer alist)
return it))
(when-let* ((popup (cl-loop for func in actions
if (funcall func buffer alist)
return it)))
(with-current-buffer buffer
(+popup--init popup alist))
(+popup--maybe-select-window popup origin)
@ -325,7 +325,7 @@ Any non-nil value besides the above will be used as the raw value for
;;;###autoload
(defun +popup-kill-buffer-hook-h ()
"TODO"
(when-let (window (get-buffer-window))
(when-let* ((window (get-buffer-window)))
(when (+popup-window-p window)
(let ((+popup--inhibit-transient t))
(+popup--delete-window window)))))
@ -499,10 +499,10 @@ prevent the popup(s) from messing up the UI (or vice versa)."
(defun +popup-display-buffer-fullframe-fn (buffer alist)
"Displays the buffer fullscreen."
(let ((wconf (current-window-configuration)))
(when-let (window (or (display-buffer-reuse-window buffer alist)
(display-buffer-same-window buffer alist)
(display-buffer-pop-up-window buffer alist)
(display-buffer-use-some-window buffer alist)))
(when-let* ((window (or (display-buffer-reuse-window buffer alist)
(display-buffer-same-window buffer alist)
(display-buffer-pop-up-window buffer alist)
(display-buffer-use-some-window buffer alist))))
(set-window-parameter window 'saved-wconf wconf)
(add-to-list 'window-persistent-parameters '(saved-wconf . t))
(delete-other-windows window)
@ -578,7 +578,7 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
((not windows)
(cl-letf (((symbol-function 'window--make-major-side-window-next-to)
(lambda (_side) (frame-root-window (selected-frame)))))
(when-let (window (window--make-major-side-window buffer side slot alist))
(when-let* ((window (window--make-major-side-window buffer side slot alist)))
(set-window-parameter window 'window-vslot vslot)
(add-to-list 'window-persistent-parameters '(window-vslot . writable))
window)))

View file

@ -53,7 +53,7 @@
"Return a workspace named NAME. Unless NOERROR is non-nil, this throws an
error if NAME doesn't exist."
(cl-check-type name string)
(when-let (persp (persp-get-by-name name))
(when-let* ((persp (persp-get-by-name name)))
(cond ((+workspace-p persp) persp)
((not noerror)
(error "No workspace called '%s' was found" name)))))
@ -630,7 +630,7 @@ This be hooked to `projectile-after-switch-project-hook'."
;;;###autoload
(defun +workspaces-load-tab-bar-data-from-file-h (&rest _)
"Restores the tab bar data from file."
(when-let ((persp-tab-data (persp-parameter 'tab-bar-tabs)))
(when-let* ((persp-tab-data (persp-parameter 'tab-bar-tabs)))
(tab-bar-tabs-set persp-tab-data)
(tab-bar--update-tab-bar-lines t)))

View file

@ -77,7 +77,7 @@ stored in `persp-save-dir'.")
(persp-add-new +workspaces-main))
;; HACK: Fix #319: the warnings buffer gets swallowed when creating
;; `+workspaces-main', so display it ourselves, if it exists.
(when-let (warnings (get-buffer "*Warnings*"))
(when-let* ((warnings (get-buffer "*Warnings*")))
(unless (get-buffer-window warnings)
(save-excursion
(display-buffer-in-side-window