11

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?

holocronweaver
  • 1,319
  • 10
  • 22

1 Answers1

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
J David Smith
  • 2,635
  • 1
  • 16
  • 27
  • 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. –  Oct 30 '15 at 15:04