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: Jarosław Rzeszótko
Subject: Re: Rename, delete and move current buffer and file
Date: Tue, 8 May 2018 09:05:55 +0200



On Tue, May 8, 2018 at 3:28 AM, Stefan Monnier <address@hidden> wrote:
> 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).

I do not understand what you have in mind with write-file. This creates a copy, which is natural given the name. Do you envision some changes to it? Or do you mean I should just use write-file and delete the old file? Some years ago there was a conversation on emacs-devel on this topic and you yourself proposed something like rename-current-file:

https://lists.gnu.org/archive/html/emacs-devel/2009-08/msg01132.html

Someone even sent a patch, RMS objected to the name, and then the conversation stalled and I think nothing was changed. Some of the names I have thrown around like rename-visited-file-with-buffer attempt to deal with the ambiguity & asymmetry with respect to existing functions RMS might possibly had in mind back then. I think in this case the function names will either be short, intuitive and slightly ambiguous or the names will be long, unintuitive and precise - due to the distinction between buffer, visisted file, the fact that you have a current buffer but not really a current file, the fact that many buffers might visit the same file etc., it is very easy to come up with a lot of different names and equally easy to find something slightly wrong with each of them. Maybe it is better to have a shorter name that is not 100% precise but is intuitive to the users than have a very precise name that nobody remembers and few people will be able to discover.

To try to move this forward constructively: I like the idea of delete-file/rename-file prompting whether to also kill/rename the associated buffers. However, by itself it does not yet fulfill the use case I had in mind, of dealing the file visited by the current buffer. I would be fine with something like delete-current-file/rename-current-file that just calls delete-file/rename-file on the current buffers file, and then having delete-file/rename-file prompt for modifying some or all of the (potentially several) visiting buffers. That's I think a pretty conservative change that helps accomplish a basic task many people want to do, quickly, easily and without distractions. 

Cheers,
Jarosław Rzeszótko

reply via email to

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