Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 5668:ee95ef1e644c
Update `file-name-remote-p'.
2008-01-03 Michael Sperber <mike@xemacs.org>
* files.el (file-remote-p): Synch with GNU Emac: Add
`identification' and `connected' parameters, and use file-name
handler if available. Zap support for ange-ftp.
author | Mike Sperber <sperber@deinprogramm.de> |
---|---|
date | Mon, 02 Jul 2012 20:39:12 +0200 |
parents | b7ae5f44b950 |
children | dae33b5feffe |
comparison
equal
deleted
inserted
replaced
5667:b4715fcbe001 | 5668:ee95ef1e644c |
---|---|
4480 (if (> count 0) | 4480 (if (> count 0) |
4481 filename | 4481 filename |
4482 (error "Apparently circular symlink path")))) | 4482 (error "Apparently circular symlink path")))) |
4483 | 4483 |
4484 ;; Suggested by Michael Kifer <kifer@CS.SunySB.EDU> | 4484 ;; Suggested by Michael Kifer <kifer@CS.SunySB.EDU> |
4485 (defun file-remote-p (file-name) | 4485 (defun file-remote-p (file &optional identification connected) |
4486 "Test whether FILE-NAME is looked for on a remote system." | 4486 "Test whether FILE specifies a location on a remote system. |
4487 (cond ((not (declare-boundp allow-remote-paths)) nil) | 4487 Return an identification of the system if the location is indeed |
4488 ((fboundp 'ange-ftp-ftp-path) | 4488 remote. The identification of the system may comprise a method |
4489 (declare-fboundp (ange-ftp-ftp-path file-name))) | 4489 to access the system and its hostname, amongst other things. |
4490 ((fboundp 'efs-ftp-path) | 4490 |
4491 (declare-fboundp (efs-ftp-path file-name))) | 4491 For example, the filename \"/user@host:/foo\" specifies a location |
4492 (t nil))) | 4492 on the system \"/user@host:\". |
4493 | |
4494 IDENTIFICATION specifies which part of the identification shall | |
4495 be returned as string. IDENTIFICATION can be the symbol | |
4496 `method', `user' or `host'; any other value is handled like nil | |
4497 and means to return the complete identification string. | |
4498 | |
4499 If CONNECTED is non-nil, the function returns an identification only | |
4500 if FILE is located on a remote system, and a connection is established | |
4501 to that remote system. | |
4502 | |
4503 `file-remote-p' will never open a connection on its own." | |
4504 (let ((handler (find-file-name-handler file 'file-remote-p))) | |
4505 (cond | |
4506 (handler | |
4507 (funcall handler 'file-remote-p file identification connected)) | |
4508 ;; legacy code; can probably go by mid-2008 | |
4509 ((fboundp 'efs-ftp-path) | |
4510 (let ((parsed (declare-fboundp (efs-ftp-path file)))) | |
4511 (and parsed | |
4512 (let ((host (nth 0 parsed)) | |
4513 (user (nth 1 parsed))) | |
4514 (and (or (not connected) | |
4515 (let ((proc (get-process (declare-fboundp (efs-ftp-process-buffer host user))))) | |
4516 (and proc (processp proc) | |
4517 (memq (process-status proc) '(run open))))) | |
4518 (cond | |
4519 ((eq identification 'method) (and parsed "ftp")) | |
4520 ((eq identification 'user) user) | |
4521 ((eq identification 'host) host) | |
4522 (t | |
4523 (concat "/" user "@" host ":/")))))))) | |
4524 (t nil)))) | |
4493 | 4525 |
4494 | 4526 |
4495 ;; We use /: as a prefix to "quote" a file name | 4527 ;; We use /: as a prefix to "quote" a file name |
4496 ;; so that magic file name handlers will not apply to it. | 4528 ;; so that magic file name handlers will not apply to it. |
4497 | 4529 |