comparison lisp/files.el @ 50351:8e666b72c381

(file-relative-name): Remove superfluous `and'. Clarify docstring. From Lars Hansen.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Mon, 31 Mar 2003 16:05:50 +0000
parents b8ecb0403fa1
children e1c7e157854c
comparison
equal deleted inserted replaced
50350:807c5a3c80d1 50351:8e666b72c381
2824 (defun file-relative-name (filename &optional directory) 2824 (defun file-relative-name (filename &optional directory)
2825 "Convert FILENAME to be relative to DIRECTORY (default: `default-directory'). 2825 "Convert FILENAME to be relative to DIRECTORY (default: `default-directory').
2826 This function returns a relative file name which is equivalent to FILENAME 2826 This function returns a relative file name which is equivalent to FILENAME
2827 when used with that default directory as the default. 2827 when used with that default directory as the default.
2828 If FILENAME and DIRECTORY lie on different machines or on different drives 2828 If FILENAME and DIRECTORY lie on different machines or on different drives
2829 \(DOS/Windows), it returns FILENAME in expanded form." 2829 on a DOS/Windows machine, it returns FILENAME on expanded form."
2830 (save-match-data 2830 (save-match-data
2831 (setq directory 2831 (setq directory
2832 (file-name-as-directory (expand-file-name (or directory 2832 (file-name-as-directory (expand-file-name (or directory
2833 default-directory)))) 2833 default-directory))))
2834 (setq filename (expand-file-name filename)) 2834 (setq filename (expand-file-name filename))
2835 (let ((hf (find-file-name-handler filename 'file-local-copy)) 2835 (let ((hf (find-file-name-handler filename 'file-local-copy))
2836 (hd (find-file-name-handler directory 'file-local-copy))) 2836 (hd (find-file-name-handler directory 'file-local-copy)))
2837 (when (and hf (not (get hf 'file-remote-p))) (setq hf nil)) 2837 (when (and hf (not (get hf 'file-remote-p))) (setq hf nil))
2838 (when (and hd (not (get hd 'file-remote-p))) (setq hd nil)) 2838 (when (and hd (not (get hd 'file-remote-p))) (setq hd nil))
2839 (if (and 2839 (if ;; Conditions for separate trees
2840 ;; Conditions for separate trees 2840 (or
2841 (or 2841 ;; Test for different drives on DOS/Windows
2842 ;; Test for different drives on DOS/Windows 2842 (and
2843 (and 2843 (memq system-type '(ms-dos cygwin windows-nt))
2844 (memq system-type '(ms-dos cygwin windows-nt)) 2844 (not (string-equal (substring filename 0 2)
2845 (not (string-equal (substring filename 0 2) 2845 (substring directory 0 2))))
2846 (substring directory 0 2)))) 2846 ;; Test for different remote file handlers
2847 ;; Test for different remote file handlers 2847 (not (eq hf hd))
2848 (not (eq hf hd)) 2848 ;; Test for different remote file system identification
2849 ;; Test for different remote file system identification 2849 (and
2850 (and 2850 hf
2851 hf 2851 (let ((re (car (rassq hf file-name-handler-alist))))
2852 (let ((re (car (rassq hf file-name-handler-alist)))) 2852 (not
2853 (not 2853 (equal
2854 (equal 2854 (and
2855 (and 2855 (string-match re filename)
2856 (string-match re filename) 2856 (substring filename 0 (match-end 0)))
2857 (substring filename 0 (match-end 0))) 2857 (and
2858 (and 2858 (string-match re directory)
2859 (string-match re directory) 2859 (substring directory 0 (match-end 0))))))))
2860 (substring directory 0 (match-end 0)))))))))
2861 filename 2860 filename
2862 (unless (eq (aref filename 0) ?/) 2861 (unless (eq (aref filename 0) ?/)
2863 (setq filename (concat "/" filename))) 2862 (setq filename (concat "/" filename)))
2864 (unless (eq (aref directory 0) ?/) 2863 (unless (eq (aref directory 0) ?/)
2865 (setq directory (concat "/" directory))) 2864 (setq directory (concat "/" directory)))