Function: completing-read-multiple
completing-read-multiple is an autoloaded and byte-compiled function
defined in crm.el.gz.
Signature
(completing-read-multiple PROMPT TABLE &optional PREDICATE REQUIRE-MATCH INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)
Documentation
Read multiple strings in the minibuffer, with completion.
The arguments are the same as those of completing-read.
Input multiple strings by separating each one with a string that
matches the regexp crm-separator. For example, if the separator
regexp is ",", entering "alice,bob,eve" specifies the strings
"alice", "bob", and "eve".
We refer to contiguous strings of non-separator-characters as
"elements". In this example there are three elements.
Completion is available on a per-element basis. For example, if the
contents of the minibuffer are "alice,bob,eve" and point is between
"l" and "i", pressing TAB (minibuffer-complete) operates on the element "alice".
This function returns a list of the strings that were read, with empty strings removed.
Probably introduced at or before Emacs version 24.4.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/crm.el.gz
;; superemulates behavior of completing_read in src/minibuf.c
;; Use \\<crm-local-completion-map> so that help-enable-autoload can
;; do its thing. Any keymap that is defined will do.
;;;###autoload
(defun completing-read-multiple
(prompt table &optional predicate require-match initial-input
hist def inherit-input-method)
"Read multiple strings in the minibuffer, with completion.
The arguments are the same as those of `completing-read'.
\\<crm-local-completion-map>
Input multiple strings by separating each one with a string that
matches the regexp `crm-separator'. For example, if the separator
regexp is \",\", entering \"alice,bob,eve\" specifies the strings
\"alice\", \"bob\", and \"eve\".
We refer to contiguous strings of non-separator-characters as
\"elements\". In this example there are three elements.
Completion is available on a per-element basis. For example, if the
contents of the minibuffer are \"alice,bob,eve\" and point is between
\"l\" and \"i\", pressing \\[minibuffer-complete] operates on the element \"alice\".
This function returns a list of the strings that were read,
with empty strings removed."
(let* ((map (if require-match
crm-local-must-match-map
crm-local-completion-map))
(map (if minibuffer-visible-completions
(make-composed-keymap
(list minibuffer-visible-completions-map
map))
map))
(buffer (current-buffer))
input)
(minibuffer-with-setup-hook
(lambda ()
(add-hook 'choose-completion-string-functions
'crm--choose-completion-string nil 'local)
(setq-local minibuffer-completion-table #'crm--collection-fn)
(setq-local minibuffer-completion-predicate predicate)
(setq-local completion-list-insert-choice-function
(lambda (_start _end choice)
(let* ((beg (save-excursion
(if (search-backward-regexp crm-separator
(field-beginning)
t)
(1+ (point))
(minibuffer-prompt-end))))
(end (save-excursion
(if (search-forward-regexp crm-separator nil t)
(1- (point))
(point-max)))))
(completion--replace beg end choice))))
;; see completing_read in src/minibuf.c
(setq-local minibuffer-completion-confirm
(unless (eq require-match t) require-match))
(setq-local minibuffer--require-match require-match)
(setq-local minibuffer--original-buffer buffer)
(setq-local crm-completion-table table)
(completions--start-eager-display))
(setq input (read-from-minibuffer
(format-spec
crm-prompt
(let* ((sep (or (get-text-property 0 'separator crm-separator)
(string-replace "[ \t]*" "" crm-separator)))
(desc (or (get-text-property 0 'description crm-separator)
(concat "list separated by " sep))))
`((?s . ,sep) (?d . ,desc) (?p . ,prompt))))
initial-input map nil hist def inherit-input-method)))
;; If the user enters empty input, `read-from-minibuffer'
;; returns the empty string, not DEF.
(when (and def (string-equal input ""))
(setq input (if (consp def) (car def) def)))
;; Remove empty strings in the list of read strings.
(split-string input crm-separator t)))