Using Web mode if I type <div> and wait 0.2s later (company-idle-delay) I get a menu with every possible HTML tag I might want to use after that. It's pretty useless. If I am editing inline javascript and type console.log( it gives me a bunch of HTML tags as suggestions. If I open a string like console.log(' it offers every possible word I might want to use in that string. Even more useless.

None of this should be happening because I've customized company-mode so that company-minimum-prefix-length is 3.

I eventually traced this to the HTML layer in .emacs.d/layers/+lang/html/func.el which silently changes the customized global setting for company-minimum-prefix-length and sets it to a buffer-local value of 0:

 (defun spacemacs//company-web-minimum-prefix-length ()
    "Set company minimum prefix length to 0 for the current buffer only."
    (set (make-local-variable 'company-minimum-prefix-length) 0))

This is based on this bug: https://github.com/osv/company-web/issues/4

I've tried to fix this by adding a hook to my dotspacemacs/user-config to kill-local-variable 'company-minimum-prefix-length or setq it to something reasonable, but it doesn't work. Presumably that's because the layer makes it buffer-local and sets it in its own web-mode hook.

I can fix this by just editing the .emacs.d/layers/+lang/html/func.el file, but that seems like the wrong way to do it. That file could be overwritten by a new spacemacs update. The correct way to handle it seems like it would be to change something in my config file, but I don't know what the right "spacemacs" best practice is for things like this.

So, is there a correct spacemacs best practice to override things like a buffer-local variable defined for a layer?

Your Answer

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

Browse other questions tagged or ask your own question.