;; 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
;;; 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>
(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
(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)
;; 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)
"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))
(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.
(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)
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
"\\("
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
"\\("
(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
(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
(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)
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))))
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
(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))
(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
(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
;; 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)
""))
(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)
(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
(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)
(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))
(,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)))
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)
(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) " "))
(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)))
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
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
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
(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))
;; 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
(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)
(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)))
(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)
(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)
(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)
(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)
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
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)