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

Closed
expez opened this Issue Feb 26, 2014 · 27 comments

Projects

None yet

10 participants

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

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

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
Contributor

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
Member
dgutov commented Sep 30, 2014
@xiaohanyu xiaohanyu referenced this issue in xiaohanyu/oh-my-emacs Oct 21, 2014
Closed

Migrate from auto-complete mode to company-mode #100

@IvanMalison

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

@dgutov
Member
dgutov commented Dec 12, 2014

@IvanMalison None so far/there still are.

@asmeurer
asmeurer commented Mar 5, 2015

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

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

@dgutov
Member
dgutov commented Mar 6, 2015

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

@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
Member
dgutov commented Mar 6, 2015

@luxchris Yes please!

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

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
Member
dgutov commented Jul 23, 2015

Thanks for the reminder, updated.

@nosami nosami referenced this issue in fsharp/emacs-fsharp-mode Jan 5, 2016
Closed

Company mode #47

@hrs hrs added a commit to hrs/dotfiles that referenced this issue Feb 24, 2016
@hrs hrs Switch from auto-complete to company-mode
The configuration's a bit simpler and it seems much more extensible.

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

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
Member
dgutov commented May 22, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment