refactor: replace doom-enlist with ensure-list
doom-enlist is now a deprecated alias for ensure-list, which is built into Emacs 28.1+ and is its drop-in replacement. We've already backported it for 27.x users in doom-lib (in4bf4978
). Ref:4bf49785fd
This commit is contained in:
parent
1abcf913aa
commit
057e6c531c
28 changed files with 41 additions and 46 deletions
|
@ -118,7 +118,7 @@ list remains lean."
|
|||
(dolist (,recipe-var ,recipes-var (nreverse built))
|
||||
(cl-block nil
|
||||
(straight--with-plist (append (list :recipe ,recipe-var) ,recipe-var)
|
||||
,(doom-enlist binds)
|
||||
,(ensure-list binds)
|
||||
,@body))))))
|
||||
|
||||
(defvar doom-packages--cli-updated-recipes nil)
|
||||
|
|
|
@ -216,7 +216,7 @@ execution. Can be generated from a `doom-cli-context' with
|
|||
|
||||
This means that all non-keywords are strings, any prefixes provided by PLIST are
|
||||
prepended, and the keyword is in front."
|
||||
(let* ((command (doom-enlist command))
|
||||
(let* ((command (ensure-list command))
|
||||
(prefix (plist-get plist :prefix))
|
||||
(prefix (if prefix (doom-cli-command-normalize
|
||||
prefix (append `(:prefix nil) plist))))
|
||||
|
@ -435,14 +435,14 @@ If RECURSIVE, includes breadcrumbs leading up to COMMANDSPEC."
|
|||
collect command)))
|
||||
(seq-reduce (lambda (init next)
|
||||
(nconc (cl-loop with firstlen = (length (car init))
|
||||
for seg in (doom-enlist next)
|
||||
for seg in (ensure-list next)
|
||||
nconc
|
||||
(cl-loop for command in init
|
||||
while (= (length command) firstlen)
|
||||
collect (append command (list seg))))
|
||||
init))
|
||||
(cdr commandspec)
|
||||
`(,@(mapcar #'list (doom-enlist (car commandspec)))))))
|
||||
`(,@(mapcar #'list (ensure-list (car commandspec)))))))
|
||||
|
||||
(defun doom-cli--parse-docs (docs)
|
||||
(when (and (stringp docs)
|
||||
|
@ -1639,7 +1639,7 @@ yet. They won't be included in command listings (by help documentation)."
|
|||
(push `(cl-callf plist-put doom-cli--plist
|
||||
,key ,(if (eq key :prefix)
|
||||
`(append (plist-get doom-cli--plist ,key)
|
||||
(doom-enlist ,val))
|
||||
(ensure-list ,val))
|
||||
val))
|
||||
forms)))
|
||||
(nreverse forms))
|
||||
|
|
|
@ -290,9 +290,9 @@ For example, :nvi will map to (list 'normal 'visual 'insert). See
|
|||
(:desc
|
||||
(setq desc (pop rest)))
|
||||
(:map
|
||||
(doom--map-set :keymaps `(quote ,(doom-enlist (pop rest)))))
|
||||
(doom--map-set :keymaps `(quote ,(ensure-list (pop rest)))))
|
||||
(:mode
|
||||
(push (cl-loop for m in (doom-enlist (pop rest))
|
||||
(push (cl-loop for m in (ensure-list (pop rest))
|
||||
collect (intern (concat (symbol-name m) "-map")))
|
||||
rest)
|
||||
(push :map rest))
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
If a mode is quoted, it is left as is. If the entire HOOKS list is quoted, the
|
||||
list is returned as-is."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(let ((hook-list (doom-enlist (doom-unquote hooks))))
|
||||
(let ((hook-list (ensure-list (doom-unquote hooks))))
|
||||
(if (eq (car-safe hooks) 'quote)
|
||||
hook-list
|
||||
(cl-loop for hook in hook-list
|
||||
|
@ -53,11 +53,6 @@ list is returned as-is."
|
|||
(setq exp (cadr exp)))
|
||||
exp)
|
||||
|
||||
(defun doom-enlist (exp)
|
||||
"Return EXP wrapped in a list, or as-is if already a list."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(if (proper-list-p exp) exp (list exp)))
|
||||
|
||||
(defun doom-keyword-intern (str)
|
||||
"Converts STR (a string) into a keyword (`keywordp')."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
|
@ -760,7 +755,7 @@ DOCSTRING and BODY are as in `defun'.
|
|||
(setq docstring nil))
|
||||
(let (where-alist)
|
||||
(while (keywordp (car body))
|
||||
(push `(cons ,(pop body) (doom-enlist ,(pop body)))
|
||||
(push `(cons ,(pop body) (ensure-list ,(pop body)))
|
||||
where-alist))
|
||||
`(progn
|
||||
(defun ,symbol ,arglist ,docstring ,@body)
|
||||
|
@ -780,7 +775,7 @@ testing advice (when combined with `rotate-text').
|
|||
(unless (stringp docstring)
|
||||
(push docstring body))
|
||||
(while (keywordp (car body))
|
||||
(push `(cons ,(pop body) (doom-enlist ,(pop body)))
|
||||
(push `(cons ,(pop body) (ensure-list ,(pop body)))
|
||||
where-alist))
|
||||
`(dolist (targets (list ,@(nreverse where-alist)))
|
||||
(dolist (target (cdr targets))
|
||||
|
|
|
@ -140,7 +140,7 @@ uses a straight or package.el command directly).")
|
|||
(print! (start "Installing straight..."))
|
||||
(print-group!
|
||||
(cl-destructuring-bind (depth . options)
|
||||
(doom-enlist straight-vc-git-default-clone-depth)
|
||||
(ensure-list straight-vc-git-default-clone-depth)
|
||||
(let ((branch-switch (if (memq 'single-branch options)
|
||||
"--single-branch"
|
||||
"--no-single-branch")))
|
||||
|
@ -341,7 +341,7 @@ non-nil."
|
|||
|
||||
(defun doom-package-is-type-p (package type)
|
||||
"TODO"
|
||||
(memq type (doom-enlist (doom-package-get package :type))))
|
||||
(memq type (ensure-list (doom-package-get package :type))))
|
||||
|
||||
(defun doom-package-in-module-p (package category &optional module)
|
||||
"Return non-nil if PACKAGE was installed by the user's private config."
|
||||
|
@ -585,7 +585,7 @@ should use it!"
|
|||
(cl-loop for target in targets
|
||||
if (or (keywordp target) (listp target))
|
||||
append
|
||||
(cl-loop with (category . modules) = (doom-enlist target)
|
||||
(cl-loop with (category . modules) = (ensure-list target)
|
||||
for (name . plist) in doom-packages
|
||||
for pkg-modules = (plist-get plist :modules)
|
||||
if (and (assq category pkg-modules)
|
||||
|
|
|
@ -160,7 +160,7 @@ See `doom-real-buffer-p' for details on what that means."
|
|||
"Return a list of buffers whose `major-mode' is `eq' to MODE(S).
|
||||
|
||||
If DERIVED-P, test with `derived-mode-p', otherwise use `eq'."
|
||||
(let ((modes (doom-enlist modes)))
|
||||
(let ((modes (ensure-list modes)))
|
||||
(cl-remove-if-not (if derived-p
|
||||
(lambda (buf)
|
||||
(apply #'provided-mode-derived-p
|
||||
|
|
|
@ -101,7 +101,7 @@ The search recurses up to DEPTH and no further. DEPTH is an integer.
|
|||
|
||||
MATCH is a string regexp. Only entries that match it will be included."
|
||||
(let (result)
|
||||
(dolist (file (mapcan (doom-rpartial #'doom-glob "*") (doom-enlist paths)))
|
||||
(dolist (file (mapcan (doom-rpartial #'doom-glob "*") (ensure-list paths)))
|
||||
(cond ((file-directory-p file)
|
||||
(appendq!
|
||||
result
|
||||
|
|
|
@ -111,7 +111,7 @@ selection of all minor-modes, active or not."
|
|||
"TODO"
|
||||
(require 'org)
|
||||
(let* ((default-directory doom-docs-dir)
|
||||
(org-agenda-files (mapcar #'expand-file-name (doom-enlist files)))
|
||||
(org-agenda-files (mapcar #'expand-file-name (ensure-list files)))
|
||||
(depth (if (integerp depth) depth))
|
||||
(mindepth (if (integerp mindepth) mindepth))
|
||||
(org-inhibit-startup t))
|
||||
|
|
|
@ -316,7 +316,7 @@ editorconfig or dtrt-indent installed."
|
|||
(editorconfig-set-indentation nil width)))
|
||||
((require 'dtrt-indent nil t)
|
||||
(when-let (vars (nth 2 (assq major-mode dtrt-indent-hook-mapping-list)))
|
||||
(dolist (var (doom-enlist vars))
|
||||
(dolist (var (ensure-list vars))
|
||||
(doom-log "Updated %s = %d" var width)
|
||||
(set var width)))))
|
||||
(message "Changed indentation to %d" width))
|
||||
|
|
|
@ -28,7 +28,7 @@ all themes. It will apply to all themes once they are loaded."
|
|||
`(progn
|
||||
(defun ,fn ()
|
||||
(let (custom--inhibit-theme-enable)
|
||||
(dolist (theme (doom-enlist (or ,theme 'user)))
|
||||
(dolist (theme (ensure-list (or ,theme 'user)))
|
||||
(when (or (eq theme 'user)
|
||||
(custom-theme-enabled-p theme))
|
||||
(apply #'custom-theme-set-faces theme
|
||||
|
|
|
@ -174,7 +174,7 @@ the word at point should be spell checked. For example:
|
|||
"Return t if point is on a word that should be spell checked.
|
||||
|
||||
Return nil if on a link url, markup, html, or references."
|
||||
(let ((faces (doom-enlist (get-text-property (point) 'face))))
|
||||
(let ((faces (ensure-list (get-text-property (point) 'face))))
|
||||
(or (and (memq 'font-lock-comment-face faces)
|
||||
(memq 'markdown-code-face faces))
|
||||
(not (cl-loop with unsafe-faces = '(markdown-reference-face
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
(defun set-flyspell-predicate! (modes predicate)
|
||||
"TODO"
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes) +spell--flyspell-predicate-alist)
|
||||
(dolist (mode (ensure-list modes) +spell--flyspell-predicate-alist)
|
||||
(add-to-list '+spell--flyspell-predicate-alist (cons mode predicate))))
|
||||
|
||||
;;;###autoload
|
||||
|
|
|
@ -30,7 +30,7 @@ Examples:
|
|||
|
||||
(set-company-backend! 'sh-mode nil) ; unsets backends for sh-mode"
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(if (null (car backends))
|
||||
(setq +company-backend-alist
|
||||
(delq (assq mode +company-backend-alist)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
(declare (indent defun))
|
||||
(after! evil
|
||||
(if (listp modes)
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(evil-set-initial-state mode state))
|
||||
(evil-set-initial-state modes state))))
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@
|
|||
(when (and unset (not (gethash name format-all--format-table)))
|
||||
(error "'%s' formatter does not exist to be unset" name))
|
||||
(puthash name function format-all--format-table)
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(cl-destructuring-bind (m &optional probe)
|
||||
(doom-enlist mode)
|
||||
(ensure-list mode)
|
||||
(if unset
|
||||
(puthash m (assq-delete-all name (gethash key format-all-mode-table))
|
||||
format-all-mode-table)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"Declare :symbols, :words or :patterns (all lists of strings) that
|
||||
`rotate-text' will cycle through."
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(let ((fn-name (intern (format "+rotate-text-init-%s-h" mode))))
|
||||
(fset fn-name
|
||||
(lambda ()
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
(defun set-yas-minor-mode! (modes)
|
||||
"Register minor MODES (one mode symbol or a list of them) with yasnippet so it
|
||||
can have its own snippets category, if the folder exists."
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(let ((fn (intern (format "+snippets-register-%s-h" mode))))
|
||||
(fset fn (lambda () (yas-activate-extra-mode mode)))
|
||||
(add-hook (intern (format "%s-hook" mode)) fn))))
|
||||
|
|
|
@ -9,7 +9,7 @@ Enables `electric-indent-local-mode' in MODES.
|
|||
|
||||
\(fn MODES &key WORDS CHARS)"
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(let ((hook (intern (format "%s-hook" mode)))
|
||||
(fn (intern (format "+electric--init-%s-h" mode))))
|
||||
(cond ((null (car-safe plist))
|
||||
|
|
|
@ -26,7 +26,7 @@ exist, and `org-link' otherwise."
|
|||
(apply #'org-link-set-parameters
|
||||
key
|
||||
:complete (lambda ()
|
||||
(if requires (mapc #'require (doom-enlist requires)))
|
||||
(if requires (mapc #'require (ensure-list requires)))
|
||||
(+org--relative-path (+org--read-link-path key (funcall dir-fn))
|
||||
(funcall dir-fn)))
|
||||
:follow (lambda (link)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
:defer t
|
||||
:config
|
||||
(setq org-cite-global-bibliography
|
||||
(doom-enlist
|
||||
(ensure-list
|
||||
(or (bound-and-true-p citar-bibliography)
|
||||
(bound-and-true-p bibtex-completion-bibliography)))
|
||||
;; Setup export processor; default csl/citeproc-el, with biblatex for
|
||||
|
|
|
@ -119,9 +119,9 @@
|
|||
(pcase-dolist (`((,category . ,modules) :after ,after :require ,libs)
|
||||
+debugger--dap-alist)
|
||||
(when (doom-module-p category (car modules) (cadr modules))
|
||||
(dolist (lib (doom-enlist after))
|
||||
(dolist (lib (ensure-list after))
|
||||
(with-eval-after-load lib
|
||||
(mapc #'require (doom-enlist libs))))))
|
||||
(mapc #'require (ensure-list libs))))))
|
||||
|
||||
(dap-mode 1)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ recognized:
|
|||
Defaults to `+eval/region', which will run the :send-region specified function
|
||||
or `+eval/send-region-to-repl'."
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(setf (alist-get mode +eval-repls)
|
||||
(cons command plist))))
|
||||
|
||||
|
@ -59,7 +59,7 @@ MODES can be list of major mode symbols, or a single one.
|
|||
4. If MODE is not a string and COMMANd is a symbol, add it to
|
||||
`+eval-runners', which is used by `+eval/region'."
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(cond ((symbolp command)
|
||||
(push (cons mode command) +eval-runners))
|
||||
((stringp command)
|
||||
|
|
|
@ -27,7 +27,7 @@ Example:
|
|||
Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
||||
(declare (indent defun))
|
||||
(let ((action (if (keywordp (car docsets)) (pop docsets))))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(let ((hook (intern (format "%s-hook" mode)))
|
||||
(fn (intern (format "+lookup-init--%s-%s" (or action "set") mode))))
|
||||
(if (null docsets)
|
||||
|
|
|
@ -66,7 +66,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
|||
|
||||
\(fn MODES &key DEFINITION IMPLEMENTATIONS TYPE-DEFINITION REFERENCES DOCUMENTATION FILE XREF-BACKEND ASYNC)"
|
||||
(declare (indent defun))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(let ((hook (intern (format "%s-hook" mode)))
|
||||
(fn (intern (format "+lookup--init-%s-handlers-h" mode))))
|
||||
(if (null (car plist))
|
||||
|
@ -106,7 +106,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
|||
(defun +lookup--set-handler (spec functions-var &optional async enable)
|
||||
(when spec
|
||||
(cl-destructuring-bind (fn . plist)
|
||||
(doom-enlist spec)
|
||||
(ensure-list spec)
|
||||
(if (not enable)
|
||||
(remove-hook functions-var fn 'local)
|
||||
(put fn '+lookup-async (or (plist-get plist :async) async))
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
single one. If a list, the first field found will be returned. Will error out
|
||||
otherwise, unless NOERROR is non-nill."
|
||||
(if-let* ((data (if (listp entry) entry (+pass-get-entry entry))))
|
||||
(cl-loop for key in (doom-enlist fields)
|
||||
(cl-loop for key in (ensure-list fields)
|
||||
when (assoc key data)
|
||||
return (cdr it))
|
||||
(unless noerror
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
'(((lambda (limit)
|
||||
(let (case-fold-search)
|
||||
(and (re-search-forward hl-todo-regexp limit t)
|
||||
(memq 'font-lock-comment-face (doom-enlist (get-text-property (point) 'face))))))
|
||||
(memq 'font-lock-comment-face (ensure-list (get-text-property (point) 'face))))))
|
||||
(1 (hl-todo-get-face) t t))))
|
||||
(when hl-todo-mode
|
||||
(hl-todo-mode -1)
|
||||
|
|
|
@ -33,7 +33,7 @@ Pretty symbols can be unset for emacs-lisp-mode with:
|
|||
(set-ligatures! 'emacs-lisp-mode nil)"
|
||||
(declare (indent defun))
|
||||
(if (null (car-safe plist))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(delq! mode +ligatures-extra-alist 'assq))
|
||||
(let (results)
|
||||
(while plist
|
||||
|
@ -42,7 +42,7 @@ Pretty symbols can be unset for emacs-lisp-mode with:
|
|||
(prependq! results (pop plist))
|
||||
(when-let (char (plist-get +ligatures-extra-symbols key))
|
||||
(push (cons (pop plist) char) results)))))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(dolist (mode (ensure-list modes))
|
||||
(setf (alist-get mode +ligatures-extra-alist)
|
||||
(if-let (old-results (alist-get mode +ligatures-extra-alist))
|
||||
(dolist (cell results old-results)
|
||||
|
|
|
@ -143,7 +143,7 @@ If DEFAULT is non-nil, apply to all future buffers. Modelines are defined with
|
|||
"Set the modeline to NAME on HOOKS.
|
||||
See `def-modeline!' on how modelines are defined."
|
||||
(let ((fn (intern (format "+modeline-set-%s-format-h" name))))
|
||||
(dolist (hook (doom-enlist hooks))
|
||||
(dolist (hook (ensure-list hooks))
|
||||
(when after-init-time
|
||||
(dolist (name (mapcar #'car +modeline-format-alist))
|
||||
(remove-hook hook (intern (format "+modeline-set-%s-format-h" name)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue