I like arbitrary substring matching for buffer completion but I want to disable it when completing file names or directories. The idea is to set ido-enable-prefix to t only when ido-find-file is being used, and nil otherwise.

So something like this looks like it should work but it doesn't.

(setq ido-enable-prefix nil)

(defun ido-init-file-dir ()
  (when (or (eq ido-cur-item 'file) (eq ido-cur-item 'dir))
    (set (make-local-variable 'ido-enable-prefix) t)))

(add-hook 'ido-setup-hook 'ido-init-file-dir)

Any ideas?


The mistake was using set and make-local-variable instead of just setq. Working version:

(defun ido-setup-file-dir ()
  (when (or (eq ido-cur-item 'file) (eq ido-cur-item 'dir))
    (setq ido-enable-prefix t)))

(add-hook 'ido-setup-hook 'ido-setup-file-dir)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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