Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't obey company-minimum-prefix-length #18

Open
Stebalien opened this issue Sep 7, 2016 · 9 comments
Open

Doesn't obey company-minimum-prefix-length #18

Stebalien opened this issue Sep 7, 2016 · 9 comments

Comments

@Stebalien
Copy link

I reported this to at company-mode/company-mode#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.

@brabalan
Copy link

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.

@fredRos
Copy link

fredRos commented Aug 10, 2017

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 company-mode/company-mode#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?

@ntor
Copy link

ntor commented Aug 31, 2017

I have the very same problem and would be grateful for any help.

@JunnanZ
Copy link

JunnanZ commented Sep 26, 2017

I have the same issue

@Shourai
Copy link

Shourai commented Oct 12, 2017

@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.

@fredRos
Copy link

fredRos commented Nov 22, 2017

Apparently the problem is with auctex itself syl20bnr/spacemacs#9388 (comment) because it sets a local variable company-minimum-prefix-length which overrides global settings of the length.

@brabalan
Copy link

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))))

@tsdh
Copy link

tsdh commented Nov 23, 2017

@alexeyr
Copy link
Owner

alexeyr commented Feb 27, 2018

Does the combination of #24 (thanks, @brabalan) and AUCTeX 12.1 fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants