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

More info about how this compares to auto-complete #68

Closed
expez opened this issue Feb 26, 2014 · 31 comments
Closed

More info about how this compares to auto-complete #68

expez opened this issue Feb 26, 2014 · 31 comments

Comments

@expez
Copy link

@expez expez commented Feb 26, 2014

Hi,
it would be nice if if you provided a bit more information about why one might switch from AC to Company, or even pick Company in the first place.

Are they at feature parity? E.g. in the screenshots company is only shown listing completion candidates, but AC can also show documentation for the currently active candidate. What happens when you press F1 in company mode and how is this preferable to displaying it in a popup next to the completion candidates like AC does?

I frequently use this functionality for API discovery, I will search for whatever I'm interested in say string- and then M-n through the candidates while reviewing the documentation in the popup.

I assume you yourself used auto-complete-mode at some point. What prompted you to assume stewardship of company-mode instead of patching up any annoyances with AC?

@Silex
Copy link

@Silex Silex commented Feb 26, 2014

I'm very interested about more details from @dgutov too, but speaking for me (I switched to company-mode 3 days ago), I can say that it is MUCH simpler to get it working and to configure it. Also it always seem to work, whereas with auto-complete I often went into "it should work but doesn't" mode.

I forgot where it is but there are examples of auto-complete source vs company source and company source takes half the lines and is easy to understand.

@dgutov
Copy link
Member

@dgutov dgutov commented Feb 27, 2014

Are they at feature parity?

Roughly. Here's a quick difference list:

Company doesn't have:

  • ac-fuzzy-complete
  • ac-comphist
  • ac-stop-words
  • symbol backend property
  • a way to override candidate and selection faces per completion backend
  • a way to show documentation in a popup Now we have company-quickhelp!

Auto-Complete doesn't have:

  • company-require-match
  • company-auto-complete
  • company-show-numbers
  • company-show-location
  • flexible customization through company-frontends and company-transformers
  • company-echo-frontend :)

What happens when you press F1 in company mode

It uses pop-to-window to display the help buffer, but hides it before the next command (unless that command is scroll-other-window or scroll-other-window-down). ac-help seems to work pretty much the same.

Company doesn't have a correspondence to ac-persist-help, but we can add that, or something slightly different.

A "graphical" documentation popup might look neat (aside from eating all syntax highlighting), but it also requires a certain amount of horizontal space in the current window to the right of the completion popup menu. What if your windows are 80-100 columns wide and you're typing something at the end of a line? The popup rectangle is squished against the window border. Things should be better when AC is using pos-tip to render the documentation popup, but I haven't tried it for quite a while, and judging by the MELPA stats it's a lot less popular than Auto-Complete itself.

Writing a Company frontend that would show the doc-buffer contents using pos-tip should be relatively easy, by the way. But it'll probably have to stay a third-party package, because pos-tip is unlikely to ever be included in GNU ELPA.

What prompted you to assume stewardship of company-mode instead of patching up any annoyances with AC?

In short, less than readable code and non-responsive maintainer.

There's an annoying, still-present issue with AC that if you initiate completion in the middle of a symbol, it will insert the candidate, and also keep the part of the symbol that was already present after point.

I tried to fix it a while ago, got essentially no response, and in the process concluded I didn't really want to touch AC source code ever again. The way they've been discussing the vaporware full-rewrite a year ago gives an impression that the author doesn't like the code either (at least not anymore).

Company just has a convention whereby prefix command always returns nil in the middle of a symbol, thus never triggering completion. It's not ideal (the user might want it to behave otherwise at times), but it's a much better default. And we can work from here by adding a suffix backend command, deciding how it would figure into completions (filter the candidates, or just get replaced in the end), and handling backends that support that command differently.

I forgot where it is but there are examples of auto-complete source vs company source and company source takes half the lines and is easy to understand.

Here's a typical example:

https://github.com/company-mode/company-inf-ruby/blob/master/company-inf-ruby.el
vs
https://github.com/purcell/ac-inf-ruby/blob/master/ac-inf-ruby.el

(The functionality is pretty much the same).

@expez
Copy link
Author

@expez expez commented Feb 27, 2014

Your involvement in company-mode was actually the number one reason I wanted to take a closer look. Your name has been popping up all over Github with quality pull requests and comments. Robe is also brilliant.

Your response above is just another case in point 😄

Regarding the difference in features I never could get ac-fuzzy-complete to work, even though I tried several times. I think comphist is a nice touch, but it's not that important. It does make the completion engine feel a bit more intelligent, though, by moving candidates that are likely to be more relevant to the top of the list.

You might consider making a version of your post above available somewhere, where potential users can be made aware of the differences.

When I have some free time I'll do s/ac/company/g on my .emacs.d👍

@expez expez closed this Feb 27, 2014
@dgutov
Copy link
Member

@dgutov dgutov commented Feb 27, 2014

Thanks!

I think comphist is a nice touch, but it's not that important. It does make the completion engine feel a bit more intelligent, though, by moving candidates that are likely to be more relevant to the top of the list.

I've recently added company-sort-by-occurrence for the same purpose (you add it to company-transformers). Works fairly well, I'd say.

You might consider making a version of your post above available somewhere

I'll just link to this issue, for now. :)

@HongxuChen
Copy link

@HongxuChen HongxuChen commented Sep 25, 2014

It seems that company-mode doesn't have similar functionalities as ac-source-dictionary in auto-complete; I think it's useful when syntax/semantics completion is not available. For examples, sometimes company-cmake won't help for several variables such as CMAKE_CXX_COMPILER_ID, this is because company-cmake generates the candidates with cmake --help-variable-list, which gives the answer CMAKE_<LANG>_COMPILER_ID in this case; here <LANG> should be replaced with CXX but it simply drops this candidate.

Update: I later saw there is company-keywords, however it seems not expected to be altered.

@dgutov
Copy link
Member

@dgutov dgutov commented Sep 25, 2014

doesn't have similar functionalities as ac-source-dictionary in auto-complete; I think it's useful when syntax/semantics completion is not available

I think company-dabbrev-code, together with company-keywords, do that job well enough.

sometimes company-cmake won't help for several variables such as CMAKE_CXX_COMPILER_ID, this is because company-cmake generates the candidates with cmake --help-variable-list, which gives the answer CMAKE__COMPILER_ID in this case

This should be easy to fix. Can you describe what other substitutions should we make? Link to the official documentation, if you can.

company-keywords ... seems not expected to be altered

It isn't, but you can, if you really want to. Or write your own backend which will return a pre-saved list of words, that's really easy.

And if we're missing any (actual) keywords for any of the languages you're interested in, please report that, they will be added.

@HongxuChen
Copy link

@HongxuChen HongxuChen commented Sep 25, 2014

Thanks for your reply! As for company-cmake backends, since CMake is designed to be able to build projects with C/C++ or other languages; however I guess in practice people mainly use it for C++(maybe also C) projects as the flags and linkage issues are quite complicated there. Perhaps you can add a customizable list for these languages and replace <lang> with them accordingly. I haven't seen other cases for cmake when the candidates are dropped unexpectedly.

@redguardtoo
Copy link
Contributor

@redguardtoo redguardtoo commented Sep 26, 2014

I can help to fix the cmake issue this weekend, if you wish. create a independent issue and add steps to reproduce then assign it to me.

@dgutov
Copy link
Member

@dgutov dgutov commented Sep 30, 2014

@IvanMalison
Copy link

@IvanMalison IvanMalison commented Dec 12, 2014

@dgutov Has any progress been made/are there plans to implement the suffix functionality that you mentioned?

@dgutov
Copy link
Member

@dgutov dgutov commented Dec 12, 2014

@IvanMalison None so far/there still are.

@asmeurer
Copy link

@asmeurer asmeurer commented Mar 5, 2015

Unless I'm missing it, another huge advantage of auto-complete over company is the documentation.

@dgutov
Copy link
Member

@dgutov dgutov commented Mar 6, 2015

I guess so.

I don't know how huge it is, though. For most usage, the homepage and user option descriptions should be sufficient.

@asmeurer
Copy link

@asmeurer asmeurer commented Mar 6, 2015

Where are the user option descriptions documented?

I am trying to switch from auto-complete to company, but I am having a hard time configuring company the way I like, and the lack of docs is not helpful. I was able to find some stuff by searching M-x customize for company, but it's not enough (e.g., how to I make TAB cycle through the completions?).

So I'm not even talking about docs for developers of extensions, it's purely docs for users. The website says almost nothing and README is literally empty.

@dgutov
Copy link
Member

@dgutov dgutov commented Mar 6, 2015

The website says: M-x customize-group RET company. You can read the descriptions there.

how to I make TAB cycle through the completions?

By writing some Lisp. There no built-in option, but search the issues for instructions.

@cslux
Copy link

@cslux cslux commented Mar 6, 2015

@asmeurer

I was able to find some stuff by searching M-x customize for company, but it's not enough (e.g., how to I make TAB cycle through the completions?).

Try this.

(define-key company-active-map (kbd "TAB") 'company-complete-common-or-cycle)

and if you want cycle the other way too, all you must do is copy and paste the function
company-complete-common-or-cycle from company.el

(defun company-complete-common-or-cycle ()
  "Insert the common part of all candidates, or select the next one."
  (interactive)
  (when (company-manual-begin)
    (let ((tick (buffer-chars-modified-tick)))
      (call-interactively 'company-complete-common)
      (when (eq tick (buffer-chars-modified-tick))
        (let ((company-selection-wrap-around t))
          (call-interactively 'company-select-next))))))

and replace the company-select-next with company-select-previous. And give to function a different name like company-complete-common-or-previous-cycle. Finally bind it to a key
e.g. Shift-TAB

(define-key company-active-map (kbd "<backtab>") 'company-complete-common-or-previous-cycle)

Short, copy and paste this snippet into your dot emacs file or any other config file.

(defun company-complete-common-or-previous-cycle ()
  "Insert the common part of all candidates, or select the next one."
  (interactive)
  (when (company-manual-begin)
    (let ((tick (buffer-chars-modified-tick)))
      (call-interactively 'company-complete-common)
      (when (eq tick (buffer-chars-modified-tick))
        (let ((company-selection-wrap-around t))
          (call-interactively 'company-select-previous))))))
(define-key company-active-map (kbd "TAB") 'company-complete-common-or-cycle)
(define-key company-active-map (kbd "<backtab>") 'company-complete-common-or-previous-cycle)
@asmeurer
Copy link

@asmeurer asmeurer commented Mar 6, 2015

Thanks @luxchris. Would make sense for a negative prefix argument to cycle company-complete-common-or-cycle backwards? I'll open a new issue.

@asmeurer
Copy link

@asmeurer asmeurer commented Mar 6, 2015

@dgutov
Copy link
Member

@dgutov dgutov commented Mar 6, 2015

@luxchris Why don't you create a new wiki page with instructions?

@cslux
Copy link

@cslux cslux commented Mar 6, 2015

@dgutov
Sorry about that I didn't know it. I will create a new page at the wiki, ok?

@dgutov
Copy link
Member

@dgutov dgutov commented Mar 6, 2015

@luxchris Yes please!

@cslux
Copy link

@cslux cslux commented Mar 7, 2015

@dgutov I just tested your latest 5e107fd commit. Works like a charm! Unfortunately moving forward with TAB does not work anymore. Instead it seams like the mini-buffer documentation of the current completion candidate gets updated, however, the key C-i works.

But I prefer C-n and C-p for next and previous candidate, anyway.

My previous comment #68 is now more or less superfluous. To cycle forward or backward someone can now achieve this by defining the following key bindings.

(define-key company-active-map (kbd "C-n") (lambda () (interactive) (company-complete-common-or-cycle 1)))
(define-key company-active-map (kbd "C-p") (lambda () (interactive) (company-complete-common-or-cycle -1)))

PS.: Should I still write a wiki, at least I/we could create a page with some useful key bindings, like that ones.

Chears, Christian

@dgutov
Copy link
Member

@dgutov dgutov commented Mar 7, 2015

Unfortunately moving forward with TAB does not work anymore.

Works for me. Please file an issue with step-by-step repro, and include the beginning of company-diag output.

Should I still write a wiki, at least I/we could create a page with some useful key bindings, like that ones.

If you like. Probably not for this snippet, but anytime you want to post a bunch of code, a wiki page (or a pull request, actually) would likely be better.

@Alexander-Miller
Copy link

@Alexander-Miller Alexander-Miller commented Jul 22, 2015

Note: there's now a third-party package to add doc string popups to company: company-quickhelp.

Better yet: it uses pos-tip instead of popup.el, meaning it actually works well.

@dgutov
Copy link
Member

@dgutov dgutov commented Jul 23, 2015

Thanks for the reminder, updated.

hrs added a commit to hrs/dotfiles that referenced this issue Feb 24, 2016
The configuration's a bit simpler and it seems much more extensible.

See more reasons for switching here:
company-mode/company-mode#68
@jojojames
Copy link
Contributor

@jojojames jojojames commented May 20, 2016

Might not be the best place for this question but I thought it was relevant.

Is there a way in company to replicate how auto-complete initiates completions?
(def example-func() ;z;z)
exam| <-- cursor will hint the rest of the completion and only after a delay show the completion popup. Before the popup shows, user can manually complete the 'hinted completion' and move along.

Maybe a video would be better to describe this, but that's another thing I noticed between the two. (I believe company does something similar to the above but only when there's one completion candidate available).

@dgutov
Copy link
Member

@dgutov dgutov commented May 22, 2016

@jojojames You're right, it's another difference. See #123.

@jcs090218
Copy link
Contributor

@jcs090218 jcs090218 commented Apr 9, 2019

@dgutov Thanks for the auto-complete and company comparison, this helps a lot!

@dgutov
Copy link
Member

@dgutov dgutov commented Apr 9, 2019

There's one more thing to add now: since 2017, the auto-complete development has officially stopped, and the repository has been archived. Which is kind of sad, of course.

@zw963
Copy link

@zw963 zw963 commented Mar 8, 2020

It is 2020 now, it's been six years since this topic first talk about, any update on this? i get this link from official home page, maybe expect to see some news compare results, thank you!

@dgutov
Copy link
Member

@dgutov dgutov commented Mar 16, 2020

In that time, we got child frame based frontends such as https://github.com/tumashu/company-posframe/ and https://github.com/sebastiencs/company-box. And some new backends, all third-party ones. Could be forgetting something important as well. Also see NEWS.md.

Not such there's much point in refreshing this comparison, though: the auto-complete package is not developed anymore.

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

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.