Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defun rejeep-projectile-completion-fn (prompt choises)
"Projectile completion function that only shows file name.
If two files have same name, new completion appears to select between
them. These include the path relative to the project root."
(let* ((stripped-choises
(-uniq (--map (file-name-nondirectory it) choises)))
(ido-completing-read prompt stripped-choises))
(lambda (file)
(equal (file-name-nondirectory file) choise))
(if (> (length matching-files) 1)
(ido-completing-read prompt matching-files)
(car matching-files))))
(setq projectile-completion-system 'rejeep-projectile-completion-fn)
Copy link

glucas commented Sep 17, 2013

This completion function does not handle directories properly for me (emacs 24.3): the stripped version of a directory name is the empty string. This interferes with projectile-switch-project, requiring an extra step.

To fix it, replace both occurences of
(file-name-nondirectory ...)
(file-name-nondirectory (directory-file-name ...))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment