* Make rename-file() also rename visiting buffers
@ 2007-06-12 15:34 Nordlöw
2007-06-12 20:01 ` Dieter Wilhelm
2007-06-14 10:43 ` Nikolaj Schumacher
0 siblings, 2 replies; 3+ messages in thread
From: Nordlöw @ 2007-06-12 15:34 UTC (permalink / raw)
To: help-gnu-emacs
Hello again, Emacs Powerusers?
Why does not rename-file() correspondingly rename all buffers visiting
that file?
How can I make this happen?
Thanks in advance,
Nordlöw
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make rename-file() also rename visiting buffers
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
1 sibling, 0 replies; 3+ messages in thread
From: Dieter Wilhelm @ 2007-06-12 20:01 UTC (permalink / raw)
To: Nordlöw; +Cc: help-gnu-emacs
Nordlöw <per.nordlow@gmail.com> writes:
> Why does not rename-file() correspondingly rename all buffers visiting
> that file?
>
> How can I make this happen?
For me the fastest way is to use the dired-x command
(define-key global-map "\C-x\C-j" 'dired-jump)
C-x C-j in the interesting buffer leads you to dired, then type R (for
rename) and after renaming it type RET and you are in the
corresponding buffer and all others are renamed as well.
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make rename-file() also rename visiting buffers
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
1 sibling, 0 replies; 3+ messages in thread
From: Nikolaj Schumacher @ 2007-06-14 10:43 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-14 10:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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.