393 |
(defvar write-contents-functions nil |
(defvar write-contents-functions nil |
394 |
"List of functions to be called before writing out a buffer to a file. |
"List of functions to be called before writing out a buffer to a file. |
395 |
If one of them returns non-nil, the file is considered already written |
If one of them returns non-nil, the file is considered already written |
396 |
and the rest are not called. |
and the rest are not called and neither are the functions in |
397 |
|
`write-file-functions'. |
398 |
|
|
399 |
This variable is meant to be used for hooks that pertain to the |
This variable is meant to be used for hooks that pertain to the |
400 |
buffer's contents, not to the particular visited file; thus, |
buffer's contents, not to the particular visited file; thus, |
650 |
(load library)) |
(load library)) |
651 |
|
|
652 |
(defun file-remote-p (file) |
(defun file-remote-p (file) |
653 |
"Test whether FILE specifies a location on a remote system." |
"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:\"." |
660 |
(let ((handler (find-file-name-handler file 'file-remote-p))) |
(let ((handler (find-file-name-handler file 'file-remote-p))) |
661 |
(if handler |
(if handler |
662 |
(funcall handler 'file-remote-p file) |
(funcall handler 'file-remote-p file) |
2922 |
(file-name-as-directory (expand-file-name (or directory |
(file-name-as-directory (expand-file-name (or directory |
2923 |
default-directory)))) |
default-directory)))) |
2924 |
(setq filename (expand-file-name filename)) |
(setq filename (expand-file-name filename)) |
2925 |
(let ((hf (find-file-name-handler filename 'file-remote-p)) |
(let ((fremote (file-remote-p filename)) |
2926 |
(hd (find-file-name-handler directory 'file-remote-p))) |
(dremote (file-remote-p directory))) |
2927 |
(if ;; Conditions for separate trees |
(if ;; Conditions for separate trees |
2928 |
(or |
(or |
2929 |
;; Test for different drives on DOS/Windows |
;; Test for different drives on DOS/Windows |
2931 |
;; Should `cygwin' really be included here? --stef |
;; Should `cygwin' really be included here? --stef |
2932 |
(memq system-type '(ms-dos cygwin windows-nt)) |
(memq system-type '(ms-dos cygwin windows-nt)) |
2933 |
(not (eq t (compare-strings filename 0 2 directory 0 2)))) |
(not (eq t (compare-strings filename 0 2 directory 0 2)))) |
|
;; Test for different remote file handlers |
|
|
(not (eq hf hd)) |
|
2934 |
;; Test for different remote file system identification |
;; Test for different remote file system identification |
2935 |
(and |
(not (equal fremote dremote))) |
|
hf |
|
|
(let ((re (car (rassq hf file-name-handler-alist)))) |
|
|
(not |
|
|
(equal |
|
|
(and |
|
|
(string-match re filename) |
|
|
(substring filename 0 (match-end 0))) |
|
|
(and |
|
|
(string-match re directory) |
|
|
(substring directory 0 (match-end 0)))))))) |
|
2936 |
filename |
filename |
2937 |
(let ((ancestor ".") |
(let ((ancestor ".") |
2938 |
(filename-dir (file-name-as-directory filename))) |
(filename-dir (file-name-as-directory filename))) |