In Emacs, how do I figure out which package is loading tramp?

时光毁灭记忆、已成空白 提交于 2019-12-04 12:25:01

问题


I have a strange interaction with tramp and cygwin-mount (I think: Emacs: Tab completion of file name appends an extra i:\cygwin). Because of this, I want to disable tramp. I'm unable to find anything in my .emacs which is loading tramp explicitly. I can see "Loading tramp..." when I hit a tab in the find-file minibuffer. I'd like to figure out what package is causing the loading of tramp and disable that. How do I go about doing this? I tried searching for (require 'tramp) but couldn't find anything interesting. The only other option I can think of is to comment out bits of my .emacs one-by-one and see which one works - but this is so brute-force, I'd like a cleverer (and easier) way.


回答1:


What a great question! If only because I was not aware of the function (eval-after-load file form) which will enable you to write code like the following and put it in your .emacs file:

(eval-after-load "tramp"
  '(debug))

Which will, in brute force form, vomit a backtrace in your window and reveal the offending library.




回答2:


I think you'll find that tramp is turned on by default. If you do:

M-x customize-apropos
Customize (regexp): tramp

('Customize (regexp):' is the prompt from emacs) you'll see two variables listed (at least I do in emacs 23), something like:

If you set tramp-mode to 'off', save for future sessions, and restart emacs tramp should no longer be loaded. I believe you can just turning it off in the current session should allow you to test this, but this doesn't always work with customize variables, although it should do with something like tramp that is part of the standard emacs distribution.

I don't have emacs 22 installed any more, but something similar should work for that too.




回答3:


I had a similar problem with tramp, when one day I found "/C:\...\debuglog.txt" on my system. Because of that file, auto-complete was invoking tramp each time I entered "/". And tramp was of course giving an error. auto-complete was calling

(expand-file-name ...)

which, because of the current file-name-handler-alist, was calling tramp. My solution was:

(delete-if
 (lambda (x)
   (or (eq (cdr x) 'tramp-completion-file-name-handler)
       (eq (cdr x) 'tramp-file-name-handler)))
 file-name-handler-alist)



回答4:


Instrument find-file for debugging and/or instrument your init file for debugging. Then you can step through the loading and see where the tramp stuff is loaded.



来源:https://stackoverflow.com/questions/1706157/in-emacs-how-do-i-figure-out-which-package-is-loading-tramp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!