comparison lisp/files.el @ 56259:ed6c2f79cef5

* net/ange-ftp.el (ange-ftp-file-remote-p): New return value, according to new documentation of `file-remote-p'. * files.el (file-remote-p): Fix doc to say that return value is identification of remote system, if not nil. (file-relative-name): Use new return value of `file-remote-p'.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sat, 26 Jun 2004 14:41:13 +0000
parents a6383cbb5b13
children 8fc5472a5271 59dcbfe97385
comparison
equal deleted inserted replaced
56258:3b1880995ace 56259:ed6c2f79cef5
648 'locate-file-completion 648 'locate-file-completion
649 (cons load-path load-suffixes)))) 649 (cons load-path load-suffixes))))
650 (load library)) 650 (load library))
651 651
652 (defun file-remote-p (file) 652 (defun file-remote-p (file)
653 "Test whether FILE specifies a location on a remote system." 653 "Test whether FILE specifies a location on a remote system.
654 Return an identification of the system if the location is indeed
655 remote. The identification of the system may comprise a method
656 to access the system and its hostname, amongst other things.
657
658 For example, the filename \"/user@host:/foo\" specifies a location
659 on the system \"/user@host:\"."
654 (let ((handler (find-file-name-handler file 'file-remote-p))) 660 (let ((handler (find-file-name-handler file 'file-remote-p)))
655 (if handler 661 (if handler
656 (funcall handler 'file-remote-p file) 662 (funcall handler 'file-remote-p file)
657 nil))) 663 nil)))
658 664
2914 (save-match-data 2920 (save-match-data
2915 (setq directory 2921 (setq directory
2916 (file-name-as-directory (expand-file-name (or directory 2922 (file-name-as-directory (expand-file-name (or directory
2917 default-directory)))) 2923 default-directory))))
2918 (setq filename (expand-file-name filename)) 2924 (setq filename (expand-file-name filename))
2919 (let ((hf (find-file-name-handler filename 'file-remote-p)) 2925 (let ((fremote (file-remote-p filename))
2920 (hd (find-file-name-handler directory 'file-remote-p))) 2926 (dremote (file-remote-p directory)))
2921 (if ;; Conditions for separate trees 2927 (if ;; Conditions for separate trees
2922 (or 2928 (or
2923 ;; Test for different drives on DOS/Windows 2929 ;; Test for different drives on DOS/Windows
2924 (and 2930 (and
2925 ;; Should `cygwin' really be included here? --stef 2931 ;; Should `cygwin' really be included here? --stef
2926 (memq system-type '(ms-dos cygwin windows-nt)) 2932 (memq system-type '(ms-dos cygwin windows-nt))
2927 (not (eq t (compare-strings filename 0 2 directory 0 2)))) 2933 (not (eq t (compare-strings filename 0 2 directory 0 2))))
2928 ;; Test for different remote file handlers
2929 (not (eq hf hd))
2930 ;; Test for different remote file system identification 2934 ;; Test for different remote file system identification
2931 (and 2935 (not (equal fremote dremote)))
2932 hf
2933 (let ((re (car (rassq hf file-name-handler-alist))))
2934 (not
2935 (equal
2936 (and
2937 (string-match re filename)
2938 (substring filename 0 (match-end 0)))
2939 (and
2940 (string-match re directory)
2941 (substring directory 0 (match-end 0))))))))
2942 filename 2936 filename
2943 (let ((ancestor ".") 2937 (let ((ancestor ".")
2944 (filename-dir (file-name-as-directory filename))) 2938 (filename-dir (file-name-as-directory filename)))
2945 (while (not 2939 (while (not
2946 (or 2940 (or