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: Wed, 26 Aug 2009 16:35:31 -0400 Message-ID: <1f77704b0908261335y799ec0a4r74c69d9c36a82234@mail.gmail.com> References: <4A955D32.8030202@gnu.org> 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 1251318957 26819 80.91.229.12 (26 Aug 2009 20:35:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Aug 2009 20:35:57 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 26 22:35:50 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 1MgPDc-0007U0-Sr for ged-emacs-devel@m.gmane.org; Wed, 26 Aug 2009 22:35:45 +0200 Original-Received: from localhost ([127.0.0.1]:47013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgPDc-0001SP-7W for ged-emacs-devel@m.gmane.org; Wed, 26 Aug 2009 16:35:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgPDV-0001OV-Pt for emacs-devel@gnu.org; Wed, 26 Aug 2009 16:35:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgPDR-0001E3-56 for emacs-devel@gnu.org; Wed, 26 Aug 2009 16:35:37 -0400 Original-Received: from [199.232.76.173] (port=45565 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgPDQ-0001DZ-U9 for emacs-devel@gnu.org; Wed, 26 Aug 2009 16:35:32 -0400 Original-Received: from mail-qy0-f181.google.com ([209.85.221.181]:65185) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgPDQ-00089o-Lp for emacs-devel@gnu.org; Wed, 26 Aug 2009 16:35:32 -0400 Original-Received: by qyk11 with SMTP id 11so134799qyk.1 for ; Wed, 26 Aug 2009 13:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=oBrtOuuDLIVFWEzCVk6nxVTEBXIy7YgVC0pkkthDzGM=; b=Ziqy/wsttbzbrxy96eUteNO9jxONa5MbJ2Lh2gAib011XQLlUii0MzsA/hEWkdIuVe rfHYw6m1J6xeHVbTwoyvZ8MKCUQUD4UW5KpD290c3aSFWwWc3JHJw7x66VCr/EKkbeM/ 4GInbZHU1ZZocMeuWucZRrpnPxysjKLzJStF8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=U3kRYW8h8jQKidApnkmkQYmgNWPr0ZIjHvTLT7jhY6MvalYStoii4HzYopo+z6zYUg 0xPnTNJsF9JrZoT/KHk02VT0tEHkyJv8x15grDvHHvLy66mAypE8lSAWJg6G2LtkgbGd ZrM3bboVPYQIjpa0fn2FGgP+mZgh0zn08IvIA= Original-Received: by 10.229.53.76 with SMTP id l12mr2479439qcg.105.1251318931337; Wed, 26 Aug 2009 13:35:31 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: 723528c2a1d250ba X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:114635 Archived-At: On Wed, Aug 26, 2009 at 3:21 PM, Stefan Monnier w= rote: >> 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. =C2=A0Maybe we should introd= uce > 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)))) --=20 Sam Steingold