繁体   English   中英

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

[英]Emacs: disable Ido completion in Tramp mode

我经常使用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 ,没有帮助。

如果再次输入Cx Cf ,则暂时禁用ido-find并回退到默认的find-file。

有关更多信息,请使用Ch f ido-find-file RET

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

暂无
暂无

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

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