Closed shanavas786 closed 4 years ago
I observe slightly different behaviour.
File a.txt
visits tmp/a.txt
instead of tmp2/a.txt
. Also I see very funny message: File ’’ successfully renamed to ’tmp2’
.
To be honest I am not sure that rename-file
should accept directories. But there should separate function for directories that
What do you think?
On July 27, 2017 10:47:11 PM GMT+03:00, Boris notifications@github.com wrote:
I observe slightly different behaviour.
File
a.txt
visitstmp/a.txt
instead oftmp2/a.txt
. Also I see very funny message:File ’’ successfully renamed to ’tmp2’
.
Let me check it once more.
To be honest I am not sure that
rename-file
should accept directories.
I feel rename
could be thought like mv
command, and accepting directory targets makes sense then.
Or we can prompt the user target is a directory, do you want to move <file> to it ?
But there should separate function for directories that
- renames directory
- fixes all buffers visiting files in that directory
- invalidates projectile cache
- updates recentf list What do you think?
Well, that doesn't help if the user wants to move a single file out of the directory. -- ഷാനവാസ് Sent from my Android device with K-9 Mail.
I feel
rename
could be thought likemv
command, and accepting directory targets makes sense then.
Agree. And since there are other commands with 'file' in their name, that works on directories, we should improve rename as well.
Well, that doesn't help if the user wants to move a single file out of the directory.
I am talking only about moving directories, not files.
And since there are other commands with 'file' in their name, that works on directories, we should improve rename as well.
Yes, #9267 now handles renaming file to directory. Let me try to handle directory - directory renaming too.
I've also proposed a PR satisfying all the points I've mentioned: https://github.com/syl20bnr/spacemacs/pull/11470
@shanavas786 can you please try using it? Would like to have your feedback on this.
I've merged #11470. Any feedback would be valuable.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!
Hi for info, I am using the development branch and I am experiencing the exact same behaviour as @shanavas786 who first initiated this issue.
As a consequence I cannot modify a directory within Spacemacs. It is really cumbersome if you have already a file open in the folder. If you rename the folder using the bash "mv" command, it doesn't edit the buffer of your opened file. Then, when you try to save your file, it prompts you to create a new directory with the old name...
Any solutions?
Emacs version 26.3 Spacemacs version 0.300.0
I'm seeing the expected behavior:
Open a file: c:/tmp/a.txt
Rename the directory: SPC f R
to: c:/tmp2/a.txt
A prompt is shown:
Create directory 'c:/tmp2/'? (y or n)
Pressing: y
shows:
File Moved From: c:/tmp/a.txt To: c:/tmp2/a.txt
The buffer shows: a.txt
and it's located in: c:/tmp2/a.txt
#### System Info :computer: - OS: windows-nt - Emacs: 26.3 - Spacemacs: 0.300.0 - Spacemacs branch: develop (rev. 83fbc7a13) - Graphic display: t - Distribution: spacemacs - Editing style: vim - Completion: helm - Layers: ```elisp (autohotkey command-log emacs-lisp git helm imenu-list javascript (markdown :variables markdown-live-preview-engine 'vmd markdown-command "vmd") multiple-cursors org pdf python (shell :variables shell-default-shell 'shell shell-default-height 30 shell-default-position 'bottom) spell-checking syntax-checking treemacs version-control) ``` - System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2
Regarding the second issue.
Renaming a directory with an external tool, when Spacemacs is visiting a file in that directory, doesn't change the open file buffers directory association, because Spacemacs has no way of knowing what the directory was renamed to.
If the directory is renamed in for example a dired buffer: SPC a d
(or M-x dired RET
)
then the open file buffers associated directories also update.
But your right, when trying to save a file buffer that's associated with a directory that doesn't exist anymore. Then it currently just asks:
Directory 'c:/buffersAssociatedDirectory/' does not exist; create? (y or n)
It would probably be better to open a prompt where one can navigate to a new target directory.
It's not limited to Spacemacs. It also happens with just Emacs without any additional packages.
It can be reproduced like this:
When Spacemacs is installed, then Emacs can be started without loading any configurations:
runemacs --quick
(in non-Windows OSs it might just be: emacs --quick
)
C-x C-f
c:/tmp/a.txt
RET
M-x shell RET
cd /
rename tmp tmp2
(in non-Windows: mv tmp tmp2
)C-x o
C-x C-s
Directory 'c:/tmp/' does not exist; create? (y or n)
Feel free to report this upstream to the Emacs maintainers, then non-Spacemacs users also will benefit from the fix.
Thanks. Indeed, for the first "error", I guess I was not typing the right commands... Regarding the second issue, I just sent a report to the Emacs bug-related mailing list.
Description :octocat:
Giving directory as a rename target uses directory as buffer-name
Reproduction guide :beetle:
/tmp/a.txt
SPC f R
and give directory name as target say/tmp2
Observed behaviour: :eyes: :broken_heart:
a.txt
is moved to/tmp2/a.txt
/tmp2/a.txt
spacemacs/rename-file
where buffer visits target directoryExpected behaviour: :heart: :smile:
a.txt
is moved to/tmp2/a.txt
/tmp2/a.txt
System Info :computer:
Backtrace :paw_prints: