/[tramp]/tramp/lisp/tramp.el
ViewVC logotype

Diff of /tramp/lisp/tramp.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.222 by kai, Sun Sep 22 13:53:01 2002 UTC revision 2.223 by albinus, Sun Sep 22 16:25:40 2002 UTC
# Line 656  See `tramp-methods' for a list of possib Line 656  See `tramp-methods' for a list of possib
656    (unless (memq system-type '(windows-nt))    (unless (memq system-type '(windows-nt))
657      '((tramp-parse-rhosts "/etc/hosts.equiv")      '((tramp-parse-rhosts "/etc/hosts.equiv")
658        (tramp-parse-rhosts "~/.rhosts")))        (tramp-parse-rhosts "~/.rhosts")))
659    "Default list of (FUNNCTION FILE) pairs to be examined for rsh methods."    "Default list of (FUNCTION FILE) pairs to be examined for rsh methods."
660  )  )
661    
662  ;; Default values for non-Unices seeked  ;; Default values for non-Unices seeked
# Line 668  See `tramp-methods' for a list of possib Line 668  See `tramp-methods' for a list of possib
668        (tramp-parse-rhosts "~/.rhosts")        (tramp-parse-rhosts "~/.rhosts")
669        (tramp-parse-rhosts "~/.shosts")        (tramp-parse-rhosts "~/.shosts")
670        (tramp-parse-shosts "~/.ssh/known_hosts")))        (tramp-parse-shosts "~/.ssh/known_hosts")))
671    "Default list of (FUNNCTION FILE) pairs to be examined for ssh methods."    "Default list of (FUNCTION FILE) pairs to be examined for ssh methods."
672  )  )
673    
674  ;; Default values for non-Unices seeked  ;; Default values for non-Unices seeked
675  (defconst tramp-completion-function-alist-telnet  (defconst tramp-completion-function-alist-telnet
676    (unless (memq system-type '(windows-nt))    (unless (memq system-type '(windows-nt))
677      '((tramp-parse-hosts "/etc/hosts")))      '((tramp-parse-hosts "/etc/hosts")))
678    "Default list of (FUNNCTION FILE) pairs to be examined for telnet methods."    "Default list of (FUNCTION FILE) pairs to be examined for telnet methods."
679  )  )
680    
681  ;; Default values for non-Unices seeked  ;; Default values for non-Unices seeked
682  (defconst tramp-completion-function-alist-su  (defconst tramp-completion-function-alist-su
683    (unless (memq system-type '(windows-nt))    (unless (memq system-type '(windows-nt))
684      '((tramp-parse-passwd "/etc/passwd")))      '((tramp-parse-passwd "/etc/passwd")))
685    "Default list of (FUNNCTION FILE) pairs to be examined for su methods."    "Default list of (FUNCTION FILE) pairs to be examined for su methods."
686    )
687    
688    ;; Default values for non-Unices seeked
689    (defconst tramp-completion-function-alist-ftp
690      (unless (memq system-type '(windows-nt))
691        '((tramp-parse-netrc "~/.netrc")))
692      "Default list of (FUNCTION FILE) pairs to be examined for ftp methods."
693  )  )
694    
695  (defcustom tramp-completion-function-alist  (defcustom tramp-completion-function-alist
# Line 708  See `tramp-methods' for a list of possib Line 715  See `tramp-methods' for a list of possib
715          (cons "krlogin"  tramp-completion-function-alist-rsh)          (cons "krlogin"  tramp-completion-function-alist-rsh)
716          (cons "plink"    tramp-completion-function-alist-ssh)          (cons "plink"    tramp-completion-function-alist-ssh)
717          (cons "pscp"     tramp-completion-function-alist-ssh)          (cons "pscp"     tramp-completion-function-alist-ssh)
718            (cons "ftp"      tramp-completion-function-alist-ftp)
719          (cons "fcp"      nil)          (cons "fcp"      nil)
720       )       )
721    "*Alist of methods for remote files.    "*Alist of methods for remote files.
# Line 720  names from FILE for completion.  The fol Line 728  names from FILE for completion.  The fol
728   * `tramp-parse-shosts' for \"ssh_known_hosts\" like files,   * `tramp-parse-shosts' for \"ssh_known_hosts\" like files,
729   * `tramp-parse-hosts'  for \"/etc/hosts\" like files, and   * `tramp-parse-hosts'  for \"/etc/hosts\" like files, and
730   * `tramp-parse-passwd' for \"/etc/passwd\" like files.   * `tramp-parse-passwd' for \"/etc/passwd\" like files.
731     * `tramp-parse-netrc ' for \".netrc\" like files.
 A FUNCTION parsing \".netrc\" file syntax doesn't exist in TRAMP. This  
 task is delegated to ange-ftp; its customization should be used instead.  
732    
733  FUNCTION can also see a customer defined function.  For more details see  FUNCTION can also see a customer defined function.  For more details see
734  the info pages."  the info pages."
# Line 934  Derived from `tramp-postfix-multi-hop-fo Line 940  Derived from `tramp-postfix-multi-hop-fo
940    :type 'regexp)    :type 'regexp)
941    
942  (defcustom tramp-user-regexp  (defcustom tramp-user-regexp
943    "[^:@/]*"    "[^:@/ \t]*"
944    "*Regexp matching user names."    "*Regexp matching user names."
945    :group 'tramp    :group 'tramp
946    :type 'regexp)    :type 'regexp)
# Line 3611  Return (nil) if arg is nil." Line 3617  Return (nil) if arg is nil."
3617    
3618    (let*    (let*
3619        ((fullname (concat directory filename))        ((fullname (concat directory filename))
        ;; prepare ange-ftp fix  
        (fix-ange-ftp-string  
         (concat tramp-ftp-method tramp-postfix-single-method-format))  
        (fix-ange-ftp (string-match (concat "^" fix-ange-ftp-string) filename))  
3620         ;; local files         ;; local files
3621         (result         (result
3622          (if (tramp-completion-mode fullname)          (if (tramp-completion-mode fullname)
# Line 3658  Return (nil) if arg is nil." Line 3660  Return (nil) if arg is nil."
3660    
3661              ;; Possible methods              ;; Possible methods
3662              (setq result              (setq result
3663                    (append result (tramp-get-completion-methods m))))                    (append result (tramp-get-completion-methods m)))))
   
           ;; Ange-ftp completions.  
           ;; Filename might have the form "ftp:xxx". Ange-ftp isn't able to  
           ;; handle the prefix "ftp:" correctly in  
           ;; `ange-ftp-file-name-all-completions'; it simply calls  
           ;;`(all-completions file (ange-ftp-generate-root-prefixes))'.  
           ;; So we must wrap around.  
           (when (tramp-ange-ftp-file-name-p nil m)  
             (setq result (append result  
               (mapcar  
                '(lambda (x) (if fix-ange-ftp (concat fix-ange-ftp-string x) x))  
                (catch 'tramp-forward-to-ange-ftp  
                  (tramp-invoke-ange-ftp  
                   'file-name-all-completions  
                   (if fix-ange-ftp  
                       (substring filename (length fix-ange-ftp-string))  
                     filename)  
                   directory)))))))  
3664    
3665        (setq v (delq car v))))        (setq v (delq car v))))
3666    
# Line 3852  PARTIAL-USER must match USER, PARTIAL-HO Line 3836  PARTIAL-USER must match USER, PARTIAL-HO
3836     (t (setq user nil     (t (setq user nil
3837              host nil)))              host nil)))
3838    
3839    (when (or user host)    (unless (zerop (+ (length user) (length host)))
3840      ;; we must remove leading "/".      ;; we must remove leading "/".
3841      (substring (tramp-make-tramp-file-name nil method user host nil) 1)))      (substring (tramp-make-tramp-file-name nil method user host nil) 1)))
3842    
3843  (defun tramp-parse-rhosts (filename)  (defun tramp-parse-rhosts (filename)
3844    "Return a list of (user host) tuples allowed to access.    "Return a list of (user host) tuples allowed to access.
3845  Either user or host may be nil"  Either user or host may be nil."
3846    
3847    (let (res)    (let (res)
3848      (when (file-exists-p filename)      (when (file-exists-p filename)
# Line 3866  Either user or host may be nil" Line 3850  Either user or host may be nil"
3850          (insert-file-contents filename)          (insert-file-contents filename)
3851          (goto-char (point-min))          (goto-char (point-min))
3852          (while (not (eobp))          (while (not (eobp))
3853            (add-to-list 'res (tramp-parse-rhosts-group)))))            (push (tramp-parse-rhosts-group) res))))
3854      res))      res))
3855    
3856  ;; Taken from gnus/netrc.el  ;; Taken from gnus/netrc.el
# Line 3878  Either user or host may be nil" Line 3862  Either user or host may be nil"
3862    
3863  (defun tramp-parse-rhosts-group ()  (defun tramp-parse-rhosts-group ()
3864     "Return a (user host) tuple allowed to access.     "Return a (user host) tuple allowed to access.
3865  Either user or host may be nil"  Either user or host may be nil."
3866    
3867     (let ((result)     (let ((result)
3868           (regexp           (regexp
# Line 3903  User is always nil." Line 3887  User is always nil."
3887          (insert-file-contents filename)          (insert-file-contents filename)
3888          (goto-char (point-min))          (goto-char (point-min))
3889          (while (not (eobp))          (while (not (eobp))
3890            (add-to-list 'res (tramp-parse-shosts-group)))))            (push (tramp-parse-shosts-group) res))))
3891      res))      res))
3892    
3893  (defun tramp-parse-shosts-group ()  (defun tramp-parse-shosts-group ()
# Line 3932  User is always nil." Line 3916  User is always nil."
3916          (insert-file-contents filename)          (insert-file-contents filename)
3917          (goto-char (point-min))          (goto-char (point-min))
3918          (while (not (eobp))          (while (not (eobp))
3919            (add-to-list 'res (tramp-parse-hosts-group)))))            (push (tramp-parse-hosts-group) res))))
3920      res))      res))
3921    
3922  (defun tramp-parse-hosts-group ()  (defun tramp-parse-hosts-group ()
# Line 3964  Host is always \"localhost\"." Line 3948  Host is always \"localhost\"."
3948            (insert-file-contents filename)            (insert-file-contents filename)
3949            (goto-char (point-min))            (goto-char (point-min))
3950            (while (not (eobp))            (while (not (eobp))
3951              (add-to-list 'res (tramp-parse-passwd-group)))))              (push (tramp-parse-passwd-group) res))))
3952        res)))        res)))
3953    
3954  (defun tramp-parse-passwd-group ()  (defun tramp-parse-passwd-group ()
3955     "Return a (user host) tuple allowed to access.     "Return a (user host) tuple allowed to access.
3956  User is always nil."  Host is always \"localhost\"."
3957    
3958     (let ((result)     (let ((result)
3959           (regexp (concat "^\\(" tramp-user-regexp "\\):")))           (regexp (concat "^\\(" tramp-user-regexp "\\):")))
# Line 3981  User is always nil." Line 3965  User is always nil."
3965       (forward-line 1)       (forward-line 1)
3966       result))       result))
3967    
3968    (defun tramp-parse-netrc (filename)
3969      "Return a list of (user host) tuples allowed to access.
3970    User may be nil."
3971    
3972      (let (res)
3973        (when (file-exists-p filename)
3974          (with-temp-buffer
3975            (insert-file-contents filename)
3976            (goto-char (point-min))
3977            (while (not (eobp))
3978              (push (tramp-parse-netrc-group) res))))
3979        res))
3980    
3981    (defun tramp-parse-netrc-group ()
3982       "Return a (user host) tuple allowed to access.
3983    User may be nil."
3984    
3985       (let ((result)
3986             (regexp
3987              (concat
3988               "^[ \t]*machine[ \t]+" "\\(" tramp-host-regexp "\\)"
3989               "\\([ \t]+login[ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
3990    
3991         (narrow-to-region (point) (tramp-point-at-eol))
3992         (when (re-search-forward regexp nil t)
3993           (setq result (list (match-string 3) (match-string 1))))
3994         (widen)
3995         (forward-line 1)
3996         result))
3997    
3998  (defun tramp-completion-handle-expand-file-name (name &optional dir)  (defun tramp-completion-handle-expand-file-name (name &optional dir)
3999    "Like `expand-file-name' for tramp files."    "Like `expand-file-name' for tramp files."
4000    (let ((fullname (concat (or dir default-directory) name)))    (let ((fullname (concat (or dir default-directory) name)))
# Line 6461  report. Line 6475  report.
6475  ;;    without ":". Hmm. Worth a bug report?  ;;    without ":". Hmm. Worth a bug report?
6476  ;; ** Acknowledge port numbers.  ;; ** Acknowledge port numbers.
6477  ;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.  ;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.
6478  ;; ** Unify `tramp-parse-{rhosts,shosts,hosts,passwd}'.  ;; ** Unify `tramp-parse-{rhosts,shosts,hosts,passwd,netrc}'.
6479  ;;    Code is nearly identical.  ;;    Code is nearly identical.
6480  ;; ** Decide whiche files to take for searching user/host names depending on  ;; ** Decide whiche files to take for searching user/host names depending on
6481  ;;    operating system (windows-nt) in `tramp-completion-function-alist'.  ;;    operating system (windows-nt) in `tramp-completion-function-alist'.

Legend:
Removed from v.2.222  
changed lines
  Added in v.2.223

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26