diff options
| author | Stefan Monnier | 2005-09-30 21:04:56 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-09-30 21:04:56 +0000 |
| commit | 3bd1644e7567da45012a46c64321147a8afad29e (patch) | |
| tree | 5130c5b5d99f0708be6d70d6bd7e319ed6fde28f | |
| parent | c8be3cbacdca7a55e673669527bca0973d59a037 (diff) | |
| download | emacs-3bd1644e7567da45012a46c64321147a8afad29e.tar.gz emacs-3bd1644e7567da45012a46c64321147a8afad29e.zip | |
(ange-ftp-gwp-start): Use with-current-buffer.
(ange-ftp-file-directory-p): Fix the symlink case.
(ange-ftp-insert-directory): When listing a single file, get a list of
the parent buffer and extract the relevant line. Inspired from a patch by
Katsumi Yamaoka <yamaoka@jpl.org>.
(ange-ftp-file-name-sans-versions): Simplify.
| -rw-r--r-- | lisp/net/ange-ftp.el | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 152e71e64cb..9d2bf43c930 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el | |||
| @@ -1298,6 +1298,8 @@ only return the directory part of FILE." | |||
| 1298 | (setq file | 1298 | (setq file |
| 1299 | (if (file-name-absolute-p temp) | 1299 | (if (file-name-absolute-p temp) |
| 1300 | temp | 1300 | temp |
| 1301 | ;; Wouldn't `expand-file-name' be better than `concat' ? | ||
| 1302 | ;; It would fail when `a/b/..' != `a', tho. --Stef | ||
| 1301 | (concat (file-name-directory file) temp))))) | 1303 | (concat (file-name-directory file) temp))))) |
| 1302 | file) | 1304 | file) |
| 1303 | 1305 | ||
| @@ -1800,8 +1802,7 @@ good, skip, fatal, or unknown." | |||
| 1800 | (set-process-query-on-exit-flag proc nil) | 1802 | (set-process-query-on-exit-flag proc nil) |
| 1801 | (set-process-sentinel proc 'ange-ftp-gwp-sentinel) | 1803 | (set-process-sentinel proc 'ange-ftp-gwp-sentinel) |
| 1802 | (set-process-filter proc 'ange-ftp-gwp-filter) | 1804 | (set-process-filter proc 'ange-ftp-gwp-filter) |
| 1803 | (save-excursion | 1805 | (with-current-buffer (process-buffer proc) |
| 1804 | (set-buffer (process-buffer proc)) | ||
| 1805 | (goto-char (point-max)) | 1806 | (goto-char (point-max)) |
| 1806 | (set-marker (process-mark proc) (point))) | 1807 | (set-marker (process-mark proc) (point))) |
| 1807 | (setq ange-ftp-gwp-running t | 1808 | (setq ange-ftp-gwp-running t |
| @@ -2324,14 +2325,14 @@ and NOWAIT." | |||
| 2324 | ;; This works around a misfeature of some versions of netbsd ftpd | 2325 | ;; This works around a misfeature of some versions of netbsd ftpd |
| 2325 | ;; where `ls' can only take one argument: either one set of flags | 2326 | ;; where `ls' can only take one argument: either one set of flags |
| 2326 | ;; or a file/directory name. | 2327 | ;; or a file/directory name. |
| 2327 | ;; FIXME: if we're trying to `ls' a single file, this fails since we | 2328 | ;; If we're trying to `ls' a single file, this fails since we |
| 2328 | ;; can't cd to a file. We can't fix this problem here, tho, because | 2329 | ;; can't cd to a file. We can't fix this problem here, tho, because |
| 2329 | ;; at this point we don't know whether the argument is a file or | 2330 | ;; at this point we don't know whether the argument is a file or |
| 2330 | ;; a directory. Such an `ls' is only every used (apparently) from | 2331 | ;; a directory. Such an `ls' is only ever used (apparently) from |
| 2331 | ;; `insert-directory' when the `full-directory-p' argument is nil | 2332 | ;; `insert-directory' when the `full-directory-p' argument is nil |
| 2332 | ;; (which seems to only be used by dired when updating its display | 2333 | ;; (which seems to only be used by dired when updating its display |
| 2333 | ;; after operating on a set of files). We should change | 2334 | ;; after operating on a set of files). So we've changed |
| 2334 | ;; ange-ftp-insert-directory so that this case is handled by getting | 2335 | ;; `ange-ftp-insert-directory' such that in this case it gets |
| 2335 | ;; a full listing of the directory and extracting the line | 2336 | ;; a full listing of the directory and extracting the line |
| 2336 | ;; corresponding to the requested file. | 2337 | ;; corresponding to the requested file. |
| 2337 | (unless (equal cmd1 ".") | 2338 | (unless (equal cmd1 ".") |
| @@ -3174,7 +3175,7 @@ logged in as user USER and cd'd to directory DIR." | |||
| 3174 | (ange-ftp-real-file-name-directory n)))))) | 3175 | (ange-ftp-real-file-name-directory n)))))) |
| 3175 | 3176 | ||
| 3176 | (defun ange-ftp-expand-file-name (name &optional default) | 3177 | (defun ange-ftp-expand-file-name (name &optional default) |
| 3177 | "Documented as original." | 3178 | "Documented as `expand-file-name'." |
| 3178 | (save-match-data | 3179 | (save-match-data |
| 3179 | (setq default (or default default-directory)) | 3180 | (setq default (or default default-directory)) |
| 3180 | (cond ((eq (string-to-char name) ?~) | 3181 | (cond ((eq (string-to-char name) ?~) |
| @@ -3448,7 +3449,9 @@ system TYPE.") | |||
| 3448 | (let ((file-ent (ange-ftp-get-file-entry | 3449 | (let ((file-ent (ange-ftp-get-file-entry |
| 3449 | (ange-ftp-file-name-as-directory name)))) | 3450 | (ange-ftp-file-name-as-directory name)))) |
| 3450 | (if (stringp file-ent) | 3451 | (if (stringp file-ent) |
| 3451 | (file-directory-p | 3452 | ;; Calling file-directory-p doesn't work because ange-ftp |
| 3453 | ;; is temporarily disabled for this operation. | ||
| 3454 | (ange-ftp-file-directory-p | ||
| 3452 | (ange-ftp-expand-symlink file-ent | 3455 | (ange-ftp-expand-symlink file-ent |
| 3453 | (file-name-directory | 3456 | (file-name-directory |
| 3454 | (directory-file-name name)))) | 3457 | (directory-file-name name)))) |
| @@ -4476,21 +4479,41 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") | |||
| 4476 | ;; `ange-ftp-ls' handles this. | 4479 | ;; `ange-ftp-ls' handles this. |
| 4477 | 4480 | ||
| 4478 | (defun ange-ftp-insert-directory (file switches &optional wildcard full) | 4481 | (defun ange-ftp-insert-directory (file switches &optional wildcard full) |
| 4479 | (let ((parsed (ange-ftp-ftp-name (expand-file-name file))) | 4482 | (if (not (ange-ftp-ftp-name (expand-file-name file))) |
| 4480 | tem) | 4483 | (ange-ftp-real-insert-directory file switches wildcard full) |
| 4481 | (if parsed | 4484 | ;; Follow symlinks. |
| 4482 | (if (and (not wildcard) | 4485 | (let (tem) |
| 4483 | (setq tem (file-symlink-p (directory-file-name file)))) | 4486 | (while (and (not wildcard) |
| 4484 | (ange-ftp-insert-directory | 4487 | (stringp (setq tem (ange-ftp-get-file-entry |
| 4485 | (ange-ftp-expand-symlink | 4488 | (directory-file-name file))))) |
| 4486 | tem (file-name-directory (directory-file-name file))) | 4489 | (setq file |
| 4487 | switches wildcard full) | 4490 | (ange-ftp-expand-symlink |
| 4488 | (insert | 4491 | tem (file-name-directory (directory-file-name file)))))) |
| 4489 | (if wildcard | 4492 | (insert |
| 4490 | (let ((default-directory (file-name-directory file))) | 4493 | (cond |
| 4491 | (ange-ftp-ls (file-name-nondirectory file) switches nil nil t)) | 4494 | (wildcard |
| 4492 | (ange-ftp-ls file switches full)))) | 4495 | (let ((default-directory (file-name-directory file))) |
| 4493 | (ange-ftp-real-insert-directory file switches wildcard full)))) | 4496 | (ange-ftp-ls (file-name-nondirectory file) switches nil nil t))) |
| 4497 | (full | ||
| 4498 | (ange-ftp-ls file switches 'parse)) | ||
| 4499 | (t | ||
| 4500 | ;; If `full' is nil we're going to do `ls' for a single file. | ||
| 4501 | ;; Problem is that for various reasons, ange-ftp-ls needs to cd and | ||
| 4502 | ;; then do an ls of current dir, which obviously won't work if we | ||
| 4503 | ;; want to ls a file. So instead, we get a full listing of the | ||
| 4504 | ;; parent directory and extract the line corresponding to `file'. | ||
| 4505 | (when (string-match "d\\'" switches) | ||
| 4506 | ;; Remove "d" which dired added to `switches'. | ||
| 4507 | (setq switches (substring switches 0 (match-beginning 0)))) | ||
| 4508 | (let* ((dirlist (ange-ftp-ls (or (file-name-directory file) ".") | ||
| 4509 | switches nil)) | ||
| 4510 | (case-fold-search nil)) | ||
| 4511 | ;; FIXME: This presumes a particular output format, which is | ||
| 4512 | ;; basically Unix. | ||
| 4513 | (if (string-match (concat "^.+[^ ] " (regexp-quote file) | ||
| 4514 | "\\( -> .*\\)?[@/*=]?\n") dirlist) | ||
| 4515 | (match-string 0 dirlist) | ||
| 4516 | ""))))))) | ||
| 4494 | 4517 | ||
| 4495 | (defun ange-ftp-dired-uncache (dir) | 4518 | (defun ange-ftp-dired-uncache (dir) |
| 4496 | (if (ange-ftp-ftp-name (expand-file-name dir)) | 4519 | (if (ange-ftp-ftp-name (expand-file-name dir)) |
| @@ -4502,10 +4525,8 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") | |||
| 4502 | (defun ange-ftp-file-name-sans-versions (file keep-backup-version) | 4525 | (defun ange-ftp-file-name-sans-versions (file keep-backup-version) |
| 4503 | (let* ((short (ange-ftp-abbreviate-filename file)) | 4526 | (let* ((short (ange-ftp-abbreviate-filename file)) |
| 4504 | (parsed (ange-ftp-ftp-name short)) | 4527 | (parsed (ange-ftp-ftp-name short)) |
| 4505 | func) | 4528 | (func (if parsed (cdr (assq (ange-ftp-host-type (car parsed)) |
| 4506 | (if parsed | 4529 | ange-ftp-sans-version-alist))))) |
| 4507 | (setq func (cdr (assq (ange-ftp-host-type (car parsed)) | ||
| 4508 | ange-ftp-sans-version-alist)))) | ||
| 4509 | (if func (funcall func file keep-backup-version) | 4530 | (if func (funcall func file keep-backup-version) |
| 4510 | (ange-ftp-real-file-name-sans-versions file keep-backup-version)))) | 4531 | (ange-ftp-real-file-name-sans-versions file keep-backup-version)))) |
| 4511 | 4532 | ||