2

I use abbrev-mode, smex, and ido-mode. How do I turn off abbrev-mode in the minibuffer for when I smex a command?

incandescentman
  • 6,168
  • 3
  • 46
  • 86

1 Answers1

1

This piece of code disables abbrev when you enter the minibuffer, then enables it again when you leave it.

(defun conditionally-disable-abbrev ()
  ""
  (if (string-match "smex-" (format "%s" this-command))
      (abbrev-mode -1)))

(add-hook 'minibuffer-setup-hook 'conditionally-disable-abbrev)
(add-hook 'minibuffer-exit-hook (lambda () (abbrev-mode 1)))

Added the fix by juanleon.

Malabarba
  • 4,473
  • 2
  • 30
  • 49
  • 1
    Mmmm, a lambda is getting in your way. You can fix that by changing the `if` line in that function to `(if (string-match "smex-" (format "%s" this-command))`. – juanleon Jul 10 '13 at 08:07
  • Great! And how do I turn off abbrev-mode for ido-mode? When I try to save a file, for instance, it's still expanding my abbrevs in the filenames. – incandescentman Jul 17 '13 at 05:10
  • Same logic, just replace smex with ido. You can also just remove the if line and have it always disabled in the minibuffer. – Malabarba Jul 17 '13 at 07:03