From 057e6c531c2d74d4b88cadb03c12a4d776665edb Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 7 Aug 2022 12:24:14 +0200 Subject: [PATCH] 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: 4bf49785fdeb --- lisp/cli/packages.el | 2 +- lisp/doom-cli-lib.el | 8 ++++---- lisp/doom-keybinds.el | 4 ++-- lisp/doom-lib.el | 11 +++-------- lisp/doom-packages.el | 6 +++--- lisp/lib/buffers.el | 2 +- lisp/lib/files.el | 2 +- lisp/lib/help.el | 2 +- lisp/lib/text.el | 2 +- lisp/lib/themes.el | 2 +- modules/checkers/spell/README.org | 2 +- modules/checkers/spell/autoload/+flyspell.el | 2 +- modules/completion/company/autoload.el | 2 +- modules/editor/evil/autoload/evil.el | 2 +- modules/editor/format/autoload/settings.el | 4 ++-- modules/editor/rotate-text/autoload.el | 2 +- modules/editor/snippets/autoload/settings.el | 2 +- modules/emacs/electric/autoload.el | 2 +- modules/lang/org/autoload/org-link.el | 2 +- modules/tools/biblio/config.el | 2 +- modules/tools/debugger/config.el | 4 ++-- modules/tools/eval/autoload/settings.el | 4 ++-- modules/tools/lookup/autoload/docsets.el | 2 +- modules/tools/lookup/autoload/lookup.el | 4 ++-- modules/tools/pass/autoload/pass.el | 2 +- modules/ui/hl-todo/config.el | 2 +- modules/ui/ligatures/autoload/ligatures.el | 4 ++-- modules/ui/modeline/+light.el | 2 +- 28 files changed, 41 insertions(+), 46 deletions(-) diff --git a/lisp/cli/packages.el b/lisp/cli/packages.el index e325f6e3c..fda5886a0 100644 --- a/lisp/cli/packages.el +++ b/lisp/cli/packages.el @@ -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) diff --git a/lisp/doom-cli-lib.el b/lisp/doom-cli-lib.el index 93c0fd8d0..304586f78 100644 --- a/lisp/doom-cli-lib.el +++ b/lisp/doom-cli-lib.el @@ -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)) diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index cf02235f1..104854b8d 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -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)) diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index e1ee9faa3..2f41b93ee 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -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)) diff --git a/lisp/doom-packages.el b/lisp/doom-packages.el index 2008bfb8a..e69bdd9ec 100644 --- a/lisp/doom-packages.el +++ b/lisp/doom-packages.el @@ -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) diff --git a/lisp/lib/buffers.el b/lisp/lib/buffers.el index 3d3a7b876..5354b2002 100644 --- a/lisp/lib/buffers.el +++ b/lisp/lib/buffers.el @@ -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 diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 0c0e21a25..c591fa9d7 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -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 diff --git a/lisp/lib/help.el b/lisp/lib/help.el index 8cd856491..bece21ded 100644 --- a/lisp/lib/help.el +++ b/lisp/lib/help.el @@ -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)) diff --git a/lisp/lib/text.el b/lisp/lib/text.el index 6c084489e..968b127fd 100644 --- a/lisp/lib/text.el +++ b/lisp/lib/text.el @@ -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)) diff --git a/lisp/lib/themes.el b/lisp/lib/themes.el index 73c43a9bb..9af956e65 100644 --- a/lisp/lib/themes.el +++ b/lisp/lib/themes.el @@ -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 diff --git a/modules/checkers/spell/README.org b/modules/checkers/spell/README.org index 2030afe72..b6c2d18bf 100644 --- a/modules/checkers/spell/README.org +++ b/modules/checkers/spell/README.org @@ -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 diff --git a/modules/checkers/spell/autoload/+flyspell.el b/modules/checkers/spell/autoload/+flyspell.el index 97feb8330..ad7b034ee 100644 --- a/modules/checkers/spell/autoload/+flyspell.el +++ b/modules/checkers/spell/autoload/+flyspell.el @@ -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 diff --git a/modules/completion/company/autoload.el b/modules/completion/company/autoload.el index f9c0fc0d4..4d006a2c8 100644 --- a/modules/completion/company/autoload.el +++ b/modules/completion/company/autoload.el @@ -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) diff --git a/modules/editor/evil/autoload/evil.el b/modules/editor/evil/autoload/evil.el index 53644a2b0..9527c1994 100644 --- a/modules/editor/evil/autoload/evil.el +++ b/modules/editor/evil/autoload/evil.el @@ -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)))) diff --git a/modules/editor/format/autoload/settings.el b/modules/editor/format/autoload/settings.el index a98942205..0261c175f 100644 --- a/modules/editor/format/autoload/settings.el +++ b/modules/editor/format/autoload/settings.el @@ -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) diff --git a/modules/editor/rotate-text/autoload.el b/modules/editor/rotate-text/autoload.el index 618d02737..32fafc6dd 100644 --- a/modules/editor/rotate-text/autoload.el +++ b/modules/editor/rotate-text/autoload.el @@ -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 () diff --git a/modules/editor/snippets/autoload/settings.el b/modules/editor/snippets/autoload/settings.el index f83a8df9d..5e508f4f9 100644 --- a/modules/editor/snippets/autoload/settings.el +++ b/modules/editor/snippets/autoload/settings.el @@ -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)))) diff --git a/modules/emacs/electric/autoload.el b/modules/emacs/electric/autoload.el index 1326c9fbd..f9946cfd4 100644 --- a/modules/emacs/electric/autoload.el +++ b/modules/emacs/electric/autoload.el @@ -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)) diff --git a/modules/lang/org/autoload/org-link.el b/modules/lang/org/autoload/org-link.el index ebf47b6a3..ab5bc03b8 100644 --- a/modules/lang/org/autoload/org-link.el +++ b/modules/lang/org/autoload/org-link.el @@ -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) diff --git a/modules/tools/biblio/config.el b/modules/tools/biblio/config.el index 42090d158..2b31ea412 100644 --- a/modules/tools/biblio/config.el +++ b/modules/tools/biblio/config.el @@ -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 diff --git a/modules/tools/debugger/config.el b/modules/tools/debugger/config.el index 6152ad9b7..ddacbf65e 100644 --- a/modules/tools/debugger/config.el +++ b/modules/tools/debugger/config.el @@ -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) diff --git a/modules/tools/eval/autoload/settings.el b/modules/tools/eval/autoload/settings.el index a11cb3831..76d8d2587 100644 --- a/modules/tools/eval/autoload/settings.el +++ b/modules/tools/eval/autoload/settings.el @@ -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) diff --git a/modules/tools/lookup/autoload/docsets.el b/modules/tools/lookup/autoload/docsets.el index 94779290a..8a60325fc 100644 --- a/modules/tools/lookup/autoload/docsets.el +++ b/modules/tools/lookup/autoload/docsets.el @@ -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) diff --git a/modules/tools/lookup/autoload/lookup.el b/modules/tools/lookup/autoload/lookup.el index 3a727c20a..e3496d53c 100644 --- a/modules/tools/lookup/autoload/lookup.el +++ b/modules/tools/lookup/autoload/lookup.el @@ -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)) diff --git a/modules/tools/pass/autoload/pass.el b/modules/tools/pass/autoload/pass.el index 76356d9b4..375275779 100644 --- a/modules/tools/pass/autoload/pass.el +++ b/modules/tools/pass/autoload/pass.el @@ -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 diff --git a/modules/ui/hl-todo/config.el b/modules/ui/hl-todo/config.el index 9fc6bc479..8d0e6150b 100644 --- a/modules/ui/hl-todo/config.el +++ b/modules/ui/hl-todo/config.el @@ -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) diff --git a/modules/ui/ligatures/autoload/ligatures.el b/modules/ui/ligatures/autoload/ligatures.el index 7856ff7c1..3711124c4 100644 --- a/modules/ui/ligatures/autoload/ligatures.el +++ b/modules/ui/ligatures/autoload/ligatures.el @@ -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) diff --git a/modules/ui/modeline/+light.el b/modules/ui/modeline/+light.el index 289ef1030..f82f847d3 100644 --- a/modules/ui/modeline/+light.el +++ b/modules/ui/modeline/+light.el @@ -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)))))