@@ -1150,7 +1150,8 @@ The cache is created both in memory and on the hard drive."
11501150 (interactive
11511151 (list (projectile-completing-read
11521152 " Remove file from cache: "
1153- (projectile-current-project-files))))
1153+ (projectile-current-project-files)
1154+ :caller 'projectile-read-file )))
11541155 (let* ((project-root (projectile-project-root))
11551156 (project-cache (gethash project-root projectile-projects-cache)))
11561157 (if (projectile-file-cached-p file project-root)
@@ -1168,7 +1169,8 @@ The cache is created both in memory and on the hard drive."
11681169 (interactive
11691170 (list (projectile-completing-read
11701171 " Remove directory from cache: "
1171- (projectile-current-project-dirs))))
1172+ (projectile-current-project-dirs)
1173+ :caller 'projectile-read-directory )))
11721174 (let* ((project-root (projectile-project-root))
11731175 (project-cache (gethash project-root projectile-projects-cache)))
11741176 (puthash project-root
@@ -1416,7 +1418,8 @@ See also `projectile-acquire-root'."
14161418 dir
14171419 (cond
14181420 ((eq projectile-require-project-root 'prompt ) (projectile-completing-read
1419- " Switch to project: " projectile-known-projects))
1421+ " Switch to project: " projectile-known-projects
1422+ :caller 'projectile-read-project ))
14201423 (projectile-require-project-root (error " Projectile cannot find a project definition in %s " default-directory))
14211424 (t default-directory))))
14221425
@@ -1829,7 +1832,8 @@ choices."
18291832 (projectile-completing-read
18301833 prompt
18311834 (delete (buffer-name (current-buffer ))
1832- (projectile-project-buffer-names))))
1835+ (projectile-project-buffer-names))
1836+ :caller 'projectile-read-buffer ))
18331837
18341838;;;### autoload
18351839(defun projectile-switch-to-buffer ()
@@ -1859,7 +1863,8 @@ choices."
18591863 (display-buffer
18601864 (projectile-completing-read
18611865 " Display buffer: "
1862- (projectile-project-buffer-names))))
1866+ (projectile-project-buffer-names)
1867+ :caller 'projectile-read-buffer )))
18631868
18641869;;;### autoload
18651870(defun projectile-project-buffers-other-buffer ()
@@ -2126,9 +2131,10 @@ Never use on many files since it's going to recalculate the
21262131project-root for every file."
21272132 (expand-file-name name (projectile-project-root dir)))
21282133
2129- (cl-defun projectile-completing-read (prompt choices &key initial-input action )
2134+ (cl-defun projectile-completing-read (prompt choices &key initial-input action caller )
21302135 " Present a project tailored PROMPT with CHOICES."
21312136 (let ((prompt (projectile-prepend-project-name prompt))
2137+ (caller (or caller 'projectile-completing-read ))
21322138 res)
21332139 (setq res
21342140 (pcase (if (eq projectile-completion-system 'auto )
@@ -2170,7 +2176,7 @@ project-root for every file."
21702176 :initial-input initial-input
21712177 :action (prog1 action
21722178 (setq action nil ))
2173- :caller 'projectile-completing-read )
2179+ :caller caller )
21742180 (user-error " Please install ivy" )))
21752181 (_ (funcall projectile-completion-system prompt choices))))
21762182 (if action
@@ -2279,7 +2285,7 @@ instead of `find-file'. A typical example of such a defun would be
22792285 (let ((ff (or ff-variant #'find-file ))
22802286 (other-files (projectile-get-other-files (buffer-file-name ) flex-matching)))
22812287 (if other-files
2282- (let ((file-name (projectile--choose-from-candidates other-files)))
2288+ (let ((file-name (projectile--choose-from-candidates other-files :caller 'projectile-read-file )))
22832289 (funcall ff (expand-file-name file-name
22842290 (projectile-project-root))))
22852291 (error " No other file found " ))))
@@ -2428,9 +2434,11 @@ Subroutine for `projectile-find-file-dwim' and
24282434 (file (cond ((= (length files ) 1 )
24292435 (car files ))
24302436 ((> (length files ) 1 )
2431- (projectile-completing-read " Switch to: " files ))
2437+ (projectile-completing-read " Switch to: " files
2438+ :caller 'projectile-read-file ))
24322439 (t
2433- (projectile-completing-read " Switch to: " project-files))))
2440+ (projectile-completing-read " Switch to: " project-files
2441+ :caller 'projectile-read-file ))))
24342442 (ff (or ff-variant #'find-file )))
24352443 (funcall ff (expand-file-name file project-root))
24362444 (run-hooks 'projectile-find-file-hook )))
@@ -2533,7 +2541,8 @@ would be `find-file-other-window' or `find-file-other-frame'"
25332541 (projectile-maybe-invalidate-cache invalidate-cache)
25342542 (let* ((project-root (projectile-acquire-root))
25352543 (file (projectile-completing-read " Find file: "
2536- (projectile-project-files project-root)))
2544+ (projectile-project-files project-root)
2545+ :caller 'projectile-read-file ))
25372546 (ff (or ff-variant #'find-file )))
25382547 (when file
25392548 (funcall ff (expand-file-name file project-root))
@@ -2689,7 +2698,8 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache first."
26892698 " Find dir: "
26902699 (if projectile-find-dir-includes-top-level
26912700 (append '(" ./" ) project-dirs)
2692- project-dirs))))
2701+ project-dirs)
2702+ :caller 'projectile-read-directory )))
26932703
26942704;;;### autoload
26952705(defun projectile-find-test-file (&optional invalidate-cache )
@@ -2699,7 +2709,8 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache first."
26992709 (interactive " P" )
27002710 (projectile-maybe-invalidate-cache invalidate-cache)
27012711 (let ((file (projectile-completing-read " Find test file: "
2702- (projectile-current-project-test-files))))
2712+ (projectile-current-project-test-files)
2713+ :caller 'projectile-read-file )))
27032714 (find-file (expand-file-name file (projectile-project-root)))))
27042715
27052716(defun projectile-test-files (files )
@@ -2786,11 +2797,12 @@ If KIND is not provided, a list of possible kinds can be chosen."
27862797 (if-let* ((available-kinds (projectile--related-files-kinds file)))
27872798 (setq kind (if (= (length available-kinds) 1 )
27882799 (car available-kinds)
2789- (intern (projectile-completing-read " Kind :" available-kinds))))
2800+ (intern (projectile-completing-read " Kind :" available-kinds
2801+ :caller 'projectile-read-file ))))
27902802 (error " No related files found " )))
27912803
2792- (if-let* ((candidates (projectile--related-files file kind)))
2793- (projectile-expand-root (projectile--choose-from-candidates candidates))
2804+ (if-let ((candidates (projectile--related-files file kind)))
2805+ (projectile-expand-root (projectile--choose-from-candidates candidates :caller 'projectile-read-file ))
27942806 (error
27952807 " No matching related file as `%s' found for project type `%s' "
27962808 kind (projectile-project-type))))
@@ -3273,7 +3285,8 @@ select a name of a command preset, or opt a manual command by selecting
32733285 (preset-names (projectile--cmake-command-preset-names command-type)))
32743286 (projectile-completing-read
32753287 " Use preset: "
3276- (append preset-names `(, projectile--cmake-no-preset )))
3288+ (append preset-names `(, projectile--cmake-no-preset ))
3289+ :caller nil )
32773290 projectile--cmake-no-preset))
32783291
32793292(defconst projectile--cmake-manual-command-alist
@@ -4215,21 +4228,21 @@ The precedence for determining implementation files to return is:
42154228 (projectile-current-project-files))) it)
42164229 ((projectile--test-to-impl-dir-fallback test-file) (list it))))
42174230
4218- (defun projectile--choose-from-candidates (candidates )
4231+ (defun projectile--choose-from-candidates (candidates & key caller )
42194232 " Choose one item from CANDIDATES."
42204233 (if (= (length candidates) 1 )
42214234 (car candidates)
4222- (projectile-completing-read " Switch to: " candidates)))
4235+ (projectile-completing-read " Switch to: " candidates :caller caller )))
42234236
42244237(defun projectile-find-matching-test (impl-file )
42254238 " Compute the name of the test matching IMPL-FILE."
4226- (when-let* ((candidates (projectile--find-matching-test impl-file)))
4227- (projectile--choose-from-candidates candidates)))
4239+ (when-let ((candidates (projectile--find-matching-test impl-file)))
4240+ (projectile--choose-from-candidates candidates :caller 'projectile-read-file )))
42284241
42294242(defun projectile-find-matching-file (test-file )
42304243 " Compute the name of a file matching TEST-FILE."
4231- (when-let* ((candidates (projectile--find-matching-file test-file)))
4232- (projectile--choose-from-candidates candidates)))
4244+ (when-let ((candidates (projectile--find-matching-file test-file)))
4245+ (projectile--choose-from-candidates candidates :caller 'projectile-read-file )))
42334246
42344247(defun projectile-grep-default-files ()
42354248 " Try to find a default pattern for `projectile-grep' .
@@ -5051,7 +5064,8 @@ directory to open."
50515064 (list
50525065 (projectile-completing-read
50535066 " Open project VC in: "
5054- projectile-known-projects))))
5067+ projectile-known-projects
5068+ :caller 'projectile-read-project ))))
50555069 (unless project-root
50565070 (setq project-root (projectile-acquire-root)))
50575071 (let ((vcs (projectile-project-vcs project-root)))
@@ -5077,7 +5091,8 @@ directory to open."
50775091 (find-file (projectile-expand-root
50785092 (projectile-completing-read
50795093 " Recently visited files: "
5080- (projectile-recentf-files))))
5094+ (projectile-recentf-files)
5095+ :caller 'projectile-read-file )))
50815096 (message " recentf is not enabled " )))
50825097
50835098(defun projectile-recentf-files ()
@@ -5675,7 +5690,8 @@ With a prefix ARG invokes `projectile-commander' instead of
56755690 (projectile-completing-read
56765691 " Switch to project: " projects
56775692 :action (lambda (project )
5678- (projectile-switch-project-by-name project arg)))
5693+ (projectile-switch-project-by-name project arg))
5694+ :caller 'projectile-read-project )
56795695 (user-error " There are no known projects" ))))
56805696
56815697;;;### autoload
@@ -5690,7 +5706,8 @@ With a prefix ARG invokes `projectile-commander' instead of
56905706 (projectile-completing-read
56915707 " Switch to open project: " projects
56925708 :action (lambda (project )
5693- (projectile-switch-project-by-name project arg)))
5709+ (projectile-switch-project-by-name project arg))
5710+ :caller 'projectile-read-project )
56945711 (user-error " There are no open projects" ))))
56955712
56965713(defun projectile-switch-project-by-name (project-to-switch &optional arg )
@@ -5742,7 +5759,8 @@ This command will first prompt for the directory the file is in."
57425759 (if (projectile-project-p)
57435760 ; ; target directory is in a project
57445761 (let ((file (projectile-completing-read " Find file: "
5745- (projectile-dir-files directory))))
5762+ (projectile-dir-files directory)
5763+ :caller 'projectile-read-file )))
57465764 (find-file (expand-file-name file directory))
57475765 (run-hooks 'projectile-find-file-hook ))
57485766 ; ; target directory is not in a project
@@ -5762,7 +5780,8 @@ This command will first prompt for the directory the file is in."
57625780(defun projectile-find-file-in-known-projects ()
57635781 " Jump to a file in any of the known projects."
57645782 (interactive )
5765- (find-file (projectile-completing-read " Find file in projects: " (projectile-all-project-files))))
5783+ (find-file (projectile-completing-read " Find file in projects: " (projectile-all-project-files)
5784+ :caller 'projectile-read-file )))
57665785
57675786(defun projectile-keep-project-p (project )
57685787 " Determine whether we should cleanup (remove) PROJECT or not.
@@ -5813,7 +5832,8 @@ Return a list of projects removed."
58135832 " Remove PROJECT from the list of known projects."
58145833 (interactive (list (projectile-completing-read
58155834 " Remove from known projects: " projectile-known-projects
5816- :action 'projectile-remove-known-project )))
5835+ :action 'projectile-remove-known-project
5836+ :caller 'projectile-read-project )))
58175837 (unless (called-interactively-p 'any )
58185838 (setq projectile-known-projects
58195839 (cl-remove-if
@@ -5911,7 +5931,8 @@ Let user choose another project when PROMPT-FOR-PROJECT is supplied."
59115931 (let ((project-root (if prompt-for-project
59125932 (projectile-completing-read
59135933 " Project name: "
5914- (projectile-relevant-known-projects))
5934+ (projectile-relevant-known-projects)
5935+ :caller 'projectile-read-project )
59155936 (projectile-acquire-root))))
59165937 (projectile-ibuffer-by-project project-root)))
59175938
@@ -6094,7 +6115,8 @@ dirty project list."
60946115 (while (not (= (length status) 0 ))
60956116 (setq mod-proj (cons (car (pop status)) mod-proj)))
60966117 (projectile-completing-read " Select project: " mod-proj
6097- :action 'projectile-vc )))
6118+ :action 'projectile-vc
6119+ :caller 'projectile-read-project )))
60986120
60996121
61006122; ;; Find next/previous project buffer
0 commit comments