Function: projectile-completing-read

projectile-completing-read is a byte-compiled function defined in projectile.el.

Signature

(projectile-completing-read PROMPT CHOICES &key INITIAL-INPUT ACTION CALLER)

Documentation

Present a project tailored PROMPT with CHOICES.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
(cl-defun projectile-completing-read (prompt choices &key initial-input action caller)
  "Present a project tailored PROMPT with CHOICES."
  (let ((prompt (projectile-prepend-project-name prompt))
        (caller (or caller 'projectile-completing-read))
        res)
    (setq res
          (pcase (if (eq projectile-completion-system 'auto)
                     (cond
                      ((bound-and-true-p ido-mode)  'ido)
                      ((bound-and-true-p helm-mode) 'helm)
                      ((bound-and-true-p ivy-mode)  'ivy)
                      (t 'default))
                   projectile-completion-system)
            ('default (completing-read prompt (lambda (string pred action)
                                                (cond
                                                 ;; this metadata is used by
                                                 ;; packages like marginalia and
                                                 ;; embark to enhance how they
                                                 ;; present candidates
                                                 ((eq action 'metadata)
                                                  '(metadata . ((category . project-file))))
                                                 (t
                                                  (complete-with-action action choices string pred))))
                                       nil nil initial-input))
            ('ido (ido-completing-read prompt choices nil nil initial-input))
            ('helm
             (if (and (fboundp 'helm)
                      (fboundp 'helm-make-source))
                 (helm :sources
                       (helm-make-source "Projectile" 'helm-source-sync
                                         :candidates choices
                                         :action (if action
                                                     (prog1 action
                                                       (setq action nil))
                                                   #'identity))
                       :prompt prompt
                       :input initial-input
                       :buffer "*helm-projectile*")
               (user-error "Please install helm")))
            ('ivy
             (if (fboundp 'ivy-read)
                 (ivy-read prompt choices
                           :initial-input initial-input
                           :action (prog1 action
                                     (setq action nil))
                           :caller caller)
               (user-error "Please install ivy")))
            (_ (funcall projectile-completion-system prompt choices))))
    (if action
        (funcall action res)
      res)))