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

时间:2012-03-12 10:18:07

标签: 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)

当我浏览远程服务器的内容时​​,我想禁用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))))

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

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

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

我还尝试将变量ido-slow-ftp-hostsido-slow-ftp-host-regexps设置为/root@site.com#1234,但没有帮助。

0 个答案:

没有答案