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

Are company-capf and company-dabbrev meant to be mutually exclusive? #342

Closed
Alexander-Miller opened this issue Apr 26, 2015 · 6 comments
Closed

Comments

@Alexander-Miller
Copy link

Here's an example of what I mean:

  • start emacs via emacs -q
  • load company package (I use this script)
  • switch to scratch buffer and enable company mode
  • execute (setq company-backends '(company-capf company-dabbrev))
  • capf backend will now work as intended, emacs' functions are properly completed
  • dabbrev backend however will not, trying to company-complete on prefix foo when I have previously entered foobar will have company say that no matches were found
  • calling dabbrev-expand works correctly
  • now execute (setq company-backends '(company-dabbrev company-capf))
  • The situation is reversed, dabbrev backend gives correct candidates, capf backend finds none for prefixes where it should

It seems whichever backend comes first will block its successors. I don't know if other backends are also affected, so far I've only tried these two.

This behaviour would mean that for exmaple in emacs-lisp-mode I can find no completions for (load-file "~/foo[POINT]") because company-files is preceded by company-capf.

For now I've managed to get the desired behaviour through the silly workaround of stuffing everything into a single backend:

(setq-default company-backends '((company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-dabbrev-code company-gtags company-etags company-keywords company-oddmuse company-files company-capf company-dabbrev)))

Other than the completions popup always being full with dabbrev candidates I've yet to encounter any serious drawbacks.

At any rate I would like some clarifcation reguarding above behaviour - is it a bug, working as intended or a problem on my side?

I'm running emacs 24.5.1 and company version 0.9.0-cvs.

@dgutov
Copy link
Member

dgutov commented Apr 26, 2015

Yup. Have you read the company-backends docstring?

There was also a couple issues opened on this tracker with the same question.

calling dabbrev-expand works correctly

You can also call M-x company-dabbrev, or use backend grouping, like described in the docstring.

@dgutov
Copy link
Member

dgutov commented Apr 26, 2015

As for why, here's a short answer: false positives.

@Alexander-Miller
Copy link
Author

Well now I feel stupid. I thought I did read the doc and read the last couple of issues, but now that you mention it the explanation is staring me right in the face :/

At any rate the issue is resolved now.

@dgutov
Copy link
Member

dgutov commented Apr 26, 2015

Don't, since it's a recurring question, obviously that isn't documented clearly enough (contributions welcome there, by the way).

The situation with company-files is suboptimal (and similar to company-yasnippet), complicated also by the fact that certain major modes, like Eshell, include file completion in their completion-at-point-functions.

@Alexander-Miller
Copy link
Author

I'm not sure if you want a complete emacs and elisp newbie like me writing documentation for you. Maybe I'll see what I can do when my bachelor is done and I have some more time. Minor stuff like this is how people get into open source in the first place, is it not?

BTW, remember my other issue? I've gotten around to making a bug report now, though there's been no answer so far.

@dgutov
Copy link
Member

dgutov commented Apr 26, 2015

I'm not sure if you want a complete emacs and elisp newbie like me writing documentation for you.

We'll discuss the first results. And I can edit it later in any case.

Minor stuff like this is how people get into open source in the first place, is it not?

They do. :)

I've gotten around to making a bug report now, though there's been no answer so far.

Thank you. I've seen it, but it may take some time until I or someone else (probably Stefan) look into it.

ziguzagu added a commit to ziguzagu/dotfiles that referenced this issue Dec 15, 2020
Just adding `comapny-dabbrev` to company-backends hasn't been worked,
because of company-capf. See below issue.

company-mode/company-mode#342

So I add an another keybind for company-dabbrev like it used to be.
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

2 participants