1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-05 11:45:45 +00:00

Use ensure-list in many more places

* lisp/align.el (align-region):
* lisp/auth-source-pass.el (auth-source-pass--build-result-many):
* lisp/auth-source.el (auth-source-ensure-strings):
* lisp/calendar/appt.el (appt-disp-window):
* lisp/cedet/mode-local.el (mode-local-map-mode-buffers):
* lisp/cus-edit.el (custom-prompt-variable)
(custom-variable-menu-create):
* lisp/dired-x.el (dired-mark-extension, dired-mark-suffix):
* lisp/emacs-lisp/checkdoc.el (checkdoc-defun-info):
* lisp/emacs-lisp/eieio.el (object-add-to-list):
* lisp/emulation/cua-base.el (cua--M/H-key):
* lisp/epg.el (epg--list-keys-1):
* lisp/faces.el (read-face-name):
* lisp/format.el (format-decode):
* lisp/gnus/gnus-score.el (gnus-home-score-file)
(gnus-all-score-files):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-articles):
* lisp/gnus/message.el (message-make-forward-subject):
* lisp/gnus/nnmairix.el (nnmairix-create-search-group):
* lisp/gnus/spam.el (spam-copy-or-move-routine):
* lisp/help-fns.el (describe-face):
* lisp/ibuf-macs.el (define-ibuffer-filter):
* lisp/international/mule-cmds.el (select-safe-coding-system):
* lisp/net/imap.el (imap-send-command):
* lisp/printing.el (pr-menu-get-item):
* lisp/speedbar.el (speedbar-add-supported-extension)
(speedbar-add-ignored-directory-regexp):
* lisp/textmodes/rst.el (rst-forward-line-looking-at):
* lisp/vc/ediff-util.el (ediff-other-buffer):
* lisp/vc/diff.el (diff-no-select):
* lisp/vc/vc-dir.el (vc-dir-mark-state-files):
* lisp/wid-edit.el (widget-prompt-value):
* lisp/windmove.el (windmove-default-keybindings)
(windmove-display-default-keybindings)
(windmove-delete-default-keybindings)
(windmove-swap-states-default-keybindings):
* lisp/window.el (display-buffer-reuse-mode-window):
* lisp/woman.el (woman-expand-directory-path): Prefer ensure-list.
This commit is contained in:
Stefan Kangas 2023-08-27 21:45:30 +02:00
parent 48068a7344
commit 967fa846fc
32 changed files with 44 additions and 76 deletions

View File

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

View File

@ -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 <damien@cassou.me>,
;; Nicolas Petton <nicolas@petton.fr>
@ -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

View File

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

View File

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

View File

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

View File

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

View File

@ -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
"\\("

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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