aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-08-29 21:48:50 +0000
committerStefan Monnier2002-08-29 21:48:50 +0000
commite3441f426b701297b48bbaf4c2b564f9baffc4e5 (patch)
tree31f78dd6cde02953cd6b349a1828d80a01edcefc
parentc9ae8cbb2119d512853e977427275009cb8a11ba (diff)
downloademacs-e3441f426b701297b48bbaf4c2b564f9baffc4e5.tar.gz
emacs-e3441f426b701297b48bbaf4c2b564f9baffc4e5.zip
Use match-string and drop useless `function's.
(ange-ftp-get-process): Bind `ange-ftp-this-user' and `ange-ftp-this-host' before running ange-ftp-process-startup-hook. (ange-ftp-ls-parser): Use `switches' arg instead of dynamic binding. (ange-ftp-parse-dired-listing): Update the calls. (dired-local-variables-file): Declare to shut quieten the compiler. (ange-ftp-file-entry-active-p): Remove. (ange-ftp-file-name-all-completions, ange-ftp-file-name-completion): Don't exclude dangling symlinks. (ange-ftp-file-name-completion-1): Make predicate optional. (ange-ftp-parse-list-func-alist): Use add-to-list to update. (ange-ftp-fix-name-for-bs2000): Use subst-char-in-string. (ange-ftp-bs2000-posix-hook-installed): Remove. (ange-ftp-add-bs2000-posix-host): Don't use it anymore. (ange-ftp-bs2000-cd-to-posix): Use `ange-ftp-this-user' and `ange-ftp-this-host' instead of `user' and `host'.
-rw-r--r--lisp/net/ange-ftp.el252
1 files changed, 94 insertions, 158 deletions
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 010c7fe1838..54f954dde05 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -1416,8 +1416,7 @@ only return the directory part of FILE."
1416(defmacro ange-ftp-ftp-name-component (n ns name) 1416(defmacro ange-ftp-ftp-name-component (n ns name)
1417 "Extract the Nth ftp file name component from NS." 1417 "Extract the Nth ftp file name component from NS."
1418 `(let ((elt (nth ,n ,ns))) 1418 `(let ((elt (nth ,n ,ns)))
1419 (if (match-beginning elt) 1419 (match-string elt ,name)))
1420 (substring ,name (match-beginning elt) (match-end elt)))))
1421 1420
1422(defvar ange-ftp-ftp-name-arg "") 1421(defvar ange-ftp-ftp-name-arg "")
1423(defvar ange-ftp-ftp-name-res nil) 1422(defvar ange-ftp-ftp-name-res nil)
@@ -1504,19 +1503,18 @@ then kill the related ftp process."
1504 1503
1505(defun ange-ftp-quote-string (string) 1504(defun ange-ftp-quote-string (string)
1506 "Quote any characters in STRING that may confuse the ftp process." 1505 "Quote any characters in STRING that may confuse the ftp process."
1507 (apply (function concat) 1506 (apply 'concat
1508 (mapcar (function 1507 (mapcar (lambda (char)
1509 ;; This is said to be wrong; ftp is said to 1508 ;; This is said to be wrong; ftp is said to
1510 ;; need quoting only for ", and that by doubling it. 1509 ;; need quoting only for ", and that by doubling it.
1511 ;; But experiment says this kind of quoting is correct 1510 ;; But experiment says this kind of quoting is correct
1512 ;; when talking to ftp on GNU/Linux systems. 1511 ;; when talking to ftp on GNU/Linux systems.
1513 (lambda (char) 1512 (if (or (<= char ? )
1514 (if (or (<= char ? ) 1513 (> char ?\~)
1515 (> char ?\~) 1514 (= char ?\")
1516 (= char ?\") 1515 (= char ?\\))
1517 (= char ?\\)) 1516 (vector ?\\ char)
1518 (vector ?\\ char) 1517 (vector char)))
1519 (vector char))))
1520 string))) 1518 string)))
1521 1519
1522(defun ange-ftp-barf-if-not-directory (directory) 1520(defun ange-ftp-barf-if-not-directory (directory)
@@ -1538,9 +1536,7 @@ Try to categorize it into one of four categories:
1538good, skip, fatal, or unknown." 1536good, skip, fatal, or unknown."
1539 (cond ((string-match ange-ftp-xfer-size-msgs line) 1537 (cond ((string-match ange-ftp-xfer-size-msgs line)
1540 (setq ange-ftp-xfer-size 1538 (setq ange-ftp-xfer-size
1541 (/ (string-to-number (substring line 1539 (/ (string-to-number (match-string 1 line))
1542 (match-beginning 1)
1543 (match-end 1)))
1544 1024))) 1540 1024)))
1545 ((string-match ange-ftp-skip-msgs line) 1541 ((string-match ange-ftp-skip-msgs line)
1546 t) 1542 t)
@@ -1691,8 +1687,8 @@ good, skip, fatal, or unknown."
1691 "When ftp process changes state, nuke all file-entries in cache." 1687 "When ftp process changes state, nuke all file-entries in cache."
1692 (let ((name (process-name proc))) 1688 (let ((name (process-name proc)))
1693 (if (string-match "\\*ftp \\([^@]+\\)@\\([^*]+\\)\\*" name) 1689 (if (string-match "\\*ftp \\([^@]+\\)@\\([^*]+\\)\\*" name)
1694 (let ((user (substring name (match-beginning 1) (match-end 1))) 1690 (let ((user (match-string 1 name))
1695 (host (substring name (match-beginning 2) (match-end 2)))) 1691 (host (match-string 2 name)))
1696 (ange-ftp-wipe-file-entries host user)))) 1692 (ange-ftp-wipe-file-entries host user))))
1697 (setq ange-ftp-ls-cache-file nil)) 1693 (setq ange-ftp-ls-cache-file nil))
1698 1694
@@ -1773,10 +1769,10 @@ good, skip, fatal, or unknown."
1773 (start-process name name 1769 (start-process name name
1774 ange-ftp-gateway-program 1770 ange-ftp-gateway-program
1775 ange-ftp-gateway-host))) 1771 ange-ftp-gateway-host)))
1776 (ftp (mapconcat (function identity) args " "))) 1772 (ftp (mapconcat 'identity args " ")))
1777 (process-kill-without-query proc) 1773 (process-kill-without-query proc)
1778 (set-process-sentinel proc (function ange-ftp-gwp-sentinel)) 1774 (set-process-sentinel proc 'ange-ftp-gwp-sentinel)
1779 (set-process-filter proc (function ange-ftp-gwp-filter)) 1775 (set-process-filter proc 'ange-ftp-gwp-filter)
1780 (save-excursion 1776 (save-excursion
1781 (set-buffer (process-buffer proc)) 1777 (set-buffer (process-buffer proc))
1782 (goto-char (point-max)) 1778 (goto-char (point-max))
@@ -1890,8 +1886,7 @@ been queued with no result. CONT will still be called, however."
1890 (accept-process-output proc)) 1886 (accept-process-output proc))
1891 (goto-char (point-min)) 1887 (goto-char (point-min))
1892 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t) 1888 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t)
1893 (setq res (buffer-substring (match-beginning 1) 1889 (setq res (match-string 1)))
1894 (match-end 1))))
1895 (kill-buffer (current-buffer))) 1890 (kill-buffer (current-buffer)))
1896 res) 1891 res)
1897 host)) 1892 host))
@@ -1942,8 +1937,8 @@ on the gateway machine to do the ftp instead."
1942 (goto-char (point-max)) 1937 (goto-char (point-max))
1943 (set-marker (process-mark proc) (point))) 1938 (set-marker (process-mark proc) (point)))
1944 (process-kill-without-query proc) 1939 (process-kill-without-query proc)
1945 (set-process-sentinel proc (function ange-ftp-process-sentinel)) 1940 (set-process-sentinel proc 'ange-ftp-process-sentinel)
1946 (set-process-filter proc (function ange-ftp-process-filter)) 1941 (set-process-filter proc 'ange-ftp-process-filter)
1947 ;; On Windows, the standard ftp client buffers its output (because 1942 ;; On Windows, the standard ftp client buffers its output (because
1948 ;; stdout is a pipe handle) so the startup message may never appear: 1943 ;; stdout is a pipe handle) so the startup message may never appear:
1949 ;; `accept-process-output' at this point would hang indefinitely. 1944 ;; `accept-process-output' at this point would hang indefinitely.
@@ -2092,7 +2087,7 @@ suffix of the form #PORT to specify a non-default port"
2092 ange-ftp-skip-msgs skip))) 2087 ange-ftp-skip-msgs skip)))
2093 (or (car result) 2088 (or (car result)
2094 (progn 2089 (progn
2095 (ange-ftp-set-passwd host user nil) ;reset password. 2090 (ange-ftp-set-passwd host user nil) ;reset password.
2096 (ange-ftp-set-account host user nil) ;reset account. 2091 (ange-ftp-set-account host user nil) ;reset account.
2097 (ange-ftp-error host user 2092 (ange-ftp-error host user
2098 (concat "USER request failed: " 2093 (concat "USER request failed: "
@@ -2112,10 +2107,7 @@ suffix of the form #PORT to specify a non-default port"
2112 (line (cdr status))) 2107 (line (cdr status)))
2113 (save-match-data 2108 (save-match-data
2114 (if (string-match ange-ftp-hash-mark-msgs line) 2109 (if (string-match ange-ftp-hash-mark-msgs line)
2115 (let ((size (string-to-int 2110 (let ((size (string-to-int (match-string 1 line))))
2116 (substring line
2117 (match-beginning 1)
2118 (match-end 1)))))
2119 (setq ange-ftp-ascii-hash-mark-size size 2111 (setq ange-ftp-ascii-hash-mark-size size
2120 ange-ftp-hash-mark-unit (ash size -4)) 2112 ange-ftp-hash-mark-unit (ash size -4))
2121 2113
@@ -2163,7 +2155,9 @@ Create a new process if needed."
2163 2155
2164 ;; Run any user-specified hooks. Note that proc, host and user are 2156 ;; Run any user-specified hooks. Note that proc, host and user are
2165 ;; dynamically bound at this point. 2157 ;; dynamically bound at this point.
2166 (run-hooks 'ange-ftp-process-startup-hook)) 2158 (let ((ange-ftp-this-user user)
2159 (ange-ftp-this-host host))
2160 (run-hooks 'ange-ftp-process-startup-hook)))
2167 proc))) 2161 proc)))
2168 2162
2169(defun ange-ftp-passive-mode (proc on-or-off) 2163(defun ange-ftp-passive-mode (proc on-or-off)
@@ -2699,8 +2693,7 @@ The main reason for this alist is to deal with file versions in VMS.")
2699;; unquoting names obtained with the SysV b switch and the GNU Q 2693;; unquoting names obtained with the SysV b switch and the GNU Q
2700;; switch. See Sebastian's dired-get-filename. 2694;; switch. See Sebastian's dired-get-filename.
2701 2695
2702(defun ange-ftp-ls-parser () 2696(defun ange-ftp-ls-parser (switches)
2703 ;; Note that switches is dynamically bound.
2704 ;; Meant to be called by ange-ftp-parse-dired-listing 2697 ;; Meant to be called by ange-ftp-parse-dired-listing
2705 (let ((tbl (make-hash-table :test 'equal)) 2698 (let ((tbl (make-hash-table :test 'equal))
2706 (used-F (and (stringp switches) 2699 (used-F (and (stringp switches)
@@ -2731,12 +2724,9 @@ The main reason for this alist is to deal with file versions in VMS.")
2731 (and (not symlink) ; x bits don't mean a thing for symlinks 2724 (and (not symlink) ; x bits don't mean a thing for symlinks
2732 (string-match 2725 (string-match
2733 "[xst]" 2726 "[xst]"
2734 (concat (buffer-substring 2727 (concat (match-string 1)
2735 (match-beginning 1) (match-end 1)) 2728 (match-string 2)
2736 (buffer-substring 2729 (match-string 3))))))
2737 (match-beginning 2) (match-end 2))
2738 (buffer-substring
2739 (match-beginning 3) (match-end 3)))))))
2740 ;; Some ls's with the F switch mark symlinks with an @ (ULTRIX) 2730 ;; Some ls's with the F switch mark symlinks with an @ (ULTRIX)
2741 ;; and others don't. (sigh...) Beware, that some Unix's don't 2731 ;; and others don't. (sigh...) Beware, that some Unix's don't
2742 ;; seem to believe in the F-switch 2732 ;; seem to believe in the F-switch
@@ -2800,7 +2790,7 @@ match subdirectories as well.")
2800 (forward-line 1) 2790 (forward-line 1)
2801 ;; Some systems put in a blank line here. 2791 ;; Some systems put in a blank line here.
2802 (if (eolp) (forward-line 1)) 2792 (if (eolp) (forward-line 1))
2803 (ange-ftp-ls-parser)) 2793 (ange-ftp-ls-parser switches))
2804 ((looking-at "[^\n]+\\( not found\\|: Not a directory\\)\n\\'") 2794 ((looking-at "[^\n]+\\( not found\\|: Not a directory\\)\n\\'")
2805 ;; It's an ls error message. 2795 ;; It's an ls error message.
2806 nil) 2796 nil)
@@ -2814,7 +2804,7 @@ match subdirectories as well.")
2814 nil) 2804 nil)
2815 ((re-search-forward ange-ftp-date-regexp nil t) 2805 ((re-search-forward ange-ftp-date-regexp nil t)
2816 (beginning-of-line) 2806 (beginning-of-line)
2817 (ange-ftp-ls-parser)) 2807 (ange-ftp-ls-parser switches))
2818 ((re-search-forward "^[^ \n\t]+ +\\([0-9]+\\|-\\|=\\) " nil t) 2808 ((re-search-forward "^[^ \n\t]+ +\\([0-9]+\\|-\\|=\\) " nil t)
2819 ;; It's a dl listing (I hope). 2809 ;; It's a dl listing (I hope).
2820 ;; file is bound by the call to ange-ftp-ls 2810 ;; file is bound by the call to ange-ftp-ls
@@ -2871,7 +2861,7 @@ NO-ERROR, if a listing for DIRECTORY cannot be obtained."
2871(defmacro ange-ftp-get-file-part (name) 2861(defmacro ange-ftp-get-file-part (name)
2872 `(let ((file (file-name-nondirectory ,name))) 2862 `(let ((file (file-name-nondirectory ,name)))
2873 (if (string-equal file "") 2863 (if (string-equal file "")
2874 "." 2864 "."
2875 file))) 2865 file)))
2876 2866
2877;; Return whether ange-ftp-file-entry-p and ange-ftp-get-file-entry are 2867;; Return whether ange-ftp-file-entry-p and ange-ftp-get-file-entry are
@@ -2882,6 +2872,7 @@ NO-ERROR, if a listing for DIRECTORY cannot be obtained."
2882;; 2. The syntax of FILE and DIR make it impossible that FILE could be a valid 2872;; 2. The syntax of FILE and DIR make it impossible that FILE could be a valid
2883;; subdirectory. This is of course an OS dependent judgement. 2873;; subdirectory. This is of course an OS dependent judgement.
2884 2874
2875(defvar dired-local-variables-file)
2885(defmacro ange-ftp-allow-child-lookup (dir file) 2876(defmacro ange-ftp-allow-child-lookup (dir file)
2886 `(not 2877 `(not
2887 (let* ((efile ,file) ; expand once. 2878 (let* ((efile ,file) ; expand once.
@@ -3024,10 +3015,8 @@ and LINE is the relevant success or fail line from the FTP-client."
3024 (if (car result) 3015 (if (car result)
3025 (save-match-data 3016 (save-match-data
3026 (and (or (string-match "\"\\([^\"]*\\)\"" line) 3017 (and (or (string-match "\"\\([^\"]*\\)\"" line)
3027 (string-match " \\([^ ]+\\) " line)) ; stone-age VMS servers! 3018 (string-match " \\([^ ]+\\) " line)) ; stone-age VMS servers!
3028 (setq dir (substring line 3019 (setq dir (match-string 1 line)))))
3029 (match-beginning 1)
3030 (match-end 1))))))
3031 (cons dir line))) 3020 (cons dir line)))
3032 3021
3033;;; ------------------------------------------------------------ 3022;;; ------------------------------------------------------------
@@ -3061,9 +3050,7 @@ logged in as user USER and cd'd to directory DIR."
3061 (line (cdr result))) 3050 (line (cdr result)))
3062 (setq res 3051 (setq res
3063 (if (string-match ange-ftp-expand-dir-regexp line) 3052 (if (string-match ange-ftp-expand-dir-regexp line)
3064 (substring line 3053 (match-string 1 line)))))
3065 (match-beginning 1)
3066 (match-end 1))))))
3067 (or res 3054 (or res
3068 (if (string-equal dir "~") 3055 (if (string-equal dir "~")
3069 (setq res (car (ange-ftp-get-pwd host user))) 3056 (setq res (car (ange-ftp-get-pwd host user)))
@@ -3098,9 +3085,7 @@ logged in as user USER and cd'd to directory DIR."
3098 ;; Name starts with ~ or ~user. Resolve that part of the name 3085 ;; Name starts with ~ or ~user. Resolve that part of the name
3099 ;; making it absolute then re-expand it. 3086 ;; making it absolute then re-expand it.
3100 ((string-match "^~[^/]*" name) 3087 ((string-match "^~[^/]*" name)
3101 (let* ((tilda (substring name 3088 (let* ((tilda (match-string 0 name))
3102 (match-beginning 0)
3103 (match-end 0)))
3104 (rest (substring name (match-end 0))) 3089 (rest (substring name (match-end 0)))
3105 (dir (ange-ftp-expand-dir host user tilda))) 3090 (dir (ange-ftp-expand-dir host user tilda)))
3106 (if dir 3091 (if dir
@@ -3212,8 +3197,8 @@ system TYPE.")
3212 (let ((parsed (ange-ftp-ftp-name dir))) 3197 (let ((parsed (ange-ftp-ftp-name dir)))
3213 (if parsed 3198 (if parsed
3214 (ange-ftp-replace-name-component 3199 (ange-ftp-replace-name-component
3215 dir 3200 dir
3216 (ange-ftp-real-directory-file-name (nth 2 parsed))) 3201 (ange-ftp-real-directory-file-name (nth 2 parsed)))
3217 (ange-ftp-real-directory-file-name dir)))) 3202 (ange-ftp-real-directory-file-name dir))))
3218 3203
3219 3204
@@ -3595,7 +3580,7 @@ Value is (0 0) if the modification time cannot be determined."
3595;; filename 3580;; filename
3596;; newname)) 3581;; newname))
3597;; res) 3582;; res)
3598;; (set-process-sentinel proc (function ange-ftp-copy-file-locally-sentinel)) 3583;; (set-process-sentinel proc 'ange-ftp-copy-file-locally-sentinel)
3599;; (process-kill-without-query proc) 3584;; (process-kill-without-query proc)
3600;; (with-current-buffer (process-buffer proc) 3585;; (with-current-buffer (process-buffer proc)
3601;; (set (make-local-variable 'copy-cont) cont)))) 3586;; (set (make-local-variable 'copy-cont) cont))))
@@ -3683,7 +3668,7 @@ Value is (0 0) if the modification time cannot be determined."
3683 (if (and temp1 t-parsed) 3668 (if (and temp1 t-parsed)
3684 (format "Getting %s" f-abbr) 3669 (format "Getting %s" f-abbr)
3685 (format "Copying %s to %s" f-abbr t-abbr))) 3670 (format "Copying %s to %s" f-abbr t-abbr)))
3686 (list (function ange-ftp-cf1) 3671 (list 'ange-ftp-cf1
3687 filename newname binary msg 3672 filename newname binary msg
3688 f-parsed f-host f-user f-name f-abbr 3673 f-parsed f-host f-user f-name f-abbr
3689 t-parsed t-host t-user t-name t-abbr 3674 t-parsed t-host t-user t-name t-abbr
@@ -3761,7 +3746,7 @@ Value is (0 0) if the modification time cannot be determined."
3761 (if (and temp2 f-parsed) 3746 (if (and temp2 f-parsed)
3762 (format "Putting %s" newname) 3747 (format "Putting %s" newname)
3763 (format "Copying %s to %s" f-abbr t-abbr))) 3748 (format "Copying %s to %s" f-abbr t-abbr)))
3764 (list (function ange-ftp-cf2) 3749 (list 'ange-ftp-cf2
3765 newname t-host t-user binary temp1 temp2 cont) 3750 newname t-host t-user binary temp1 temp2 cont)
3766 nowait)) 3751 nowait))
3767 3752
@@ -3916,12 +3901,6 @@ E.g.,
3916;;;; File name completion support. 3901;;;; File name completion support.
3917;;;; ------------------------------------------------------------ 3902;;;; ------------------------------------------------------------
3918 3903
3919;; If the file entry SYM is a symlink, returns whether its file exists.
3920;; Note that `ange-ftp-this-dir' is used as a free variable.
3921(defun ange-ftp-file-entry-active-p (key val)
3922 (or (not (stringp val))
3923 (file-exists-p (ange-ftp-expand-symlink val ange-ftp-this-dir))))
3924
3925;; If the file entry is not a directory (nor a symlink pointing to a directory) 3904;; If the file entry is not a directory (nor a symlink pointing to a directory)
3926;; returns whether the file (or file pointed to by the symlink) is ignored 3905;; returns whether the file (or file pointed to by the symlink) is ignored
3927;; by completion-ignored-extensions. 3906;; by completion-ignored-extensions.
@@ -3952,9 +3931,7 @@ E.g.,
3952 (setq ange-ftp-this-dir 3931 (setq ange-ftp-this-dir
3953 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir)) 3932 (ange-ftp-real-file-name-as-directory ange-ftp-this-dir))
3954 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir)) 3933 (let* ((tbl (ange-ftp-get-files ange-ftp-this-dir))
3955 (completions 3934 (completions (all-completions file tbl)))
3956 (all-completions file tbl
3957 (function ange-ftp-file-entry-active-p))))
3958 3935
3959 ;; see whether each matching file is a directory or not... 3936 ;; see whether each matching file is a directory or not...
3960 (mapcar 3937 (mapcar
@@ -3994,10 +3971,9 @@ E.g.,
3994 (save-match-data 3971 (save-match-data
3995 (or (ange-ftp-file-name-completion-1 3972 (or (ange-ftp-file-name-completion-1
3996 file tbl ange-ftp-this-dir 3973 file tbl ange-ftp-this-dir
3997 (function ange-ftp-file-entry-not-ignored-p)) 3974 'ange-ftp-file-entry-not-ignored-p)
3998 (ange-ftp-file-name-completion-1 3975 (ange-ftp-file-name-completion-1
3999 file tbl ange-ftp-this-dir 3976 file tbl ange-ftp-this-dir))))))
4000 (function ange-ftp-file-entry-active-p)))))))
4001 3977
4002 (if (ange-ftp-root-dir-p ange-ftp-this-dir) 3978 (if (ange-ftp-root-dir-p ange-ftp-this-dir)
4003 (try-completion 3979 (try-completion
@@ -4008,7 +3984,7 @@ E.g.,
4008 (ange-ftp-real-file-name-completion file ange-ftp-this-dir))))) 3984 (ange-ftp-real-file-name-completion file ange-ftp-this-dir)))))
4009 3985
4010 3986
4011(defun ange-ftp-file-name-completion-1 (file tbl dir predicate) 3987(defun ange-ftp-file-name-completion-1 (file tbl dir &optional predicate)
4012 (let ((bestmatch (try-completion file tbl predicate))) 3988 (let ((bestmatch (try-completion file tbl predicate)))
4013 (if bestmatch 3989 (if bestmatch
4014 (if (eq bestmatch t) 3990 (if (eq bestmatch t)
@@ -4101,11 +4077,11 @@ directory, so that Emacs will know its current contents."
4101 (nth 2 parsed)) 4077 (nth 2 parsed))
4102 (ange-ftp-real-file-name-as-directory 4078 (ange-ftp-real-file-name-as-directory
4103 (nth 2 parsed))))) 4079 (nth 2 parsed)))))
4104 (abbr (ange-ftp-abbreviate-filename dir)) 4080 (abbr (ange-ftp-abbreviate-filename dir))
4105 (result (ange-ftp-send-cmd host user 4081 (result (ange-ftp-send-cmd host user
4106 (list 'rmdir name) 4082 (list 'rmdir name)
4107 (format "Removing directory %s" 4083 (format "Removing directory %s"
4108 abbr)))) 4084 abbr))))
4109 (or (car result) 4085 (or (car result)
4110 (ange-ftp-error host user 4086 (ange-ftp-error host user
4111 (format "Could not remove directory %s: %s" 4087 (format "Could not remove directory %s: %s"
@@ -4514,9 +4490,9 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
4514 ;; ((equal dired-chown-program program)) 4490 ;; ((equal dired-chown-program program))
4515 (t (error "Unknown remote command: %s" program))) 4491 (t (error "Unknown remote command: %s" program)))
4516 (ftp-error (insert (format "%s: %s, %s\n" 4492 (ftp-error (insert (format "%s: %s, %s\n"
4517 (nth 1 oops) 4493 (nth 1 oops)
4518 (nth 2 oops) 4494 (nth 2 oops)
4519 (nth 3 oops))) 4495 (nth 3 oops)))
4520 ;; Caller expects nonzero value to mean failure. 4496 ;; Caller expects nonzero value to mean failure.
4521 1) 4497 1)
4522 (error (insert (format "%s\n" (nth 1 oops))) 4498 (error (insert (format "%s\n" (nth 1 oops)))
@@ -4667,7 +4643,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
4667;; (t nil)))) 4643;; (t nil))))
4668;; (condition-case err 4644;; (condition-case err
4669;; (funcall file-creator from to overwrite-confirmed 4645;; (funcall file-creator from to overwrite-confirmed
4670;; (list (function ange-ftp-dcf-2) 4646;; (list 'ange-ftp-dcf-2
4671;; nil ;err 4647;; nil ;err
4672;; file-creator operation fn-list 4648;; file-creator operation fn-list
4673;; name-constructor 4649;; name-constructor
@@ -4913,16 +4889,9 @@ NEWNAME should be the name to give the new compressed or uncompressed file.")
4913 (if reverse 4889 (if reverse
4914 (if (string-match "^\\([^:]+:\\)?\\(\\[.*\\]\\)?\\([^][]*\\)$" name) 4890 (if (string-match "^\\([^:]+:\\)?\\(\\[.*\\]\\)?\\([^][]*\\)$" name)
4915 (let (drive dir file) 4891 (let (drive dir file)
4916 (if (match-beginning 1) 4892 (setq drive (match-string 1 name))
4917 (setq drive (substring name 4893 (setq dir (match-string 2 name))
4918 (match-beginning 1) 4894 (setq file (match-string 3 name))
4919 (match-end 1))))
4920 (if (match-beginning 2)
4921 (setq dir
4922 (substring name (match-beginning 2) (match-end 2))))
4923 (if (match-beginning 3)
4924 (setq file
4925 (substring name (match-beginning 3) (match-end 3))))
4926 (and dir 4895 (and dir
4927 (setq dir (subst-char-in-string 4896 (setq dir (subst-char-in-string
4928 ?/ ?. (substring dir 1 -1) t))) 4897 ?/ ?. (substring dir 1 -1) t)))
@@ -5008,9 +4977,9 @@ Other orders of $ and _ seem to all work just fine.")
5008;; Extract the next filename from a VMS dired-like listing. 4977;; Extract the next filename from a VMS dired-like listing.
5009(defun ange-ftp-parse-vms-filename () 4978(defun ange-ftp-parse-vms-filename ()
5010 (if (re-search-forward 4979 (if (re-search-forward
5011 ange-ftp-vms-filename-regexp 4980 ange-ftp-vms-filename-regexp
5012 nil t) 4981 nil t)
5013 (buffer-substring (match-beginning 0) (match-end 0)))) 4982 (match-string 0)))
5014 4983
5015;; Parse the current buffer which is assumed to be in MultiNet FTP dir 4984;; Parse the current buffer which is assumed to be in MultiNet FTP dir
5016;; format, and return a hashtable as the result. 4985;; format, and return a hashtable as the result.
@@ -5036,10 +5005,8 @@ Other orders of $ and _ seem to all work just fine.")
5036 (puthash ".." t tbl)) 5005 (puthash ".." t tbl))
5037 tbl)) 5006 tbl))
5038 5007
5039(or (assq 'vms ange-ftp-parse-list-func-alist) 5008(add-to-list 'ange-ftp-parse-list-func-alist
5040 (setq ange-ftp-parse-list-func-alist 5009 '(vms . ange-ftp-parse-vms-listing))
5041 (cons '(vms . ange-ftp-parse-vms-listing)
5042 ange-ftp-parse-list-func-alist)))
5043 5010
5044;; This version only deletes file entries which have 5011;; This version only deletes file entries which have
5045;; explicit version numbers, because that is all VMS allows. 5012;; explicit version numbers, because that is all VMS allows.
@@ -5103,10 +5070,7 @@ Other orders of $ and _ seem to all work just fine.")
5103 (and (string-match regexp name) 5070 (and (string-match regexp name)
5104 (setq version 5071 (setq version
5105 (max version 5072 (max version
5106 (string-to-int 5073 (string-to-int (match-string 1 name))))))
5107 (substring name
5108 (match-beginning 1)
5109 (match-end 1)))))))
5110 files) 5074 files)
5111 (setq version (1+ version)) 5075 (setq version (1+ version))
5112 (puthash 5076 (puthash
@@ -5337,8 +5301,7 @@ Other orders of $ and _ seem to all work just fine.")
5337;; ;; If the file has numeric backup versions, 5301;; ;; If the file has numeric backup versions,
5338;; ;; put on ange-ftp-file-version-alist an element of the form 5302;; ;; put on ange-ftp-file-version-alist an element of the form
5339;; ;; (FILENAME . VERSION-NUMBER-LIST) 5303;; ;; (FILENAME . VERSION-NUMBER-LIST)
5340;; (dired-map-dired-file-lines (function 5304;; (dired-map-dired-file-lines 'ange-ftp-dired-vms-collect-file-versions)
5341;; ange-ftp-dired-vms-collect-file-versions))
5342;; ;; Sort each VERSION-NUMBER-LIST, 5305;; ;; Sort each VERSION-NUMBER-LIST,
5343;; ;; and remove the versions not to be deleted. 5306;; ;; and remove the versions not to be deleted.
5344;; (let ((fval ange-ftp-file-version-alist)) 5307;; (let ((fval ange-ftp-file-version-alist))
@@ -5355,8 +5318,7 @@ Other orders of $ and _ seem to all work just fine.")
5355;; ;; Look at each file. If it is a numeric backup file, 5318;; ;; Look at each file. If it is a numeric backup file,
5356;; ;; find it in a VERSION-NUMBER-LIST and maybe flag it for deletion. 5319;; ;; find it in a VERSION-NUMBER-LIST and maybe flag it for deletion.
5357;; (dired-map-dired-file-lines 5320;; (dired-map-dired-file-lines
5358;; (function 5321;; 'ange-ftp-dired-vms-trample-file-versions mark)
5359;; ange-ftp-dired-vms-trample-file-versions mark))
5360;; (message (concat action " numerical backups...done")))) 5322;; (message (concat action " numerical backups...done"))))
5361 5323
5362;;(or (assq 'vms ange-ftp-dired-clean-directory-alist) 5324;;(or (assq 'vms ange-ftp-dired-clean-directory-alist)
@@ -5458,17 +5420,13 @@ Other orders of $ and _ seem to all work just fine.")
5458 (if reverse 5420 (if reverse
5459 (if (string-match "^\\([^:]+:\\)?\\(.*\\)$" name) 5421 (if (string-match "^\\([^:]+:\\)?\\(.*\\)$" name)
5460 (let (acct file) 5422 (let (acct file)
5461 (if (match-beginning 1) 5423 (setq acct (match-string 1 name))
5462 (setq acct (substring name 0 (match-end 1)))) 5424 (setq file (match-string 2 name))
5463 (if (match-beginning 2)
5464 (setq file (substring name
5465 (match-beginning 2) (match-end 2))))
5466 (concat (and acct (concat "/" acct "/")) 5425 (concat (and acct (concat "/" acct "/"))
5467 file)) 5426 file))
5468 (error "name %s didn't match" name)) 5427 (error "name %s didn't match" name))
5469 (if (string-match "^/\\([^:]+:\\)/\\(.*\\)$" name) 5428 (if (string-match "^/\\([^:]+:\\)/\\(.*\\)$" name)
5470 (concat (substring name 1 (match-end 1)) 5429 (concat (match-string 1 name) (match-string 2 name))
5471 (substring name (match-beginning 2) (match-end 2)))
5472 ;; Let's hope that mts will recognize it anyway. 5430 ;; Let's hope that mts will recognize it anyway.
5473 name)))) 5431 name))))
5474 5432
@@ -5523,10 +5481,8 @@ Other orders of $ and _ seem to all work just fine.")
5523 (puthash "." t tbl) 5481 (puthash "." t tbl)
5524 tbl)) 5482 tbl))
5525 5483
5526(or (assq 'mts ange-ftp-parse-list-func-alist) 5484(add-to-list 'ange-ftp-parse-list-func-alist
5527 (setq ange-ftp-parse-list-func-alist 5485 '(mts . ange-ftp-parse-mts-listing))
5528 (cons '(mts . ange-ftp-parse-mts-listing)
5529 ange-ftp-parse-list-func-alist)))
5530 5486
5531(defun ange-ftp-add-mts-host (host) 5487(defun ange-ftp-add-mts-host (host)
5532 "Mark HOST as the name of a machine running MTS." 5488 "Mark HOST as the name of a machine running MTS."
@@ -5627,10 +5583,9 @@ Other orders of $ and _ seem to all work just fine.")
5627 (concat "/" name) 5583 (concat "/" name)
5628 (if (string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" 5584 (if (string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$"
5629 name) 5585 name)
5630 (let ((minidisk (substring name 1 (match-end 1)))) 5586 (let ((minidisk (match-string 1 name)))
5631 (if (match-beginning 2) 5587 (if (match-beginning 2)
5632 (let ((file (substring name (match-beginning 2) 5588 (let ((file (match-string 2 name))
5633 (match-end 2)))
5634 (cmd (concat "cd " minidisk)) 5589 (cmd (concat "cd " minidisk))
5635 5590
5636 ;; Note that host and user are bound in the call 5591 ;; Note that host and user are bound in the call
@@ -5672,14 +5627,13 @@ Other orders of $ and _ seem to all work just fine.")
5672 ((string-equal "/" dir-name) 5627 ((string-equal "/" dir-name)
5673 (error "Cannot get listing for fictitious \"/\" directory")) 5628 (error "Cannot get listing for fictitious \"/\" directory"))
5674 ((string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" dir-name) 5629 ((string-match "^/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?$" dir-name)
5675 (let* ((minidisk (substring dir-name (match-beginning 1) (match-end 1))) 5630 (let* ((minidisk (match-string 1 dir-name))
5676 ;; host and user are bound in the call to ange-ftp-send-cmd 5631 ;; host and user are bound in the call to ange-ftp-send-cmd
5677 (proc (ange-ftp-get-process ange-ftp-this-host ange-ftp-this-user)) 5632 (proc (ange-ftp-get-process ange-ftp-this-host ange-ftp-this-user))
5678 (cmd (concat "cd " minidisk)) 5633 (cmd (concat "cd " minidisk))
5679 (file (if (match-beginning 2) 5634 (file (if (match-beginning 2)
5680 ;; it's a single file 5635 ;; it's a single file
5681 (substring dir-name (match-beginning 2) 5636 (match-string 2 dir-name)
5682 (match-end 2))
5683 ;; use the wild-card 5637 ;; use the wild-card
5684 "*"))) 5638 "*")))
5685 (if (car (ange-ftp-raw-send-cmd proc cmd)) 5639 (if (car (ange-ftp-raw-send-cmd proc cmd))
@@ -5748,21 +5702,13 @@ Other orders of $ and _ seem to all work just fine.")
5748 (while 5702 (while
5749 (re-search-forward 5703 (re-search-forward
5750 "^\\([-A-Z0-9$_]+\\) +\\([-A-Z0-9$_]+\\) +[VF] +[0-9]+ " nil t) 5704 "^\\([-A-Z0-9$_]+\\) +\\([-A-Z0-9$_]+\\) +[VF] +[0-9]+ " nil t)
5751 (puthash 5705 (puthash (concat (match-string 1) "." (match-string 2)) nil tbl)
5752 (concat (buffer-substring (match-beginning 1)
5753 (match-end 1))
5754 "."
5755 (buffer-substring (match-beginning 2)
5756 (match-end 2)))
5757 nil tbl)
5758 (forward-line 1)) 5706 (forward-line 1))
5759 (puthash "." t tbl)) 5707 (puthash "." t tbl))
5760 tbl)) 5708 tbl))
5761 5709
5762(or (assq 'cms ange-ftp-parse-list-func-alist) 5710(add-to-list 'ange-ftp-parse-list-func-alist
5763 (setq ange-ftp-parse-list-func-alist 5711 '(cms . ange-ftp-parse-cms-listing))
5764 (cons '(cms . ange-ftp-parse-cms-listing)
5765 ange-ftp-parse-list-func-alist)))
5766 5712
5767;;;;; Tree dired support: 5713;;;;; Tree dired support:
5768 5714
@@ -5943,12 +5889,7 @@ Other orders of $ and _ seem to all work just fine.")
5943 (and userid (concat userid ".")) 5889 (and userid (concat userid "."))
5944 ;; change every '/' in filename to a '.', normally not neccessary 5890 ;; change every '/' in filename to a '.', normally not neccessary
5945 (and filename 5891 (and filename
5946 (apply (function concat) 5892 (subst-char-in-string ?/ ?. filename)))))
5947 (mapcar (function (lambda (char)
5948 (if (= char ?/)
5949 (vector ?.)
5950 (vector char))))
5951 filename))))))
5952 ;; Let's hope that BS2000 recognize this anyway: 5893 ;; Let's hope that BS2000 recognize this anyway:
5953 name)))) 5894 name))))
5954 5895
@@ -6000,8 +5941,6 @@ Other orders of $ and _ seem to all work just fine.")
6000 ange-ftp-bs2000-host-regexp) 5941 ange-ftp-bs2000-host-regexp)
6001 ange-ftp-host-cache nil))) 5942 ange-ftp-host-cache nil)))
6002 5943
6003(defvar ange-ftp-bs2000-posix-hook-installed nil)
6004
6005(defun ange-ftp-add-bs2000-posix-host (host) 5944(defun ange-ftp-add-bs2000-posix-host (host)
6006 "Mark HOST as the name of a machine running BS2000 with POSIX subsystem." 5945 "Mark HOST as the name of a machine running BS2000 with POSIX subsystem."
6007 (interactive 5946 (interactive
@@ -6015,9 +5954,7 @@ Other orders of $ and _ seem to all work just fine.")
6015 ange-ftp-bs2000-posix-host-regexp) 5954 ange-ftp-bs2000-posix-host-regexp)
6016 ange-ftp-host-cache nil)) 5955 ange-ftp-host-cache nil))
6017 ;; Install CD hook to cd to posix on connecting: 5956 ;; Install CD hook to cd to posix on connecting:
6018 (and (not ange-ftp-bs2000-posix-hook-installed) 5957 (add-hook 'ange-ftp-process-startup-hook 'ange-ftp-bs2000-cd-to-posix)
6019 (add-hook 'ange-ftp-process-startup-hook 'ange-ftp-bs2000-cd-to-posix)
6020 (setq ange-ftp-bs2000-posix-hook-installed t))
6021 host) 5958 host)
6022 5959
6023(defconst ange-ftp-bs2000-filename-regexp 5960(defconst ange-ftp-bs2000-filename-regexp
@@ -6039,7 +5976,7 @@ Other orders of $ and _ seem to all work just fine.")
6039;; Extract the next filename from a BS2000 dired-like listing. 5976;; Extract the next filename from a BS2000 dired-like listing.
6040(defun ange-ftp-parse-bs2000-filename () 5977(defun ange-ftp-parse-bs2000-filename ()
6041 (if (re-search-forward ange-ftp-bs2000-filename-regexp nil t) 5978 (if (re-search-forward ange-ftp-bs2000-filename-regexp nil t)
6042 (buffer-substring (match-beginning 2) (match-end 2)))) 5979 (match-string 2)))
6043 5980
6044;; Parse the current buffer which is assumed to be in (some) BS2000 FTP dir 5981;; Parse the current buffer which is assumed to be in (some) BS2000 FTP dir
6045;; format, and return a hashtable as the result. 5982;; format, and return a hashtable as the result.
@@ -6050,7 +5987,7 @@ Other orders of $ and _ seem to all work just fine.")
6050 ;; get current pubset 5987 ;; get current pubset
6051 (goto-char (point-min)) 5988 (goto-char (point-min))
6052 (if (re-search-forward ange-ftp-bs2000-filename-pubset-regexp nil t) 5989 (if (re-search-forward ange-ftp-bs2000-filename-pubset-regexp nil t)
6053 (setq pubset (buffer-substring (match-beginning 0) (match-end 0)))) 5990 (setq pubset (match-string 0)))
6054 ;; add files to hashtable 5991 ;; add files to hashtable
6055 (goto-char (point-min)) 5992 (goto-char (point-min))
6056 (save-match-data 5993 (save-match-data
@@ -6065,25 +6002,24 @@ Other orders of $ and _ seem to all work just fine.")
6065 ange-ftp-bs2000-additional-pubsets)) 6002 ange-ftp-bs2000-additional-pubsets))
6066 tbl)) 6003 tbl))
6067 6004
6068(or (assq 'bs2000 ange-ftp-parse-list-func-alist) 6005(add-to-list 'ange-ftp-parse-list-func-alist
6069 (setq ange-ftp-parse-list-func-alist 6006 '(bs2000 . ange-ftp-parse-bs2000-listing))
6070 (cons '(bs2000 . ange-ftp-parse-bs2000-listing)
6071 ange-ftp-parse-list-func-alist)))
6072 6007
6073(defun ange-ftp-bs2000-cd-to-posix () 6008(defun ange-ftp-bs2000-cd-to-posix ()
6074 "cd to POSIX subsystem if the current host matches 6009 "cd to POSIX subsystem if the current host matches
6075ange-ftp-bs2000-posix-host-regexp. All BS2000 hosts with POSIX subsystem 6010`ange-ftp-bs2000-posix-host-regexp'. All BS2000 hosts with POSIX subsystem
6076MUST BE EXPLICITLY SET with ange-ftp-add-bs2000-posix-host for they cannot 6011MUST BE EXPLICITLY SET with `ange-ftp-add-bs2000-posix-host' for they cannot
6077be recognized automatically (they are all valid BS2000 hosts too)." 6012be recognized automatically (they are all valid BS2000 hosts too)."
6078 (if (and host (ange-ftp-bs2000-posix-host host)) 6013 (if (and ange-ftp-this-host (ange-ftp-bs2000-posix-host ange-ftp-this-host))
6079 (progn 6014 (progn
6080 ;; change to POSIX: 6015 ;; change to POSIX:
6081; (ange-ftp-raw-send-cmd proc "cd %POSIX") 6016; (ange-ftp-raw-send-cmd proc "cd %POSIX")
6082 (ange-ftp-cd host user "%POSIX") 6017 (ange-ftp-cd ange-ftp-this-host ange-ftp-this-user "%POSIX")
6083 ;; put new home directory in the expand-dir hashtable. 6018 ;; put new home directory in the expand-dir hashtable.
6084 ;; `host' and `user' are bound in ange-ftp-get-process. 6019 ;; `ange-ftp-this-host' and `ange-ftp-this-user' are bound in
6085 (puthash (concat host "/" user "/~") 6020 ;; ange-ftp-get-process.
6086 (car (ange-ftp-get-pwd host user)) 6021 (puthash (concat ange-ftp-this-host "/" ange-ftp-this-user "/~")
6022 (car (ange-ftp-get-pwd ange-ftp-this-host ange-ftp-this-user))
6087 ange-ftp-expand-dir-hashtable)))) 6023 ange-ftp-expand-dir-hashtable))))
6088 6024
6089;; Not available yet: 6025;; Not available yet: