company-auctex
company-auctex copied to clipboard
Doesn't obey `company-minimum-prefix-length`
I reported this to at https://github.com/company-mode/company-mode/issues/578 but apparently this is an issue with company-auctex. Basically, if company-minimum-prefix-length
is 2, typing \l
and then backspacing should show no completions (there's only one prefix letter). However, with the company-auctex backend enabled, it completes every latex command.
After further investigation, it turns out that this package simply ignores company-minimum-prefix-length
entirely. \l
is completed (no backspacing) even if company-minimum-prefix-length
is set to 3.
I fixed it locally this way:
(defun as/company-auctex-prefix (regexp)
"Returns the prefix for matching given REGEXP."
(and (derived-mode-p 'latex-mode)
(when (looking-back regexp)
(match-string-no-properties 1))))
(advice-add 'company-auctex-prefix :override 'as/company-auctex-prefix)
The company-auctex-prefix
should not return a pair, but just the prefix. The t
part in the pair prevents the comparison to company-minimum-prefix-length
.
I tried the fix by @brabalan but it didn't help me. I still get completion for a single character, which is annoying when typing math symbols that usually only have one character. I had posted this originally as a spacemacs problem but I'm not sure where it belongs. In a tex file, typing n
brings up the completions and using M-x company-diag
as suggested in https://github.com/company-mode/company-mode/issues/578, it tells me it uses the company-dabbrev
backend.
Emacs 25.2.2 (x86_64-pc-linux-gnu) of 2017-05-06 on lgw01-59
Company 0.9.4
company-backends: ((company-auctex-macros company-auctex-symbols company-auctex-environments :with company-yasnippet)
(company-auctex-bibs :with company-yasnippet)
(company-auctex-labels :with company-yasnippet)
(company-dabbrev-code company-gtags company-etags company-keywords :with company-yasnippet)
(company-files :with company-yasnippet)
(company-dabbrev :with company-yasnippet))
Used backend: (company-dabbrev :with company-yasnippet)
Major mode: latex-mode
Prefix: "n"
Completions:
"next"
"node"
"null"
...
Even if I type \tex
, The info is that it uses dabbvrev
.
Any ideas?
I have the very same problem and would be grateful for any help.
I have the same issue
@fredRos this is exactly what I am also experiencing.
company-minimum-prefix-length
which defaults to 3 does not get respected in latex-mode with AUCtex.
Apparently the problem is with auctex itself https://github.com/syl20bnr/spacemacs/issues/9388#issuecomment-346275072 because it sets a local variable company-minimum-prefix-length
which overrides global settings of the length.
As a workaround for the prefix length, I have this in my configuration.
(eval-after-load "latex"
'(add-hook 'LaTeX-mode-hook
(lambda ()
(setq company-minimum-prefix-length 4))))
Fixed in Git: http://git.savannah.gnu.org/cgit/auctex.git/commit/?id=b2571b6048928882903204553716b9ec19d3e15b
Does the combination of #24 (thanks, @brabalan) and AUCTeX 12.1 fix this?