emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rename, delete and move current buffer and file


From: Stefan Monnier
Subject: Re: Rename, delete and move current buffer and file
Date: Mon, 07 May 2018 21:28:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> I have a file open in a buffer in front of me. I want to rename this file
> and have the buffer be changed accordingly: it should now be visiting the
> file under the new name.
>
> rename-file will instead:
> - rename the file but do nothing with the buffer, if I now save the buffer
> it will get saved under the old file name. The buffer still visits the file
> under the old name.

That's how it works currently.  But we're talking about making changes.

> - it will also first prompt for a file to rename, while I want to rename
> the file I am currently editing in a buffer, along with the buffer.

Right.  That's why I suggested to use C-x C-w for this particular case.
(but rename-file (c|sh)ould still be changed accordingly).

>> > Also, note there is rename-file, rename-buffer, but then
>> > set-visited-file-name for what is effectively
>> > rename-file-with-visited-buffer.
>> set-visited-file-name does not rename any file, AFAIK (and I don't see
>> any suggestion to change this).
> If you set the along-with-file argument to t, or use prefix argument, I
> think it executes a rename like the one I would like to be able to do, so
> file+buffer.

Nope, it ignores prefix args and the `along-with-file` argument only
tells it that *something else* has moved the file.

> delete-file and rename-file prompting whether to do the corresponding
> action also on the buffer makes sense in general, better yet if it would be
> possible to configure Emacs to do this always, by default, when using the
> functions interactively. Is something like that safe with regards to
> backward compatibility?

If it's only done when used interactively, it should be safe, yes.

> Those act on a file you have to select though, I would like something that
> specifically acts on the current buffer and its visited file.

Hence C-x C-w (aka `write-file`).


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]