diff --git a/lisp/align.el b/lisp/align.el index 0608c64deab..13e31e2ad60 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -1463,8 +1463,7 @@ aligner would have dealt with are." ;; that we need it (unless nil ;; group-c (setq groups (or (cdr (assq 'group rule)) 1)) - (unless (listp groups) - (setq groups (list groups))) + (setq groups (ensure-list groups)) (setq first (car groups))) (unless spacing-c diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index dbcc9d05753..0f51755a250 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -1,6 +1,6 @@ ;;; auth-source-pass.el --- Integrate auth-source with password-store -*- lexical-binding: t -*- -;; Copyright (C) 2015, 2017-2023 Free Software Foundation, Inc. +;; Copyright (C) 2015-2023 Free Software Foundation, Inc. ;; Author: Damien Cassou , ;; Nicolas Petton @@ -122,9 +122,9 @@ HOSTS can be a string or a list of strings." (defun auth-source-pass--build-result-many (hosts ports users require max) "Return multiple `auth-source-pass--build-result' values." - (unless (listp hosts) (setq hosts (list hosts))) - (unless (listp users) (setq users (list users))) - (unless (listp ports) (setq ports (list ports))) + (setq hosts (ensure-list hosts)) + (setq users (ensure-list users)) + (setq ports (ensure-list ports)) (let* ((auth-source-pass--match-regexp (auth-source-pass--match-regexp auth-source-pass-port-separator)) (rv (auth-source-pass--find-match-many hosts users ports diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 66de763f671..365f6697ec8 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -899,8 +899,7 @@ Remove trailing \": \"." (defun auth-source-ensure-strings (values) (if (eq values t) values - (unless (listp values) - (setq values (list values))) + (setq values (ensure-list values)) (mapcar (lambda (value) (if (numberp value) (format "%s" value) diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index 11beee94e64..469b3f4023c 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el @@ -453,8 +453,7 @@ separate appointment." ;; It repeatedly reminds you of the date? ;; It would make more sense if it was eg the time of the appointment. ;; Let's allow it to be a list or not independent of the other elements. - (or (listp new-time) - (setq new-time (list new-time))) + (setq new-time (ensure-list new-time)) ;; FIXME Link to diary entry? (calendar-set-mode-line (format " %s. %s" (appt-mode-line min-to-app) diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el index e1746e1a541..c1a48bc50c8 100644 --- a/lisp/cedet/mode-local.el +++ b/lisp/cedet/mode-local.el @@ -89,7 +89,7 @@ Return nil if MODE has no parent." "Run FUNCTION on every file buffer with major mode in MODES. MODES can be a symbol or a list of symbols. FUNCTION does not have arguments." - (or (listp modes) (setq modes (list modes))) + (setq modes (ensure-list modes)) (mode-local-map-file-buffers function (lambda () (let ((mm (mode-local-equivalent-mode-p major-mode)) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 9b73a72b238..1021707907d 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -973,8 +973,7 @@ it as the third element in the list." (let ((prop (get var 'variable-interactive)) (type (get var 'custom-type)) (prompt (format prompt-val var))) - (unless (listp type) - (setq type (list type))) + (setq type (ensure-list type)) (cond (prop ;; Use VAR's `variable-interactive' property ;; as an interactive spec for prompting. @@ -5145,8 +5144,7 @@ This function does not save the buffer." (defun custom-variable-menu-create (_widget symbol) "Ignoring WIDGET, create a menu entry for customization variable SYMBOL." (let ((type (get symbol 'custom-type))) - (unless (listp type) - (setq type (list type))) + (setq type (ensure-list type)) (if (and type (widget-get type :custom-menu)) (widget-apply type :custom-menu symbol) (vector (custom-unlispify-menu-entry symbol) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 5780f1353ad..398f55f2a24 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -300,8 +300,7 @@ Interactively, ask for EXTENSION. Prefixed with one \\[universal-argument], unmark files instead. Prefixed with two \\[universal-argument]'s, prompt for MARKER-CHAR and mark files with it." (interactive (dired--mark-suffix-interactive-spec)) - (unless (listp extension) - (setq extension (list extension))) + (setq extension (ensure-list extension)) (dired-mark-files-regexp (concat ".";; don't match names with nothing but an extension "\\(" @@ -325,8 +324,7 @@ Interactively, ask for SUFFIX. Prefixed with one \\[universal-argument], unmark files instead. Prefixed with two \\[universal-argument]'s, prompt for MARKER-CHAR and mark files with it." (interactive (dired--mark-suffix-interactive-spec)) - (unless (listp suffix) - (setq suffix (list suffix))) + (setq suffix (ensure-list suffix)) (dired-mark-files-regexp (concat ".";; don't match names with nothing but an extension "\\(" diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index aadd6480086..3c4b6baca53 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -2042,8 +2042,7 @@ from the comment." (condition-case nil (setq lst (read (current-buffer))) (error (setq lst nil))) ; error in text - (if (not (listp lst)) ; not a list of args - (setq lst (list lst))) + (setq lst (ensure-list lst)) (if (and lst (not (symbolp (car lst)))) ;weird arg (setq lst nil)) (while lst diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 9a1f5b9db0f..ccdb52d6a1f 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -652,8 +652,7 @@ If SLOT is unbound, bind it to the list containing ITEM." (setq ov (list item)) (setq ov (eieio-oref object slot)) ;; turn it into a list. - (unless (listp ov) - (setq ov (list ov))) + (setq ov (ensure-list ov)) ;; Do the combination (if (not (member item ov)) (setq ov diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index a6d6f47ead5..6d21088cb29 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el @@ -1134,7 +1134,7 @@ If ARG is the atom `-', scroll upward by nearly full screen." (defun cua--M/H-key (map key fct) ;; bind H-KEY or M-KEY to FCT in MAP - (unless (listp key) (setq key (list key))) + (setq key (ensure-list key)) (define-key map (vector (cons cua--rectangle-modifier-key key)) fct)) (defun cua--self-insert-char-p (def) diff --git a/lisp/epg.el b/lisp/epg.el index 9da5a36ba3d..b8423d82a26 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -1264,8 +1264,7 @@ callback data (if any)." keys string field index) (if name (progn - (unless (listp name) - (setq name (list name))) + (setq name (ensure-list name)) (while name (setq args (append args (list list-keys-option (car name))) name (cdr name)))) diff --git a/lisp/faces.el b/lisp/faces.el index 1a446aacacd..8f93f9b2c0c 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -1118,8 +1118,7 @@ element of DEFAULT is returned. If DEFAULT isn't a list, but MULTIPLE is non-nil, a one-element list containing DEFAULT is returned. Otherwise, DEFAULT is returned verbatim." (let (defaults) - (unless (listp default) - (setq default (list default))) + (setq default (ensure-list default)) (when default (setq default (if multiple diff --git a/lisp/format.el b/lisp/format.el index 5c72a78f325..89a83c3cee2 100644 --- a/lisp/format.el +++ b/lisp/format.el @@ -295,7 +295,7 @@ For most purposes, consider using `format-decode-region' instead." (setq try format-alist)) (setq try (cdr try)))))) ;; Deal with given format(s) - (or (listp format) (setq format (list format))) + (setq format (ensure-list format)) (let ((do format) f) (while do (or (setq f (assq (car do) format-alist)) diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el index 8bdfccf7eb8..62167ea9e6a 100644 --- a/lisp/gnus/gnus-score.el +++ b/lisp/gnus/gnus-score.el @@ -2994,10 +2994,7 @@ The list is determined from the variable `gnus-score-file-alist'." (group (or group gnus-newsgroup-name)) score-files) (when group - ;; Make sure funcs is a list. - (and funcs - (not (listp funcs)) - (setq funcs (list funcs))) + (setq funcs (ensure-list funcs)) (when gnus-score-use-all-scores ;; Get the initial score files for this group. (when funcs @@ -3104,12 +3101,8 @@ The list is determined from the variable `gnus-score-file-alist'." (defun gnus-home-score-file (group &optional adapt) "Return the home score file for GROUP. If ADAPT, return the home adaptive file instead." - (let ((list (if adapt gnus-home-adapt-file gnus-home-score-file)) + (let ((list (ensure-list (if adapt gnus-home-adapt-file gnus-home-score-file))) elem found) - ;; Make sure we have a list. - (unless (listp list) - (setq list (list list))) - ;; Go through the list and look for matches. (while (and (not found) (setq elem (pop list))) (setq found diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el index 1846f05af2d..6ed6358e8ce 100644 --- a/lisp/gnus/gnus-uu.el +++ b/lisp/gnus/gnus-uu.el @@ -1371,8 +1371,7 @@ When called interactively, prompt for REGEXP." ;; Allow user-defined functions to be run on this file. (when gnus-uu-grabbed-file-functions (let ((funcs gnus-uu-grabbed-file-functions)) - (unless (listp funcs) - (setq funcs (list funcs))) + (setq funcs (ensure-list funcs)) (while funcs (funcall (pop funcs) result-file)))) (setq result-file nil) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 45cc21701b3..7a31f86a2c4 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -7707,10 +7707,7 @@ the message." "")) (when message-wash-forwarded-subjects (setq subject (message-wash-subject subject))) - ;; Make sure funcs is a list. - (and funcs - (not (listp funcs)) - (setq funcs (list funcs))) + (setq funcs (ensure-list funcs)) ;; Apply funcs in order, passing subject generated by previous ;; func to the next one. (dolist (func funcs) diff --git a/lisp/gnus/nnmairix.el b/lisp/gnus/nnmairix.el index 72833d7bc33..deb2b669b6b 100644 --- a/lisp/gnus/nnmairix.el +++ b/lisp/gnus/nnmairix.el @@ -741,8 +741,7 @@ called interactively, user will be asked for parameters." (when (and (stringp query) (string-match "\\s-" query)) (setq query (split-string query))) - (when (not (listp query)) - (setq query (list query))) + (setq query (ensure-list query)) (when (and server group query) (let ((groupname (gnus-group-prefixed-name group server)) ) ;; info diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el index 3178d9f59e6..c598b10bc08 100644 --- a/lisp/gnus/spam.el +++ b/lisp/gnus/spam.el @@ -1375,8 +1375,7 @@ In the case of mover backends, checks the setting of (when (and (car-safe groups) (listp (car-safe groups))) (setq groups (pop groups))) - (unless (listp groups) - (setq groups (list groups))) + (setq groups (ensure-list groups)) ;; remove the current process mark (gnus-summary-kill-process-mark) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 22cfbbc39cd..609bed18f2f 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1749,8 +1749,7 @@ If FRAME is omitted or nil, use the selected frame." (called-interactively-p 'interactive)) (unless face (setq face 'default)) - (if (not (listp face)) - (setq face (list face))) + (setq face (ensure-list face)) (with-help-window (help-buffer) (with-current-buffer standard-output (dolist (f face (buffer-string)) diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 2c9e9ea8bcd..c38dfefe0c5 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -310,7 +310,7 @@ bound to the current value of the filter. (,qualifier-str qualifier)) ,(when accept-list `(progn - (unless (listp qualifier) (setq qualifier (list qualifier))) + (setq qualifier (ensure-list qualifier)) ;; Reject equivalent filters: (or f1 f2) is same as (or f2 f1). (setq qualifier (sort (delete-dups qualifier) #'string-lessp)) (setq ,filter (cons ',name (car qualifier))) diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index e3811d81ec2..c26898f7649 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -868,8 +868,7 @@ overrides ACCEPT-DEFAULT-P. Kludgy feature: if FROM is a string, the string is the target text, and TO is ignored." - (if (not (listp default-coding-system)) - (setq default-coding-system (list default-coding-system))) + (setq default-coding-system (ensure-list default-coding-system)) (let ((no-other-defaults nil) auto-cs) diff --git a/lisp/net/imap.el b/lisp/net/imap.el index cfb92674d8a..7de847e2a59 100644 --- a/lisp/net/imap.el +++ b/lisp/net/imap.el @@ -1833,7 +1833,7 @@ on failure." (defun imap-send-command (command &optional buffer) (with-current-buffer (or buffer (current-buffer)) - (if (not (listp command)) (setq command (list command))) + (setq command (ensure-list command)) (let ((tag (setq imap-tag (1+ imap-tag))) cmd cmdstr) (setq cmdstr (concat (number-to-string imap-tag) " ")) diff --git a/lisp/printing.el b/lisp/printing.el index 4a6d14260a0..8aea58e157b 100644 --- a/lisp/printing.el +++ b/lisp/printing.el @@ -1148,8 +1148,7 @@ Used by `pr-menu-bind' and `pr-update-menus'.") (defun pr-menu-get-item (name-list) ;; NAME-LIST is a string or a list of strings. - (or (listp name-list) - (setq name-list (list name-list))) + (setq name-list (ensure-list name-list)) (and name-list (let* ((reversed (reverse name-list)) (name (easy-menu-intern (car reversed))) diff --git a/lisp/speedbar.el b/lisp/speedbar.el index f56c3915521..67d4e8c4df1 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -662,7 +662,7 @@ the dot should NOT be quoted in with \\. Other regular expression matchers are allowed however. EXTENSION may be a single string or a list of strings." (interactive "sExtension: ") - (if (not (listp extension)) (setq extension (list extension))) + (setq extension (ensure-list extension)) (while extension (if (member (car extension) speedbar-supported-extension-expressions) nil @@ -677,8 +677,7 @@ list of strings." This function will modify `speedbar-ignored-directory-regexp' and add DIRECTORY-EXPRESSION to `speedbar-ignored-directory-expressions'." (interactive "sDirectory regex: ") - (if (not (listp directory-expression)) - (setq directory-expression (list directory-expression))) + (setq directory-expression (ensure-list directory-expression)) (while directory-expression (if (member (car directory-expression) speedbar-ignored-directory-expressions) nil diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index 6108e80363c..d2661a44734 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el @@ -170,8 +170,7 @@ When FUN is called match data is just set by `looking-at' and point is at the beginning of the line. Return nil if moving forward failed or otherwise the return value of FUN. Preserve global match data, point, mark and current buffer." - (unless (listp rst-re-args) - (setq rst-re-args (list rst-re-args))) + (setq rst-re-args (ensure-list rst-re-args)) (unless fun (setq fun #'identity)) (save-match-data diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el index 90c43d111f5..a411d98da31 100644 --- a/lisp/vc/diff.el +++ b/lisp/vc/diff.el @@ -165,7 +165,7 @@ returns the buffer used." (unless (bufferp new) (setq new (expand-file-name new))) (unless (bufferp old) (setq old (expand-file-name old))) (or switches (setq switches diff-switches)) ; If not specified, use default. - (unless (listp switches) (setq switches (list switches))) + (setq switches (ensure-list switches)) (or buf (setq buf (get-buffer-create "*Diff*"))) (diff-check-labels) (let* ((old-alt (diff-file-local-copy old)) diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el index 8011d7ce2e0..c4ebe20d7e4 100644 --- a/lisp/vc/ediff-util.el +++ b/lisp/vc/ediff-util.el @@ -3741,7 +3741,7 @@ Ediff Control Panel to restore highlighting." ;; these buffers). ;; EXCL-BUFF-LIST is an exclusion list. (defun ediff-other-buffer (excl-buff-lst) - (or (listp excl-buff-lst) (setq excl-buff-lst (list excl-buff-lst))) + (setq excl-buff-lst (ensure-list excl-buff-lst)) (let* ((all-buffers (nconc (ediff-get-selected-buffers) (buffer-list))) ;; we compute this the second time because we need to do memq on it ;; later, and nconc above will break it. Either this or use slow diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 53d58870b32..d5226910211 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -785,8 +785,7 @@ MARK-FILES should be a list of absolute filenames." (defun vc-dir-mark-state-files (states) "Mark files that are in the state specified by the list in STATES." - (unless (listp states) - (setq states (list states))) + (setq states (ensure-list states)) (ewoc-map (lambda (filearg) (when (memq (vc-dir-fileinfo->state filearg) states) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index a70598bb6c9..ae060c92d0e 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -644,8 +644,7 @@ Return a list whose car contains all members of VALS that matched WIDGET." (defun widget-prompt-value (widget prompt &optional value unbound) "Prompt for a value matching WIDGET, using PROMPT. The current value is assumed to be VALUE, unless UNBOUND is non-nil." - (unless (listp widget) - (setq widget (list widget))) + (setq widget (ensure-list widget)) (setq prompt (format "[%s] %s" (widget-type widget) prompt)) (setq widget (widget-convert widget)) (let ((answer (widget-apply widget :prompt-value prompt value unbound))) diff --git a/lisp/windmove.el b/lisp/windmove.el index 746a440bacb..96b8597ae09 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -485,7 +485,7 @@ Default value of MODIFIERS is `shift'." (interactive) (unless modifiers (setq modifiers 'shift)) (when (eq modifiers 'none) (setq modifiers nil)) - (unless (listp modifiers) (setq modifiers (list modifiers))) + (setq modifiers (ensure-list modifiers)) (windmove-install-defaults nil modifiers '((windmove-left left) (windmove-right right) @@ -626,7 +626,7 @@ Default value of MODIFIERS is `shift-meta'." (interactive) (unless modifiers (setq modifiers '(shift meta))) (when (eq modifiers 'none) (setq modifiers nil)) - (unless (listp modifiers) (setq modifiers (list modifiers))) + (setq modifiers (ensure-list modifiers)) (windmove-install-defaults nil modifiers '((windmove-display-left left) (windmove-display-right right) @@ -703,10 +703,10 @@ Default value of PREFIX is \\`C-x' and MODIFIERS is `shift'." (interactive) (unless prefix (setq prefix '(?\C-x))) (when (eq prefix 'none) (setq prefix nil)) - (unless (listp prefix) (setq prefix (list prefix))) + (setq prefix (ensure-list prefix)) (unless modifiers (setq modifiers '(shift))) (when (eq modifiers 'none) (setq modifiers nil)) - (unless (listp modifiers) (setq modifiers (list modifiers))) + (setq modifiers (ensure-list modifiers)) (windmove-install-defaults prefix modifiers '((windmove-delete-left left) (windmove-delete-right right) @@ -766,7 +766,7 @@ Default value of MODIFIERS is `shift-super'." (interactive) (unless modifiers (setq modifiers '(shift super))) (when (eq modifiers 'none) (setq modifiers nil)) - (unless (listp modifiers) (setq modifiers (list modifiers))) + (setq modifiers (ensure-list modifiers)) (windmove-install-defaults nil modifiers '((windmove-swap-states-left left) (windmove-swap-states-right right) diff --git a/lisp/window.el b/lisp/window.el index b0970cfb064..b9b032c33e9 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7990,8 +7990,7 @@ indirectly called by the latter." buffer-mode)) (curwin (selected-window)) (curframe (selected-frame))) - (unless (listp allowed-modes) - (setq allowed-modes (list allowed-modes))) + (setq allowed-modes (ensure-list allowed-modes)) (let (same-mode-same-frame same-mode-other-frame derived-mode-same-frame diff --git a/lisp/woman.el b/lisp/woman.el index e0af72b2b66..e20a2399c00 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -1338,8 +1338,8 @@ PATH-DIRS should be a list of general manual directories (like manual directory regexps (like `woman-path'). Ignore any paths that are unreadable or not directories." ;; Allow each path to be a single string or a list of strings: - (if (not (listp path-dirs)) (setq path-dirs (list path-dirs))) - (if (not (listp path-regexps)) (setq path-regexps (list path-regexps))) + (setq path-dirs (ensure-list path-dirs)) + (setq path-regexps (ensure-list path-regexps)) (let (head dirs path) (dolist (dir path-dirs) (when (consp dir)