Function: tramp-sh-handle-file-name-all-completions

tramp-sh-handle-file-name-all-completions is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-sh-handle-file-name-all-completions FILENAME DIRECTORY)

Documentation

Like file-name-all-completions for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
;; This function should return "foo/" for directories and "bar" for
;; files.
(defun tramp-sh-handle-file-name-all-completions (filename directory)
  "Like `file-name-all-completions' for Tramp files."
  (tramp-skeleton-file-name-all-completions filename directory
    (with-parsed-tramp-file-name (expand-file-name directory) nil
      (when (and (not (string-search "/" filename))
		 (tramp-connectable-p v))
	(unless (string-search "/" filename)
	  (all-completions
	   filename
	   (with-tramp-file-property v localname "file-name-all-completions"
	     (let (result)
	       ;; Get a list of directories and files, including
	       ;; reliably tagging the directories with a trailing "/".
	       ;; Because I rock.  --daniel@danann.net
	       (if (tramp-get-remote-perl v)
		   (tramp-maybe-send-script
		    v tramp-perl-file-name-all-completions
		    "tramp_perl_file_name_all_completions")
		 (tramp-maybe-send-script
		  v tramp-shell-file-name-all-completions
		  "tramp_shell_file_name_all_completions"))

	       (dolist
		   (elt
		    (tramp-send-command-and-read
		     v (format
			"%s %s"
			(if (tramp-get-remote-perl v)
			    "tramp_perl_file_name_all_completions"
			  "tramp_shell_file_name_all_completions")
			(tramp-shell-quote-argument localname))
		     'noerror)
		    result)
		 ;; Don't cache "." and "..".
		 (when (string-match-p
			directory-files-no-dot-files-regexp
			(file-name-nondirectory (car elt)))
		   (tramp-set-file-property v (car elt) "file-exists-p" (nth 1 elt))
		   (tramp-set-file-property v (car elt) "file-readable-p" (nth 2 elt))
		   (tramp-set-file-property v (car elt) "file-directory-p" (nth 3 elt))
		   (tramp-set-file-property v (car elt) "file-executable-p" (nth 4 elt)))

		 (push
		  (concat
		   (file-name-nondirectory (car elt)) (and (nth 3 elt) "/"))
		  result))))))))))