12

Often I have many buffers open and, for whatever reason, I no longer wish to use a particular minor mode with them. Is there currently a built-in way to disable a particular minor mode for all open buffers, or does this require writing a custom elisp function?

19

This does require a custom elisp function unless the minor mode has a (global-*-mode) function attached to it.

Luckily, it is a pretty simple function:

(defun global-disable-mode (mode-fn)
  "Disable `MODE-FN' in ALL buffers."
  (interactive "a")
  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      (funcall mode-fn -1))))

To use (for example, on projectile-mode):

(global-disable-mode 'projectile-mode)

Or call it interactively:

M-x global-disable-mode RET projectile-mode
  • 1
    Seems to work! And nicely written to boot. Thank you very much. =) – holocronweaver Dec 20 '14 at 22:31
  • alternatively, if you only need this one time, you can just copy Eval the body of the function: M-S-; (dolist ....) and replace mode-fn with 'projectile-mode in this case. – Rudolf Olah Oct 30 '15 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.