7

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

Mat
  • 202,337
  • 40
  • 393
  • 406
Sean
  • 29,130
  • 4
  • 80
  • 105
  • I know that for some commands, using the last shortcut twice disables temporarily ido (e.g, for opening a file, `C-x C-f C-f` uses the classic file open interface in the minibuffer) but I don't know with `M-x` commands. – Seki Jul 21 '11 at 11:02

1 Answers1

5

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)
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • 2
    ...Although this doesn't quite work as written, as I discovered later. You have to say `(setq ad-return-value (apply 'read-buffer (ad-get-args 0)))` instead of just `(apply 'read-buffer (ad-get-args 0))`. – Sean Jul 21 '11 at 23:29
  • @Sean duh, I only checked to see if the completion changed, I forgot to actually use it. Thanks, I've updated the answer. – Trey Jackson Jul 22 '11 at 02:50