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

In ivy mode, commands that have input as prefix of their name should be presented first #265

Closed
rudi opened this Issue Oct 16, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@rudi

rudi commented Oct 16, 2015

Using standard completion or icomplete-mode, M-x man RET executes the man command. When turning on ivy-mode, man is somewhere on the 8th screen. (Entering ^man on the prompt helps a bit, but once the library is loaded, various commands starting with uppercase "Man-" prefix are presented before man even in that case.) Other commands have the same problem, e.g., gnus is presented after diary-from-outlook-gnus when typing M-x gnus.

Would it be possible to sort the list of completions so that prefix matches of the input string come before other possibilities?

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Oct 16, 2015

Owner

You should use a dedicated command for M-x:

(global-set-key (kbd "M-x") 'counsel-M-x)

It already comes with ^ as the initial input, so the issue disappears.

Alternatively, you can rely on flx to do the prefix sorting:

(setq ivy-re-builders-alist
      '((t . ivy--regex-fuzzy)))
Owner

abo-abo commented Oct 16, 2015

You should use a dedicated command for M-x:

(global-set-key (kbd "M-x") 'counsel-M-x)

It already comes with ^ as the initial input, so the issue disappears.

Alternatively, you can rely on flx to do the prefix sorting:

(setq ivy-re-builders-alist
      '((t . ivy--regex-fuzzy)))

@abo-abo abo-abo closed this in f246178 Nov 13, 2015

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Nov 13, 2015

Owner

Use:

(setq ivy-prefix-sort t)

to turn on the new behavior. It's off by default, because it can be potentially more time-consuming.
If it turns out to be fast enough, ivy-prefix-sort will be made on by default.

Owner

abo-abo commented Nov 13, 2015

Use:

(setq ivy-prefix-sort t)

to turn on the new behavior. It's off by default, because it can be potentially more time-consuming.
If it turns out to be fast enough, ivy-prefix-sort will be made on by default.

abo-abo added a commit that referenced this issue Nov 13, 2015

Allow user-specified matched candidate sorting
* ivy.el (ivy-prefix-sort): Remove defcustom.
(ivy--filter): Forward sorting of matched candidates to `ivy--sort'.
(ivy-sort-matches-functions-alist): New defcustom.
(ivy--sort): New defun.

Fixes #269
Fixes #265
@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Nov 13, 2015

Owner

I reconsidered the customization interface because of #269. You should now use:

(setq ivy-sort-matches-functions-alist
      '((t . ivy--prefix-sort)))

to turn on the prefix sorting. It's more flexible, since it allows to turn on extra sorting only for some commands if you want.

Owner

abo-abo commented Nov 13, 2015

I reconsidered the customization interface because of #269. You should now use:

(setq ivy-sort-matches-functions-alist
      '((t . ivy--prefix-sort)))

to turn on the prefix sorting. It's more flexible, since it allows to turn on extra sorting only for some commands if you want.

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