purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.84k stars 2.05k forks source link

The order of company candidates is incorrect in Emacs lisp mode #778

Closed Eason0210 closed 3 years ago

Eason0210 commented 3 years ago

Hi @purcell , with latest commit, the order of company candidates is incorrect in Emacs lisp mode. But it works well in the other major modes .

image

similar issue, orderless & company-capf

purcell commented 3 years ago

So completion-styles was set to (substring orderless), and that var apparently affects completion-at-point. The solution here was to remove substring from completion-styles: the new value is (basic partial-completion orderless). At least in the above case, this yields a more reasonable result.

yugaego commented 3 years ago

Not as a fix, but as an additional option, you might also be interested to try company-transformers customization setting. Such as, f.i. (setq company-transformers '(company-sort-by-occurrence))

purcell commented 3 years ago

Interesting, thanks. I checked it out briefly but it wasn't obvious to me if there'd be a benefit right now.

Eason0210 commented 3 years ago

Hi, @purcell
Now we have changed the completion style to (setq completion-styles '(basic partial-completion orderless)) globally, this also affect the completion in minibuffer. Now the behavior is like this:

before

I think it is better to set minibuffer completion-styles to use only orderless to get a better experience.
something like this would work.

  (defun sanityinc/use-orderless-in-minibuffer ()
    (setq-local completion-styles '(substring orderless)))
  (add-hook 'minibuffer-setup-hook 'sanityinc/use-orderless-in-minibuffer)

Now it the behavior is like this:

after
purcell commented 3 years ago

Agree, done

liuyinz commented 3 years ago

@purcell After I set a local value in minibuffer, It seems confilct with consult async related command.

See https://github.com/minad/consult/issues/396, the origin grep and filter style fails.

Another possible solution : https://github.com/oantolin/orderless/issues/48#issuecomment-856750410

(define-advice company-capf
    (:around (orig-fun &rest args) set-completion-styles)
  (let ((completion-styles '(basic partial-completion)))
    (apply orig-fun args)))

(setq completion-styles '(orderless))