emacs-devel
[Top][All Lists]
Advanced

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

Re: rename-file


From: Eli Zaretskii
Subject: Re: rename-file
Date: Thu, 27 Aug 2009 06:15:13 +0300

> Date: Wed, 26 Aug 2009 16:35:31 -0400
> From: Sam Steingold <address@hidden>
> Cc: address@hidden
> 
> > 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))))

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?





reply via email to

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