【问题标题】:Disable ido-mode for specific commands?禁用特定命令的 ido 模式?
【发布时间】:2011-07-21 05:32:05
【问题描述】:

我已经使用 ido-mode 几个月了,并且 ido-everywhere 已打开,而且总体上对它非常满意。不过,有一件事我希望我能改变。当我键入 C-u M-x shell 以创建具有特定名称的新 shell 缓冲区时,ido 为我提供了所有打开缓冲区的完成列表。如果我选择一个,则在该缓冲区中启动一个新的 shell 并进入 shell 模式,无论它包含什么。很难想象一个有用的用例。

有没有办法只为 shell 命令停用 ido 模式? (当然,还有我将来可能会偶然发现的任何其他类似命令。)

【问题讨论】:

  • 我知道对于某些命令,使用最后一个快捷方式两次会暂时禁用 ido(例如,对于打开文件,C-x C-f C-f 使用 minibuffer 中的经典文件打开界面)但我不知道使用M-x 命令。

标签: emacs ido


【解决方案1】:

嘿,事实证明,无论您是否启用了ido-everywhere,您都会获得相同的完成选择。

没有内置的方法可以做你想做的事。 ido-mode 仅提供挂钩让您能够覆盖 find-file 行为是否被 ido 接管。 read-buffer 当前总是ido-everywhere 覆盖。

幸运的是,一点 Emacs lisp 可以得到你想要的:

(put 'shell 'ido 'ignore)
(defadvice ido-read-buffer (around ido-read-buffer-possibly-ignore activate)
  "Check to see if use wanted to avoid using ido"
  (if (eq (get this-command 'ido) 'ignore)
      (let ((read-buffer-function nil))
        (run-hook-with-args 'ido-before-fallback-functions 'read-buffer)
        (setq ad-return-value (apply 'read-buffer (ad-get-args 0))))
    ad-do-it))

对于您不希望在ido-everywhere 之后进行缓冲区选择的任何其他命令,只需在 .emacs 中添加一个新表达式即可自定义:

(put 'other-command-i-want-untouched 'ido 'ignore)

【讨论】:

  • ...虽然这不像写的那样工作,但我后来发现。你必须说(setq ad-return-value (apply 'read-buffer (ad-get-args 0))) 而不仅仅是(apply 'read-buffer (ad-get-args 0))
  • @Sean duh,我只检查完成是否更改,我忘了实际使用它。谢谢,我已经更新了答案。
猜你喜欢
  • 2020-12-09
  • 1970-01-01
  • 2012-03-28
  • 2019-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-15
相关资源
最近更新 更多