Minor refactors across the board
- when-let* -> when-let - Fix projectile-locate-dominating-file for connected remote files
This commit is contained in:
parent
4ecf6c9414
commit
9a02bd8ac8
42 changed files with 114 additions and 110 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
33
core/core.el
33
core/core.el
|
@ -318,22 +318,21 @@ 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
|
||||
(doom-log "Incrementally loading %s" req)
|
||||
(condition-case e
|
||||
(or (while-no-input (require req nil t) t)
|
||||
(push req reqs))
|
||||
((error debug)
|
||||
(message "Failed to load '%s' package incrementally, because: %s"
|
||||
req e)))
|
||||
(if reqs
|
||||
(run-with-idle-timer doom-incremental-idle-timer
|
||||
nil #'doom-load-packages-incrementally
|
||||
reqs t)
|
||||
(doom-log "Finished incremental loading"))))))))
|
||||
(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)
|
||||
(push req reqs))
|
||||
((error debug)
|
||||
(message "Failed to load '%s' package incrementally, because: %s"
|
||||
req e)))
|
||||
(if reqs
|
||||
(run-with-idle-timer doom-incremental-idle-timer
|
||||
nil #'doom-load-packages-incrementally
|
||||
reqs t)
|
||||
(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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue