Emacs:在Tramp模式下禁用Ido完成

Mir*_*lov 9 emacs elisp tramp ido

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

(require 'tramp)
(setq tramp-default-method "ssh")
(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
Run Code Online (Sandbox Code Playgroud)

当我浏览远程服务器的内容时​​,我想禁用Ido完成.请注意,变量ido-enable-tramp-completion与我的问题无关.考虑一下/root@site.com#1234:/var/www/file.txt.我需要Ido 不要在冒号(远程文件路径)之后扣除部分,我不关心冒号之前的部分.我使用ssh,每次运行ido-find-file时Ido使Emacs滞后几秒钟,当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))))
Run Code Online (Sandbox Code Playgroud)

没有成功.然后我改变了正则表达式

"\\`/[^/]+[:@]"
Run Code Online (Sandbox Code Playgroud)

并且它工作 - 当迷你缓冲区包含匹配时,Ido被禁用.但是,由于Ido无法在远程服务器上看到文件,因此ido-make-merged-file-list每次输入内容时,它都会开始调用其他目录中的文件.这使得在远程服务器上使用Ido更加痛苦.

我也尝试设置变量ido-slow-ftp-hostsido-slow-ftp-host-regexps/root@site.com#1234,并没有帮助.

mat*_*thk 10

如果C-x C-f再次输入,则暂时禁用ido-find并回退到默认的find-file.

欲获得更多信息 C-h f ido-find-file RET

为了在每次ido找到冒号时这样做,我想你必须为此编写自己的函数.