aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ftp.el53
1 files changed, 32 insertions, 21 deletions
diff --git a/lisp/ftp.el b/lisp/ftp.el
index c7d7b7e59df..919a1d809b1 100644
--- a/lisp/ftp.el
+++ b/lisp/ftp.el
@@ -74,6 +74,7 @@
74 (substring s (match-beginning 2) (match-end 2))))) 74 (substring s (match-beginning 2) (match-end 2)))))
75 75
76 76
77;;;###autoload
77(defun ftp-find-file (host file &optional user password) 78(defun ftp-find-file (host file &optional user password)
78 "FTP to HOST to get FILE, logging in as USER with password PASSWORD. 79 "FTP to HOST to get FILE, logging in as USER with password PASSWORD.
79Interactively, HOST and FILE are specified by reading a string with 80Interactively, HOST and FILE are specified by reading a string with
@@ -87,6 +88,7 @@ USER and PASSWORD are defaulted from the values used when
87 (list nil (not (null current-prefix-arg))))) 88 (list nil (not (null current-prefix-arg)))))
88 (ftp-find-file-or-directory host file t user password)) 89 (ftp-find-file-or-directory host file t user password))
89 90
91;;;###autoload
90(defun ftp-list-directory (host file &optional user password) 92(defun ftp-list-directory (host file &optional user password)
91 "FTP to HOST to list DIRECTORY, logging in as USER with password PASSWORD. 93 "FTP to HOST to list DIRECTORY, logging in as USER with password PASSWORD.
92Interactively, HOST and FILE are specified by reading a string with 94Interactively, HOST and FILE are specified by reading a string with
@@ -143,12 +145,13 @@ we prompt for the user name and password."
143 (error "Ftp %s:%s lost" host file))))) 145 (error "Ftp %s:%s lost" host file)))))
144 146
145 147
148;;;###autoload
146(defun ftp-write-file (host file &optional user password) 149(defun ftp-write-file (host file &optional user password)
147 "FTP to HOST to write FILE, logging in as USER with password PASSWORD. 150 "FTP to HOST to write FILE, logging in as USER with password PASSWORD.
148Interactively, HOST and FILE are specified by reading a string with colon 151Interactively, HOST and FILE are specified by reading a string with colon
149separating the host from the filename. 152separating the host from the filename.
150USER and PASSWORD are defaulted from the values used when 153USER and PASSWORD are defaulted from the values used when
151 last ftping from HOST (unless password-remembering is disabled). 154 last ftping from HOST (unless `password-remembering' is disabled).
152 Supply a password of the symbol `t' to override this default 155 Supply a password of the symbol `t' to override this default
153 (interactively, this is done by giving a prefix arg)" 156 (interactively, this is done by giving a prefix arg)"
154 (interactive 157 (interactive
@@ -176,7 +179,7 @@ USER and PASSWORD are defaulted from the values used when
176 (message "Opening file %s:%s..." host file) 179 (message "Opening file %s:%s..." host file)
177 (if (ftp-command process 180 (if (ftp-command process
178 (format "send \"%s\" \"%s\"\nquit\n" tmp file) 181 (format "send \"%s\" \"%s\"\nquit\n" tmp file)
179 "150.*\n" 182 "\\(150\\|125\\).*\n"
180 "200.*\n") 183 "200.*\n")
181 (progn (forward-line 1) 184 (progn (forward-line 1)
182 (setq foo1 (current-buffer)) 185 (setq foo1 (current-buffer))
@@ -236,12 +239,18 @@ USER and PASSWORD are defaulted from the values used when
236 (let ((p 1)) 239 (let ((p 1))
237 (while (numberp p) 240 (while (numberp p)
238 (cond ;((not (bolp))) 241 (cond ;((not (bolp)))
242 ((looking-at "^[0-9]+-")
243 (while (not (re-search-forward "^[0-9]+ " nil t))
244 (save-excursion
245 (accept-process-output process)))
246 (beginning-of-line))
239 ((looking-at win) 247 ((looking-at win)
240 (goto-char (point-max)) 248 (goto-char (point-max))
241 (setq p t)) 249 (setq p t))
242 ((looking-at "^ftp> \\|^\n") 250 ((looking-at "^ftp> \\|^\n")
243 (goto-char (match-end 0))) 251 (goto-char (match-end 0)))
244 ((looking-at ignore) 252 ((looking-at ignore)
253 ;; Ignore status messages whose codes indicate no problem.
245 (forward-line 1)) 254 (forward-line 1))
246 ((not (search-forward "\n" nil t)) 255 ((not (search-forward "\n" nil t))
247 ;; the way asynchronous process-output works with (point) 256 ;; the way asynchronous process-output works with (point)
@@ -251,6 +260,9 @@ USER and PASSWORD are defaulted from the values used when
251 (accept-process-output process) 260 (accept-process-output process)
252 (error nil)) 261 (error nil))
253 (goto-char p)) 262 (goto-char p))
263 ((looking-at "^[a-z]")
264 ;; Ignore any lines that don't have error codes.
265 (forward-line 1))
254 (t 266 (t
255 (setq p nil)))) 267 (setq p nil))))
256 p)) 268 p))
@@ -275,25 +287,24 @@ USER and PASSWORD are defaulted from the values used when
275 (set-buffer (process-buffer process)) 287 (set-buffer (process-buffer process))
276 (let (msg 288 (let (msg
277 (r (if input "[0-9]+ bytes received in [0-9]+\\.[0-9]+ seconds.*$" "[0-9]+ bytes sent in [0-9]+\\.[0-9]+ seconds.*$"))) 289 (r (if input "[0-9]+ bytes received in [0-9]+\\.[0-9]+ seconds.*$" "[0-9]+ bytes sent in [0-9]+\\.[0-9]+ seconds.*$")))
278 (let ((buffer-read-only nil)) 290 (goto-char (point-max))
279 (goto-char (point-max)) 291 (search-backward "226 ")
280 (search-backward "226 ") 292 (if (looking-at r)
281 (if (looking-at r) 293 (search-backward "226 "))
282 (search-backward "226 ")) 294 (let ((p (point)))
283 (let ((p (point))) 295 (setq msg (concat (format "ftp %s %s:%s done"
284 (setq msg (concat (format "ftp %s %s:%s done" 296 (if input "read" "write")
285 (if input "read" "write") 297 ftp-host ftp-file)
286 ftp-host ftp-file) 298 (if (re-search-forward r nil t)
287 (if (re-search-forward r nil t) 299 (concat ": " (buffer-substring
288 (concat ": " (buffer-substring 300 (match-beginning 0)
289 (match-beginning 0) 301 (match-end 0)))
290 (match-end 0))) 302 "")))
291 ""))) 303 (delete-region p (point-max))
292 (delete-region p (point-max)) 304 (save-excursion
293 (save-excursion 305 (set-buffer (get-buffer-create "*ftp log*"))
294 (set-buffer (get-buffer-create "*ftp log*")) 306 (let ((buffer-read-only nil))
295 (let ((buffer-read-only nil)) 307 (insert msg ?\n))))
296 (insert msg ?\n)))))
297 ;; Note the preceding let must end here 308 ;; Note the preceding let must end here
298 ;; so it doesn't cross the (kill-buffer (current-buffer)). 309 ;; so it doesn't cross the (kill-buffer (current-buffer)).
299 (if (not input) 310 (if (not input)