Function: tramp-remove-external-operation

tramp-remove-external-operation is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-remove-external-operation OPERATION BACKEND)

Documentation

Remove OPERATION from Tramp BACKEND as handler for OPERATION.

OPERATION must not be one of the magic operations listed in Info node (elisp) Magic File Names. BACKEND, a symbol, must be one of the Tramp backend packages like tramp-sh.

Probably introduced at or before Emacs version 31.1.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-remove-external-operation (operation backend)
  "Remove OPERATION from Tramp BACKEND as handler for OPERATION.
OPERATION must not be one of the magic operations listed in Info
node `(elisp) Magic File Names'. BACKEND, a symbol, must be one of the
Tramp backend packages like `tramp-sh'."
  ;; Remove OPERATION from BACKEND.
  (when-let* ((fnha
	       (intern-soft
		(concat (symbol-name backend) "-file-name-handler-alist")))
	      ((boundp fnha)))
    (setf (alist-get operation (symbol-value fnha) nil 'remove) nil))
  ;; Check, whether OPERATION is still used in any backend.
  (unless (seq-some
	   (lambda (item)
	     (when-let*
		 ((fnha (intern-soft (concat (symbol-name (cdr item)) "-alist")))
		  ((boundp fnha)))
	       (alist-get operation (symbol-value fnha))))
	   tramp-foreign-file-name-handler-alist)
    ;; Make Tramp unaware of OPERATION.
    (setq tramp-file-name-for-operation-external
	  (delq operation tramp-file-name-for-operation-external))
    (put #'tramp-file-name-handler
	 'operations (delq operation (get 'tramp-file-name-handler 'operations)))
    ;; Remove the advice for OPERATION.
    (advice-remove operation (concat "tramp-advice-" (symbol-name operation)))))