2

When i want to create a new file with C-x C-f (ido-find-file), and type main.lua, Emacs does not create a new file in the current directory (default-directory). Instead, it visits an existing main.lua which is in another directory.

Similarly when I want to create a new directory src, instead of creating a new directory Emacs visits a src directory in another project.

This means I can never create a new file or a new directory.

I've installed the package tree-emacs. I have the same problem when I right-click a tree-emacs buffer and try to create a new file or a new directory - Emacs visits an existing file or directory which I do not want.

How can I stop Emacs from looking outside the current directory for an existing file or dir, instead of creating a buffer for a new one in the current directory?

Drew
  • 75,699
  • 9
  • 109
  • 225
  • To which command is your `C-x C-f` bound? You can tell it with `C-h k C-x C-f`. – Marioba Jan 29 '21 at 09:06
  • "C-x C-f runs the command ido-find-file, which is an interactive autoloaded compiled Lisp function in ‘ido.el’. It is bound to , C-x C-f, . (ido-find-file)" – oleg harput Jan 29 '21 at 10:52

1 Answers1

3

If you're using Ido, you can hit C-f whenever you want to fall back to regular find-file, thus preventing Ido from doing fancy things. If you want to disable the feature that lets Ido retrieve files from subdirectories for good, add

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

to your init file. Then you can always use M-s to invoke it manually.

Arch Stanton
  • 1,525
  • 9
  • 22
  • it works thanks a lot. – oleg harput Jan 29 '21 at 11:03
  • Or you could disable `ido-find-file` completely but continue to use `ido`: `(define-key (cdr ido-minor-mode-map-entry) [remap find-file] nil)` – Edman Jan 29 '21 at 11:26
  • @olegharput: if the answer works for you, please [accept it](https://emacs.stackexchange.com/help/someone-answers). – NickD Jan 29 '21 at 13:50
  • I was about to say that. I guessed that some completion package might be interfering. – Pankaj Jangid Jan 29 '21 at 15:49
  • If this answers the question, you might want to *accept* this answer. (Or you might want to wait a while, to see if you get another answer that you prefer.) – Drew Jan 29 '21 at 17:37