refactor: (if|when)-let -> (if|when)-let*

With the former macros' future in the air (and likely to be targeted in
future, potentially breaking changes), I'll deal with this now than have
it bite me later.

Ref: https://lists.gnu.org/archive/html/emacs-devel/2024-10/msg00637.html
This commit is contained in:
Henrik Lissner
2024-12-07 14:35:54 -05:00
parent e3bc367ba2
commit 0a715cc3f2
43 changed files with 207 additions and 205 deletions

View File

@ -69,10 +69,10 @@
(delq nil (mapcar #'doom-gc--repo repos)))))) (delq nil (mapcar #'doom-gc--repo repos))))))
(defun doom-gc--eln () (defun doom-gc--eln ()
(if-let (dirs (if-let* ((dirs
(cl-delete (expand-file-name comp-native-version-dir doom-packages--eln-output-path) (cl-delete (expand-file-name comp-native-version-dir doom-packages--eln-output-path)
(directory-files doom-packages--eln-output-path t "^[^.]" t) (directory-files doom-packages--eln-output-path t "^[^.]" t)
:test #'file-equal-p)) :test #'file-equal-p)))
(progn (progn
(print! (start "Purging old native bytecode...")) (print! (start "Purging old native bytecode..."))
(print-group! (print-group!

View File

@ -272,7 +272,7 @@ execution. Can be generated from a `doom-cli-context' with
(defun doom-cli-key (cli) (defun doom-cli-key (cli)
"Return CLI's (type . command), used as a table key or unique identifier." "Return CLI's (type . command), used as a table key or unique identifier."
(let ((command (doom-cli-command cli))) (let ((command (doom-cli-command cli)))
(if-let (type (doom-cli-type cli)) (if-let* ((type (doom-cli-type cli)))
(cons type command) (cons type command)
command))) command)))
@ -648,11 +648,11 @@ Throws `doom-cli-invalid-option-error' for illegal values."
"A CLI context, containing all state pertinent to the current session." "A CLI context, containing all state pertinent to the current session."
(init-time before-init-time) ; When this context was created (init-time before-init-time) ; When this context was created
;; A session-specific ID of the current context (defaults to number ;; A session-specific ID of the current context (defaults to number
(pid (if-let (pid (getenv "__DOOMPID")) (pid (if-let* ((pid (getenv "__DOOMPID")))
(string-to-number pid) (string-to-number pid)
(emacs-pid))) (emacs-pid)))
;; Number of Emacs processes this context has been processed through ;; Number of Emacs processes this context has been processed through
(step (if-let (step (getenv "__DOOMSTEP")) (step (if-let* ((step (getenv "__DOOMSTEP")))
(string-to-number step) (string-to-number step)
-1)) -1))
;; The geometry of the terminal window. ;; The geometry of the terminal window.
@ -877,10 +877,10 @@ state tied to switches (\"--foo\" or \"-x\") or arbitrary symbols (state).
If KEY is a string, fetch KEY from context's OPTIONS (by switch). If KEY is a string, fetch KEY from context's OPTIONS (by switch).
If KEY is a symbol, fetch KEY from context's STATE. If KEY is a symbol, fetch KEY from context's STATE.
Return NULL-VALUE if KEY does not exist." Return NULL-VALUE if KEY does not exist."
(if-let (value (if-let* ((value
(if (stringp key) (if (stringp key)
(assoc key (doom-cli-context-options context)) (assoc key (doom-cli-context-options context))
(assq key (doom-cli-context-state context)))) (assq key (doom-cli-context-state context)))))
(cdr value) (cdr value)
null-value)) null-value))
@ -1254,7 +1254,7 @@ Emacs' batch library lacks an implementation of the exec system call."
;; Run a custom action, defined in `doom-cli-exit-commands'. ;; Run a custom action, defined in `doom-cli-exit-commands'.
((pred (keywordp)) ((pred (keywordp))
(if-let (fn (alist-get command doom-cli-exit-commands)) (if-let* ((fn (alist-get command doom-cli-exit-commands)))
(funcall fn args context) (funcall fn args context)
(error "Invalid exit command: %s" command))) (error "Invalid exit command: %s" command)))
@ -1290,7 +1290,7 @@ Arguments don't have to be switches either."
(when omit (when omit
(while argv (while argv
(let ((arg (pop argv))) (let ((arg (pop argv)))
(if-let (n (cdr (assoc arg omit))) (if-let* ((n (cdr (assoc arg omit))))
(if (= n -1) (if (= n -1)
(setq argv nil) (setq argv nil)
(dotimes (i n) (pop argv))) (dotimes (i n) (pop argv)))
@ -1905,7 +1905,7 @@ errors to `doom-cli-error-file')."
(setq doom-print-backend nil)) (setq doom-print-backend nil))
(when (doom-cli-context-pipe-p context :in) (when (doom-cli-context-pipe-p context :in)
(with-current-buffer (doom-cli-context-stdin context) (with-current-buffer (doom-cli-context-stdin context)
(while (if-let (in (ignore-errors (read-from-minibuffer ""))) (while (if-let* ((in (ignore-errors (read-from-minibuffer ""))))
(insert in "\n") (insert in "\n")
(ignore-errors (delete-char -1)))))) (ignore-errors (delete-char -1))))))
(doom-cli--exit (doom-cli--exit
@ -1960,9 +1960,9 @@ errors to `doom-cli-error-file')."
(doom-cli-invalid-prefix-error (doom-cli-invalid-prefix-error
(let ((prefix (cadr e))) (let ((prefix (cadr e)))
(print! (red "Error: `run!' called with invalid prefix %S") prefix) (print! (red "Error: `run!' called with invalid prefix %S") prefix)
(if-let (suggested (cl-loop for cli being the hash-value of doom-cli--table (if-let* ((suggested (cl-loop for cli being the hash-value of doom-cli--table
unless (doom-cli-type cli) unless (doom-cli-type cli)
return (car (doom-cli-command cli)))) return (car (doom-cli-command cli)))))
(print! "Did you mean %S?" suggested) (print! "Did you mean %S?" suggested)
(print! "There are no commands defined under %S." prefix))) (print! "There are no commands defined under %S." prefix)))
4) 4)

View File

@ -43,9 +43,9 @@ TYPE should be a keyword of any of the known doom-*-error errors (e.g. :font,
(defvar doom-log-level (defvar doom-log-level
(if init-file-debug (if init-file-debug
(if-let ((level (getenv-internal "DEBUG")) (if-let* ((level (getenv-internal "DEBUG"))
(level (string-to-number level)) (level (string-to-number level))
((not (zerop level)))) ((not (zerop level))))
level level
2) 2)
0) 0)
@ -1346,7 +1346,7 @@ NAME is a symbol (e.g. \\='python). FILE is a string that will be appended to
the resulting path. If said path doesn't exist, this returns nil, otherwise an the resulting path. If said path doesn't exist, this returns nil, otherwise an
absolute path." absolute path."
(let (file-name-handler-alist) (let (file-name-handler-alist)
(if-let ((path (doom-module-expand-path key file))) (if-let* ((path (doom-module-expand-path key file)))
(if (or (null file) (if (or (null file)
(file-exists-p path)) (file-exists-p path))
path) path)
@ -1463,7 +1463,7 @@ For more about modules and flags, see `doom!'."
',(doom-module-context-flags doom-module-context) ',(doom-module-context-flags doom-module-context)
(backquote ,flags)) (backquote ,flags))
`(let ((file (file!))) `(let ((file (file!)))
(if-let ((module (doom-module-from-path file))) (if-let* ((module (doom-module-from-path file)))
(doom-module--has-flag-p (doom-module--has-flag-p
(doom-module (car module) (cdr module) :flags) (doom-module (car module) (cdr module) :flags)
(backquote ,flags)) (backquote ,flags))
@ -1670,9 +1670,9 @@ If DEFAULT? is non-nil, an unspecified CAR/CDR will fall bakc to (_default .
"Return PROFILE-NAME's PROFILE, otherwise its PROPERTY, otherwise NULL-VALUE." "Return PROFILE-NAME's PROFILE, otherwise its PROPERTY, otherwise NULL-VALUE."
(when (stringp profile-name) (when (stringp profile-name)
(setq profile-name (intern profile-name))) (setq profile-name (intern profile-name)))
(if-let (profile (assq profile-name (doom-profiles))) (if-let* ((profile (assq profile-name (doom-profiles))))
(if property (if property
(if-let (propval (assq property (cdr profile))) (if-let* ((propval (assq property (cdr profile))))
(cdr propval) (cdr propval)
null-value) null-value)
profile) profile)

View File

@ -191,9 +191,9 @@
;;; Fix $HOME on Windows ;;; Fix $HOME on Windows
;; $HOME isn't normally defined on Windows, but many unix tools expect it. ;; $HOME isn't normally defined on Windows, but many unix tools expect it.
(when doom--system-windows-p (when doom--system-windows-p
(when-let (realhome (when-let* ((realhome
(and (null (getenv-internal "HOME")) (and (null (getenv-internal "HOME"))
(getenv "USERPROFILE"))) (getenv "USERPROFILE"))))
(setenv "HOME" realhome) (setenv "HOME" realhome)
(setq abbreviated-home-dir nil))) (setq abbreviated-home-dir nil)))
@ -221,7 +221,7 @@
"The time it took, in seconds (as a float), for Doom Emacs to start up.") "The time it took, in seconds (as a float), for Doom Emacs to start up.")
(defconst doom-profile (defconst doom-profile
(if-let (profile (getenv-internal "DOOMPROFILE")) (if-let* ((profile (getenv-internal "DOOMPROFILE")))
(save-match-data (save-match-data
(if (string-match "^\\([^@]+\\)@\\(.+\\)$" profile) (if (string-match "^\\([^@]+\\)@\\(.+\\)$" profile)
(cons (match-string 1 profile) (cons (match-string 1 profile)
@ -244,7 +244,7 @@
(defvar doom-user-dir (defvar doom-user-dir
(expand-file-name (expand-file-name
(if-let (doomdir (getenv-internal "DOOMDIR")) (if-let* ((doomdir (getenv-internal "DOOMDIR")))
(file-name-as-directory doomdir) (file-name-as-directory doomdir)
(or (let ((xdgdir (or (let ((xdgdir
(file-name-concat (file-name-concat
@ -280,7 +280,7 @@ slash.")
;; DEPRECATED: .local will be removed entirely in 3.0 ;; DEPRECATED: .local will be removed entirely in 3.0
(defvar doom-local-dir (defvar doom-local-dir
(if-let (localdir (getenv-internal "DOOMLOCALDIR")) (if-let* ((localdir (getenv-internal "DOOMLOCALDIR")))
(expand-file-name (file-name-as-directory localdir)) (expand-file-name (file-name-as-directory localdir))
(expand-file-name ".local/" doom-emacs-dir)) (expand-file-name ".local/" doom-emacs-dir))
"Root directory for local storage. "Root directory for local storage.

View File

@ -380,7 +380,7 @@ current project."
(defun doom/kill-project-buffers (project &optional interactive) (defun doom/kill-project-buffers (project &optional interactive)
"Kill buffers for the specified PROJECT." "Kill buffers for the specified PROJECT."
(interactive (interactive
(list (if-let (open-projects (doom-open-projects)) (list (if-let* ((open-projects (doom-open-projects)))
(completing-read (completing-read
"Kill buffers for project: " open-projects "Kill buffers for project: " open-projects
nil t nil nil nil t nil nil

View File

@ -491,7 +491,7 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
(let ((host (or (file-remote-p file 'host) "localhost"))) (let ((host (or (file-remote-p file 'host) "localhost")))
(concat "/" (when (file-remote-p file) (concat "/" (when (file-remote-p file)
(concat (file-remote-p file 'method) ":" (concat (file-remote-p file 'method) ":"
(if-let (user (file-remote-p file 'user)) (if-let* ((user (file-remote-p file 'user)))
(concat user "@" host) (concat user "@" host)
host) host)
"|")) "|"))
@ -561,7 +561,7 @@ which case it will save it without prompting."
"Save this file as root." "Save this file as root."
(interactive) (interactive)
(let ((file (doom--sudo-file-path (buffer-file-name (buffer-base-buffer))))) (let ((file (doom--sudo-file-path (buffer-file-name (buffer-base-buffer)))))
(if-let (buffer (find-file-noselect file)) (if-let* ((buffer (find-file-noselect file)))
(let ((origin (current-buffer))) (let ((origin (current-buffer)))
(copy-to-buffer buffer (point-min) (point-max)) (copy-to-buffer buffer (point-min) (point-max))
(unwind-protect (unwind-protect

View File

@ -157,7 +157,7 @@ selection of all minor-modes, active or not."
(append (apply #'doom--org-headings files plist) (append (apply #'doom--org-headings files plist)
extra-candidates)) extra-candidates))
ivy-sort-functions-alist) ivy-sort-functions-alist)
(if-let (result (completing-read prompt alist nil nil initial-input)) (if-let* ((result (completing-read prompt alist nil nil initial-input)))
(cl-destructuring-bind (file &optional location) (cl-destructuring-bind (file &optional location)
(cdr (assoc result alist)) (cdr (assoc result alist))
(if action (if action
@ -557,7 +557,7 @@ If prefix arg is present, refresh the cache."
(`straight (`straight
(insert "Straight\n") (insert "Straight\n")
(package--print-help-section "Pinned") (package--print-help-section "Pinned")
(insert (if-let (pin (plist-get (cdr (assq package doom-packages)) :pin)) (insert (if-let* ((pin (plist-get (cdr (assq package doom-packages)) :pin)))
pin pin
"unpinned") "unpinned")
"\n") "\n")
@ -642,7 +642,7 @@ If prefix arg is present, refresh the cache."
(insert ")\n")))) (insert ")\n"))))
(package--print-help-section "Configs") (package--print-help-section "Configs")
(if-let ((configs (doom--help-package-configs package))) (if-let* ((configs (doom--help-package-configs package)))
(progn (progn
(insert "This package is configured in the following locations:") (insert "This package is configured in the following locations:")
(dolist (location configs) (dolist (location configs)

View File

@ -246,7 +246,7 @@ processed."
(memq (plist-get recipe :host) '(github gitlab bitbucket))) (memq (plist-get recipe :host) '(github gitlab bitbucket)))
(plist-put recipe :type 'git) (plist-put recipe :type 'git)
recipe)) recipe))
(repo (if-let (local-repo (plist-get recipe :local-repo)) (repo (if-let* ((local-repo (plist-get recipe :local-repo)))
(directory-file-name local-repo) (directory-file-name local-repo)
(ignore-errors (straight-vc-local-repo-name recipe))))) (ignore-errors (straight-vc-local-repo-name recipe)))))
repo repo
@ -452,7 +452,7 @@ also be a list of module keys."
("gnu" ("gnu"
(format "https://elpa.gnu.org/packages/%s.html" package)) (format "https://elpa.gnu.org/packages/%s.html" package))
(archive (archive
(if-let (src (cdr (assoc package package-archives))) (if-let* ((src (cdr (assoc package package-archives))))
(format "%s" src) (format "%s" src)
(user-error "%s isn't installed through any known source (%s)" (user-error "%s isn't installed through any known source (%s)"
package archive))))) package archive)))))
@ -475,7 +475,7 @@ also be a list of module keys."
(require 'straight) (require 'straight)
(doom-plist-merge (doom-plist-merge
(plist-get plist :recipe) (plist-get plist :recipe)
(if-let (recipe (straight-recipes-retrieve package)) (if-let* ((recipe (straight-recipes-retrieve package)))
(cdr (if (memq (car recipe) '(quote \`)) (cdr (if (memq (car recipe) '(quote \`))
(eval recipe t) (eval recipe t)
recipe)) recipe))
@ -623,7 +623,7 @@ each package."
(ignore-errors (intern (cadr module))) (ignore-errors (intern (cadr module)))
current-prefix-arg))) current-prefix-arg)))
(mapc (lambda! (key) (mapc (lambda! (key)
(if-let (packages-file (doom-module-locate-path key doom-module-packages-file)) (if-let* ((packages-file (doom-module-locate-path key doom-module-packages-file)))
(with-current-buffer (with-current-buffer
(or (get-file-buffer packages-file) (or (get-file-buffer packages-file)
(find-file-noselect packages-file)) (find-file-noselect packages-file))
@ -959,75 +959,77 @@ Must be run from a magit diff buffer."
(pinned (doom-package-pinned-alist))) (pinned (doom-package-pinned-alist)))
(add-hook 'native-comp-async-cu-done-functions #'doom-packages--native-compile-done-h) (add-hook 'native-comp-async-cu-done-functions #'doom-packages--native-compile-done-h)
(straight--make-build-cache-available) (straight--make-build-cache-available)
(if-let (built (if-let* ((built
(doom-packages--with-recipes recipes (package local-repo recipe) (doom-packages--with-recipes recipes (package local-repo recipe)
(let ((repo-dir (straight--repos-dir (or local-repo package))) (let ((repo-dir (straight--repos-dir (or local-repo package)))
(build-dir (straight--build-dir package))) (build-dir (straight--build-dir package)))
(unless force-p (unless force-p
;; Ensure packages with outdated files/bytecode are rebuilt ;; Ensure packages w/ outdated files/bytecode are rebuilt
(let* ((build (if (plist-member recipe :build) (let* ((build (if (plist-member recipe :build)
(plist-get recipe :build) (plist-get recipe :build)
t)) t))
(want-byte-compile (want-byte-compile
(or (eq build t) (or (eq build t)
(memq 'compile build))) (memq 'compile build)))
(want-native-compile (want-native-compile
(or (eq build t) (or (eq build t)
(memq 'native-compile build)))) (memq 'native-compile build))))
(and (eq (car-safe build) :not) (and (eq (car-safe build) :not)
(setq want-byte-compile (not want-byte-compile) (setq want-byte-compile (not want-byte-compile)
want-native-compile (not want-native-compile))) want-native-compile (not want-native-compile)))
(when (or (not (featurep 'native-compile)) (when (or (not (featurep 'native-compile))
(not straight--native-comp-available)) (not straight--native-comp-available))
(setq want-native-compile nil)) (setq want-native-compile nil))
(and (or want-byte-compile want-native-compile) (and (or want-byte-compile want-native-compile)
(or (file-newer-than-file-p repo-dir build-dir) (or (file-newer-than-file-p repo-dir build-dir)
(file-exists-p (straight--modified-dir package)) (file-exists-p (straight--modified-dir package))
(cl-loop with outdated = nil (cl-loop with outdated = nil
for file in (doom-files-in build-dir :match "\\.el$" :full t) for file in (doom-files-in build-dir :match "\\.el$" :full t)
if (or (if want-byte-compile (doom-packages--elc-file-outdated-p file)) if (or (if want-byte-compile (doom-packages--elc-file-outdated-p file))
(if want-native-compile (doom-packages--eln-file-outdated-p file))) (if want-native-compile (doom-packages--eln-file-outdated-p file)))
do (setq outdated t) do (setq outdated t)
(when want-native-compile (when want-native-compile
(push file doom-packages--eln-output-expected)) (push file doom-packages--eln-output-expected))
finally return outdated)) finally return outdated))
(puthash package t straight--packages-to-rebuild)))) (puthash package t straight--packages-to-rebuild))))
(unless (file-directory-p repo-dir) (unless (file-directory-p repo-dir)
(doom-packages--cli-recipes-update)) (doom-packages--cli-recipes-update))
(condition-case-unless-debug e (condition-case-unless-debug e
(let ((straight-vc-git-post-clone-hook (let ((straight-vc-git-post-clone-hook
(cons (lambda! (&key commit) (cons (lambda! (&key commit)
(print-group! (print-group!
(if-let (pin (cdr (assoc package pinned))) (if-let* ((pin (cdr (assoc package pinned))))
(print! (item "Pinned to %s") pin) (print! (item "Pinned to %s") pin)
(when commit (when commit
(print! (item "Checked out %s") commit))))) (print! (item "Checked out %s") commit)))))
straight-vc-git-post-clone-hook))) straight-vc-git-post-clone-hook)))
(straight-use-package (intern package)) (straight-use-package (intern package))
(when (file-in-directory-p repo-dir straight-base-dir) (when (file-in-directory-p repo-dir straight-base-dir)
;; HACK: Straight can sometimes fail to clone a repo, ;; HACK: Straight can sometimes fail to clone a
;; leaving behind an empty directory which, in ;; repo, leaving behind an empty directory which,
;; future invocations, it will assume indicates a ;; in future invocations, it will assume
;; successful clone (causing load errors later). ;; indicates a successful clone (causing load
(let ((try 0)) ;; errors later).
(while (not (file-directory-p (doom-path repo-dir ".git"))) (let ((try 0))
(when (= try 3) (while (not (file-directory-p (doom-path repo-dir ".git")))
(error "Failed to clone package")) (when (= try 3)
(print! (warn "Failed to clone %S, trying again (attempt #%d)...") package (1+ try)) (error "Failed to clone package"))
(delete-directory repo-dir t) (print! (warn "Failed to clone %S, trying again (attempt #%d)...") package (1+ try))
(delete-directory build-dir t) (delete-directory repo-dir t)
(straight-use-package (intern package)) (delete-directory build-dir t)
(cl-incf try))) (straight-use-package (intern package))
;; HACK: Line encoding issues can plague repos with (cl-incf try)))
;; dirty worktree prompts when updating packages or ;; HACK: Line encoding issues can plague repos with
;; "Local variables entry is missing the suffix" ;; dirty worktree prompts when updating packages
;; errors when installing them (see #2637), so have ;; or "Local variables entry is missing the
;; git handle conversion by force. ;; suffix" errors when installing them (see
(when doom--system-windows-p ;; #2637), so have git handle conversion by
(let ((default-directory repo-dir)) ;; force.
(straight--process-run "git" "config" "core.autocrlf" "true"))))) (when doom--system-windows-p
(error (let ((default-directory repo-dir))
(signal 'doom-package-error (list package e))))))) (straight--process-run "git" "config" "core.autocrlf" "true")))))
(error
(signal 'doom-package-error (list package e))))))))
(progn (progn
(when (and (featurep 'native-compile) (when (and (featurep 'native-compile)
straight--native-comp-available) straight--native-comp-available)
@ -1279,10 +1281,10 @@ Must be run from a magit diff buffer."
e))))))) e)))))))
(defun doom-packages--purge-eln () (defun doom-packages--purge-eln ()
(if-let (dirs (if-let* ((dirs
(cl-delete (expand-file-name comp-native-version-dir doom-packages--eln-output-path) (cl-delete (expand-file-name comp-native-version-dir doom-packages--eln-output-path)
(directory-files doom-packages--eln-output-path t "^[^.]" t) (directory-files doom-packages--eln-output-path t "^[^.]" t)
:test #'file-equal-p)) :test #'file-equal-p)))
(progn (progn
(print! (start "Purging old native bytecode...")) (print! (start "Purging old native bytecode..."))
(print-group! (print-group!

View File

@ -10,7 +10,7 @@ Profile directories are in the format {data-profiles-dir}/$NAME/@/$VERSION, for
example: '~/.local/share/doom/_/@/0/'") example: '~/.local/share/doom/_/@/0/'")
(defvar doom-profile-load-path (defvar doom-profile-load-path
(if-let (path (getenv-internal "DOOMPROFILELOADPATH")) (if-let* ((path (getenv-internal "DOOMPROFILELOADPATH")))
(mapcar #'expand-file-name (split-string-and-unquote path path-separator)) (mapcar #'expand-file-name (split-string-and-unquote path path-separator))
(list (file-name-concat doom-user-dir "profiles.el") (list (file-name-concat doom-user-dir "profiles.el")
(file-name-concat doom-emacs-dir "profiles.el") (file-name-concat doom-emacs-dir "profiles.el")
@ -114,7 +114,7 @@ run.")
`(,val) `(,val)
`(,(abbreviate-file-name path) ,val)))) `(,(abbreviate-file-name path) ,val))))
(cons `(user-emacs-directory :path ,@val) (cons `(user-emacs-directory :path ,@val)
(if-let (profile-file (file-exists-p! doom-profile-rcfile path)) (if-let* ((profile-file (file-exists-p! doom-profile-rcfile path)))
(car (doom-file-read profile-file :by 'read*)) (car (doom-file-read profile-file :by 'read*))
(when (file-exists-p (doom-path path subdir "lisp/doom.el")) (when (file-exists-p (doom-path path subdir "lisp/doom.el"))
'((doom-user-dir :path ,@val))))))) '((doom-user-dir :path ,@val)))))))

View File

@ -119,8 +119,8 @@ Returns nil if not in a project."
"Return the name of the current project. "Return the name of the current project.
Returns '-' if not in a valid project." Returns '-' if not in a valid project."
(if-let (project-root (or (doom-project-root dir) (if-let* ((project-root (or (doom-project-root dir)
(if dir (expand-file-name dir)))) (if dir (expand-file-name dir)))))
(funcall projectile-project-name-function project-root) (funcall projectile-project-name-function project-root)
"-")) "-"))

View File

@ -5,9 +5,9 @@
"Name of the workspace created by `=calendar', dedicated to calfw.") "Name of the workspace created by `=calendar', dedicated to calfw.")
(defun +calendar--init () (defun +calendar--init ()
(if-let (win (cl-find-if (lambda (b) (string-match-p "^\\*cfw:" (buffer-name b))) (if-let* ((win (cl-find-if (lambda (b) (string-match-p "^\\*cfw:" (buffer-name b)))
(doom-visible-windows) (doom-visible-windows)
:key #'window-buffer)) :key #'window-buffer)))
(select-window win) (select-window win)
(call-interactively +calendar-open-function))) (call-interactively +calendar-open-function)))

View File

@ -160,10 +160,10 @@ If ARG (universal argument), open selection in other-window."
(user-error "No completion session is active")) (user-error "No completion session is active"))
(require 'wgrep) (require 'wgrep)
(let ((caller (ivy-state-caller ivy-last))) (let ((caller (ivy-state-caller ivy-last)))
(if-let (occur-fn (plist-get +ivy-edit-functions caller)) (if-let* ((occur-fn (plist-get +ivy-edit-functions caller)))
(ivy-exit-with-action (ivy-exit-with-action
(lambda (_) (funcall occur-fn))) (lambda (_) (funcall occur-fn)))
(if-let (occur-fn (plist-get ivy--occurs-list caller)) (if-let* ((occur-fn (plist-get ivy--occurs-list caller)))
(let ((buffer (generate-new-buffer (let ((buffer (generate-new-buffer
(format "*ivy-occur%s \"%s\"*" (format "*ivy-occur%s \"%s\"*"
(if caller (concat " " (prin1-to-string caller)) "") (if caller (concat " " (prin1-to-string caller)) "")

View File

@ -81,7 +81,7 @@ buffer will be opened in the current workspace instead."
(funcall consult--buffer-display (car buffer)) (funcall consult--buffer-display (car buffer))
(+workspace-switch origin-workspace) (+workspace-switch origin-workspace)
(message "Switched to %S workspace" origin-workspace) (message "Switched to %S workspace" origin-workspace)
(if-let (window (get-buffer-window (car buffer))) (if-let* ((window (get-buffer-window (car buffer))))
(select-window window) (select-window window)
(funcall consult--buffer-display (car buffer))))))) (funcall consult--buffer-display (car buffer)))))))

View File

@ -77,7 +77,7 @@ If prefix ARG is set, include ignored/hidden files."
(current-prefix-arg (unless (eq arg 'other) arg)) (current-prefix-arg (unless (eq arg 'other) arg))
(default-directory (default-directory
(if (eq arg 'other) (if (eq arg 'other)
(if-let (projects (projectile-relevant-known-projects)) (if-let* ((projects (projectile-relevant-known-projects)))
(completing-read "Search project: " projects nil t) (completing-read "Search project: " projects nil t)
(user-error "There are no known projects")) (user-error "There are no known projects"))
default-directory))) default-directory)))
@ -101,7 +101,7 @@ If prefix ARG is set, prompt for a known project to search from."
(list (or (doom-thing-at-point-or-region) "") (list (or (doom-thing-at-point-or-region) "")
(let ((projectile-project-root nil)) (let ((projectile-project-root nil))
(if current-prefix-arg (if current-prefix-arg
(if-let (projects (projectile-relevant-known-projects)) (if-let* ((projects (projectile-relevant-known-projects)))
(completing-read "Search project: " projects nil t) (completing-read "Search project: " projects nil t)
(user-error "There are no known projects")) (user-error "There are no known projects"))
(doom-project-root default-directory))))) (doom-project-root default-directory)))))

View File

@ -42,8 +42,8 @@
(defun +default/yank-buffer-path (&optional root) (defun +default/yank-buffer-path (&optional root)
"Copy the current buffer's path to the kill ring." "Copy the current buffer's path to the kill ring."
(interactive) (interactive)
(if-let (filename (or (buffer-file-name (buffer-base-buffer)) (if-let* ((filename (or (buffer-file-name (buffer-base-buffer))
(bound-and-true-p list-buffers-directory))) (bound-and-true-p list-buffers-directory))))
(let ((path (abbreviate-file-name (let ((path (abbreviate-file-name
(if root (if root
(file-relative-name filename root) (file-relative-name filename root)

View File

@ -50,7 +50,7 @@
(not (re-search-forward "^ *#\\+begin_src e\\(?:macs-\\)?lisp" nil t)))) (not (re-search-forward "^ *#\\+begin_src e\\(?:macs-\\)?lisp" nil t))))
(print! (warn "No src blocks to tangle in %s. Skipping...") (path target)) (print! (warn "No src blocks to tangle in %s. Skipping...") (path target))
nil) nil)
((if-let (files (org-babel-tangle-file target dest)) ((if-let* ((files (org-babel-tangle-file target dest)))
(always (print! (success "Done tangling %d file(s)!" (length files)))) (always (print! (success "Done tangling %d file(s)!" (length files))))
(print! (error "Failed to tangle any blocks from your config.")) (print! (error "Failed to tangle any blocks from your config."))
nil)))))))) nil))))))))

View File

@ -26,7 +26,7 @@ This excludes the protocol and querystring."
(re-search-forward "://" end t)) (re-search-forward "://" end t))
(save-excursion (save-excursion
(goto-char end) (goto-char end)
(- (if-let (pos (re-search-backward "[?#]" beg t)) (- (if-let* ((pos (re-search-backward "[?#]" beg t)))
pos pos
end) end)
(if (evil-visual-state-p) (if (evil-visual-state-p)

View File

@ -32,7 +32,7 @@
;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq ;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq
;; dired-use-ls-dired nil)' to your config to suppress the Dired warning ;; dired-use-ls-dired nil)' to your config to suppress the Dired warning
;; when not using GNU ls. ;; when not using GNU ls.
(if-let (gls (executable-find "gls")) (if-let* ((gls (executable-find "gls")))
(setq insert-directory-program gls) (setq insert-directory-program gls)
;; BSD ls doesn't support -v or --group-directories-first ;; BSD ls doesn't support -v or --group-directories-first
(setq args (list (car args))))) (setq args (list (car args)))))

View File

@ -20,10 +20,10 @@
(let ((buf (ibuffer-current-buffer t))) (let ((buf (ibuffer-current-buffer t)))
(unless (buffer-live-p buf) (unless (buffer-live-p buf)
(user-error "Not a valid or live buffer: %s" buf)) (user-error "Not a valid or live buffer: %s" buf))
(if-let (workspaces (if-let* ((workspaces
(cl-loop for wk in (+workspace-list) (cl-loop for wk in (+workspace-list)
if (+workspace-contains-buffer-p buf wk) if (+workspace-contains-buffer-p buf wk)
collect wk)) collect wk)))
(+workspace-switch (+workspace-switch
(if (and (not select-first) (cdr workspaces)) (if (and (not select-first) (cdr workspaces))
(or (completing-read "Select workspace: " (mapcar #'persp-name workspaces)) (or (completing-read "Select workspace: " (mapcar #'persp-name workspaces))

View File

@ -311,7 +311,7 @@ When otherwise called, open a dired buffer and enable `dired-mu4e-attach-ctrl-c-
(progn (progn
(message "No files marked, aborting.") (message "No files marked, aborting.")
(kill-buffer-and-window)) (kill-buffer-and-window))
(if-let ((mail-target-buffer (bound-and-true-p dired-mail-buffer))) (if-let* ((mail-target-buffer (bound-and-true-p dired-mail-buffer)))
(progn (kill-buffer-and-window) (progn (kill-buffer-and-window)
(switch-to-buffer mail-target-buffer)) (switch-to-buffer mail-target-buffer))
(if (and (+mu4e-current-buffers) (if (and (+mu4e-current-buffers)

View File

@ -115,9 +115,9 @@ is non-nil."
(t #'ido-completing-read)) (t #'ido-completing-read))
mu4e-attachment-dir mu4e-attachment-dir
(concat (concat
(if-let ((xdg-download-query (and (executable-find "xdg-user-dir") (if-let* ((xdg-download-query (and (executable-find "xdg-user-dir")
(doom-call-process "xdg-user-dir" "DOWNLOAD"))) (doom-call-process "xdg-user-dir" "DOWNLOAD")))
(xdg-download-dir (and (= 0 (car xdg-download-query)) (cdr xdg-download-query)))) (xdg-download-dir (and (= 0 (car xdg-download-query)) (cdr xdg-download-query))))
xdg-download-dir xdg-download-dir
(expand-file-name (or (getenv "XDG_DOWNLOAD_DIR") (expand-file-name (or (getenv "XDG_DOWNLOAD_DIR")
"Downloads") "Downloads")
@ -291,12 +291,12 @@ is non-nil."
(defun +mu4e-view-select-attachment () (defun +mu4e-view-select-attachment ()
"Use completing-read to select a single attachment. "Use completing-read to select a single attachment.
Acts like a singular `mu4e-view-save-attachments', without the saving." Acts like a singular `mu4e-view-save-attachments', without the saving."
(if-let ((parts (delq nil (mapcar (if-let* ((parts (delq nil (mapcar
(lambda (part) (lambda (part)
(when (assoc "attachment" (cdr part)) (when (assoc "attachment" (cdr part))
part)) part))
(mu4e--view-gather-mime-parts)))) (mu4e--view-gather-mime-parts))))
(files (+mu4e-part-selectors parts))) (files (+mu4e-part-selectors parts)))
(cdr (assoc (completing-read "Select attachment: " (mapcar #'car files)) files)) (cdr (assoc (completing-read "Select attachment: " (mapcar #'car files)) files))
(user-error (mu4e-format "No attached files found")))) (user-error (mu4e-format "No attached files found"))))

View File

@ -44,10 +44,10 @@
((or `mbsync ((or `mbsync
`mbsync-xdg) ; DEPRECATED `mbsync-xdg' is now just `mbsync' `mbsync-xdg) ; DEPRECATED `mbsync-xdg' is now just `mbsync'
(format "mbsync %s -a && notmuch new" (format "mbsync %s -a && notmuch new"
(if-let (config-file (if-let* ((config-file
(doom-glob (or (getenv "XDG_CONFIG_HOME") (doom-glob (or (getenv "XDG_CONFIG_HOME")
"~/.config") "~/.config")
"isync/mbsyncrc")) "isync/mbsyncrc")))
(format "-c %S" (car config-file)) (format "-c %S" (car config-file))
""))) "")))
(`offlineimap (`offlineimap

View File

@ -20,7 +20,7 @@ at point."
;; type is `clj' for clojure and `cljs' for clojurescript ;; type is `clj' for clojure and `cljs' for clojurescript
;; ... with no type specified, assume `clj'. ;; ... with no type specified, assume `clj'.
(let ((type (or type 'clj))) (let ((type (or type 'clj)))
(if-let (buffer (cider-current-repl type)) (if-let* ((buffer (cider-current-repl type)))
(pop-to-buffer buffer) (pop-to-buffer buffer)
(let ((process (cond ((eq type 'clj) (cider-jack-in-clj arg)) (let ((process (cond ((eq type 'clj) (cider-jack-in-clj arg))
((eq type 'cljs) (cider-jack-in-cljs arg))))) ((eq type 'cljs) (cider-jack-in-cljs arg)))))

View File

@ -91,7 +91,7 @@ Intended to replace `lisp-outline-level'."
;;;###autoload ;;;###autoload
(defun +emacs-lisp-lookup-definition (_thing) (defun +emacs-lisp-lookup-definition (_thing)
"Lookup definition of THING." "Lookup definition of THING."
(if-let (module (+emacs-lisp--module-at-point)) (if-let* ((module (+emacs-lisp--module-at-point)))
(doom/help-modules (car module) (cadr module) 'visit-dir) (doom/help-modules (car module) (cadr module) 'visit-dir)
(call-interactively #'elisp-def))) (call-interactively #'elisp-def)))

View File

@ -7,8 +7,8 @@
(interactive) (interactive)
(let ((config (json-read-file (graphql-locate-config ".")))) (let ((config (json-read-file (graphql-locate-config "."))))
(let-alist config (let-alist config
(if-let ((endpoints .extensions.endpoints) (if-let* ((endpoints .extensions.endpoints)
(endpoint (cdr (assq (intern (graphql--completing-read-endpoint endpoints)) endpoints)))) (endpoint (cdr (assq (intern (graphql--completing-read-endpoint endpoints)) endpoints))))
(let-alist endpoint (let-alist endpoint
(graphql-doc--start .url `(:url ,.url :headers ,.headers))) (graphql-doc--start .url `(:url ,.url :headers ,.headers)))
(error "No endpoint configurations in .graphqlconfig"))))) (error "No endpoint configurations in .graphqlconfig")))))

View File

@ -5,9 +5,9 @@
"Opens a Haskell REPL." "Opens a Haskell REPL."
(interactive "P") (interactive "P")
(require 'haskell-interactive-mode) (require 'haskell-interactive-mode)
(if-let (window (if-let* ((window
(display-buffer (display-buffer
(haskell-session-interactive-buffer (haskell-session)))) (haskell-session-interactive-buffer (haskell-session)))))
(window-buffer window) (window-buffer window)
(error "Failed to display Haskell REPL"))) (error "Failed to display Haskell REPL")))

View File

@ -47,6 +47,6 @@ Returns nil if 'love' executable can't be found."
(defun +lua/run-love-game () (defun +lua/run-love-game ()
"Run the current project with Love2D." "Run the current project with Love2D."
(interactive) (interactive)
(if-let (cmd (+lua-love-build-command)) (if-let* ((cmd (+lua-love-build-command)))
(async-shell-command cmd) (async-shell-command cmd)
(user-error "Couldn't find love project"))) (user-error "Couldn't find love project")))

View File

@ -19,7 +19,7 @@
"TODO" "TODO"
(interactive) (interactive)
(require 'org-attach) (require 'org-attach)
(if-let (dir (org-attach-dir)) (if-let* ((dir (org-attach-dir)))
(pop-to-buffer (pop-to-buffer
;; Rather than opening dired *and* image-dired windows, suppress them ;; Rather than opening dired *and* image-dired windows, suppress them
;; both and open only the image-dired window. ;; both and open only the image-dired window.

View File

@ -341,7 +341,7 @@ exist, and `org-link' otherwise."
"Interpret LINK as an URL to an image file." "Interpret LINK as an URL to an image file."
(when (and (image-type-from-file-name link) (when (and (image-type-from-file-name link)
(not (eq org-display-remote-inline-images 'skip))) (not (eq org-display-remote-inline-images 'skip)))
(if-let (buf (url-retrieve-synchronously (concat protocol ":" link))) (if-let* ((buf (url-retrieve-synchronously (concat protocol ":" link))))
(with-current-buffer buf (with-current-buffer buf
(goto-char (point-min)) (goto-char (point-min))
(re-search-forward "\r?\n\r?\n" nil t) (re-search-forward "\r?\n\r?\n" nil t)

View File

@ -133,7 +133,7 @@ EXAMPLES:
;; Tangling doesn't expand #+INCLUDE directives, so we do it ;; Tangling doesn't expand #+INCLUDE directives, so we do it
;; ourselves, since includes are so useful for literate configs! ;; ourselves, since includes are so useful for literate configs!
(org-export-expand-include-keyword) (org-export-expand-include-keyword)
(if-let ((results (reverse (org-babel-tangle nil nil lang)))) (if-let* ((results (reverse (org-babel-tangle nil nil lang))))
(dolist (file results) (dolist (file results)
(if (not quiet?) (if (not quiet?)
(print-group! (print-group!

View File

@ -794,7 +794,7 @@ these buffers they'll see a gimped, half-broken org buffer, so to avoid that,
install a hook to restart `org-mode' when they're switched to so they can grow install a hook to restart `org-mode' when they're switched to so they can grow
up to be fully-fledged org-mode buffers." up to be fully-fledged org-mode buffers."
:around #'org-get-agenda-file-buffer :around #'org-get-agenda-file-buffer
(if-let (buf (org-find-base-buffer-visiting file)) (if-let* ((buf (org-find-base-buffer-visiting file)))
buf buf
(let ((recentf-exclude '(always)) (let ((recentf-exclude '(always))
(doom-inhibit-large-file-detection t) (doom-inhibit-large-file-detection t)
@ -1124,7 +1124,7 @@ between the two."
(defadvice! +org-eldoc--display-link-at-point-a (&rest _) (defadvice! +org-eldoc--display-link-at-point-a (&rest _)
"Display help for doom-*: links in minibuffer when cursor/mouse is over it." "Display help for doom-*: links in minibuffer when cursor/mouse is over it."
:before-until #'org-eldoc-documentation-function :before-until #'org-eldoc-documentation-function
(if-let ((url (thing-at-point 'url t))) (if-let* ((url (thing-at-point 'url t)))
(format "LINK: %s" url) (format "LINK: %s" url)
(and (eq (get-text-property (point) 'help-echo) (and (eq (get-text-property (point) 'help-echo)
#'+org-link-doom--help-echo-from-textprop) #'+org-link-doom--help-echo-from-textprop)

View File

@ -63,8 +63,8 @@
;; terminals. Requires the `input-decode-map' entry in ;; terminals. Requires the `input-decode-map' entry in
;; lisp/doom-keybinds.el. ;; lisp/doom-keybinds.el.
(define-key! key-translation-map (define-key! key-translation-map
[?\C-i] (cmd! (if-let (((kkp--terminal-has-active-kkp-p)) [?\C-i] (cmd! (if-let* (((kkp--terminal-has-active-kkp-p))
(keys (this-single-command-raw-keys)) (keys (this-single-command-raw-keys))
((> (length keys) 2)) ((> (length keys) 2))
((equal (cl-subseq keys -3) [27 91 49]))) ((equal (cl-subseq keys -3) [27 91 49])))
[C-i] [?\C-i])))) [C-i] [?\C-i]))))

View File

@ -98,7 +98,7 @@
(with-current-buffer eshell-buffer (with-current-buffer eshell-buffer
(fundamental-mode) (fundamental-mode)
(erase-buffer)))) (erase-buffer))))
(if-let (win (get-buffer-window eshell-buffer)) (if-let* ((win (get-buffer-window eshell-buffer)))
(let (confirm-kill-processes) (let (confirm-kill-processes)
(delete-window win) (delete-window win)
(ignore-errors (kill-buffer eshell-buffer))) (ignore-errors (kill-buffer eshell-buffer)))

View File

@ -68,7 +68,7 @@ If popup is focused, kill it."
(safe-persp-name (get-current-persp)) (safe-persp-name (get-current-persp))
"main")))) "main"))))
(dir default-directory)) (dir default-directory))
(if-let (win (get-buffer-window buffer)) (if-let* ((win (get-buffer-window buffer)))
(let (confirm-kill-processes) (let (confirm-kill-processes)
(set-process-query-on-exit-flag (get-buffer-process buffer) nil) (set-process-query-on-exit-flag (get-buffer-process buffer) nil)
(delete-window win) (delete-window win)

View File

@ -27,7 +27,7 @@ Returns the vterm buffer."
(kill-buffer buffer)) (kill-buffer buffer))
(when (window-live-p window) (when (window-live-p window)
(delete-window window)))) (delete-window window))))
(if-let (win (get-buffer-window buffer-name)) (if-let* ((win (get-buffer-window buffer-name)))
(delete-window win) (delete-window win)
(let ((buffer (or (cl-loop for buf in (doom-buffers-in-mode 'vterm-mode) (let ((buffer (or (cl-loop for buf in (doom-buffers-in-mode 'vterm-mode)
if (equal (buffer-local-value '+vterm--id buf) if (equal (buffer-local-value '+vterm--id buf)

View File

@ -58,7 +58,7 @@
;; Realgud doesn't generate its autoloads properly so we do it ourselves ;; Realgud doesn't generate its autoloads properly so we do it ourselves
(dolist (debugger +debugger--realgud-alist) (dolist (debugger +debugger--realgud-alist)
(autoload (car debugger) (autoload (car debugger)
(if-let (sym (plist-get (cdr debugger) :package)) (if-let* ((sym (plist-get (cdr debugger) :package)))
(symbol-name sym) (symbol-name sym)
"realgud") "realgud")
nil t)) nil t))

View File

@ -92,14 +92,14 @@ of the buffer instead."
#'+eval/send-region-to-repl) #'+eval/send-region-to-repl)
beg end)) beg end))
((let (lang) ((let (lang)
(if-let ((runner (if-let* ((runner
(or (alist-get runner-major-mode +eval-runners) (or (alist-get runner-major-mode +eval-runners)
(and (require 'quickrun nil t) (and (require 'quickrun nil t)
(equal (setq (equal (setq
lang (quickrun--command-key lang (quickrun--command-key
(buffer-file-name (buffer-base-buffer)))) (buffer-file-name (buffer-base-buffer))))
"emacs") "emacs")
(alist-get 'emacs-lisp-mode +eval-runners))))) (alist-get 'emacs-lisp-mode +eval-runners)))))
(funcall runner beg end) (funcall runner beg end)
(let ((quickrun-option-cmdkey lang)) (let ((quickrun-option-cmdkey lang))
(quickrun-region beg end)))))))) (quickrun-region beg end))))))))
@ -126,7 +126,7 @@ of the buffer instead."
(buffer-file-name (buffer-base-buffer)))) (buffer-file-name (buffer-base-buffer))))
"emacs") "emacs")
(alist-get 'emacs-lisp-mode +eval-runners))) (alist-get 'emacs-lisp-mode +eval-runners)))
(if-let ((buffer-handler (plist-get (cdr (alist-get major-mode +eval-repls)) :send-buffer))) (if-let* ((buffer-handler (plist-get (cdr (alist-get major-mode +eval-repls)) :send-buffer)))
(funcall buffer-handler) (funcall buffer-handler)
(+eval/region (point-min) (point-max))) (+eval/region (point-min) (point-max)))
(quickrun)))) (quickrun))))

View File

@ -5,7 +5,7 @@
(defun set-lsp-priority! (client priority) (defun set-lsp-priority! (client priority)
"Change the PRIORITY of lsp CLIENT." "Change the PRIORITY of lsp CLIENT."
(require 'lsp-mode) (require 'lsp-mode)
(if-let (client (gethash client lsp-clients)) (if-let* ((client (gethash client lsp-clients)))
(setf (lsp--client-priority client) (setf (lsp--client-priority client)
priority) priority)
(error "No LSP client named %S" client))) (error "No LSP client named %S" client)))

View File

@ -53,16 +53,16 @@ window that already exists in that direction. It will split otherwise."
(let ((direction (or (alist-get 'direction alist) (let ((direction (or (alist-get 'direction alist)
+magit-open-windows-in-direction)) +magit-open-windows-in-direction))
(origin-window (selected-window))) (origin-window (selected-window)))
(if-let (window (window-in-direction direction)) (if-let* ((window (window-in-direction direction)))
(unless magit-display-buffer-noselect (unless magit-display-buffer-noselect
(select-window window)) (select-window window))
(if-let (window (and (not (one-window-p)) (if-let* ((window (and (not (one-window-p))
(window-in-direction (window-in-direction
(pcase direction (pcase direction
(`right 'left) (`right 'left)
(`left 'right) (`left 'right)
((or `up `above) 'down) ((or `up `above) 'down)
((or `down `below) 'up))))) ((or `down `below) 'up))))))
(unless magit-display-buffer-noselect (unless magit-display-buffer-noselect
(select-window window)) (select-window window))
(let ((window (split-window nil nil direction))) (let ((window (split-window nil nil direction)))

View File

@ -43,7 +43,7 @@ Note that this will keep all ligatures in `+ligatures-prog-mode-list' active, as
(push (cons (pop plist) char) results)))) (push (cons (pop plist) char) results))))
(dolist (mode (ensure-list modes)) (dolist (mode (ensure-list modes))
(setf (alist-get mode +ligatures-extra-alist) (setf (alist-get mode +ligatures-extra-alist)
(if-let (old-results (alist-get mode +ligatures-extra-alist)) (if-let* ((old-results (alist-get mode +ligatures-extra-alist)))
(dolist (cell results old-results) (dolist (cell results old-results)
(setf (alist-get (car cell) old-results) (cdr cell))) (setf (alist-get (car cell) old-results) (cdr cell)))
results)))))) results))))))

View File

@ -111,7 +111,7 @@ isn't disabled in `+ligatures-extras-in-modes'."
(when-let* (when-let*
(((+ligatures--enable-p +ligatures-extras-in-modes)) (((+ligatures--enable-p +ligatures-extras-in-modes))
(symbols (symbols
(if-let ((symbols (assq major-mode +ligatures-extra-alist))) (if-let* ((symbols (assq major-mode +ligatures-extra-alist)))
(cdr symbols) (cdr symbols)
(cl-loop for (mode . symbols) in +ligatures-extra-alist (cl-loop for (mode . symbols) in +ligatures-extra-alist
if (derived-mode-p mode) if (derived-mode-p mode)

View File

@ -129,7 +129,7 @@ Using optionals attributes FACE, HELP-ECHO and VOFFSET."
"Set the modeline to NAME. "Set the modeline to NAME.
If DEFAULT is non-nil, apply to all future buffers. Modelines are defined with If DEFAULT is non-nil, apply to all future buffers. Modelines are defined with
`def-modeline!'." `def-modeline!'."
(if-let (format (assq name +modeline-format-alist)) (if-let* ((format (assq name +modeline-format-alist)))
(cl-destructuring-bind (lhs . rhs) (cdr format) (cl-destructuring-bind (lhs . rhs) (cdr format)
(if default (if default
(setq-default +modeline-format-left lhs (setq-default +modeline-format-left lhs

View File

@ -47,7 +47,7 @@ the buffer is visible, then set another timer and try again later."
(let ((buffer (window-buffer window)) (let ((buffer (window-buffer window))
(inhibit-quit t)) (inhibit-quit t))
(and (or (buffer-file-name buffer) (and (or (buffer-file-name buffer)
(if-let (base-buffer (buffer-base-buffer buffer)) (if-let* ((base-buffer (buffer-base-buffer buffer)))
(buffer-file-name base-buffer))) (buffer-file-name base-buffer)))
(buffer-modified-p buffer) (buffer-modified-p buffer)
(let ((autosave (+popup-parameter 'autosave window))) (let ((autosave (+popup-parameter 'autosave window)))
@ -58,7 +58,7 @@ the buffer is visible, then set another timer and try again later."
(funcall autosave buffer)))) (funcall autosave buffer))))
(with-current-buffer buffer (save-buffer))) (with-current-buffer buffer (save-buffer)))
(let ((ignore-window-parameters t)) (let ((ignore-window-parameters t))
(if-let (wconf (window-parameter window 'saved-wconf)) (if-let* ((wconf (window-parameter window 'saved-wconf)))
(set-window-configuration wconf) (set-window-configuration wconf)
(delete-window window))) (delete-window window)))
(unless (window-live-p window) (unless (window-live-p window)
@ -351,13 +351,13 @@ Any non-nil value besides the above will be used as the raw value for
(defun +popup/other () (defun +popup/other ()
"Cycle through popup windows, like `other-window'. Ignores regular windows." "Cycle through popup windows, like `other-window'. Ignores regular windows."
(interactive) (interactive)
(if-let (popups (cl-remove-if-not (if-let* ((popups (cl-remove-if-not
(lambda (w) (or (+popup-window-p w) (lambda (w) (or (+popup-window-p w)
;; This command should be able to hop between ;; This command should be able to hop between
;; windows with a `no-other-window' ;; windows with a `no-other-window'
;; parameter, since `other-window' won't. ;; parameter, since `other-window' won't.
(window-parameter w 'no-other-window))) (window-parameter w 'no-other-window)))
(window-list))) (window-list))))
(select-window (if (or (+popup-window-p) (select-window (if (or (+popup-window-p)
(window-parameter nil 'no-other-window)) (window-parameter nil 'no-other-window))
(let ((window (selected-window))) (let ((window (selected-window)))
@ -450,12 +450,12 @@ window and return that window."
(defun +popup/diagnose () (defun +popup/diagnose ()
"Reveal what popup rule will be used for the current buffer." "Reveal what popup rule will be used for the current buffer."
(interactive) (interactive)
(if-let (rule (cl-loop with bname = (buffer-name) (if-let* ((rule (cl-loop with bname = (buffer-name)
for (pred . action) in display-buffer-alist for (pred . action) in display-buffer-alist
if (and (functionp pred) (funcall pred bname action)) if (and (functionp pred) (funcall pred bname action))
return (cons pred action) return (cons pred action)
else if (and (stringp pred) (string-match-p pred bname)) else if (and (stringp pred) (string-match-p pred bname))
return (cons pred action))) return (cons pred action))))
(message "Rule matches: %s" rule) (message "Rule matches: %s" rule)
(message "No popup rule for this buffer"))) (message "No popup rule for this buffer")))