简体   繁体   English

在Emacs中,我如何确定哪个包正在加载tramp?

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

I have a strange interaction with tramp and cygwin-mount (I think: Emacs: Tab completion of file name appends an extra i:\\cygwin ). 我与tramp和cygwin-mount有一个奇怪的交互(我认为: Emacs:Tab文件名的完成附加了一个额外的i:\\ cygwin )。 Because of this, I want to disable tramp. 因此,我想禁用tramp。 I'm unable to find anything in my .emacs which is loading tramp explicitly. 我无法在明确加载tramp的.emacs中找到任何内容。 I can see "Loading tramp..." when I hit a tab in the find-file minibuffer. 当我点击查找文件迷你缓冲区中的选项卡时,我可以看到“正在加载tramp ...”。 I'd like to figure out what package is causing the loading of tramp and disable that. 我想弄清楚什么包导致了tramp的加载并禁用它。 How do I go about doing this? 我该怎么做呢? I tried searching for (require 'tramp) but couldn't find anything interesting. 我试着寻找(需要'tramp)但找不到任何有趣的东西。 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. 我能想到的唯一另一个选择是逐一评论我的.emacs中的一些,看看哪一个有效 - 但这是如此蛮力,我想要一个更聪明(更容易)的方式。

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文件格式),它将使您能够编写如下代码并将其放入.emacs文件中:

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

Which will, in brute force form, vomit a backtrace in your window and reveal the offending library. 这将以蛮力形式在你的窗口中呕吐一个回溯并揭示有问题的图书馆。

I think you'll find that tramp is turned on by default. 我想你会发现tramp默认是打开的。 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: ('Customize(regexp):'是来自emacs的提示)你会看到列出的两个变量(至少我在emacs 23中做过),类似于:

替代文字

If you set tramp-mode to 'off', save for future sessions, and restart emacs tramp should no longer be loaded. 如果将tramp-mode设置为'off',则保存以备将来的会话,并重新启动emacs tramp应该不再加载。 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. 我相信你可以在当前会话中关闭它应该允许你测试这个,但这并不总是适用于自定义变量,虽然它应该与像tramp这样的标准emacs发布的一部分。

I don't have emacs 22 installed any more, but something similar should work for that too. 我没有安装emacs 22,但类似的东西也适用于此。

I had a similar problem with tramp, when one day I found "/C:\\...\\debuglog.txt" on my system. 我和tramp有类似的问题,有一天我在我的系统上找到了“/C:\\...\\debuglog.txt”。 Because of that file, auto-complete was invoking tramp each time I entered "/". 由于该文件,每次输入“/”时自动完成都会调用tramp。 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. 由于当前的file-name-handler-alist,它正在调用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)

Instrument find-file for debugging and/or instrument your init file for debugging. 用于调试的仪器查找文件和/或检测init文件以进行调试。 Then you can step through the loading and see where the tramp stuff is loaded. 然后你可以逐步完成加载并查看tramp stuff的加载位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM