Emacs:禁用Ido在Tramp模式下完成 [英] Emacs: disable Ido completion in Tramp mode

查看:181
本文介绍了Emacs:禁用Ido在Tramp模式下完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用ido进行自动完成和流氓,通过ssh访问远程服务器。我的 .emacs 包括以下行:

I often use ido for auto-completion and tramp to access remote server via ssh. My .emacs includes the following lines:

(require 'tramp)
(setq tramp-default-method "ssh")
(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)

当我浏览远程服务器的内容时​​,我想禁用Ido完成。请注意,变量 ido-enable-tramp-completion 与我的问题无关。考虑行 /root@site.com#1234:/var/www/file.txt 。我需要Ido 扣除冒号后的部分(远程文件路径),我不在意冒号前的部分。我使用ssh,Ido使Emacs每次运行 ido-find-file 时延迟几秒钟,当ssh超时结束时,Tramp尝试重新连接,请求我密码等等。这个行为是不可取的。

I want to disable Ido completion, when i'm browsing contents of remote server. Note that variable ido-enable-tramp-completion has nothing to do with my problem. Consider line /root@site.com#1234:/var/www/file.txt. I need Ido not to deduct the part after the colon (remote file path), i don't care about the part before the colon. I use ssh, and Ido makes Emacs lag for a few seconds every time i run ido-find-file, and when ssh timeout is over, Tramp tries to reconnect, asks me for a password and so on. This behavior is undesirable.

Emacs版本 - 24.0.94.1

Emacs version - 24.0.94.1

编辑(20.03.12) :与Ido作者联系后,我尝试将 ido-file-name-all-completions-1 更改为以下内容:

Edit (20.03.12): After contact with Ido author I tried to change the ido-file-name-all-completions-1 to the following:

(defun ido-file-name-all-completions-1 (dir)
  (cond
   ((ido-nonreadable-directory-p dir) '())
   ;; do not check (ido-directory-too-big-p dir) here.
   ;; Caller must have done that if necessary.

   ((and ido-enable-tramp-completion
     (or (fboundp 'tramp-completion-mode-p)
         (require 'tramp nil t))
     (string-match "\\`/[^/]+[:@]\\'" dir))
    ;; TRAMP RELATED CODE DELETED
    nil)
   (t
    (file-name-all-completions "" dir))))

没有成功。然后我将正则表达式更改为

No success. I then changed regex to

"\\`/[^/]+[:@]"

它的工作 - Ido被禁用,当minibuffer包含该匹配。但是,由于Ido无法在远程服务器上看到文件,所以每次进入某些东西时,都会开始调用 ido-make-merged-file-list 来搜索其他目录中的文件。这使得Ido在远程服务器上工作更加痛苦。

and it worked - Ido was disabled, when minibuffer contained that match. However as Ido couldn't see files on a remote server, it started calling ido-make-merged-file-list to search for files in other directories every time i enter something. This made working with Ido on remote servers even more pain.

我还尝试设置变量 ido-slow-ftp-hosts ido-slow-ftp-host-regexps /root@site.com#1234 ,didn

I also tried setting up variables ido-slow-ftp-hosts and ido-slow-ftp-host-regexps to /root@site.com#1234, didn't help.

推荐答案

如果您暂时输入 Cx Cf 禁用ido-find并返回到默认find文件。

If you enter C-x C-f again you temporally disable ido-find and fall back to the default find-file.

更多信息 Chf ido-find-file RET

为了做到这一点,每次ido发现一个冒号,我想你必须为自己编写自己的功能。

To do this every time ido found a colon, I guess you have to write your own function for that.

这篇关于Emacs:禁用Ido在Tramp模式下完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆