Function: completion--sifn-boundaries
completion--sifn-boundaries is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion--sifn-boundaries STRING TABLE PRED SUFFIX)
Documentation
Return completion boundaries on file name STRING.
Runs substitute-in-file-name on STRING first, but returns completion
boundaries for the original string.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion--sifn-boundaries (string table pred suffix)
"Return completion boundaries on file name STRING.
Runs `substitute-in-file-name' on STRING first, but returns completion
boundaries for the original string."
;; We want to compute the start boundary on the result of
;; `substitute-in-file-name' (since that's what we use for actual completion),
;; and then transform that into an offset in STRING instead. We can't do this
;; if we expand environment variables, so double the $s to prevent that.
(let* ((doubled-string (replace-regexp-in-string "\\$" "$$" string t t))
;; sifn will change $$ back into $, so SIFNED is mostly the
;; same as STRING, with some text deleted.
(sifned (substitute-in-file-name doubled-string))
(bounds (completion-boundaries sifned table pred suffix))
(sifned-start (car bounds))
;; Adjust SIFNED-START to be an offset in STRING instead of in SIFNED.
(string-start (+ (- sifned-start (length sifned)) (length string))))
;; The text within the boundaries should be identical.
(cl-assert
(eq t (compare-strings sifned sifned-start nil string string-start nil))
t)
;; No special processing happens on SUFFIX and the end boundary.
(cons string-start (cdr bounds))))