From: Nikolaj Schumacher <n_schumacher@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Make rename-file() also rename visiting buffers
Date: Thu, 14 Jun 2007 12:43:14 +0200 [thread overview]
Message-ID: <m28xam7r5p.fsf@nschum.de> (raw)
In-Reply-To: <1181662469.979165.162730@q19g2000prn.googlegroups.com> ("Nordlöw"'s message of "Tue\, 12 Jun 2007 08\:34\:29 -0700")
Nordlöw <per.nordlow@gmail.com> wrote:
> Why does not rename-file() correspondingly rename all buffers visiting
> that file?
Because buffers are associated with file names and not files. Changing
the buffer name would break backup for instance, which (by default)
renames the file and then writes it again.
I don't think there can be multiple buffers visiting the same file, thuogh.
> How can I make this happen?
Something like this:
(defun rename-this-file (new-name)
"Rename this buffer's file to NEW-NAME."
(interactive
(let ((file (or buffer-file-name (error "Not a file"))))
(list (read-file-name
"New name: " (file-name-directory file) nil nil
(file-name-nondirectory file)))))
(if (vc-backend buffer-file-name)
(vc-rename-file buffer-file-name new-name))
(rename-file buffer-file-name new-name)
(set-visited-file-name new-name t t))
regards,
Nikolaj Schumacher
prev parent reply other threads:[~2007-06-14 10:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-12 15:34 Make rename-file() also rename visiting buffers Nordlöw
2007-06-12 20:01 ` Dieter Wilhelm
2007-06-14 10:43 ` Nikolaj Schumacher [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m28xam7r5p.fsf@nschum.de \
--to=n_schumacher@web.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.