Minor refactors across the board

- when-let* -> when-let
- Fix projectile-locate-dominating-file for connected remote files
This commit is contained in:
Henrik Lissner 2019-06-25 21:38:16 +02:00
parent 4ecf6c9414
commit 9a02bd8ac8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
42 changed files with 114 additions and 110 deletions

View file

@ -128,7 +128,7 @@ 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 (buf (get-buffer buffer-or-name))
(and (buffer-live-p buf)
(not (doom-temp-buffer-p buf))
(or (buffer-local-value 'doom-real-buffer-p buf)

View file

@ -167,7 +167,7 @@ file if it exists, without confirmation."
(list (read-file-name "Copy file to: ")
current-prefix-arg))
(pcase (catch 'status
(when-let* ((dest (doom--copy-file (buffer-file-name) new-path force-p)))
(when-let (dest (doom--copy-file (buffer-file-name) new-path force-p))
(doom--update-file new-path)
(message "File successfully copied to %s" dest)))
(`overwrite-self (error "Cannot overwrite self"))
@ -184,7 +184,7 @@ file if it exists, without confirmation."
(pcase (catch 'status
(let ((old-path (buffer-file-name))
(new-path (expand-file-name new-path)))
(when-let* ((dest (doom--copy-file old-path new-path force-p)))
(when-let (dest (doom--copy-file old-path new-path force-p))
(when (file-exists-p old-path)
(delete-file old-path))
(kill-current-buffer)

View file

@ -27,7 +27,7 @@ acceptable values for this variable.")
(defun doom--font-name (fontname frame)
(when (query-fontset fontname)
(when-let* ((ascii (assq 'ascii (aref (fontset-info fontname frame) 2))))
(when-let (ascii (assq 'ascii (aref (fontset-info fontname frame) 2)))
(setq fontname (nth 2 ascii))))
(or (x-decompose-font-name fontname)
(error "Cannot decompose font name")))

View file

@ -309,9 +309,9 @@ current file is in, or d) the module associated with the current major mode (see
(when (memq (car-safe sexp) '(featurep! require!))
(format "%s %s" (nth 1 sexp) (nth 2 sexp)))))))
((and buffer-file-name
(when-let* ((mod (doom-module-from-path buffer-file-name)))
(when-let (mod (doom-module-from-path buffer-file-name))
(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)))))))
@ -498,7 +498,7 @@ If prefix arg is present, refresh the cache."
(defun doom--package-url (package)
(cond ((assq package package--builtins)
(user-error "Package is built into Emacs and cannot be looked up"))
((when-let* ((location (locate-library (symbol-name package))))
((when-let (location (locate-library (symbol-name package)))
(with-temp-buffer
(insert-file-contents (concat (file-name-sans-extension location) ".el")
nil 0 4096)

View file

@ -30,7 +30,7 @@ one wants that.")
"Delete FILE (an autoloads file) and accompanying *.elc file, if any."
(cl-check-type file string)
(when (file-exists-p file)
(when-let* ((buf (find-buffer-visiting doom-autoload-file)))
(when-let (buf (find-buffer-visiting doom-autoload-file))
(with-current-buffer buf
(set-buffer-modified-p nil))
(kill-buffer buf))

View file

@ -128,10 +128,10 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
;; don't meet their own predicates.
(push (list :no-require t
(lambda (_name args)
(or (when-let* ((pred (or (plist-get args :if)
(plist-get args :when))))
(or (when-let (pred (or (plist-get args :if)
(plist-get args :when)))
(not (eval pred t)))
(when-let* ((pred (plist-get args :unless)))
(when-let (pred (plist-get args :unless))
(eval pred t)))))
use-package-defaults)
(dolist (target (cl-delete-duplicates (mapcar #'file-truename target-files) :test #'equal))

View file

@ -129,7 +129,7 @@ detected.")
"Bump file in recent file list when it is switched or written to."
(when buffer-file-name
(recentf-add-file buffer-file-name))
;; Return nil to call from `write-file-functions'
;; Return nil for `write-file-functions'
nil)
(add-hook 'doom-switch-window-hook #'doom|recentf-touch-buffer)
(add-hook 'write-file-functions #'doom|recentf-touch-buffer)
@ -181,7 +181,7 @@ savehist file."
:when (display-graphic-p)
:after-call (pre-command-hook after-find-file)
:init
(when-let* ((name (getenv "EMACS_SERVER_NAME")))
(when-let (name (getenv "EMACS_SERVER_NAME"))
(setq server-name name))
:config
(unless (server-running-p)

View file

@ -98,7 +98,7 @@ If any hook returns non-nil, 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)))
(push `(which-key-add-key-based-replacements
(general--concat t doom-leader-alt-key ,key)
,desc)

View file

@ -112,7 +112,7 @@ non-nil."
(defun doom-module-get (category module &optional property)
"Returns the plist for CATEGORY MODULE. Gets PROPERTY, specifically, if set."
(declare (pure t) (side-effect-free t))
(when-let* ((plist (gethash (cons category module) doom-modules)))
(when-let (plist (gethash (cons category module) doom-modules))
(if property
(plist-get plist property)
plist)))
@ -278,7 +278,7 @@ If ALL-P is non-nil, return paths of possible modules, activated or otherwise."
(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

@ -133,7 +133,7 @@ them."
(defun doom-ensure-core-packages ()
"Make sure `doom-core-packages' are installed."
(when-let* ((core-packages (cl-remove-if #'package-installed-p doom-core-packages)))
(when-let (core-packages (cl-remove-if #'package-installed-p doom-core-packages))
(message "Installing core packages")
(unless doom--refreshed-p
(package-refresh-contents))

View file

@ -93,7 +93,7 @@ c) are not valid projectile projects."
(defun doom*projectile-locate-dominating-file (orig-fn file name)
"Don't traverse the file system if on a remote connection."
(when (and (stringp file)
(not (file-remote-p file)))
(not (file-remote-p file nil t)))
(funcall orig-fn file name)))
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)

View file

@ -109,7 +109,7 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(and (eq orig-fn #'switch-to-buffer) (car args)))
(apply orig-fn buffer-or-name args)
(let ((doom-inhibit-switch-buffer-hooks t))
(when-let* ((buffer (apply orig-fn buffer-or-name args)))
(when-let (buffer (apply orig-fn buffer-or-name args))
(with-current-buffer (if (windowp buffer)
(window-buffer buffer)
buffer)
@ -121,7 +121,7 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(if doom-inhibit-switch-buffer-hooks
(apply orig-fn args)
(let ((doom-inhibit-switch-buffer-hooks t))
(when-let* ((buffer (apply orig-fn args)))
(when-let (buffer (apply orig-fn args))
(with-current-buffer buffer
(run-hooks 'doom-switch-buffer-hook))
buffer)))))
@ -508,9 +508,10 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
:around #'doom*run-switch-buffer-hooks))
;; Apply `doom-theme'
(if (daemonp)
(add-hook 'after-make-frame-functions #'doom|init-theme)
(add-hook 'doom-init-ui-hook #'doom|init-theme))
(add-hook (if (daemonp)
'after-make-frame-functions
'doom-init-ui-hook)
#'doom|init-theme)
;; Apply `doom-font' et co
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts)
;; Ensure unicode fonts are set on each frame

View file

@ -318,10 +318,9 @@ intervals."
(nconc doom-incremental-packages packages)
(when packages
(let ((gc-cons-threshold doom-gc-cons-upper-limit)
(reqs (cl-delete-if #'featurep packages))
file-name-handler-alist)
(let* ((reqs (cl-delete-if #'featurep packages))
(req (ignore-errors (pop reqs))))
(when req
(when-let (req (if reqs (ignore-errors (pop reqs))))
(doom-log "Incrementally loading %s" req)
(condition-case e
(or (while-no-input (require req nil t) t)
@ -333,7 +332,7 @@ intervals."
(run-with-idle-timer doom-incremental-idle-timer
nil #'doom-load-packages-incrementally
reqs t)
(doom-log "Finished incremental loading"))))))))
(doom-log "Finished incremental loading")))))))
(defun doom|load-packages-incrementally ()
"Begin incrementally loading packages in `doom-incremental-packages'.
@ -433,8 +432,8 @@ in interactive sessions, nil otherwise (but logs a warning)."
(if (not (file-readable-p file))
(doom-log "Couldn't read %S envvar file" file)
(with-temp-buffer
(insert-file-contents file)
(re-search-forward "\n\n" nil t)
(insert-file-contents-literally file)
(search-forward "\n\n" nil t)
(while (re-search-forward "\n\\([^= \n]+\\)=" nil t)
(save-excursion
(let ((var (match-string 1))

View file

@ -98,7 +98,7 @@ playback.")
(defun +irc*circe-truncate-nicks ()
"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

@ -259,7 +259,7 @@ __DATA__
(overlay-put ov 'category '+regex))
(cl-incf i)
(dotimes (i 10)
(when-let* ((text (match-string i)))
(when-let (text (match-string i))
(save-match-data
(with-current-buffer +regex--groups-buffer
(goto-char (point-max))

View file

@ -71,7 +71,7 @@
(show-buffers (doom-buffers-in-mode 'elfeed-show-mode))
kill-buffer-query-functions)
(dolist (file +rss-elfeed-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

@ -183,9 +183,9 @@ If ARG (universal argument), open selection in other-window."
(task-tags (mapcar #'car +ivy-task-tags))
(cmd
(format "%s -H -S --no-heading -- %s %s"
(or (when-let* ((bin (executable-find "rg")))
(or (when-let (bin (executable-find "rg"))
(concat bin " --line-number"))
(when-let* ((bin (executable-find "ag")))
(when-let (bin (executable-find "ag"))
(concat bin " --numbers"))
(error "ripgrep & the_silver_searcher are unavailable"))
(shell-quote-argument
@ -306,7 +306,7 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
(interactive)
(call-interactively
(cond ((or (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

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

View file

@ -33,7 +33,9 @@ ignored. This makes it easy to override built-in snippets with private ones."
(interactive)
(let* ((snippet (car (yas-active-snippets)))
(active-field (yas--snippet-active-field snippet))
(position (if (yas--field-p active-field) (yas--field-start active-field) -1)))
(position (if (yas--field-p active-field)
(yas--field-start active-field)
-1)))
(if (= (point) position)
(move-beginning-of-line 1)
(goto-char position))))
@ -44,7 +46,9 @@ ignored. This makes it easy to override built-in snippets with private ones."
(interactive)
(let* ((snippet (car (yas-active-snippets)))
(active-field (yas--snippet-active-field snippet))
(position (if (yas--field-p active-field) (yas--field-end active-field) -1)))
(position (if (yas--field-p active-field)
(yas--field-end active-field)
-1)))
(if (= (point) position)
(move-end-of-line 1)
(goto-char position))))

View file

@ -19,7 +19,7 @@ OPTIONAL:
DEFAULT-P is a boolean. If non-nil, it marks that email account as the
default/fallback account."
(after! mu4e
(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))
(setq mu4e-contexts
(cl-loop for context in mu4e-contexts

View file

@ -173,7 +173,7 @@ compilation dbs."
;; (defun +cc|init-ccls-compile-options ()
;; "TODO"
;; (when (memq major-mode '(c-mode c++-mode objc-mode))
;; (when-let* ((include-paths (+cc-resolve-include-paths)))
;; (when-let (include-paths (+cc-resolve-include-paths))
;; (let ((args (delq nil (cdr-safe (assq major-mode +cc-default-compiler-options)))))
;; (setf (alist-get (or (lsp-workspace-root)
;; (lsp--suggest-project-root)
@ -190,10 +190,10 @@ compilation dbs."
"Takes the local project include paths and registers them with ffap.
This way, `find-file-at-point' (and `+lookup/file') will know where to find most
header files."
(when-let* ((project-root (or (bound-and-true-p irony--working-directory)
(when-let (project-root (or (bound-and-true-p irony--working-directory)
(and (featurep 'lsp)
(or (lsp-workspace-root)
(doom-project-root))))))
(doom-project-root)))))
(require 'ffap)
(make-local-variable 'ffap-c-path)
(make-local-variable 'ffap-c++-path)

View file

@ -10,15 +10,15 @@ ignore the cache."
(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)
(when-let (json (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file))))
(json-read-file package-file)))
(puthash project-root json +javascript-npm-conf))))))
;;;###autoload
(defun +javascript-npm-dep-p (packages &optional project-root refresh-p)
(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)

View file

@ -11,7 +11,7 @@
(defun +lua/run-love-game ()
"Run the current project with Love2D."
(interactive)
(when-let* ((root (locate-dominating-file buffer-file-name "main.lua")))
(when-let (root (locate-dominating-file buffer-file-name "main.lua"))
(async-shell-command
(format "%s %s"
(or (executable-find "love")

View file

@ -89,8 +89,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
shell-file-name nil output-buffer nil
shell-command-switch

View file

@ -124,7 +124,7 @@ If on a:
(org-table-blank-field)
(org-table-recalculate)
(when (and (string-empty-p (string-trim (org-table-get-field)))
(bound-and-true-p evil-mode))
(bound-and-true-p evil-local-mode))
(evil-change-state 'insert)))
(`babel-call
@ -226,7 +226,7 @@ wrong places)."
(save-excursion
(insert "\n")
(if (= level 1) (insert "\n")))))
(when-let* ((todo-keyword (org-element-property :todo-keyword context)))
(when-let (todo-keyword (org-element-property :todo-keyword context))
(org-todo (or (car (+org-get-todo-keywords-for todo-keyword))
'todo)))))
@ -234,7 +234,7 @@ wrong places)."
(when (org-invisible-p)
(org-show-hidden-entry))
(when (bound-and-true-p evil-mode)
(when (bound-and-true-p evil-local-mode)
(evil-insert 1))))
;;;###autoload
@ -365,8 +365,8 @@ another level of headings on each invocation."
"Indent the current item (header or item), if possible.
Made for `org-tab-first-hook' in evil-mode."
(interactive)
(cond ((or (not (bound-and-true-p evil-mode))
(not (eq evil-state 'insert)))
(cond ((not (and (bound-and-true-p evil-local-mode)
(evil-insert-state-p)))
nil)
((org-at-item-p)
(if (eq this-command 'org-shifttab)
@ -505,6 +505,6 @@ an effect when `evil-org-special-o/O' has `item' in it (not the default)."
;;;###autoload
(defun +org*display-link-in-eldoc (orig-fn &rest args)
"Display the link at point in eldoc."
(or (when-let* ((link (org-element-property :raw-link (org-element-context))))
(or (when-let (link (org-element-property :raw-link (org-element-context)))
(format "Link: %s" link))
(apply orig-fn args)))

View file

@ -20,9 +20,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)
(when-let (data (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file))))
(json-read-file package-file)))
(puthash project-root data +php-composer-conf))))))
;;;###autoload

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

@ -50,6 +50,6 @@
(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 "bin/python")))
((when-let (bin (projectile-locate-dominating-file default-directory "bin/python"))
(setq-local doom-modeline-python-executable (expand-file-name "bin/python" 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))
@ -26,7 +26,7 @@
(when (eq major-mode 'eshell-mode)
(switch-to-buffer (doom-fallback-buffer)))
(when +eshell-enable-new-shell-on-split
(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)
@ -284,7 +284,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

@ -15,7 +15,7 @@
(defun +eval*quickrun-auto-close (&rest _)
"Allows us to silently re-run quickrun from within the quickrun buffer."
(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 ""))
@ -41,7 +41,7 @@
(defun +eval|quickrun-shrink-window ()
"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)))))
@ -49,7 +49,7 @@
(defun +eval|quickrun-scroll-to-bof ()
"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)))))
(add-hook 'quickrun-after-run-hook #'+eval|quickrun-scroll-to-bof))

View file

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

View file

@ -65,7 +65,7 @@ Docsets must be installed with one of the following commands:
+ `dash-docs-async-install-docset-from-file'
Docsets can be searched directly via `+lookup/in-docsets'."
(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

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

View file

@ -98,7 +98,7 @@ It is passed a user and repository name.")
[tab] #'magit-section-toggle)
(after! git-rebase
(dolist (key '(("M-k" . "gk") ("M-j" . "gj")))
(when-let* ((desc (assoc (car key) evil-magit-rebase-commands-w-descriptions)))
(when-let (desc (assoc (car key) evil-magit-rebase-commands-w-descriptions))
(setcar desc (cdr key))))
(evil-define-key* evil-magit-state git-rebase-mode-map
"gj" #'git-rebase-move-line-down

View file

@ -12,7 +12,7 @@
"Delete service at point. Asks for confirmation."
(interactive "P")
(prodigy-with-refresh
(when-let* ((service (prodigy-service-at-pos)))
(when-let (service (prodigy-service-at-pos))
(let ((name (plist-get service :name)))
(cond ((or arg
(y-or-n-p (format "Delete '%s' service?" name)))

View file

@ -255,7 +255,7 @@ This and `+doom-dashboard|record-project' 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 pwd))))
(defun +doom-dashboard|record-project (&optional persp &rest _)
@ -420,7 +420,7 @@ controlled by `+doom-dashboard-pwd-policy'."
(propertize (symbol-name action) 'face 'font-lock-constant-face)))
(format "%-37s" (buffer-string)))
;; Lookup command keys dynamically
(or (when-let* ((key (where-is-internal action nil t)))
(or (when-let (key (where-is-internal action nil t))
(with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)

View file

@ -45,12 +45,12 @@
:defer t
:init
(defun +doom|solaire-mode-swap-bg-maybe ()
(when-let* ((rule (assq doom-theme +doom-solaire-themes)))
(when-let (rule (assq doom-theme +doom-solaire-themes))
(require 'solaire-mode)
(when (cdr rule)
(solaire-mode-swap-bg)
(with-eval-after-load 'ansi-color
(when-let* ((color (face-background 'default)))
(when-let (color (face-background 'default))
(setf (aref ansi-color-names-vector 0) color))))))
(add-hook 'doom-load-theme-hook #'+doom|solaire-mode-swap-bg-maybe t)
:config

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 (file-directory-p node)
(if (neo-buffer--expanded-node-p node)
(+neotree/collapse)
@ -49,7 +49,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))
@ -60,7 +60,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

@ -160,7 +160,7 @@ the command buffer."
origin)
(save-popups!
(find-file path)
(-when-let (pos (get-text-property button 'position
(when-let (pos (get-text-property button 'position
(marker-buffer button)))
(goto-char pos))
(setq origin (selected-window))
@ -179,7 +179,7 @@ the command buffer."
(cl-letf* ((old-org-completing-read (symbol-function 'org-completing-read))
((symbol-function 'org-completing-read)
(lambda (&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
@ -216,7 +216,7 @@ the command buffer."
;;;###package Info
(defun +popup*switch-to-info-window (&rest _)
(when-let* ((win (get-buffer-window "*info*")))
(when-let (win (get-buffer-window "*info*"))
(when (+popup-window-p win)
(select-window win))))
(advice-add #'info-lookup-symbol :after #'+popup*switch-to-info-window)

View file

@ -25,7 +25,7 @@ the buffer is visible, then set another timer and try again later."
((with-demoted-errors "Error killing transient buffer: %s"
(with-current-buffer buffer
(let (confirm-kill-processes)
(when-let* ((process (get-buffer-process buffer)))
(when-let (process (get-buffer-process buffer))
(kill-process process))
(let (kill-buffer-hook kill-buffer-query-functions)
(kill-buffer buffer))))))))))
@ -50,7 +50,7 @@ the buffer is visible, then set another timer and try again later."
(funcall autosave buffer))))
(with-current-buffer buffer (save-buffer)))
(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)
(delete-window window)))
(unless (window-live-p window)
@ -75,7 +75,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)
@ -179,9 +179,9 @@ and enables `+popup-buffer-mode'."
(unless +popup--inhibit-select
(select-window window))
window))
(when-let* ((popup (cl-loop for func in actions
(when-let (popup (cl-loop for func in actions
if (funcall func buffer alist)
return it)))
return it))
(+popup--init popup alist)
(unless +popup--inhibit-select
(let ((select (+popup-parameter 'select popup)))
@ -302,7 +302,7 @@ Any non-nil value besides the above will be used as the raw value for
;;;###autoload
(defun +popup|kill-buffer-hook ()
"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)))))
@ -504,7 +504,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

@ -98,7 +98,7 @@ Pretty symbols can be unset for emacs-lisp-mode with:
(:merge (setq merge (pop plist)))
(:alist (setq results (append (pop plist) results)))
(_
(when-let* ((char (plist-get +pretty-code-symbols key)))
(when-let (char (plist-get +pretty-code-symbols key))
(push (cons (pop plist) char) results)))))
(dolist (mode (doom-enlist modes))
(unless merge

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)))))