Function: project--completing-read-strict

project--completing-read-strict is a byte-compiled function defined in project.el.gz.

Signature

(project--completing-read-strict PROMPT COLLECTION &optional PREDICATE HIST MB-DEFAULT COMMON-PARENT-DIRECTORY)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
(defun project--completing-read-strict (prompt
                                        collection &optional predicate
                                        hist mb-default
                                        common-parent-directory)
  (cl-letf* ((mb-default (mapcar (lambda (mb-default)
                                   (if (and common-parent-directory
                                            mb-default
                                            (file-name-absolute-p mb-default))
                                       (file-relative-name
                                        mb-default common-parent-directory)
                                     mb-default))
                                 (if (listp mb-default) mb-default (list mb-default))))
             (abs-cpd (expand-file-name (or common-parent-directory "")))
             (abs-cpd-length (length abs-cpd))
             (non-essential t)          ;Avoid new Tramp connections.
             ((symbol-value hist)
              (if common-parent-directory
                  (mapcan
                   (lambda (s)
                     (setq s (expand-file-name s))
                     (and (string-prefix-p abs-cpd s)
                          (not (eq abs-cpd-length (length s)))
                          (list (substring s abs-cpd-length))))
                   (symbol-value hist))
                (symbol-value hist))))
    (minibuffer-with-setup-hook
        (lambda ()
          (setq-local minibuffer-default-add-function
                      (lambda ()
                        (let ((minibuffer-default mb-default))
                          (minibuffer-default-add-completions)))))
      (completing-read (format "%s: " prompt)
                       collection predicate 'confirm
                       nil
                       hist))))