禁用特定命令的 ido 模式?

发布于 2024-11-25 12:00:14 字数 280 浏览 1 评论 0原文

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

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

I've been using ido-mode for a few months, with ido-everywhere turned on, and am generally pretty happy with it. There's one thing I wish I could change, though. When I type C-u M-x shell to create a new shell buffer with a specific name, ido offers me a completion list of all of my open buffers. If I choose one, a new shell is launched in that buffer and it's put into shell-mode, no matter what it contains. It's hard to imagine a useful use case for this.

Is there a way to deactivate ido-mode for the shell command only? (As well as any other similar commands I may stumble across in the future, of course.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖凝香 2024-12-02 12:00:14

呵呵,事实证明,无论您是否启用了 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))

对于任何其他你不想要的命令,可以通过在 .emacs 中添加一个新表达式来自定义缓冲区选择的 ido-everywhere

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

Heh, it turns out you'll get the same completion choices whether or not you have ido-everywhere enabled.

There's no built-in way to do what you want. ido-mode only provides hooks for you to be able to override whether or not the find-file behavior is taken over by ido or not. The read-buffer is currently always overridden by ido-everywhere.

Luckily, a little Emacs lisp can get what you want:

(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))

And for any other command you don't want following ido-everywhere for buffer selection can be customized by simply adding a new expression to your .emacs:

(put 'other-command-i-want-untouched 'ido 'ignore)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文