From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: rename-file Date: Thu, 27 Aug 2009 06:15:13 +0300 Message-ID: <83ocq2c5ha.fsf@gnu.org> References: <4A955D32.8030202@gnu.org> <1f77704b0908261335y799ec0a4r74c69d9c36a82234@mail.gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: ger.gmane.org 1251343173 21540 80.91.229.12 (27 Aug 2009 03:19:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Aug 2009 03:19:33 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Sam Steingold Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 27 05:19:26 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 1MgVWH-00008t-KE for ged-emacs-devel@m.gmane.org; Thu, 27 Aug 2009 05:19:25 +0200 Original-Received: from localhost ([127.0.0.1]:55653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgVWG-00055L-Eo for ged-emacs-devel@m.gmane.org; Wed, 26 Aug 2009 23:19:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgVWA-000536-UF for emacs-devel@gnu.org; Wed, 26 Aug 2009 23:19:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgVW9-00050d-HL for emacs-devel@gnu.org; Wed, 26 Aug 2009 23:19:18 -0400 Original-Received: from [199.232.76.173] (port=56846 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgVW9-00050L-AS for emacs-devel@gnu.org; Wed, 26 Aug 2009 23:19:17 -0400 Original-Received: from mtaout6.012.net.il ([84.95.2.16]:51769) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgVSD-00035h-5q; Wed, 26 Aug 2009 23:15:13 -0400 Original-Received: from conversion-daemon.i-mtaout6.012.net.il by i-mtaout6.012.net.il (HyperSendmail v2007.08) id <0KP000L00M9PUX00@i-mtaout6.012.net.il>; Thu, 27 Aug 2009 06:15:11 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.228.144.38]) by i-mtaout6.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0KP0009EXMD9JH40@i-mtaout6.012.net.il>; Thu, 27 Aug 2009 06:15:10 +0300 (IDT) In-reply-to: <1f77704b0908261335y799ec0a4r74c69d9c36a82234@mail.gmail.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (1203?) 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:114659 Archived-At: > Date: Wed, 26 Aug 2009 16:35:31 -0400 > From: Sam Steingold > Cc: emacs-devel@gnu.org >=20 > > Because rename-file is a low-level function. =C2=A0Maybe we shoul= d introduce > > a new command rename-file-buffer which automatically applies to t= he > > current buffer's file. >=20 > OK to commit? >=20 > (defun rename-buffer-file (new-name) > "Rename the current buffer and the file it is visiting to NEW-NAM= E." > (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)))) Will this work in a Dired buffer, especially if there are files in that directory visited by other buffers? What about other buffers visiting the same file?