Function: completion--file-name-table
completion--file-name-table is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion--file-name-table ORIG PRED ACTION)
Documentation
Internal subroutine for read-file-name. Do not call this.
This is a completion table for file names, like completion-file-name-table
except that it passes the file name through substitute-in-file-name.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion--file-name-table (orig pred action)
"Internal subroutine for `read-file-name'. Do not call this.
This is a completion table for file names, like `completion-file-name-table'
except that it passes the file name through `substitute-in-file-name'."
(let ((table #'completion-file-name-table))
(if (eq (car-safe action) 'boundaries)
(cons 'boundaries (completion--sifn-boundaries orig table pred (cdr action)))
(let* ((sifned (substitute-in-file-name orig))
(orig-start (car (completion--sifn-boundaries orig table pred "")))
(sifned-start (car (completion-boundaries sifned table pred "")))
(orig-in-bounds (substring orig orig-start))
(sifned-in-bounds (substring sifned sifned-start))
(only-need-double-dollars
;; If true, sifn only un-doubled $s in ORIG, so we can fix a
;; completion to match ORIG by just doubling $s again. This
;; preserves more text from the completion, behaving better with
;; non-nil `completion-ignore-case'.
(string-equal orig-in-bounds (minibuffer--double-dollars sifned-in-bounds)))
(result
(let ((completion-regexp-list
;; Regexps are matched against the real file names after
;; expansion, so regexps containing $ won't work. Drop
;; them; we'll return more completions, but callers need to
;; handle that anyway.
(seq-remove (lambda (regexp) (string-search "$" regexp))
completion-regexp-list)))
(complete-with-action action table sifned pred))))
(cond
((null action) ; try-completion
(if (stringp result)
;; Extract the newly added text, quote any dollar signs, and
;; append it to ORIG.
(if only-need-double-dollars
(concat (substring orig nil orig-start)
(minibuffer--double-dollars (substring result sifned-start)))
(let ((new-text (substring result (length sifned))))
(concat orig (minibuffer--double-dollars new-text))))
result))
((eq action t) ; all-completions
(mapcar
(if only-need-double-dollars
#'minibuffer--double-dollars
;; Extract the newly added text, quote any dollar signs, and append
;; it to the part of ORIG inside the completion boundaries.
(lambda (compl)
(let ((new-text (substring compl (length sifned-in-bounds))))
(concat orig-in-bounds (minibuffer--double-dollars new-text)))))
result))
(t result))))))