2

Is there a way to keep auto-completion enabled as a layer, but have it disabled by default in spacemacs?

For example, I want to have the auto-completion layer enabled in dotspacemacs-configuration-layers, but I want auto-completion to start disabled whenever I open up a new buffer.

Currently, whenever I open a buffer, I need to press SPC t a (which calls spacemacs/toggle-auto-completion) to disable auto-completion. I'd like this to be the other way around. I'd like for auto-completion to be disabled by default. I'd like to be able to press SPC t a to enable auto-completion.

I'm a beginner with emacs/spacemacs, so I'm not sure how I would express this, but one thought would be to call spacemacs/toggle-auto-completion-off whenever I open a new buffer. How would you write this in elisp?

1 Answer 1

3
+50

You could add spacemacs/toggle-auto-completion-off to the buffer-list-update-hook by adding

(add-hook 'buffer-list-update-hook 'spacemacs/toggle-auto-completion-off)

to your .spacemacs-file (in the dotspacemacs/user-config-section). This toggles auto completion off every time the buffer list updates, which happens when you open or close a file or buffer.

2
  • Thanks, this works well. I ended up going with something like this: (add-hook 'buffer-list-update-hook (lambda () (if (eq 'company auto-completion-front-end) (company-mode -1))))
    – illabout
    Aug 23, 2017 at 18:03
  • Can this be done only for the REPL loaded using SPC m s b ? I see that when a Haskell program requires user input and when I start typing, auto-completion freezes the entire editor. When I disable auto-completion it works. Aug 7, 2022 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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