comparison lisp/efs/efs.el @ 118:7d55a9ba150c r20-1b11

Import from CVS: tag r20-1b11
author cvs
date Mon, 13 Aug 2007 09:24:17 +0200
parents 9f59509498e1
children 6608ceec7cf8
comparison
equal deleted inserted replaced
117:578fd4947a72 118:7d55a9ba150c
4 ;; File: efs.el 4 ;; File: efs.el
5 ;; Release: $efs release: 1.15 $ 5 ;; Release: $efs release: 1.15 $
6 ;; Version: #Revision: 1.56 $ 6 ;; Version: #Revision: 1.56 $
7 ;; RCS: 7 ;; RCS:
8 ;; Description: Transparent FTP support for the original GNU Emacs 8 ;; Description: Transparent FTP support for the original GNU Emacs
9 ;; from FSF and Lucid Emacs 9 ;; from FSF and XEmacs
10 ;; Authors: Andy Norman <ange@hplb.hpl.hp.com>, 10 ;; Authors: Andy Norman <ange@hplb.hpl.hp.com>,
11 ;; Sandy Rutherford <sandy@ibm550.sissa.it> 11 ;; Sandy Rutherford <sandy@ibm550.sissa.it>
12 ;; Created: Thu Oct 12 14:00:05 1989 (as ange-ftp) 12 ;; Created: Thu Oct 12 14:00:05 1989 (as ange-ftp)
13 ;; 13 ;;
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
900 ;;; 900 ;;;
901 ;;; LCD Archive Entry: 901 ;;; LCD Archive Entry:
902 ;;; efs|Andy Norman and Sandy Rutherford 902 ;;; efs|Andy Norman and Sandy Rutherford
903 ;;; |ange@hplb.hpl.hp.com and sandy@ibm550.sissa.it 903 ;;; |ange@hplb.hpl.hp.com and sandy@ibm550.sissa.it
904 ;;; |transparent FTP Support for GNU Emacs 904 ;;; |transparent FTP Support for GNU Emacs
905 ;;; |$Date: 1997/03/28 02:28:27 $|$efs release: 1.15 beta $| 905 ;;; |$Date: 1997/04/05 18:07:24 $|$efs release: 1.15 beta $|
906 906
907 ;;; Host and listing type notation: 907 ;;; Host and listing type notation:
908 ;;; 908 ;;;
909 ;;; The functions efs-host-type and efs-listing-type, and the 909 ;;; The functions efs-host-type and efs-listing-type, and the
910 ;;; variable efs-dired-host-type follow the following conventions 910 ;;; variable efs-dired-host-type follow the following conventions
1385 "How many iterations efs waits on the nslookup program. 1385 "How many iterations efs waits on the nslookup program.
1386 Applies when nslookup is used to compute a fully qualified domain name 1386 Applies when nslookup is used to compute a fully qualified domain name
1387 for the local host, in the case when `system-name' does not return one. 1387 for the local host, in the case when `system-name' does not return one.
1388 If you set this to nil, efs will wait an arbitrary amount of time to get 1388 If you set this to nil, efs will wait an arbitrary amount of time to get
1389 output.") 1389 output.")
1390
1391 (defvar efs-remote-shell-file-name
1392 (if (memq system-type '(hpux usg-unix-v)) ; hope that's right
1393 "remsh"
1394 "rsh")
1395 "Remote shell used by efs.")
1396
1397 (defvar efs-remote-shell-takes-user
1398 (null (null (memq system-type '(aix aix-v3 hpux silicon-graphics-unix
1399 berkeley-unix))))
1400 ;; Complete? Doubt it.
1401 "Set to non-nil if your remote shell command takes \"-l USER\".")
1390 1402
1391 (defvar efs-make-backup-files efs-unix-host-types 1403 (defvar efs-make-backup-files efs-unix-host-types
1392 "*A list of operating systems for which efs will make Emacs backup files. 1404 "*A list of operating systems for which efs will make Emacs backup files.
1393 The backup files are made on the remote host. 1405 The backup files are made on the remote host.
1394 1406
8087 (sticky (memq int '(1 3 5 7)))) 8099 (sticky (memq int '(1 3 5 7))))
8088 (concat (efs-build-mode-string-element owner-int suid nil) 8100 (concat (efs-build-mode-string-element owner-int suid nil)
8089 (efs-build-mode-string-element group-int sgid nil) 8101 (efs-build-mode-string-element group-int sgid nil)
8090 (efs-build-mode-string-element other-int nil sticky)))) 8102 (efs-build-mode-string-element other-int nil sticky))))
8091 8103
8104 (defun efs-shell-call-process (command dir &optional in-background)
8105 ;; Runs shell process on remote hosts.
8106 (let* ((parsed (efs-ftp-path dir))
8107 (host (car parsed))
8108 (user (nth 1 parsed))
8109 (rdir (nth 2 parsed))
8110 (file-name-handler-alist nil))
8111 (or (string-equal (efs-internal-directory-file-name dir)
8112 (efs-expand-tilde "~" (efs-host-type host) host user))
8113 (string-match "^cd " command)
8114 (setq command (concat "cd " rdir "; " command)))
8115 (setq command
8116 (format "%s %s%s \"%s\"" ; remsh -l USER does not work well
8117 ; on a hp-ux machine I tried
8118 efs-remote-shell-file-name host
8119 (if efs-remote-shell-takes-user
8120 (concat " -l " user)
8121 "")
8122 command))
8123 (message "Doing shell command on %s..." host)
8124 ;; do it
8125 (let ((process-connection-type ; don't waste pty's
8126 (null (null in-background))))
8127 (setq default-directory (file-name-directory efs-tmp-name-template))
8128 (if in-background
8129 (progn
8130 (setq mode-line-process '(": %s"))
8131 (start-process "Shell" (current-buffer)
8132 shell-file-name "-c" command))
8133 (call-process shell-file-name nil t nil "-c" command)))))
8134
8092 (defun efs-set-file-modes (file mode) 8135 (defun efs-set-file-modes (file mode)
8093 ;; set-file-modes for remote files. 8136 ;; set-file-modes for remote files.
8094 ;; For remote files, if mode is nil, does nothing. 8137 ;; For remote files, if mode is nil, does nothing.
8095 ;; This is because efs-file-modes returns nil if the modes 8138 ;; This is because efs-file-modes returns nil if the modes
8096 ;; of a remote file couldn't be determined, even if the file exists. 8139 ;; of a remote file couldn't be determined, even if the file exists.
8109 host user 8152 host user
8110 (list 'quote 'site 'chmod omode r-file) 8153 (list 'quote 'site 'chmod omode r-file)
8111 nil nil 8154 nil nil
8112 (efs-cont (result line cont-lines) (host file r-file omode) 8155 (efs-cont (result line cont-lines) (host file r-file omode)
8113 (if result 8156 (if result
8114 (progn 8157 (let ((exit-code
8115 (efs-set-host-property host 'chmod-failed t) 8158 (efs-shell-call-process
8116 (message "CHMOD %s failed for %s on %s." omode r-file host) 8159 (concat "chmod " mode " " (file-name-nondirectory file))
8117 (if efs-ding-on-chmod-failure 8160 (file-name-directory file))))
8118 (progn (ding) (sit-for 1)))) 8161 (if (not (equal 0 exit-code))
8162 (progn
8163 (efs-set-host-property host 'chmod-failed t)
8164 (message "CHMOD %s failed for %s on %s." omode r-file host)
8165 (if efs-ding-on-chmod-failure
8166 (progn (ding) (sit-for 1))))))
8119 (let ((ent (efs-get-file-entry file))) 8167 (let ((ent (efs-get-file-entry file)))
8120 (if ent 8168 (if ent
8121 (let* ((type 8169 (let* ((type
8122 (cond 8170 (cond
8123 ((null (car ent)) "-") 8171 ((null (car ent)) "-")
8859 (downcase def-user)) 8907 (downcase def-user))
8860 (string-equal user def-user)) 8908 (string-equal user def-user))
8861 (format efs-path-format-without-user host path) 8909 (format efs-path-format-without-user host path)
8862 (format efs-path-format-string user host path)))) 8910 (format efs-path-format-string user host path))))
8863 8911
8864 (efs-define-fun efs-abbreviate-file-name (filename) 8912 (efs-define-fun efs-abbreviate-file-name (filename &optional ignored-for-now)
8865 ;; Version of abbreviate-file-name for remote files. 8913 ;; Version of abbreviate-file-name for remote files.
8866 (efs-save-match-data 8914 (efs-save-match-data
8867 (let ((tail directory-abbrev-alist)) 8915 (let ((tail directory-abbrev-alist))
8868 (while tail 8916 (while tail
8869 (if (string-match (car (car tail)) filename) 8917 (if (string-match (car (car tail)) filename)
10759 (apply operation args)))) 10807 (apply operation args))))
10760 10808
10761 ;; Yes, this is what it looks like. I'm defining the handler to run our 10809 ;; Yes, this is what it looks like. I'm defining the handler to run our
10762 ;; version whenever there is an environment variable. 10810 ;; version whenever there is an environment variable.
10763 10811
10764 (nconc file-name-handler-alist 10812 (defvar efs-path-sifn-regexp "\\(^\\|[^$]\\)\\(\\$\\$\\)*\\$[{a-zA-Z0-9]"
10765 (list 10813 "Regexp to match environment variables in file names.")
10766 (cons "\\(^\\|[^$]\\)\\(\\$\\$\\)*\\$[{a-zA-Z0-9]" 10814
10767 'efs-sifn-handler-function))) 10815 (or (assoc efs-path-sifn-regexp file-name-handler-alist)
10816 (nconc file-name-handler-alist
10817 (list
10818 (cons efs-path-sifn-regexp
10819 'efs-sifn-handler-function))))
10768 10820
10769 ;;;; ------------------------------------------------------------ 10821 ;;;; ------------------------------------------------------------
10770 ;;;; Necessary overloads. 10822 ;;;; Necessary overloads.
10771 ;;;; ------------------------------------------------------------ 10823 ;;;; ------------------------------------------------------------
10772 10824