[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rename-file

From: Sam Steingold
Subject: Re: rename-file
Date: Thu, 27 Aug 2009 10:47:38 -0400
User-agent: Thunderbird (X11/20090625)

Sam Steingold wrote:
On Wed, Aug 26, 2009 at 3:21 PM, Stefan Monnier<address@hidden> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]