Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable ido-mode for specific commands?

Tags:

emacs

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

like image 680
Sean Avatar asked Jul 21 '11 05:07

Sean


1 Answers

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)
like image 57
Trey Jackson Avatar answered Sep 28 '22 19:09

Trey Jackson