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

标签 emacs elisp tramp ido

我经常使用 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 not 扣除冒号之后的部分(远程文件路径),我不关心冒号之前的部分。我使用 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,没有帮助。

最佳答案

如果您再次输入C-x C-f,您将暂时禁用 ido-find 并回退到默认的查找文件。

了解更多信息C-h f ido-find-file RET

要在每次 ido 找到冒号时执行此操作,我想您必须为此编写自己的函数。

关于Emacs:在 TRAMP 模式下禁用 Ido 完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9665235/

相关文章:

git - 如何在 TRAMP 环境中为 Git 设置不同的作者/提交者?

emacs - emacs 中的流浪汉模式通过登录服务器(多跳 ssh)

regex - emacs:突出平衡表达式(例如 LaTeX 标签)

emacs - 让 Emacs 填充段落与类似 javadoc 的注释一起玩

emacs - 我怎样才能改进这个 Emacs lisp 功能?

windows - 适用于 Windows 的 Emacs 24.3,流浪者字节码 : Couldn't find a proper `ls' command

emacs - 从 Emacs 在 Markdown 中呈现 unicode 字符

Emacs:打开大型存储库中的任何文件

shell - emacs ansi-term 背景色

emacs - Emacs Lisp 的自然顺序排序