# HG changeset patch # User Richard M. Stallman # Date 719563164 0 # Node ID fb2d16111e4b4b34ff7973b4cd7deb9bbde1e129 # Parent ed79bb8047e8646e26eb9ee58ea8d943b113d745 (file-truename): Check for root by seeing if directory-file-name returns same as DIR. Look for a file-truename handler for the file name. diff -r ed79bb8047e8 -r fb2d16111e4b lisp/files.el --- a/lisp/files.el Tue Oct 20 06:13:00 1992 +0000 +++ b/lisp/files.el Tue Oct 20 06:39:24 1992 +0000 @@ -270,21 +270,35 @@ containing it, until no links are left at any level." (if (string= filename "~") (setq filename (expand-file-name filename))) - (let ((dir (file-name-directory filename)) - target) - ;; Get the truename of the directory. - (or (string= dir "/") - (setq dir (file-name-as-directory (file-truename (directory-file-name dir))))) - ;; Put it back on the file name. - (setq filename (concat dir (file-name-nondirectory filename))) - ;; Is the file name the name of a link? - (setq target (file-symlink-p filename)) - (if target - ;; Yes => chase that link, then start all over - ;; since the link may point to a directory name that uses links. - (file-truename (expand-file-name target dir)) - ;; No, we are done! - filename))) + (let (handler (handlers file-name-handler-alist)) + (save-match-data + (while (and (consp handlers) (null handler)) + (if (and (consp (car handlers)) + (stringp (car (car handlers))) + (string-match (car (car handlers)) filename)) + (setq handler (cdr (car handlers)))) + (setq handlers (cdr handlers)))) + ;; For file name that has a special handler, call handler. + ;; This is so that ange-ftp can save time by doing a no-op. + (if handler + (funcall handler 'file-truename filename) + (let ((dir (file-name-directory filename)) + target dirfile) + ;; Get the truename of the directory. + (setq dirfile (directory-file-name dir)) + ;; If these are equal, we have the (or a) root directory. + (or (string= dir dirfile) + (setq dir (file-name-as-directory (file-truename dirfile)))) + ;; Put it back on the file name. + (setq filename (concat dir (file-name-nondirectory filename))) + ;; Is the file name the name of a link? + (setq target (file-symlink-p filename)) + (if target + ;; Yes => chase that link, then start all over + ;; since the link may point to a directory name that uses links. + (file-truename (expand-file-name target dir)) + ;; No, we are done! + filename))))) (defun switch-to-buffer-other-window (buffer) "Select buffer BUFFER in another window."