Commit a522e5bf authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(set-visited-file-name): Handle find-file-visit-truename

early on, before we deal with lock files.
parent ed160f1f
...@@ -1172,35 +1172,40 @@ nil or empty string as argument means make buffer not be visiting any file. ...@@ -1172,35 +1172,40 @@ nil or empty string as argument means make buffer not be visiting any file.
Remember to delete the initial contents of the minibuffer Remember to delete the initial contents of the minibuffer
if you wish to pass an empty string as the argument." if you wish to pass an empty string as the argument."
(interactive "FSet visited file name: ") (interactive "FSet visited file name: ")
(if filename (let (truename)
(setq filename (if filename
(if (string-equal filename "") (setq filename
nil (if (string-equal filename "")
(expand-file-name filename)))) nil
(or (equal filename buffer-file-name) (expand-file-name filename))))
(progn (if filename
(and filename (lock-buffer filename)) (progn
(unlock-buffer))) (setq truename (file-truename filename))
(setq buffer-file-name filename) (if find-file-visit-truename
(if filename ; make buffer name reflect filename. ;; Do not use the abbreviated filename, because
(let ((new-name (file-name-nondirectory buffer-file-name))) ;; write-region will reset it to the expanded filename
(if (string= new-name "") (setq filename truename))))
(error "Empty file name")) (or (equal filename buffer-file-name)
(if (eq system-type 'vax-vms) (progn
(setq new-name (downcase new-name))) (and filename (lock-buffer filename))
(setq default-directory (file-name-directory buffer-file-name)) (unlock-buffer)))
(or (string= new-name (buffer-name)) (setq buffer-file-name filename)
(rename-buffer new-name t)))) (if filename ; make buffer name reflect filename.
(setq buffer-backed-up nil) (let ((new-name (file-name-nondirectory buffer-file-name)))
(clear-visited-file-modtime) (if (string= new-name "")
(if filename (error "Empty file name"))
(progn (if (eq system-type 'vax-vms)
(setq buffer-file-truename (setq new-name (downcase new-name)))
(abbreviate-file-name (file-truename buffer-file-name))) (setq default-directory (file-name-directory buffer-file-name))
(if find-file-visit-truename (or (string= new-name (buffer-name))
(setq buffer-file-name buffer-file-truename)) (rename-buffer new-name t))))
(setq buffer-file-number (nth 10 (file-attributes buffer-file-name)))) (setq buffer-backed-up nil)
(setq buffer-file-truename nil buffer-file-number nil)) (clear-visited-file-modtime)
(setq buffer-file-truename (abbreviate-file-name truename))
(setq buffer-file-number
(if filename
(nth 10 (file-attributes buffer-file-name))
nil)))
;; write-file-hooks is normally used for things like ftp-find-file ;; write-file-hooks is normally used for things like ftp-find-file
;; that visit things that are not local files as if they were files. ;; that visit things that are not local files as if they were files.
;; Changing to visit an ordinary local file instead should flush the hook. ;; Changing to visit an ordinary local file instead should flush the hook.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment