counsel-company now automatically selects its candidate if there is only one choice#2849
counsel-company now automatically selects its candidate if there is only one choice#2849NightMachinery wants to merge 1 commit intoabo-abo:masterfrom
Conversation
basil-conto
left a comment
There was a problem hiding this comment.
Thanks.
counsel-companynow automatically selects its candidate if there is only one choice
Is that unconditional, or is there a user option that controls whether this happens?
| :action #'ivy-completion-in-region-action | ||
| :caller 'counsel-company)))) | ||
| (cond | ||
| ((= (length company-candidates) 1) |
There was a problem hiding this comment.
Nit: If company-candidates is a list, it's better to say:
(and company-candidates
(null (cdr company-candidates)))to avoid traversing the entire list. In Emacs 28, you can alternatively say:
(length= company-candidates 1)Not sure if it's worth writing a compatibility shim for this.
| ) | ||
| (t (ivy-read "Candidate: " company-candidates | ||
| :action #'ivy-completion-in-region-action | ||
| :caller 'counsel-company)))))) |
There was a problem hiding this comment.
Nit: there's a trailing paren and the indentation seems off. Suggest to simplify:
(if (cdr company-candidates)
(ivy-read "Candidate: " company-candidates
:action #'ivy-completion-in-region-action
:caller 'counsel-company)
(ivy-completion-in-region-action (car company-candidates)))|
@basil-conto Thanks. There is no user-configurable option, but it's addable. I think my PR is stale if #2835 is to be merged, so they should keep your points in mind if they want to also add this feature. PS: I don't like =if= as it is asymmetric and needs =progn= for its direct clause. |
Not in this case ;). |
No description provided.