1

I am learning to use project-find-file. I know there are better alternatives in melpa, but I would like to learn the "out of the box" functionality.

When I do project-find-file, start typing a filename, then TAB, I get a completion buffer. I expected to be able to navigate in that buffer with arrows, and C-n/C-p. Is it possible to set it up like that, or is this just a limitation of the tool?

If it's just not possible, I'd be ok to use ido for this.

Here is my current config for ido:

(ido-mode 'both) ;; for buffers and files
(setq
  ido-save-directory-list-file "~/.emacs.d/cache/ido.last"

  ido-ignore-buffers ;; ignore these guys
  '("\\` " "^\*Mess" "^\*Back" ".*Completion" "^\*Ido" "^\*trace"
     "^\*compilation" "^\*GTAGS" "^session\.*" "\*GNU Emacs\*")
  ido-work-directory-list '("~/" "~/Desktop" "~/Documents" "~/src")
  ido-case-fold  t                 ; be case-insensitiver

  ido-enable-last-directory-history t ; remember last used dirs
  ido-max-work-directory-list 30   ; should be enough
  ido-max-work-file-list      50   ; remember many
  ido-use-filename-at-point nil    ; don't use filename at point (annoying)
  ido-use-url-at-point nil         ; don't use url at point (annoying)

  ido-enable-flex-matching nil     ; don't try to be too smart
  ido-max-prospects 8              ; don't spam my minibuffer
  ido-confirm-unique-completion t) ; wait for RET, even with unique completion

;; when using ido, the confirmation is rather annoying...
(setq confirm-nonexistent-file-or-buffer nil)
2
  • You can navigate the *Completions* buffer, but you first need to switch to it.
    – d125q
    Aug 15, 2022 at 16:13
  • @d125q Correct. But I expected to be able to do it without switching buffer, and more, to get the ido interface in my mini-buffer.
    – Gauthier
    Aug 16, 2022 at 6:06

2 Answers 2

1

You can install a package which replaces the traditional completion interface, such as https://elpa.gnu.org/packages/counsel.html or https://elpa.gnu.org/packages/vertico.html.

Or indeed https://github.com/DarwinAwardWinner/ido-completing-read-plus, if you want to continue using the Ido interface.

When you enable such package, it can affect project-find-file as well.

0

Here is a way to use ido as completion framework almost everywhere:

(defvar ido-enable-replace-completing-read t
  "If t, use ido-completing-read instead of completing-read if possible.
    
    Set it to nil using let in around-advice for functions where the
    original completing-read is required.  For example, if a function
    foo absolutely must use the original completing-read, define some
    advice like this:
    
    (defadvice foo (around original-completing-read-only activate)
      (let (ido-enable-replace-completing-read) ad-do-it))")

;; Replace completing-read wherever possible, unless directed otherwise
(defadvice completing-read
    (around use-ido-when-possible activate)
  (if (or (not ido-enable-replace-completing-read) ; Manual override disable ido
          (and (boundp 'ido-cur-list)
               ido-cur-list)) ; Avoid infinite loop from ido calling this
      ad-do-it
    (let ((allcomp (all-completions "" collection predicate)))
      (if allcomp
          (setq ad-return-value
                (ido-completing-read prompt
                                     allcomp
                                     nil require-match initial-input hist def))
        ad-do-it))))

It surprises me that this requires so much plumbing. I'd expect ido to replace completion everywhere, as soon as (ido-mode 'both) runs.

1
  • 1
    If your goal is to configure Ido to be used everywhere, you should look into ido-completing-read-plus. The main problem, and what your code is trying to solve, is that ido-completing-read is not fully compatible with completing-read.
    – d125q
    Aug 16, 2022 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.