From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Rename, delete and move current buffer and file Date: Mon, 07 May 2018 21:28:12 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1525742782 13873 195.159.176.226 (8 May 2018 01:26:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 8 May 2018 01:26:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 08 03:26:18 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fFrOU-0003Wq-HV for ged-emacs-devel@m.gmane.org; Tue, 08 May 2018 03:26:18 +0200 Original-Received: from localhost ([::1]:48794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFrQb-0006NQ-M7 for ged-emacs-devel@m.gmane.org; Mon, 07 May 2018 21:28:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFrQU-0006M9-Lx for emacs-devel@gnu.org; Mon, 07 May 2018 21:28:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fFrQR-0001bF-HI for emacs-devel@gnu.org; Mon, 07 May 2018 21:28:22 -0400 Original-Received: from [195.159.176.226] (port=48221 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fFrQR-0001aR-AA for emacs-devel@gnu.org; Mon, 07 May 2018 21:28:19 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fFrOI-0003Jk-9O for emacs-devel@gnu.org; Tue, 08 May 2018 03:26:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:LM/8jNgvw+//RTMmGHIlQdOQeX4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:225140 Archived-At: > 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