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 (in 4bf4978).

Ref: 4bf49785fd
This commit is contained in:
Henrik Lissner 2022-08-07 12:24:14 +02:00
parent 1abcf913aa
commit 057e6c531c
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
28 changed files with 41 additions and 46 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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