Any way to make ido-find-file switch to another recently opened file if there is no match in current directory?

StackOverflow https://stackoverflow.com/questions/16121151

  •  11-04-2022
  •  | 
  •  

Pregunta

Emacs ido is very nice and it makes my work more efficient.

But I feel rather annoyed that it always take it upon herself to change directory when she thinks there is no match in current directory for the string I input. While in most cases I would hope she could stay.

I know there some keymaps to solve this problem: an additional C-f would return to normal find-file mode, and C-j can be used to force ido to use the current directory. But is there any setting that make ido restricted to current directory by default?

¿Fue útil?

Solución

This feature is called auto-merge. The following three options relate to that feature:

(defcustom ido-auto-merge-work-directories-length 0
  "Automatically switch to merged work directories during file name input.
The value is number of characters to type before switching to merged mode.
If zero, the switch happens when no matches are found in the current directory.
Automatic merging is disabled if the value is negative."
  :type 'integer
  :group 'ido)

(defcustom ido-auto-merge-delay-time 0.70
  "Delay in seconds to wait for more input before doing auto merge."
  :type 'number
  :group 'ido)

(defcustom ido-auto-merge-inhibit-characters-regexp "[][*?~]"
  "Regexp matching characters which should inhibit automatic merging.
When a (partial) file name matches this regexp, merging is inhibited."
  :type 'regexp
  :group 'ido)

You can for example put a longer delay or disabling the feature. To disable the feature add the following statement to your .emacs:

(setq ido-auto-merge-work-directories-length -1)

The C-z keybinding also cancels the last auto-merge. See the following snippet from ido.el:

(define-key map "\C-z" 'ido-undo-merge-work-directory)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top