1

When using M-x``ido-find-file and typing "//" via keyboard in the minibuffer, some hook or function is triggered which starts loading the tramp package.

Which tramp function is triggered and how to get this information?
(in case there is more which gets triggered)

Note: this is my use-package definition of tramp:

(use-package tramp
    :defer t
    :config
    (message "tramp-loaded"))
3

I think the relevant things to look at are:

  • tramp-file-name-regexp which defines expressions to match file names that tramp should handle.

  • tramp-register-autoload-file-name-handlers which registers tramp to handle file names that match the specified patterns.

I haven't looked at this in detail, but I believe tramp registers handlers to complete / handle file names, so when you try to complete a path matching one of the defined expressions, tramp gets loaded.

Specifically, I think the following code in tramp.el causes the file handlers to be registered before tramp itself is loaded:

;;;###autoload
(tramp-register-autoload-file-name-handlers)
| improve this answer | |
  • Yes, it seems that tramp-completion-file-name-handler and tramp-autoload-file-name-handler trigger loading of tramp. Both are registered in file-name-handler-alist. I wonder how they got into this alist if tramp has not been loaded before ... – jue Jun 27 '17 at 18:51
  • Tramp's file handlers are registered using the autoload functionality. Search for tramp in M-x find-library RET loaddefs.el RET – phils Jun 28 '17 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.