Subject: bug#40140: 26.3; Renaming a directory with an external tool

From: Tomas Nordin <[email-masked]>
Date: Sat, 21 Mar 2020 15:08:32 +0100

Hello Nicolas

Nicolas Gimenez <[email-masked]> writes:

> Hi!
>
>
> Right after renaming a directory with an external tool when Emacs is 
> visiting a file in that directory, Emacs doesn't change the open file 
> buffers directory association.
>
> It would probably be better to open a prompt where one can navigate to a 
> new target directory.
>
>
> Steps to reproduce:
>
> 1) Create file and directory 
> '/home/nicolas/elixir_learn/mastery/test/support/tmp/test.ex' within 
> Spacemacs.
>
> 2) Edit file, still from Spacemacs add dummy info. Save file.
>
> 3) Save file 
> '/home/nicolas/elixir_learn/mastery/test/support/tmp/test.ex from Spacemacs
>
> 4) Switch to bash in an external terminal and run: "mv 
> /home/nicolas/elixir_learn/mastery/test/support/tmp 
> /home/nicolas/elixir_learn/mastery/test/support/tmp2". (Emacs still open 
> in another OS's frame.)
>
> 5) Get back to Emacs. Attempt to write file from Emacs, minibuffer in 
> the bottom shows: "Please answer y or n. Directory 
> '/home/nicolas/elixir_learn/mastery/test/support/tmp/' does not exist; 
> create? (y or n)"

If you try this experiment with any other text editor I think you will
see similar effects. I tried with gedit and vim and got the
corresponding effects.

Using Emacs in this case I would do C-x C-w and then navigate to the
existing directory, then one with the new name tmp2. Then I will have to
allow over-writing the copy of test.ex on disc in tmp2.

I think the text editor cannot assume that the buffer holding test.ex is
to be associated with the file in the new directory. The buffer-file
association is broken by the external renaming of the directory.

Best regards
--
Tomas