5

When typing a number in spacemacs all kind of numbers are being suggested. I can autocomplete them with enter. I like this behaviour in the case I'm typing words (made up of letters). But I don't want this behaviour when I'm typing numbers.

Often I have to type a number at the end of a line. So for instance, when I want the number 10 but type enter in order to go to the next line, the 10 I type expands to 1001004005438142.

example of a number being suggested when typing 10

To avoid the 10 being expanded, I can type a space and after that an enter. That's the way I handle this at this moment.

However I just don't want numbers to automatically expand.

What functions or strings can I put into my .spacemacs (or init.el) to prevent numbers, and only numbers, from being suggested (and consequently being expanding when I type enter)?

2

It seems to be as simple as:

(setq company-dabbrev-char-regexp "[A-z:-]")

I got this far by studying this q&a: How can I prevent company-mode completing non-English chars?

  • I still worry a bit about the regex I used here, since I don't know if it matches every word/expression that I want to be suggested... – jajpater Sep 5 '18 at 7:57
1

When this drop-down menu for numbers completion appears, typically the mode-line would show the company backend which is causing this completion. You can remove this backend from the list 'company-backends.

E.g. if company-dabbrev is doing it,

(delete 'company-dabbrev company-backends)

Alternatively, you could prevent company from completing without your consent by setting company-idle-delay to a large number. Mine is

(setq company-idle-delay 999999)
  • Thanks for your answer but I don't want to lose company-dabbrev in its entirety, since (as far as I understand) it is responsible for autocompletion of the words previously used in the buffer. – jajpater Sep 5 '18 at 7:33
  • OK, are you sure that dabbrev backend is causing the numbers drop down appearance ? – Jeeves Sep 6 '18 at 9:54
  • Yes, it is, since, changing the company-dabbrev-char-regexp changes the drop down behaviour. – jajpater Sep 6 '18 at 14:40

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.