我经常使用ido自动完成和tramp通过ssh访问远程服务器.我的.emacs包括以下几行:
(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尝试重新连接,询问我密码等等。这种行为是不可取的。
Emacs版本- 24.0.94.1
编辑(20.03.12):与Ido作者联系后,我尝试将ido-file-name-all-completions-1更改为:
(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))))没有成功。然后我将regex改为
"\\`/[^/]+[:@]"它起了作用- Ido被禁用了,当小型缓冲器中包含了这种匹配。但是,由于Ido看不到远程服务器上的文件,所以每次我输入文件时,它都会调用ido-make-merged-file-list来搜索其他目录中的文件。这使得在远程服务器上使用Ido更加痛苦。
我还尝试将变量ido-slow-ftp-hosts和ido-slow-ftp-host-regexps设置为/root@site.com#1234,但没有帮助。
发布于 2012-03-13 09:56:43
如果再次输入C-x C-f,则暂时禁用ido-find,然后返回到默认的find-文件。
有关更多信息,C-h f ido-find-file RET
要做到这一点,每次我做找到一个冒号,我想你必须写你自己的函数。
https://stackoverflow.com/questions/9665235
复制相似问题