[Top][All Lists]

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

Re: rename-file

From: martin rudalics
Subject: Re: rename-file
Date: Wed, 26 Aug 2009 22:42:51 +0200
User-agent: Thunderbird (Windows/20090302)

> Why isn't the buffer, which is visiting a file, renamed
> when I rename the underlying file with rename-file?

Personally, I do the following when renaming a file or a directory:
First I do a `bookmark-set-filename' on every involved buffer.  Next I
do (the precise reasons I don't remember) for any BUFFER whose filename
is set to NEW

        (with-current-buffer buffer
          (let ((buffer-modified-p (buffer-modified-p)))
            ;; make buffer visit new
            (set-visited-file-name new nil t)
            (set-buffer-modified-p buffer-modified-p)))))

`dired-rename-file' does something similar, but I never looked into

Finally, I do a redisplay to assure that modelines and frame titles get
updated correctly.  When renaming directories I also set the default
directory, if necessary.

All these are sufficient for my personal needs and have not caused any
problems over the past five years.  But I'm afraid there's a number of
more hairy issues involved when a package has stored away some buffers'
names in a local list.


reply via email to

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