From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: rename-file Date: Thu, 27 Aug 2009 10:47:38 -0400 Message-ID: <4A969C8A.3080106@gnu.org> References: <4A955D32.8030202@gnu.org> <1f77704b0908261335y799ec0a4r74c69d9c36a82234@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1251384616 3248 80.91.229.12 (27 Aug 2009 14:50:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Aug 2009 14:50:16 +0000 (UTC) Cc: Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 27 16:50:09 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MggIf-0001iu-EA for ged-emacs-devel@m.gmane.org; Thu, 27 Aug 2009 16:50:05 +0200 Original-Received: from localhost ([127.0.0.1]:34605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MggIe-0006Ip-4Q for ged-emacs-devel@m.gmane.org; Thu, 27 Aug 2009 10:50:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MggGo-000561-2E for emacs-devel@gnu.org; Thu, 27 Aug 2009 10:48:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MggGh-00053Y-QM for emacs-devel@gnu.org; Thu, 27 Aug 2009 10:48:09 -0400 Original-Received: from [199.232.76.173] (port=60136 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MggGh-00053S-Fi for emacs-devel@gnu.org; Thu, 27 Aug 2009 10:48:03 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:42455) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MggGg-0005JJ-Gc for emacs-devel@gnu.org; Thu, 27 Aug 2009 10:48:02 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1MggGY-00012y-BQ for emacs-devel@gnu.org; Thu, 27 Aug 2009 16:47:54 +0200 Original-Received: from 38.105.200.250 ([38.105.200.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 Aug 2009 16:47:54 +0200 Original-Received: from sds by 38.105.200.250 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 Aug 2009 16:47:54 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 26 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.105.200.250 User-Agent: Thunderbird 2.0.0.22 (X11/20090625) In-Reply-To: <1f77704b0908261335y799ec0a4r74c69d9c36a82234@mail.gmail.com> X-Enigmail-Version: 0.95.6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114690 Archived-At: Sam Steingold wrote: > On Wed, Aug 26, 2009 at 3:21 PM, Stefan Monnier wrote: >>> Why isn't the buffer, which is visiting a file, renamed >>> when I rename the underlying file with rename-file? >> Because rename-file is a low-level function. Maybe we should introduce >> a new command rename-file-buffer which automatically applies to the >> current buffer's file. > > OK to commit? > > (defun rename-buffer-file (new-name) > "Rename the current buffer and the file it is visiting to NEW-NAME." > (interactive "FRename current file and buffer to: ") > (let ((filename (or buffer-file-name > (error "This buffer is not visiting a file"))) > (oldbuf (find-buffer-visiting new-name))) > (when (or (null oldbuf) > (y-or-n-p "Buffer %s is already visiting %s, proceed? " > oldbuf new-name)) > (rename-file filename new-name 1) > (set-visited-file-name new-name nil t)))) > on a second thought I decided that R in dired + M-x vc-rename-file are already sufficient. sorry about the noise.