Search code examples
emacsidominibuffer

turn off abbrev-mode in Emacs minibuffer?


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


Solution

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