Function: tramp-skeleton-file-name-all-completions

tramp-skeleton-file-name-all-completions is a macro defined in tramp.el.gz.

Signature

(tramp-skeleton-file-name-all-completions FILENAME DIRECTORY &rest BODY)

Documentation

Skeleton for tramp-*-handle-filename-all-completions.

BODY is the backend specific code.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defmacro tramp-skeleton-file-name-all-completions
    (filename directory &rest body)
  "Skeleton for `tramp-*-handle-filename-all-completions'.
BODY is the backend specific code."
  (declare (indent 2) (debug t))
  `(ignore-error file-missing
     (all-completions
      ,filename
      (when (file-directory-p ,directory)
	(seq-uniq (delq nil
         (let* ((case-fold-search read-file-name-completion-ignore-case)
                (remote-file-name-inhibit-cache
		 (tramp-suppress-remote-file-name-inhibit-cache))
		(result
		 (if (tramp-tramp-file-p ,directory)
		     (with-parsed-tramp-file-name
			 (expand-file-name ,directory) nil
		       (when (and (not (string-search "/" ,filename))
				  (tramp-connectable-p v))
			 (with-tramp-file-property
			     v localname
			     (format
			      "file-name-all-completions-%s"
			      tramp-fnac-add-trailing-slash)
			   ;; Mark directories, including symlinks to
			   ;; directories.
			   (mapcar
			    (lambda (x)
			      (let ((f (file-name-concat ,directory x)))
				(if (and tramp-fnac-add-trailing-slash
					 (not (string-suffix-p "/" x))
					 (file-directory-p f))
				    (concat x "/") x)))
			    ;; Some storage systems do not return "." and "..".
			    (seq-union
			     (seq-difference (progn ,@body) '("." ".."))
			     '("./" "../"))))))
                   ,@body)))
	   ;; Discriminate over `completion-regexp-list'.
	   (if (consp completion-regexp-list)
	       (mapcar
		(lambda (x)
		  (when (stringp x)
		    (catch 'match
		      (dolist (elt completion-regexp-list x)
			(unless (string-match-p elt x) (throw 'match nil))))))
		result)
	     result))))))))