Function: tramp-completion-handle-file-name-directory

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

Signature

(tramp-completion-handle-file-name-directory FILENAME)

Documentation

Like file-name-directory for partial Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-completion-handle-file-name-directory (filename)
  "Like `file-name-directory' for partial Tramp files."
  ;; We need special handling only when a method is needed.  Then we
  ;; return "/method:" or "/[method/", if "method" is a valid Tramp
  ;; method.  In the `separate' file name syntax, we return "/[" when
  ;; `filename' is "/[string" w/o a trailing method separator "/".
  (cond
   ((string-match
     (tramp-compat-rx
      (group (regexp tramp-prefix-regexp)
	     (* (regexp tramp-remote-file-name-spec-regexp)
		(regexp tramp-postfix-hop-regexp)))
      (? (regexp tramp-completion-method-regexp)) eos)
     filename)
    (match-string 1 filename))
   ((and (string-match
          (tramp-compat-rx
	   (group
	    (regexp tramp-prefix-regexp)
	    (* (regexp tramp-remote-file-name-spec-regexp)
	       (regexp tramp-postfix-hop-regexp))
            (group (regexp tramp-method-regexp))
	    (regexp tramp-postfix-method-regexp)
	    (? (regexp tramp-user-regexp)
	       (regexp tramp-postfix-user-regexp)))
	   (? (| (regexp tramp-host-regexp)
                 (: (regexp tramp-prefix-ipv6-regexp)
		    (? (regexp tramp-ipv6-regexp)
		       (? (regexp tramp-postfix-ipv6-regexp))))))
	   eos)
          filename)
         ;; Is it a valid method?
	 (or (tramp-string-empty-or-nil-p (match-string 2 filename))
             (assoc (match-string 2 filename) tramp-methods)))
    (match-string 1 filename))
   (t (tramp-run-real-handler #'file-name-directory (list filename)))))