/[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.179.2.1 by albinus, Tue Aug 20 19:33:49 2002 UTC revision 2.179.2.2 by albinus, Mon Aug 26 21:18:38 2002 UTC
# Line 330  This variable defaults to CMD.EXE on Win Line 330  This variable defaults to CMD.EXE on Win
330                (tramp-su-args              nil)                (tramp-su-args              nil)
331                (tramp-telnet-program       nil)                (tramp-telnet-program       nil)
332                (tramp-telnet-args          nil))                (tramp-telnet-args          nil))
      ("ssh1-old"  
               (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-completion-function  tramp-get-completion-ssh)  
               (tramp-rsh-program          "ssh1")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-e" "none"))  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
      ("ssh2-old"  
               (tramp-connection-function  tramp-open-connection-rsh)  
               (tramp-completion-function  tramp-get-completion-ssh)  
               (tramp-rsh-program          "ssh2")  
               (tramp-rcp-program          nil)  
               (tramp-remote-sh            "/bin/sh")  
               (tramp-rsh-args             ("-e" "none"))  
               (tramp-rcp-args             nil)  
               (tramp-rcp-keep-date-arg    nil)  
               (tramp-su-program           nil)  
               (tramp-su-args              nil)  
               (tramp-telnet-program       nil)  
               (tramp-telnet-args          nil))  
333       ("telnet"       ("telnet"
334                (tramp-connection-function  tramp-open-connection-telnet)                (tramp-connection-function  tramp-open-connection-telnet)
335                (tramp-completion-function  tramp-get-completion-telnet)                (tramp-completion-function  tramp-get-completion-telnet)
# Line 489  pair of the form (KEY VALUE).  The follo Line 463  pair of the form (KEY VALUE).  The follo
463      Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet'      Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet'
464      and `tramp-open-connection-su' are defined.  See the documentation      and `tramp-open-connection-su' are defined.  See the documentation
465      of these functions for more details.      of these functions for more details.
466       * `tramp-completion-function'
467        This specifies the function to use to complete the file name.
468        Currently, `tramp-get-completion-rsh', `tramp-get-completion-ssh'
469        and `tramp-get-completion-telnet' are defined.  See the documentation
470        of these functions for more details.
471    * `tramp-remote-sh'    * `tramp-remote-sh'
472      This specifies the Bourne shell to use on the remote host.  This      This specifies the Bourne shell to use on the remote host.  This
473      MUST be a Bourne-like shell.  It is normally not necessary to set      MUST be a Bourne-like shell.  It is normally not necessary to set
# Line 605  For Irix, no solution is known yet." Line 584  For Irix, no solution is known yet."
584    :type '(repeat    :type '(repeat
585            (cons string            (cons string
586                  (set (list (const tramp-connection-function) function)                  (set (list (const tramp-connection-function) function)
587                         (list (const tramp-completion-function)
588                               (choice (const nil) function))
589                       (list (const tramp-rsh-program)                       (list (const tramp-rsh-program)
590                             (choice (const nil) string))                             (choice (const nil) string))
591                       (list (const tramp-rcp-program)                       (list (const tramp-rcp-program)
# Line 885  Tramp.  See `tramp-file-name-structure-u Line 866  Tramp.  See `tramp-file-name-structure-u
866    
867  ;;;###autoload  ;;;###autoload
868  (defconst tramp-completion-file-name-regexp-separate  (defconst tramp-completion-file-name-regexp-separate
869    "^/\\[.*$"    "^/\\([[][^]]*\\)?$"
870    "Value for `tramp-completion-file-name-regexp' for separate remoting.    "Value for `tramp-completion-file-name-regexp' for separate remoting.
871  XEmacs uses a separate filename syntax for Tramp and EFS.  XEmacs uses a separate filename syntax for Tramp and EFS.
872  See `tramp-file-name-structure-separate' for more explanations.")  See `tramp-file-name-structure-separate' for more explanations.")
# Line 895  See `tramp-file-name-structure-separate' Line 876  See `tramp-file-name-structure-separate'
876    (if (featurep 'xemacs)    (if (featurep 'xemacs)
877        tramp-completion-file-name-regexp-separate        tramp-completion-file-name-regexp-separate
878      tramp-completion-file-name-regexp-unified)      tramp-completion-file-name-regexp-unified)
879    "*Regular expression matching incomplete file names handled by tramp    "*Regular expression matching file names handled by tramp completion.
880  method / hostname / username completion. This regexp should match incomplete  This regexp should match incomplete tramp file names only.
 tramp file names only.  
881    
882  Please note that the entry in `file-name-handler-alist' is made when  Please note that the entry in `file-name-handler-alist' is made when
883  this file (tramp.el) is loaded.  This means that this variable must be set  this file (tramp.el) is loaded.  This means that this variable must be set
# Line 1157  the visited file modtime.") Line 1137  the visited file modtime.")
1137  In the connection buffer, this variable has the value of the like-named  In the connection buffer, this variable has the value of the like-named
1138  method parameter, as specified in `tramp-methods' (which see).")  method parameter, as specified in `tramp-methods' (which see).")
1139    
1140    (defvar tramp-completion-function nil
1141      "This internal variable holds a parameter for `tramp-methods'.
1142    In the connection buffer, this variable has the value of the like-named
1143    method parameter, as specified in `tramp-methods' (which see).")
1144    
1145  (defvar tramp-remote-sh nil  (defvar tramp-remote-sh nil
1146    "This internal variable holds a parameter for `tramp-methods'.    "This internal variable holds a parameter for `tramp-methods'.
1147  In the connection buffer, this variable has the value of the like-named  In the connection buffer, this variable has the value of the like-named
# Line 1491  This variable is buffer-local in every b Line 1476  This variable is buffer-local in every b
1476          "Alist of handler functions.          "Alist of handler functions.
1477  Operations not mentioned here will be handled by the normal Emacs functions.")  Operations not mentioned here will be handled by the normal Emacs functions.")
1478    
1479  ;; Handlers for incomplete tramp file names. Until now it is just  ;; Handlers for incomplete tramp file names. For GNU Emacs just
1480  ;; `file-name-all-completions'. There might be other candidates (like  ;; `file-name-all-completions' is needed. The other ones are necessary
1481  ;; `file-name-completion', but I haven't seen the need yet.  ;; for XEmacs.
1482  (defconst tramp-completion-file-name-handler-alist  (defconst tramp-completion-file-name-handler-alist
1483    '((file-name-all-completions . tramp-completion-handle-file-name-all-completions))    '(
1484    "Alist of completion handler functions for file names matching      (file-name-directory . tramp-completion-handle-file-name-directory)
1485  `tramp-file-name-regexp'. Operations not mentioned here will be handled by      (file-name-nondirectory . tramp-completion-handle-file-name-nondirectory)
1486  `tramp-file-name-handler-alist' or the normal Emacs functions.")      (file-name-all-completions . tramp-completion-handle-file-name-all-completions)
1487        (file-name-completion . tramp-completion-handle-file-name-completion))
1488      "Alist of completion handler functions.
1489    Used for file names matching `tramp-file-name-regexp'. Operations not
1490    mentioned here will be handled by `tramp-file-name-handler-alist' or the
1491    normal Emacs functions.")
1492    
1493  ;;; Internal functions which must come first.  ;;; Internal functions which must come first.
1494    
# Line 3206  pass to the OPERATION." Line 3196  pass to the OPERATION."
3196           (inhibit-file-name-operation op))           (inhibit-file-name-operation op))
3197      (apply operation args)))      (apply operation args)))
3198    
3199    ;; This function is used from `tramp-completion-file-name-handler' functions
3200    ;; only, if `tramp-completion-mode' is true. But this cannot be checked here
3201    ;; because the check is based on a full filename, not available for all
3202    ;; basic I/O operations.
3203    (defun tramp-completion-run-real-handler (operation args)
3204      "Invoke `tramp-file-name-handler' for OPERATION.
3205    First arg specifies the OPERATION, second arg is a list of arguments to
3206    pass to the OPERATION."
3207      (let* ((op (if (eq operation 'ange-ftp-hook-function)
3208                     (car args)
3209                   operation))
3210             (inhibit-file-name-handlers
3211              (list 'tramp-completion-file-name-handler
3212                    (and (eq inhibit-file-name-operation op)
3213                         inhibit-file-name-handlers)))
3214             (inhibit-file-name-operation op))
3215        (apply operation args)))
3216    
3217  ;; Main function.  ;; Main function.
3218  ;;;###autoload  ;;;###autoload
3219  (defun tramp-file-name-handler (operation &rest args)  (defun tramp-file-name-handler (operation &rest args)
# Line 3225  Falls back to normal file name handler i Line 3233  Falls back to normal file name handler i
3233      (if fn      (if fn
3234          (catch 'tramp-forward-to-ange-ftp          (catch 'tramp-forward-to-ange-ftp
3235            (save-match-data (apply (cdr fn) args)))            (save-match-data (apply (cdr fn) args)))
3236        (tramp-run-real-handler operation args))))        (tramp-completion-run-real-handler operation args))))
3237    
3238  ;; Register in file name handler alist  ;; Register in file name handler alist
3239  ;;;###autoload  ;;;###autoload
# Line 3272  necessary anymore." Line 3280  necessary anymore."
3280  (tramp-repair-jka-compr)  (tramp-repair-jka-compr)
3281    
3282  (defun tramp-flatten-list (arg)  (defun tramp-flatten-list (arg)
3283    "Expands all lists inside ARG to a sequential list. Return (nil) if arg is nil."    "Expands all lists inside ARG to a sequential list.
3284    Return (nil) if arg is nil."
3285    (let ((car (car arg))    (let ((car (car arg))
3286          (cdr (cdr arg)))          (cdr (cdr arg)))
3287      (cond      (cond
# Line 3372  necessary anymore." Line 3381  necessary anymore."
3381      (tramp-setup-complete)      (tramp-setup-complete)
3382    (eval-after-load "complete" '(tramp-setup-complete)))    (eval-after-load "complete" '(tramp-setup-complete)))
3383    
3384    ;; Necessary because `tramp-file-name-regexp-unified' and
3385    ;; `tramp-completion-file-name-regexp-unified' aren't different.
3386    ;; In case of XEmacs it is always true.
3387    (defun tramp-completion-mode (file)
3388      "Checks whether method / user name / host name completion is active."
3389    
3390      (cond
3391       ((string-match "^/.*:.*:$" file) nil)
3392       ((string-match "^/\\([a-zA-Z0-9_-]+\\):$" file)
3393        (member (match-string 1 file) (cons "ftp" (mapcar 'car tramp-methods))))
3394       (t t)))
3395    
3396    ;; Path manipulation in case of incomplete TRAMP file names.
3397    (defun tramp-completion-handle-file-name-directory (file)
3398      "Like `file-name-directory' but aware of TRAMP files."
3399      (if (tramp-completion-mode file)
3400          "/"
3401        (tramp-completion-run-real-handler
3402         'file-name-directory (list file))))
3403    
3404    ;; Path manipulation in case of incomplete TRAMP file names.
3405    (defun tramp-completion-handle-file-name-nondirectory (file)
3406      "Like `file-name-nondirectory' but aware of TRAMP files."
3407      (substring
3408       file (length (tramp-completion-handle-file-name-directory file))))
3409    
3410  ;; Method, host name and user name completion.  ;; Method, host name and user name completion.
3411  ;; `tramp-completion-dissect-file-name' returns a list of  ;; `tramp-completion-dissect-file-name' returns a list of
# Line 3379  necessary anymore." Line 3413  necessary anymore."
3413  (defun tramp-completion-handle-file-name-all-completions (filename directory)  (defun tramp-completion-handle-file-name-all-completions (filename directory)
3414    "Like `file-name-all-completions' for incomplete tramp files."    "Like `file-name-all-completions' for incomplete tramp files."
3415    
3416    (let ;; local files    (let*
3417        ((result        ((fullname (concat directory filename))
3418          (tramp-run-real-handler 'file-name-all-completions         ;; local files
3419                                  (list filename directory)))         (result
3420            (if (tramp-completion-mode fullname)
3421                (tramp-run-real-handler
3422                 'file-name-all-completions (list filename directory))
3423              (tramp-completion-run-real-handler
3424               'file-name-all-completions (list filename directory))))
3425         ;; possible completion structures         ;; possible completion structures
3426         (v (tramp-completion-dissect-file-name         (v (tramp-completion-dissect-file-name fullname)))
            (concat directory filename))))  
3427    
3428      (while v      (while v
3429        (let* ((car (car v))        (let* ((car (car v))
# Line 3402  necessary anymore." Line 3440  necessary anymore."
3440                 (fn (tramp-get-completion-function nil m)))                 (fn (tramp-get-completion-function nil m)))
3441    
3442            ;; method dependent user / host combinations            ;; method dependent user / host combinations
3443            (if fn            (when fn
3444                (setq result (append result              (setq result (append result
3445                  (funcall fn method user host))))                (funcall fn method user host))))
3446    
3447            ;; possible methods            ;; possible methods
3448            (unless (or user host)            (unless (or user host)
# Line 3412  necessary anymore." Line 3450  necessary anymore."
3450                (tramp-get-completion-methods m))))                (tramp-get-completion-methods m))))
3451    
3452            ;; ange-ftp completions            ;; ange-ftp completions
3453            (if (tramp-ange-ftp-file-name-p nil m)            (when (tramp-ange-ftp-file-name-p nil m)
3454                (setq result (append result              (setq result (append result
3455                  (catch 'tramp-forward-to-ange-ftp                (catch 'tramp-forward-to-ange-ftp
3456                    (tramp-invoke-ange-ftp 'file-name-all-completions                  (tramp-invoke-ange-ftp 'file-name-all-completions
3457                                           filename directory)))))))                                         filename directory)))))))
3458    
3459        (setq v (delq car v))))        (setq v (delq car v))))
3460    
3461      ;;; unify list, remove nil elements      ;;; unify list, remove nil elements
3462      (setq result1 nil)      (setq result1 nil)
3463      (while result (progn      (while result
3464        (when (car result) (add-to-list 'result1 (car result)))        (let ((car (car result)))
3465        (setq result (delq (car result) result))))          (when car (add-to-list 'result1 car))
3466            (setq result (delq car result))))
3467    
3468      result1))      result1))
3469    
3470    ;; Method, host name and user name completion for a file.
3471    ;; Likely necessary for XEmacs only, therefore ange-ftp isn't handled
3472    (defun tramp-completion-handle-file-name-completion (filename directory)
3473      "Like `file-name-completion' for tramp files."
3474      (try-completion
3475       filename
3476       (mapcar (lambda (x) (cons x nil))
3477               (tramp-completion-handle-file-name-all-completions
3478                filename directory))))
3479    
3480  ;; I misuse a little bit the tramp-file-name structure in order to handle  ;; I misuse a little bit the tramp-file-name structure in order to handle
3481  ;; completion possibilities for incomplete methods / user names / host names.  ;; completion possibilities for incomplete methods / user names / host names.
3482  ;; Return value is a list of tramp-file-name structures according to possible  ;; Return value is a list of tramp-file-name structures according to possible
3483  ;; completions.  ;; completions.
3484  (defun tramp-completion-dissect-file-name (name)  (defun tramp-completion-dissect-file-name (name)
3485    "Returns a list of `tramp-file-name' structures as collected by    "Returns a list of `tramp-file-name' structures.
3486  `tramp-completion-dissect-file-name1'."  They are collected by `tramp-completion-dissect-file-name1'."
3487    
3488    (let ;; Local definitions. Maybe general definitions are better?    (let ;; Local definitions. Maybe general definitions are better?
3489        ((tramp-completion-file-name-structure-host        ((tramp-completion-file-name-structure-host
# Line 3457  necessary anymore." Line 3506  necessary anymore."
3506         tramp-completion-file-name-structure-method         tramp-completion-file-name-structure-method
3507         name))         name))
3508    
3509  ;;  (message "tramp-completion-file-name-structure-method '%s'" result)  ;  (tramp-message 10 "tramp-completion-file-name-structure-method '%s'" result)
3510    
3511      ;; check user      ;; check user
3512      (add-to-list 'result      (add-to-list 'result
3513        (tramp-completion-dissect-file-name1        (tramp-completion-dissect-file-name1
3514         tramp-completion-file-name-structure-user         tramp-completion-file-name-structure-user
3515        name))         name))
3516    
3517  ;;  (message "tramp-completion-file-name-structure-user '%s'" result)  ;  (tramp-message 10 "tramp-completion-file-name-structure-user '%s'" result)
3518    
3519      ;; check host      ;; check host
3520      (add-to-list 'result      (add-to-list 'result
3521        (tramp-completion-dissect-file-name1        (tramp-completion-dissect-file-name1
3522         tramp-completion-file-name-structure-host         tramp-completion-file-name-structure-host
3523        name))         name))
3524    
3525  ;;  (message "tramp-completion-file-name-structure-host '%s'" result)  ;  (tramp-message 10 "tramp-completion-file-name-structure-host '%s'" result)
3526    
3527      ;; check path      ;; check path
3528      (add-to-list 'result      (add-to-list 'result
3529        (tramp-completion-dissect-file-name1        (tramp-completion-dissect-file-name1
3530         tramp-file-name-structure         tramp-file-name-structure
3531        name))         name))
3532    
3533  ;;  (message "tramp-file-name-structure'%s'" result)  ;  (tramp-message 10 "tramp-completion-file-name-structure '%s'" result)
3534    
3535      (delq nil result)))      (delq nil result)))
3536    
# Line 3528  remote host and remote path name." Line 3577  remote host and remote path name."
3577           (<= (length method) (length string))           (<= (length method) (length string))
3578           (string-equal method           (string-equal method
3579                         (substring string 0 (length method)))                         (substring string 0 (length method)))
3580           (concat string (if (featurep 'xemacs) "/" ":"))))           (concat
3581              (when (featurep 'xemacs) "[")
3582              string
3583              (if (featurep 'xemacs) "/" ":"))))
3584       (add-to-list 'all-methods (unless (featurep 'xemacs) "ftp")))))       (add-to-list 'all-methods (unless (featurep 'xemacs) "ftp")))))
3585    
3586  ;; This function isn't as good as it should because necessary information is  ;; This function isn't as good as it should because necessary information is
# Line 3538  remote host and remote path name." Line 3590  remote host and remote path name."
3590  ;; whenever it has been collected, and reuse it in later sessions.  ;; whenever it has been collected, and reuse it in later sessions.
3591  ;; Shining example: .newsrc.eld  ;; Shining example: .newsrc.eld
3592  (defun tramp-get-completion-rsh (method user host)  (defun tramp-get-completion-rsh (method user host)
3593    "Returns all user/host combinations found in \"/etc/hosts.equiv\" and \"~/.rhosts\"."    "Returns all user / host combinations for rsh-like methods.
3594    Parsed files are \"/etc/hosts.equiv\" and \"~/.rhosts\"."
3595    
3596    (mapcar    (mapcar
3597     '(lambda (l)     '(lambda (l)
# Line 3555  remote host and remote path name." Line 3608  remote host and remote path name."
3608                (string-equal user                (string-equal user
3609                              (substring u 0 (length user)))))                              (substring u 0 (length user)))))
3610           (concat           (concat
3611            (if method (concat method (if (featurep 'xemacs) "/" ":")))            (when (featurep 'xemacs) "[")
3612            (if (and u user) (concat u "@"))            (when method (concat method (if (featurep 'xemacs) "/" ":")))
3613              (when (and u user) (concat u "@"))
3614            h (if (featurep 'xemacs) "]" ":")))))            h (if (featurep 'xemacs) "]" ":")))))
3615    
3616        (delq nil (append (tramp-parse-rhosts "/etc/hosts.equiv")        (delq nil (append (tramp-parse-rhosts "/etc/hosts.equiv")
3617                          (tramp-parse-rhosts "~/.rhosts")))))                          (tramp-parse-rhosts "~/.rhosts")))))
3618    
3619  (defun tramp-parse-rhosts (filename)  (defun tramp-parse-rhosts (filename)
3620    "Return a list of (user host) tuples allowed to access. Either user or host    "Return a list of (user host) tuples allowed to access.
3621  may be nil"  Either user or host may be nil"
3622    
3623    (let ((result nil))    (let (res)
3624      (if (file-readable-p filename)      (when (file-exists-p filename)
3625          (save-match-data        (with-temp-buffer
3626            (save-excursion          (insert-file-contents filename)
3627              (set-buffer (generate-new-buffer "*tramp-hosts*"))          (goto-char (point-min))
3628              (insert-file-contents filename)          (while (not (eobp))
3629              (setq buffer-file-name filename)            (add-to-list 'res (tramp-parse-rhosts-group)))))
3630              (setq default-directory (file-name-directory filename))      res))
3631              (normal-mode t)  
3632              (setq buffer-file-name nil)  ;; Taken from gnus/netrc.el
3633              (goto-char (point-min))  (eval-and-compile
3634              (while (not (eobp))    (defalias 'tramp-point-at-eol
3635                (add-to-list 'result (tramp-parse-rhosts-group)))      (if (fboundp 'point-at-eol)
3636              (kill-buffer (current-buffer)))))          'point-at-eol
3637      result))        'line-end-position)))
3638    
3639  (defun tramp-parse-rhosts-group ()  (defun tramp-parse-rhosts-group ()
3640     "Return a (user host) tuple allowed to access. Either user or host     "Return a (user host) tuple allowed to access.
3641  may be nil"  Either user or host may be nil"
3642    
3643     (let ((regexp "^\\([a-zA-Z_][a-zA-Z0-9_.-]*\\)\\([ \t]+\\([a-zA-Z_-][a-zA-Z0-9_.-]*\\)\\)?")     (let ((regexp "^\\([a-zA-Z0-9_][a-zA-Z0-9_.-]*\\)\\([ \t]+\\([a-zA-Z_-][a-zA-Z0-9_.-]*\\)\\)?")
3644           result)           result)
3645    
3646       (skip-chars-forward " \t\r\n\f")       (narrow-to-region (point) (tramp-point-at-eol))
3647       (if (re-search-forward regexp nil t)       (when (re-search-forward regexp nil t)
3648           (setq result (append (list (match-string 3) (match-string 1)))))         (setq result (append (list (match-string 3) (match-string 1)))))
3649       (skip-chars-forward "^\r\n\f")       (widen)
3650         (forward-line 1)
3651       result))       result))
3652    
3653  ;; Same comment as with `tramp-get-completion-rsh'  ;; Same comment as with `tramp-get-completion-rsh'
3654  (defun tramp-get-completion-ssh (method user host)  (defun tramp-get-completion-ssh (method user host)
3655    "Returns all user/host combinations found in \"/etc/{s}hosts.equiv\",    "Returns all user / host combinations for ssh-like methods.
3656  \"/etc/ssh_known_hosts\", \"~/.{r,s}hosts\" and \"~/.ssh/known_hosts\"."  Parsed files are \"/etc/{s}hosts.equiv\", \"/etc/ssh_known_hosts\",
3657    \"~/.{r,s}hosts\" and \"~/.ssh/known_hosts\"."
3658    
3659    (mapcar    (mapcar
3660     '(lambda (l)     '(lambda (l)
# Line 3615  may be nil" Line 3671  may be nil"
3671                (string-equal user                (string-equal user
3672                              (substring u 0 (length user)))))                              (substring u 0 (length user)))))
3673           (concat           (concat
3674            (if method (concat method (if (featurep 'xemacs) "/" ":")))            (when (featurep 'xemacs) "[")
3675            (if (and u user) (concat u "@"))            (when method (concat method (if (featurep 'xemacs) "/" ":")))
3676              (when (and u user) (concat u "@"))
3677            h (if (featurep 'xemacs) "]" ":")))))            h (if (featurep 'xemacs) "]" ":")))))
3678    
3679        (delq nil (append (tramp-parse-rhosts "/etc/hosts.equiv")        (delq nil (append (tramp-parse-rhosts "/etc/hosts.equiv")
# Line 3628  may be nil" Line 3685  may be nil"
3685    
3686  (defun tramp-parse-shosts (filename)  (defun tramp-parse-shosts (filename)
3687    "Return a list of (user host) tuples allowed to access.    "Return a list of (user host) tuples allowed to access.
3688  User is always nil"  User is always nil."
3689    
3690    (let ((result nil))    (let (res)
3691      (if (file-readable-p filename)      (when (file-exists-p filename)
3692          (save-match-data        (with-temp-buffer
3693            (save-excursion          (insert-file-contents filename)
3694              (set-buffer (generate-new-buffer "*tramp-hosts*"))          (goto-char (point-min))
3695              (insert-file-contents filename)          (while (not (eobp))
3696              (setq buffer-file-name filename)            (add-to-list 'res (tramp-parse-shosts-group)))))
3697              (setq default-directory (file-name-directory filename))      res))
             (normal-mode t)  
             (setq buffer-file-name nil)  
             (goto-char (point-min))  
             (while (not (eobp))  
               (add-to-list 'result (tramp-parse-shosts-group)))  
             (kill-buffer (current-buffer)))))  
     result))  
3698    
3699  (defun tramp-parse-shosts-group ()  (defun tramp-parse-shosts-group ()
3700     "Return a (user host) tuple allowed to access. User is always nil"     "Return a (user host) tuple allowed to access.
3701    User is always nil."
3702    
3703     (let ((regexp "^\\([a-zA-Z_][a-zA-Z0-9_.-]*\\)")     (let ((regexp "^\\([a-zA-Z0-9_][a-zA-Z0-9_.-]*\\)")
3704           result)           result)
3705    
3706       (skip-chars-forward " \t\r\n\f")       (narrow-to-region (point) (tramp-point-at-eol))
3707       (if (re-search-forward regexp nil t)       (when (re-search-forward regexp nil t)
3708           (setq result (list nil (match-string 1))))         (setq result (list nil (match-string 1))))
3709         (widen)
3710       (or       (or
3711        (> (skip-chars-forward ",") 0)        (> (skip-chars-forward ",") 0)
3712        (skip-chars-forward "^\r\n\f"))        (forward-line 1))
3713       result))       result))
3714    
3715  ;; Same comment as with `tramp-get-completion-rsh'  ;; Same comment as with `tramp-get-completion-rsh'
3716  (defun tramp-get-completion-telnet (method user host)  (defun tramp-get-completion-telnet (method user host)
3717    "Returns all user / host combinations found in \"/etc/hosts\".    "Returns all user / host combinations found in \"/etc/hosts\".
3718  Not implemented yet"  Not implemented yet."
3719    nil)    nil)
3720    
3721  ;;; Internal Functions:  ;;; Internal Functions:

Legend:
Removed from v.2.179.2.1  
changed lines
  Added in v.2.179.2.2

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