diff options
| author | Michael Albinus | 2009-11-29 20:19:48 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-11-29 20:19:48 +0000 |
| commit | 61eef560b9308934f10a6bb2decef44062b1aa45 (patch) | |
| tree | 54101bd624eacc8b5b3d3e944d60f34870bbdc4e /lisp/eshell | |
| parent | e7b538cd65e8bb299c6915231a8f5752ee1f15e1 (diff) | |
| download | emacs-61eef560b9308934f10a6bb2decef44062b1aa45.tar.gz emacs-61eef560b9308934f10a6bb2decef44062b1aa45.zip | |
* eshell/esh-util.el (top): Require also Tramp when compiling.
(eshell-directory-files-and-attributes): Check for FTP remote
connection.
(eshell-parse-ange-ls): Let-bind `ange-ftp-name-format',
`ange-ftp-ftp-name-arg', `ange-ftp-ftp-name-res'.
(eshell-file-attributes): Handle ".". Return `entry'.
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/esh-util.el | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 37802a412b5..c5e5bba18ff 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el | |||
| @@ -613,20 +613,14 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. | |||
| 613 | 613 | ||
| 614 | (defun eshell-directory-files-and-attributes (dir &optional full match nosort id-format) | 614 | (defun eshell-directory-files-and-attributes (dir &optional full match nosort id-format) |
| 615 | "Make sure to use the handler for `directory-file-and-attributes'." | 615 | "Make sure to use the handler for `directory-file-and-attributes'." |
| 616 | (let* ((dir (expand-file-name dir)) | 616 | (let* ((dir (expand-file-name dir))) |
| 617 | (dfh (find-file-name-handler dir 'directory-files))) | 617 | (if (string-equal (file-remote-p dir 'method) "ftp") |
| 618 | (if (not dfh) | 618 | (let ((files (directory-files dir full match nosort))) |
| 619 | (directory-files-and-attributes dir full match nosort id-format) | 619 | (mapcar |
| 620 | (let ((files (funcall dfh 'directory-files dir full match nosort)) | 620 | (lambda (file) |
| 621 | (fah (find-file-name-handler dir 'file-attributes))) | 621 | (cons file (eshell-file-attributes (expand-file-name file dir)))) |
| 622 | (mapcar | 622 | files)) |
| 623 | (function | 623 | (directory-files-and-attributes dir full match nosort id-format)))) |
| 624 | (lambda (file) | ||
| 625 | (cons file (if fah | ||
| 626 | (eshell-file-attributes | ||
| 627 | (expand-file-name file dir)) | ||
| 628 | (file-attributes (expand-file-name file dir)))))) | ||
| 629 | files))))) | ||
| 630 | 624 | ||
| 631 | (defun eshell-current-ange-uids () | 625 | (defun eshell-current-ange-uids () |
| 632 | (if (string-match "/\\([^@]+\\)@\\([^:]+\\):" default-directory) | 626 | (if (string-match "/\\([^@]+\\)@\\([^:]+\\):" default-directory) |
| @@ -643,10 +637,23 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. | |||
| 643 | (autoload 'parse-time-string "parse-time")) | 637 | (autoload 'parse-time-string "parse-time")) |
| 644 | 638 | ||
| 645 | (eval-when-compile | 639 | (eval-when-compile |
| 646 | (require 'ange-ftp nil t)) | 640 | (require 'ange-ftp nil t) |
| 641 | (require 'tramp nil t)) | ||
| 647 | 642 | ||
| 648 | (defun eshell-parse-ange-ls (dir) | 643 | (defun eshell-parse-ange-ls (dir) |
| 649 | (let (entry) | 644 | (let ((ange-ftp-name-format |
| 645 | (list (nth 0 tramp-file-name-structure) | ||
| 646 | (nth 3 tramp-file-name-structure) | ||
| 647 | (nth 2 tramp-file-name-structure) | ||
| 648 | (nth 4 tramp-file-name-structure))) | ||
| 649 | ;; ange-ftp uses `ange-ftp-ftp-name-arg' and `ange-ftp-ftp-name-res' | ||
| 650 | ;; for optimization in `ange-ftp-ftp-name'. If Tramp wasn't active, | ||
| 651 | ;; there could be incorrect values from previous calls in case the | ||
| 652 | ;; "ftp" method is used in the Tramp file name. So we unset | ||
| 653 | ;; those values. | ||
| 654 | (ange-ftp-ftp-name-arg "") | ||
| 655 | (ange-ftp-ftp-name-res nil) | ||
| 656 | entry) | ||
| 650 | (with-temp-buffer | 657 | (with-temp-buffer |
| 651 | (insert (ange-ftp-ls dir "-la" nil)) | 658 | (insert (ange-ftp-ls dir "-la" nil)) |
| 652 | (goto-char (point-min)) | 659 | (goto-char (point-min)) |
| @@ -701,6 +708,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. | |||
| 701 | (if (string-equal (file-remote-p file 'method) "ftp") | 708 | (if (string-equal (file-remote-p file 'method) "ftp") |
| 702 | (let ((base (file-name-nondirectory file)) | 709 | (let ((base (file-name-nondirectory file)) |
| 703 | (dir (file-name-directory file))) | 710 | (dir (file-name-directory file))) |
| 711 | (if (string-equal "" base) (setq base ".")) | ||
| 704 | (if (boundp 'ange-cache) | 712 | (if (boundp 'ange-cache) |
| 705 | (setq entry (cdr (assoc base (cdr (assoc dir ange-cache)))))) | 713 | (setq entry (cdr (assoc base (cdr (assoc dir ange-cache)))))) |
| 706 | (unless entry | 714 | (unless entry |
| @@ -713,7 +721,8 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. | |||
| 713 | (let ((fentry (assoc base (cdr entry)))) | 721 | (let ((fentry (assoc base (cdr entry)))) |
| 714 | (if fentry | 722 | (if fentry |
| 715 | (setq entry (cdr fentry)) | 723 | (setq entry (cdr fentry)) |
| 716 | (setq entry nil)))))) | 724 | (setq entry nil))))) |
| 725 | entry) | ||
| 717 | (file-attributes file)))) | 726 | (file-attributes file)))) |
| 718 | 727 | ||
| 719 | (defalias 'eshell-copy-tree 'copy-tree) | 728 | (defalias 'eshell-copy-tree 'copy-tree) |