Function: tramp-set-completion-function

tramp-set-completion-function is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-set-completion-function METHOD FUNCTION-LIST)

Documentation

Set the list of completion functions for METHOD.

FUNCTION-LIST is a list of entries of the form (FUNCTION FILE). The FUNCTION is intended to parse FILE according its syntax. It might be a predefined FUNCTION, or a user defined FUNCTION. For the list of predefined FUNCTIONs see tramp-completion-function-alist.

Example:

    (tramp-set-completion-function
     "ssh"
     '((tramp-parse-sconfig "/etc/ssh_config")
       (tramp-parse-sconfig "~/.ssh/config")))

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-set-completion-function (method function-list)
  "Set the list of completion functions for METHOD.
FUNCTION-LIST is a list of entries of the form (FUNCTION FILE).
The FUNCTION is intended to parse FILE according its syntax.
It might be a predefined FUNCTION, or a user defined FUNCTION.
For the list of predefined FUNCTIONs see `tramp-completion-function-alist'.

Example:

    (tramp-set-completion-function
     \"ssh\"
     \\='((tramp-parse-sconfig \"/etc/ssh_config\")
       (tramp-parse-sconfig \"~/.ssh/config\")))"
  (let ((r function-list)
	(v function-list))
    (setq tramp-completion-function-alist
	  (delete (assoc method tramp-completion-function-alist)
		  tramp-completion-function-alist))

    (while v
      ;; Remove double entries.
      (when (member (car v) (cdr v))
	(setcdr v (delete (car v) (cdr v))))
      ;; Check for function and file or registry key.
      (unless (and (functionp (nth 0 (car v)))
		   (cond
		    ;; Windows registry.
		    ((string-prefix-p "HKEY_CURRENT_USER" (nth 1 (car v)))
		     (and (memq system-type '(cygwin windows-nt))
			  (zerop
			   (tramp-call-process
			    v "reg" nil nil nil "query" (nth 1 (car v))))))
		    ;; DNS-SD service type.
		    ((string-match-p
		      tramp-dns-sd-service-regexp (nth 1 (car v))))
		    ;; Configuration file or empty string.
		    (t (file-exists-p (nth 1 (car v))))))
	(setq r (delete (car v) r)))
      (setq v (cdr v)))

    (when r
      (add-to-list 'tramp-completion-function-alist
		   (cons method r)))))