The smartparens minor mode is quite annoying to me, so I want to have it disabled on default. However, I don't want to uninstall it, in case I need it someday.

Can I disable a minor mode without uninstalling it?

  • 6
    Why is it enabled in the first place? Are you using an Emacs configuration that's not your own? – wasamasa Feb 11 '17 at 15:05
  • Put this in your init file after smartparens is loaded (and after whatever is turning it on turns it on): (smartparens-mode -1). But it's better to not turn it on in the first place, so look for where that's happening. – Drew Feb 11 '17 at 16:10
  • @wasamasa I forgot to say that I'm using Spacemacs. Question tag edited. My bad. – nalzok Feb 11 '17 at 17:30
  • 1
    @SunQingyao in the case of smartparens it won't be uninstalled because it is a dependency of other packages like evil-lisp-state package, but you will lose the Spacemacs configuration for smartparens. Let me find a solution for you. – syl20bnr Feb 12 '17 at 2:03
  • 1
    I added and edited an answer which explains how I came with the solution, I hope it will help. – syl20bnr Feb 12 '17 at 2:17

First, to know what Spacemacs configures about smartparens you can SPC h SPC and type smartparens, you'll get a list of all the places where smartparens is configured, choose the candidate smartparens (owner: spacemacs-editing layer) to go to the code configuring the package. In the code you can see that in the :init section of use-package we setup some hooks.

Spacemacs enables an hidden feature of use-package which allows to define hooks for :init and :config blocks.

So you can add a :post-init use-package hook in your dotspacemacs/user-init function whose job is to remove the hooks:

(spacemacs|use-package-add-hook smartparens
  (remove-hook 'prog-mode-hook 'smartparens-mode)
  (remove-hook 'comint-mode-hook 'smartparens-mode)
  (remove-hook 'minibuffer-setup-hook
  • It works like magic, thank you! However, to encourage potential answers, please let me wait for a while before I accept this answer. – nalzok Feb 12 '17 at 2:45
  • Also, do you know how to eagerly load a package when Emacs starts up? Please see my comment to the other answer for the background. – nalzok Feb 12 '17 at 3:20
  • 1
    You can explicitly require it in your dotspacemacs/user-config function. – syl20bnr Feb 15 '17 at 13:30

There is another approach besides the ones mentioned in the comments. All of these choices expand the configurability of Emacs. You may want to look into Shingo Fukuyama's package, manage-minor-mode, which is also on MELPA.

Can I disable a minor mode without uninstalling it?

Yes. With M-x manage-minor-mode, you can toggle any selectively and temporarily. How selective and how temporary is up for your exploration, but this is an option to consider. I use it for seeing the list of currently active minor modes. I'd think would have had a feature like this.

  • How can I installed a package locally? MELPA does have a package called manage-minor-mode, but adding manage-minor-mode to dotspacemacs-configuration-layers gave me an - Unknown layer manage-minor-mode declared in dotfile. warning. – nalzok Feb 12 '17 at 1:34
  • OK, I've installed it now. However, manage-minor-mode is lazily loaded, making it incapable of doing anything until I explicitly load it with M-x manage-minor-mode. How to make it automatically loads when Emacs starts up? – nalzok Feb 12 '17 at 2:35
  • 1
    Just (require 'manage-minor-mode) before using it ;-) – syl20bnr Feb 13 '17 at 0:38

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.