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) (or (bufferp buffer-or-name)
(stringp buffer-or-name) (stringp buffer-or-name)
(signal 'wrong-type-argument (list '(bufferp 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) (and (buffer-live-p buf)
(not (doom-temp-buffer-p buf)) (not (doom-temp-buffer-p buf))
(or (buffer-local-value 'doom-real-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: ") (list (read-file-name "Copy file to: ")
current-prefix-arg)) current-prefix-arg))
(pcase (catch 'status (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) (doom--update-file new-path)
(message "File successfully copied to %s" dest))) (message "File successfully copied to %s" dest)))
(`overwrite-self (error "Cannot overwrite self")) (`overwrite-self (error "Cannot overwrite self"))
@ -184,7 +184,7 @@ file if it exists, without confirmation."
(pcase (catch 'status (pcase (catch 'status
(let ((old-path (buffer-file-name)) (let ((old-path (buffer-file-name))
(new-path (expand-file-name new-path))) (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) (when (file-exists-p old-path)
(delete-file old-path)) (delete-file old-path))
(kill-current-buffer) (kill-current-buffer)

View file

@ -27,7 +27,7 @@ acceptable values for this variable.")
(defun doom--font-name (fontname frame) (defun doom--font-name (fontname frame)
(when (query-fontset fontname) (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)))) (setq fontname (nth 2 ascii))))
(or (x-decompose-font-name fontname) (or (x-decompose-font-name fontname)
(error "Cannot decompose font name"))) (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!)) (when (memq (car-safe sexp) '(featurep! require!))
(format "%s %s" (nth 1 sexp) (nth 2 sexp))))))) (format "%s %s" (nth 1 sexp) (nth 2 sexp)))))))
((and buffer-file-name ((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))))) (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" (format "%s %s"
(symbol-name (car mod)) (symbol-name (car mod))
(symbol-name (cadr mod))))))) (symbol-name (cadr mod)))))))
@ -498,7 +498,7 @@ If prefix arg is present, refresh the cache."
(defun doom--package-url (package) (defun doom--package-url (package)
(cond ((assq package package--builtins) (cond ((assq package package--builtins)
(user-error "Package is built into Emacs and cannot be looked up")) (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 (with-temp-buffer
(insert-file-contents (concat (file-name-sans-extension location) ".el") (insert-file-contents (concat (file-name-sans-extension location) ".el")
nil 0 4096) nil 0 4096)

View file

@ -30,7 +30,7 @@ one wants that.")
"Delete FILE (an autoloads file) and accompanying *.elc file, if any." "Delete FILE (an autoloads file) and accompanying *.elc file, if any."
(cl-check-type file string) (cl-check-type file string)
(when (file-exists-p file) (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 (with-current-buffer buf
(set-buffer-modified-p nil)) (set-buffer-modified-p nil))
(kill-buffer buf)) (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. ;; don't meet their own predicates.
(push (list :no-require t (push (list :no-require t
(lambda (_name args) (lambda (_name args)
(or (when-let* ((pred (or (plist-get args :if) (or (when-let (pred (or (plist-get args :if)
(plist-get args :when)))) (plist-get args :when)))
(not (eval pred t))) (not (eval pred t)))
(when-let* ((pred (plist-get args :unless))) (when-let (pred (plist-get args :unless))
(eval pred t))))) (eval pred t)))))
use-package-defaults) use-package-defaults)
(dolist (target (cl-delete-duplicates (mapcar #'file-truename target-files) :test #'equal)) (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." "Bump file in recent file list when it is switched or written to."
(when buffer-file-name (when buffer-file-name
(recentf-add-file buffer-file-name)) (recentf-add-file buffer-file-name))
;; Return nil to call from `write-file-functions' ;; Return nil for `write-file-functions'
nil) nil)
(add-hook 'doom-switch-window-hook #'doom|recentf-touch-buffer) (add-hook 'doom-switch-window-hook #'doom|recentf-touch-buffer)
(add-hook 'write-file-functions #'doom|recentf-touch-buffer) (add-hook 'write-file-functions #'doom|recentf-touch-buffer)
@ -181,7 +181,7 @@ savehist file."
:when (display-graphic-p) :when (display-graphic-p)
:after-call (pre-command-hook after-find-file) :after-call (pre-command-hook after-find-file)
:init :init
(when-let* ((name (getenv "EMACS_SERVER_NAME"))) (when-let (name (getenv "EMACS_SERVER_NAME"))
(setq server-name name)) (setq server-name name))
:config :config
(unless (server-running-p) (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) (push `(define-key doom-leader-map (general--kbd ,key)
,bdef) ,bdef)
forms)) forms))
(when-let* ((desc (cadr (memq :which-key udef)))) (when-let (desc (cadr (memq :which-key udef)))
(push `(which-key-add-key-based-replacements (push `(which-key-add-key-based-replacements
(general--concat t doom-leader-alt-key ,key) (general--concat t doom-leader-alt-key ,key)
,desc) ,desc)

View file

@ -112,7 +112,7 @@ non-nil."
(defun doom-module-get (category module &optional property) (defun doom-module-get (category module &optional property)
"Returns the plist for CATEGORY MODULE. Gets PROPERTY, specifically, if set." "Returns the plist for CATEGORY MODULE. Gets PROPERTY, specifically, if set."
(declare (pure t) (side-effect-free t)) (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 (if property
(plist-get plist property) (plist-get plist property)
plist))) plist)))
@ -278,7 +278,7 @@ If ALL-P is non-nil, return paths of possible modules, activated or otherwise."
(require ',name) (require ',name)
((debug error) ((debug error)
(message "Failed to load deferred package %s: %s" ',name e))) (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)) (dolist (hook (cdr deferral-list))
(advice-remove hook #',fn) (advice-remove hook #',fn)
(remove-hook hook #',fn)) (remove-hook hook #',fn))

View file

@ -133,7 +133,7 @@ them."
(defun doom-ensure-core-packages () (defun doom-ensure-core-packages ()
"Make sure `doom-core-packages' are installed." "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") (message "Installing core packages")
(unless doom--refreshed-p (unless doom--refreshed-p
(package-refresh-contents)) (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) (defun doom*projectile-locate-dominating-file (orig-fn file name)
"Don't traverse the file system if on a remote connection." "Don't traverse the file system if on a remote connection."
(when (and (stringp file) (when (and (stringp file)
(not (file-remote-p file))) (not (file-remote-p file nil t)))
(funcall orig-fn file name))) (funcall orig-fn file name)))
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file) (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))) (and (eq orig-fn #'switch-to-buffer) (car args)))
(apply orig-fn buffer-or-name args) (apply orig-fn buffer-or-name args)
(let ((doom-inhibit-switch-buffer-hooks t)) (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) (with-current-buffer (if (windowp buffer)
(window-buffer buffer) (window-buffer 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 (if doom-inhibit-switch-buffer-hooks
(apply orig-fn args) (apply orig-fn args)
(let ((doom-inhibit-switch-buffer-hooks t)) (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 (with-current-buffer buffer
(run-hooks 'doom-switch-buffer-hook)) (run-hooks 'doom-switch-buffer-hook))
buffer))))) buffer)))))
@ -508,9 +508,10 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
:around #'doom*run-switch-buffer-hooks)) :around #'doom*run-switch-buffer-hooks))
;; Apply `doom-theme' ;; Apply `doom-theme'
(if (daemonp) (add-hook (if (daemonp)
(add-hook 'after-make-frame-functions #'doom|init-theme) 'after-make-frame-functions
(add-hook 'doom-init-ui-hook #'doom|init-theme)) 'doom-init-ui-hook)
#'doom|init-theme)
;; Apply `doom-font' et co ;; Apply `doom-font' et co
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts) (add-hook 'doom-after-init-modules-hook #'doom|init-fonts)
;; Ensure unicode fonts are set on each frame ;; Ensure unicode fonts are set on each frame

View file

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

View file

@ -98,7 +98,7 @@ playback.")
(defun +irc*circe-truncate-nicks () (defun +irc*circe-truncate-nicks ()
"Truncate long nicknames in chat output non-destructively." "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) (goto-char beg)
(let ((end (next-single-property-change beg 'lui-format-argument)) (let ((end (next-single-property-change beg 'lui-format-argument))
(nick (plist-get (plist-get (text-properties-at beg) 'lui-keywords) (nick (plist-get (plist-get (text-properties-at beg) 'lui-keywords)

View file

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

View file

@ -71,7 +71,7 @@
(show-buffers (doom-buffers-in-mode 'elfeed-show-mode)) (show-buffers (doom-buffers-in-mode 'elfeed-show-mode))
kill-buffer-query-functions) kill-buffer-query-functions)
(dolist (file +rss-elfeed-files) (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))) (kill-buffer buf)))
(dolist (b search-buffers) (dolist (b search-buffers)
(with-current-buffer b (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)) (task-tags (mapcar #'car +ivy-task-tags))
(cmd (cmd
(format "%s -H -S --no-heading -- %s %s" (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")) (concat bin " --line-number"))
(when-let* ((bin (executable-find "ag"))) (when-let (bin (executable-find "ag"))
(concat bin " --numbers")) (concat bin " --numbers"))
(error "ripgrep & the_silver_searcher are unavailable")) (error "ripgrep & the_silver_searcher are unavailable"))
(shell-quote-argument (shell-quote-argument
@ -306,7 +306,7 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
(interactive) (interactive)
(call-interactively (call-interactively
(cond ((or (file-equal-p default-directory "~") (cond ((or (file-equal-p default-directory "~")
(when-let* ((proot (doom-project-root))) (when-let (proot (doom-project-root))
(file-equal-p proot "~"))) (file-equal-p proot "~")))
#'counsel-find-file) #'counsel-find-file)

View file

@ -124,7 +124,7 @@ more information on modifiers."
(file-relative-name parent))))) (file-relative-name parent)))))
("s" ("s"
(if (featurep 'evil) (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))) (let ((pattern (evil-transform-vim-style-regexp (car args)))
(replace (cadr args))) (replace (cadr args)))
(replace-regexp-in-string (replace-regexp-in-string

View file

@ -33,7 +33,9 @@ ignored. This makes it easy to override built-in snippets with private ones."
(interactive) (interactive)
(let* ((snippet (car (yas-active-snippets))) (let* ((snippet (car (yas-active-snippets)))
(active-field (yas--snippet-active-field snippet)) (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) (if (= (point) position)
(move-beginning-of-line 1) (move-beginning-of-line 1)
(goto-char position)))) (goto-char position))))
@ -44,7 +46,9 @@ ignored. This makes it easy to override built-in snippets with private ones."
(interactive) (interactive)
(let* ((snippet (car (yas-active-snippets))) (let* ((snippet (car (yas-active-snippets)))
(active-field (yas--snippet-active-field snippet)) (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) (if (= (point) position)
(move-end-of-line 1) (move-end-of-line 1)
(goto-char position)))) (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-P is a boolean. If non-nil, it marks that email account as the
default/fallback account." default/fallback account."
(after! mu4e (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)) (add-to-list 'mu4e-user-mail-address-list address))
(setq mu4e-contexts (setq mu4e-contexts
(cl-loop for context in mu4e-contexts (cl-loop for context in mu4e-contexts

View file

@ -173,7 +173,7 @@ compilation dbs."
;; (defun +cc|init-ccls-compile-options () ;; (defun +cc|init-ccls-compile-options ()
;; "TODO" ;; "TODO"
;; (when (memq major-mode '(c-mode c++-mode objc-mode)) ;; (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))))) ;; (let ((args (delq nil (cdr-safe (assq major-mode +cc-default-compiler-options)))))
;; (setf (alist-get (or (lsp-workspace-root) ;; (setf (alist-get (or (lsp-workspace-root)
;; (lsp--suggest-project-root) ;; (lsp--suggest-project-root)
@ -190,10 +190,10 @@ compilation dbs."
"Takes the local project include paths and registers them with ffap. "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 This way, `find-file-at-point' (and `+lookup/file') will know where to find most
header files." 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) (and (featurep 'lsp)
(or (lsp-workspace-root) (or (lsp-workspace-root)
(doom-project-root)))))) (doom-project-root)))))
(require 'ffap) (require 'ffap)
(make-local-variable 'ffap-c-path) (make-local-variable 'ffap-c-path)
(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) (or (and (not refresh-p)
(gethash project-root +javascript-npm-conf)) (gethash project-root +javascript-npm-conf))
(let ((package-file (expand-file-name "package.json" project-root))) (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) (require 'json)
(json-read-file package-file)))) (json-read-file package-file)))
(puthash project-root json +javascript-npm-conf)))))) (puthash project-root json +javascript-npm-conf))))))
;;;###autoload ;;;###autoload
(defun +javascript-npm-dep-p (packages &optional project-root refresh-p) (defun +javascript-npm-dep-p (packages &optional project-root refresh-p)
(when-let* ((data (and (bound-and-true-p +javascript-npm-mode) (when-let (data (and (bound-and-true-p +javascript-npm-mode)
(+javascript-npm-conf project-root refresh-p)))) (+javascript-npm-conf project-root refresh-p)))
(let ((deps (append (cdr (assq 'dependencies data)) (let ((deps (append (cdr (assq 'dependencies data))
(cdr (assq 'devDependencies data))))) (cdr (assq 'devDependencies data)))))
(cond ((listp packages) (cond ((listp packages)

View file

@ -11,7 +11,7 @@
(defun +lua/run-love-game () (defun +lua/run-love-game ()
"Run the current project with Love2D." "Run the current project with Love2D."
(interactive) (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 (async-shell-command
(format "%s %s" (format "%s %s"
(or (executable-find "love") (or (executable-find "love")

View file

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

View file

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

View file

@ -20,9 +20,9 @@ ignore the cache."
(let ((project-root (or project-root (doom-project-root)))) (let ((project-root (or project-root (doom-project-root))))
(or (and (not refresh-p) (gethash project-root +php-composer-conf)) (or (and (not refresh-p) (gethash project-root +php-composer-conf))
(let ((package-file (expand-file-name "composer.json" project-root))) (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) (require 'json)
(json-read-file package-file)))) (json-read-file package-file)))
(puthash project-root data +php-composer-conf)))))) (puthash project-root data +php-composer-conf))))))
;;;###autoload ;;;###autoload

View file

@ -11,7 +11,7 @@ can use a remote conda environment, including the corresponding remote python
executable and packages." executable and packages."
(interactive) (interactive)
(require 'conda) (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) (setq conda-anaconda-home home)
(message "Successfully changed conda home to: %s" (abbreviate-file-name 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) (let ((bin (expand-file-name (concat conda-env-current-name "/" exe-root)
(conda-env-default-location)))) (conda-env-default-location))))
(if (file-executable-p bin) bin)))) (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)))) (setq-local doom-modeline-python-executable (expand-file-name "bin/python" bin))))
((executable-find exe)))))) ((executable-find exe))))))

View file

@ -16,7 +16,7 @@
(ring-remove+insert+extend +eshell-buffers buf 'grow)) (ring-remove+insert+extend +eshell-buffers buf 'grow))
(defun +eshell--remove-buffer (buf) (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) (ring-remove +eshell-buffers idx)
t)) t))
@ -26,7 +26,7 @@
(when (eq major-mode 'eshell-mode) (when (eq major-mode 'eshell-mode)
(switch-to-buffer (doom-fallback-buffer))) (switch-to-buffer (doom-fallback-buffer)))
(when +eshell-enable-new-shell-on-split (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)))) (set-window-dedicated-p win dedicated-p))))
(defun +eshell--setup-window (window &optional flag) (defun +eshell--setup-window (window &optional flag)
@ -284,7 +284,7 @@ delete."
"Close window (or workspace) on quit." "Close window (or workspace) on quit."
(let ((buf (current-buffer))) (let ((buf (current-buffer)))
(when (+eshell--remove-buffer buf) (when (+eshell--remove-buffer buf)
(when-let* ((win (get-buffer-window buf))) (when-let (win (get-buffer-window buf))
(+eshell--setup-window win nil) (+eshell--setup-window win nil)
(cond ((and (one-window-p t) (cond ((and (one-window-p t)
(window-configuration-p (frame-parameter nil 'saved-wconf))) (window-configuration-p (frame-parameter nil 'saved-wconf)))

View file

@ -15,7 +15,7 @@
(defun +eval*quickrun-auto-close (&rest _) (defun +eval*quickrun-auto-close (&rest _)
"Allows us to silently re-run quickrun from within the quickrun buffer." "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)) (let ((inhibit-message t))
(quickrun--kill-running-process) (quickrun--kill-running-process)
(message "")) (message ""))
@ -41,7 +41,7 @@
(defun +eval|quickrun-shrink-window () (defun +eval|quickrun-shrink-window ()
"Shrink the quickrun output window once code evaluation is complete." "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) (with-selected-window (get-buffer-window quickrun--buffer-name)
(let ((ignore-window-parameters t)) (let ((ignore-window-parameters t))
(shrink-window-if-larger-than-buffer))))) (shrink-window-if-larger-than-buffer)))))
@ -49,7 +49,7 @@
(defun +eval|quickrun-scroll-to-bof () (defun +eval|quickrun-scroll-to-bof ()
"Ensures window is scrolled to BOF on invocation." "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 (with-selected-window win
(goto-char (point-min))))) (goto-char (point-min)))))
(add-hook 'quickrun-after-run-hook #'+eval|quickrun-scroll-to-bof)) (add-hook 'quickrun-after-run-hook #'+eval|quickrun-scroll-to-bof))

View file

@ -16,7 +16,7 @@
;;;###autoload ;;;###autoload
(defun +flyspell|init-predicate () (defun +flyspell|init-predicate ()
"TODO" "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)))) (setq-local flyspell-generic-check-word-predicate (cdr pred))))
;;;###autoload ;;;###autoload

View file

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

View file

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

View file

@ -98,7 +98,7 @@ It is passed a user and repository name.")
[tab] #'magit-section-toggle) [tab] #'magit-section-toggle)
(after! git-rebase (after! git-rebase
(dolist (key '(("M-k" . "gk") ("M-j" . "gj"))) (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)))) (setcar desc (cdr key))))
(evil-define-key* evil-magit-state git-rebase-mode-map (evil-define-key* evil-magit-state git-rebase-mode-map
"gj" #'git-rebase-move-line-down "gj" #'git-rebase-move-line-down

View file

@ -12,7 +12,7 @@
"Delete service at point. Asks for confirmation." "Delete service at point. Asks for confirmation."
(interactive "P") (interactive "P")
(prodigy-with-refresh (prodigy-with-refresh
(when-let* ((service (prodigy-service-at-pos))) (when-let (service (prodigy-service-at-pos))
(let ((name (plist-get service :name))) (let ((name (plist-get service :name)))
(cond ((or arg (cond ((or arg
(y-or-n-p (format "Delete '%s' service?" name))) (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 the Doom dashboard. It ensures that the dashboard is always in the correct
project (which may be different across perspective)." project (which may be different across perspective)."
(when (bound-and-true-p persp-mode) (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)))) (+doom-dashboard-update-pwd pwd))))
(defun +doom-dashboard|record-project (&optional persp &rest _) (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))) (propertize (symbol-name action) 'face 'font-lock-constant-face)))
(format "%-37s" (buffer-string))) (format "%-37s" (buffer-string)))
;; Lookup command keys dynamically ;; 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 (with-temp-buffer
(save-excursion (insert (key-description key))) (save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t) (while (re-search-forward "<\\([^>]+\\)>" nil t)

View file

@ -45,12 +45,12 @@
:defer t :defer t
:init :init
(defun +doom|solaire-mode-swap-bg-maybe () (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) (require 'solaire-mode)
(when (cdr rule) (when (cdr rule)
(solaire-mode-swap-bg) (solaire-mode-swap-bg)
(with-eval-after-load 'ansi-color (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)))))) (setf (aref ansi-color-names-vector 0) color))))))
(add-hook 'doom-load-theme-hook #'+doom|solaire-mode-swap-bg-maybe t) (add-hook 'doom-load-theme-hook #'+doom|solaire-mode-swap-bg-maybe t)
:config :config

View file

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

View file

@ -160,7 +160,7 @@ the command buffer."
origin) origin)
(save-popups! (save-popups!
(find-file path) (find-file path)
(-when-let (pos (get-text-property button 'position (when-let (pos (get-text-property button 'position
(marker-buffer button))) (marker-buffer button)))
(goto-char pos)) (goto-char pos))
(setq origin (selected-window)) (setq origin (selected-window))
@ -179,7 +179,7 @@ the command buffer."
(cl-letf* ((old-org-completing-read (symbol-function 'org-completing-read)) (cl-letf* ((old-org-completing-read (symbol-function 'org-completing-read))
((symbol-function 'org-completing-read) ((symbol-function 'org-completing-read)
(lambda (&rest args) (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 ;; While helm is opened as a popup, it will mistaken the
;; *Org Links* popup for the "originated window", and will ;; *Org Links* popup for the "originated window", and will
;; target it for actions invoked by the user. However, since ;; target it for actions invoked by the user. However, since
@ -216,7 +216,7 @@ the command buffer."
;;;###package Info ;;;###package Info
(defun +popup*switch-to-info-window (&rest _) (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) (when (+popup-window-p win)
(select-window win)))) (select-window win))))
(advice-add #'info-lookup-symbol :after #'+popup*switch-to-info-window) (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-demoted-errors "Error killing transient buffer: %s"
(with-current-buffer buffer (with-current-buffer buffer
(let (confirm-kill-processes) (let (confirm-kill-processes)
(when-let* ((process (get-buffer-process buffer))) (when-let (process (get-buffer-process buffer))
(kill-process process)) (kill-process process))
(let (kill-buffer-hook kill-buffer-query-functions) (let (kill-buffer-hook kill-buffer-query-functions)
(kill-buffer buffer)))))))))) (kill-buffer buffer))))))))))
@ -50,7 +50,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)
@ -75,7 +75,7 @@ the buffer is visible, then set another timer and try again later."
(defun +popup--delete-other-windows (window) (defun +popup--delete-other-windows (window)
"Fixes `delete-other-windows' when used from a popup 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)) (let ((ignore-window-parameters t))
(delete-other-windows window))) (delete-other-windows window)))
nil) nil)
@ -179,9 +179,9 @@ and enables `+popup-buffer-mode'."
(unless +popup--inhibit-select (unless +popup--inhibit-select
(select-window window)) (select-window 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) if (funcall func buffer alist)
return it))) return it))
(+popup--init popup alist) (+popup--init popup alist)
(unless +popup--inhibit-select (unless +popup--inhibit-select
(let ((select (+popup-parameter 'select popup))) (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 ;;;###autoload
(defun +popup|kill-buffer-hook () (defun +popup|kill-buffer-hook ()
"TODO" "TODO"
(when-let* ((window (get-buffer-window))) (when-let (window (get-buffer-window))
(when (+popup-window-p window) (when (+popup-window-p window)
(let ((+popup--inhibit-transient t)) (let ((+popup--inhibit-transient t))
(+popup--delete-window window))))) (+popup--delete-window window)))))
@ -504,7 +504,7 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
((not windows) ((not windows)
(cl-letf (((symbol-function 'window--make-major-side-window-next-to) (cl-letf (((symbol-function 'window--make-major-side-window-next-to)
(lambda (_side) (frame-root-window (selected-frame))))) (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) (set-window-parameter window 'window-vslot vslot)
(add-to-list 'window-persistent-parameters '(window-vslot . writable)) (add-to-list 'window-persistent-parameters '(window-vslot . writable))
window))) window)))

View file

@ -98,7 +98,7 @@ Pretty symbols can be unset for emacs-lisp-mode with:
(:merge (setq merge (pop plist))) (:merge (setq merge (pop plist)))
(:alist (setq results (append (pop plist) results))) (: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))))) (push (cons (pop plist) char) results)))))
(dolist (mode (doom-enlist modes)) (dolist (mode (doom-enlist modes))
(unless merge (unless merge

View file

@ -53,7 +53,7 @@
"Return a workspace named NAME. Unless NOERROR is non-nil, this throws an "Return a workspace named NAME. Unless NOERROR is non-nil, this throws an
error if NAME doesn't exist." error if NAME doesn't exist."
(cl-check-type name string) (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) (cond ((+workspace-p persp) persp)
((not noerror) ((not noerror)
(error "No workspace called '%s' was found" name))))) (error "No workspace called '%s' was found" name)))))