From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Andreas_R=c3=b6hler?= Newsgroups: gmane.emacs.devel Subject: Re: Rename, delete and move current buffer and file Date: Mon, 7 May 2018 17:38:48 +0200 Message-ID: <3280f44f-b3ce-74f1-5452-e465e1dc00bd@online.de> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1525707375 21627 195.159.176.226 (7 May 2018 15:36:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 May 2018 15:36:15 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 07 17:36:11 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 1fFiBO-0005Vi-RZ for ged-emacs-devel@m.gmane.org; Mon, 07 May 2018 17:36:11 +0200 Original-Received: from localhost ([::1]:46832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFiDV-0005BU-JJ for ged-emacs-devel@m.gmane.org; Mon, 07 May 2018 11:38:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFiCq-0005AL-80 for emacs-devel@gnu.org; Mon, 07 May 2018 11:37:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fFiCn-0007s2-0E for emacs-devel@gnu.org; Mon, 07 May 2018 11:37:40 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.131]:58095) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fFiCm-0007q6-LQ for emacs-devel@gnu.org; Mon, 07 May 2018 11:37:36 -0400 Original-Received: from [192.168.178.35] ([188.103.18.182]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Lafge-1ea1eY1c4W-00kMFf for ; Mon, 07 May 2018 17:37:34 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:SIJtlVv/pe5hP15oMSUx4O/MHlTA5KC5zKYPL0ceoTLgaPnhG9r 3ZEWBOsBzgqo2PqOzn01+qqciOZKnJ8MOV8wnL1AQDGbfzuGb5VaVLRnb/2HJO4ahaK1Fp8 0AFcw5nNaAZo59eMTBgsgCpwNaaTIlLIr0o4TLKDtuSuml8oHzWOjdIXT2/YKHMVt0k5Up3 Mzne5SYW/Js7xywaUcDKg== X-UI-Out-Filterresults: notjunk:1;V01:K0:32XSUy2OOAQ=:3HGCysO47Gqf+1wZ42wTxH zPWNUHBHxAz06zEsCE5CjlAO3RnEP99zCuRLEiJ7fOAIQlX9Ya/jkqRiRjk4LhS1IKPUa8Lff yQpou3cdf6hbP4vfWunxp/rcPyuupQGKO/mADSqYV/j5uQ1472btqFC/shU3E5C6YyAkQFpOZ yrV5G/TeGRND53pg9VW+obJsF6qLpXhrUfikI6RsJJveDwA3XEMD7kwtWLEnnAyXtBoXv5/6x P5TGJW73A1xYjZM8v3seVagZJ0d/xRZzYD5ToZFLzuUFVWE45v7D+Xbpf48bvEzjTE6yoDLFb 8feZEaqAGtNGHiWXWu06NDQZXX03V1Ui550xd7XXFtXheTNm0ZbWw/sCtJzd5AXFfy1Cf+2FW ob03kGnNKqR+n8A5u9TshZU0UR/ccxkdPclem+v/scJj7bPYptSaZ/VAmYaDdlm+qyt5UgHoc 5mPDFNTO8xD26NppxDWtkJpReLiqtYUPkvo4xIJnoPF49rhcvhu/jn5mDMJAYbCN7Xm9tXSVr By/Zs+XNgTYwf79yCkjFEyzh2BCnUZECMk0C4BWlVHd6aGhxFWeiaaC02eYoirQo0cEiCFcVF tHuWgBGFQlngchlQ/y9yYEB4n5CzD2FOEgPF5x6Jc+g7iyY129stlPKA1+5XbPfij3j0QA+6H /8BDj2m88QA+Gu6ckZwLBQh42ntr0iIBKdRpaKMjWp3aBHzqdDZ/gJscKC4shHbpyEeI8lEhv PsI7Y99eyKAIBS2D X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.131 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:225118 Archived-At: On 07.05.2018 17:29, Andreas Röhler wrote: > > > On 07.05.2018 15:58, Jarosław Rzeszótko wrote: >> It is surprisingly hard to do this in Emacs, and I think it is a >> common problem, as evidenced by e.g.: >> >> https://stackoverflow.com/questions/384284/how-do-i-rename-an-open-file-in-emacs >> >> http://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/ >> http://rejeep.github.io/emacs/elisp/2010/03/26/rename-file-and-buffer-in-emacs.html >> >> >> You can use dired, but I personally find it to be a distraction for >> this use case. >> >> There is set-visited-file-name, but: >> a) it creates a copy of the file by default >> b) the name is not intuitive and I doubt many people looking to rename >> a file will find it >> c) the best UI/UX is IMO different for different use cases, rename is >> different from move >> >> A very similar related pain point is that it is hard to get the path >> and directory of the current buffers visited file. There exist ways to >> do it, but this is a pair of related use cases and the handling is >> completely different: for the path you have default-directory, an >> elisp variable, and pwd, a command capable of displaying the path in >> minibuffer or yanking it at point. For file name I am only aware of >> the elisp function: buffer-file-name. Again, two closely related use >> cases, handled very differently, I by now looked those up like 10 >> times and every time I forget how to get this info because the names >> are so far from what you would expect. >> >> How can we fix or improve those issues? >> >> For rename/delete/move I would create three distinct commands: >> rename-visited-file-with-buffer >> move-visited-file-with-buffer >> delete-visited-file-with-buffer >> >> Those names make the functions easy to discover if you are using >> something like ivy or ido for M-x, while they are still precise from >> the standpoint of Emacs concepts. It seems good to me to separate >> rename, which should prefill the minibuffer prompt with the current >> name, and ask only for a new filename, WITHOUT directory selection, >> from move, which should prompt for a full new path, WITH directory >> selection. >> >> For the current buffers file and directory name, I think aliasing >> default-directory as visited-file-name-directory, and introducing >> visited-file-name is one option. Another option: introduce >> buffer-directory-name as a complement to the existing buffer-file-name >> function. That would cleanup the elisp part, and then at least the >> names are something you can remember, and with M-: you can kill, >> insert or display those. >> >> Question remains how to fix those things also on an user interface >> level. I think it's a pity clicking on the filename in the modeline >> changes the current buffer, I am happy to hear if I am mistaken, but >> today this behavior is rather unexpected and I would be very surprised >> to see somebody switching buffers this way. On the other hand it looks >> like a nice place for a menu where all the operations mentioned could >> be triggered (rename, move and delete file+buffer, display/kill/insert >> directory name or file name). Providing default key bindings under a >> common prefix for them could be nice too. >> >> Maybe someone has some more, or better, ideas for this. >> >> Finally, while we are discussing functions everyone re-implements in >> their .emacs, please lets make transpose-windows happen as an Emacs >> builtin :) >> >> Cheers, >> Jarosław Rzeszótko > > > Good question. > > My workflow is the following: > > [(control a)]         ;; Store the buffer-name in kill-ring, code see below > [(control x) (d)]     ;; dired, commonly the wanted working dir > [(control s)(meta y)] ;; yank the buffer-name as argument to >               ;; isearch-forward After all seeing dired-jump is better here. So lets forget about that ;)