Function: tramp-completion-dissect-file-name

tramp-completion-dissect-file-name is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-completion-dissect-file-name NAME)

Documentation

Return a list of tramp-file-name structures for NAME.

They are collected by tramp-completion-dissect-file-name1.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
;; I misuse a little bit the `tramp-file-name' structure in order to
;; handle completion possibilities for partial methods / user names /
;; host names.  Return value is a list of `tramp-file-name' structures
;; according to possible completions.  If "localname" is non-nil it
;; means there shouldn't be a completion anymore.

;; Expected results:

;; "/x" "/[x"
;; ["x" nil nil nil]

;; "/x:" "/[x/"         "/x:y" "/[x/y"       "/x:y:" "/[x/y]"
;; ["x" nil "" nil]     ["x" nil "y" nil]    ["x" nil "y" ""]
;; ["x" "" nil nil]     ["x" "y" nil nil]

;; "/x:y@" "/[x/y@"     "/x:y@z" "/[x/y@z"   "/x:y@z:" "/[x/y@z]"
;; ["x" "y" nil nil]    ["x" "y" "z" nil]    ["x" "y" "z" ""]
(defun tramp-completion-dissect-file-name (name)
  "Return a list of `tramp-file-name' structures for NAME.
They are collected by `tramp-completion-dissect-file-name1'."
  (let (;; "/method" "/[method"
	(tramp-completion-file-name-structure1
	 (list
	  (tramp-compat-rx
	   (regexp tramp-prefix-regexp)
	   (group (? (regexp tramp-completion-method-regexp))) eol)
	  1 nil nil nil))
	;; "/method:user" "/[method/user"
	(tramp-completion-file-name-structure2
	 (list
	  (tramp-compat-rx
	   (regexp tramp-prefix-regexp)
	   (group (regexp tramp-method-regexp))
	   (regexp tramp-postfix-method-regexp)
	   (group (? (regexp tramp-user-regexp))) eol)
	  1 2 nil nil))
	;; "/method:host" "/[method/host"
	(tramp-completion-file-name-structure3
	 (list
	  (tramp-compat-rx
	   (regexp tramp-prefix-regexp)
	   (group (regexp tramp-method-regexp))
	   (regexp tramp-postfix-method-regexp)
	   (group (? (regexp tramp-host-regexp))) eol)
	  1 nil 2 nil))
	;; "/method:[ipv6" "/[method/ipv6"
	(tramp-completion-file-name-structure4
	 (list
	  (tramp-compat-rx
	   (regexp tramp-prefix-regexp)
	   (group (regexp tramp-method-regexp))
	   (regexp tramp-postfix-method-regexp)
	   (regexp tramp-prefix-ipv6-regexp)
	   (group (? (regexp tramp-ipv6-regexp))) eol)
	  1 nil 2 nil))
	;; "/method:user@host" "/[method/user@host"
	(tramp-completion-file-name-structure5
	 (list
	  (tramp-compat-rx
	   (regexp tramp-prefix-regexp)
	   (group (regexp tramp-method-regexp))
	   (regexp tramp-postfix-method-regexp)
	   (group (regexp tramp-user-regexp))
	   (regexp tramp-postfix-user-regexp)
	   (group (? (regexp tramp-host-regexp))) eol)
	  1 2 3 nil))
	;; "/method:user@[ipv6" "/[method/user@ipv6"
	(tramp-completion-file-name-structure6
	 (list
	  (tramp-compat-rx
	   (regexp tramp-prefix-regexp)
	   (group (regexp tramp-method-regexp))
	   (regexp tramp-postfix-method-regexp)
	   (group (regexp tramp-user-regexp))
	   (regexp tramp-postfix-user-regexp)
	   (regexp tramp-prefix-ipv6-regexp)
	   (group (? (regexp tramp-ipv6-regexp))) eol)
	  1 2 3 nil)))
    (delq
     nil
     (mapcar
      (lambda (structure) (tramp-completion-dissect-file-name1 structure name))
      (list
       tramp-completion-file-name-structure1
       tramp-completion-file-name-structure2
       tramp-completion-file-name-structure3
       tramp-completion-file-name-structure4
       tramp-completion-file-name-structure5
       tramp-completion-file-name-structure6)))))