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

sorting ivy buffer by custom criteria #213

Closed
drorbemet opened this Issue Aug 29, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@drorbemet

drorbemet commented Aug 29, 2015

Maybe the following feature could be interesting and helpful in the future.
Sometimes the list of matches stays long because of missing features to filter further.
How about sorting the matches in an ivy buffer by metadata?

  • And using the free space on the right side of the ivy options panel to provide it? Maybe one could even toggle three states with one key?
  • And let the user add new sorting commands by giving him a template for writing his own comparison functions which use new metadata of items in an ivy buffer?
  • The metadata value used for current sorting could be displayed on the right side of the ivy buffer. Just like the keybindings in counsel-M-x.
  • This would even provide the basis for toggling filtering by metadata via options panel as well. Should the need arise.

more decisions to be made on open questions:

  • Metadate should not be part of the string when copied using M-w ?
  • What options for text alignment of match, metadata and window?

example - sort a list of file system paths by date of last change

right side of options panel:
Sort by

d: last change (ascending, descending, no sorting)

ivy buffer search results list sorted with visible metadata value (and text align left):
/a/file/path/file.ext ............... (2015.08.12 20:10:49)
/an/other/file/path/anothe ... (2015.08.10 08:24:16)
/an/other/file/path/file.ext .... (2015.03.19 14:31:56)

(and text align right):
............../a/file/path/filea.ext (2015.08.12 20:10:49)
... /file/path/another/fileb.ext (2015.08.10 08:24:16)
...../an/other/file/path/file.ext (2015.03.19 14:31:56)

example - sort a list of emacs commands by keybinding

right side of options panel:
Sort by

k: keybinding (ascending, descending, no sorting)

ivy buffer search results list sorted with visible metadata value:
command-name ... (C-x a)
an-other-command (C-x b)

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Nov 13, 2015

Owner

Thanks. It should now be possible to customize ivy-sort-matches-functions-alist to do what you want.

Example of use:

(add-to-list
 'ivy-sort-matches-functions-alist
 '(read-file-name-internal . ivy--sort-files-by-date))

This will result in e.g. find-file' orcounsel-find-file' sorting files by last modification time.

Owner

abo-abo commented Nov 13, 2015

Thanks. It should now be possible to customize ivy-sort-matches-functions-alist to do what you want.

Example of use:

(add-to-list
 'ivy-sort-matches-functions-alist
 '(read-file-name-internal . ivy--sort-files-by-date))

This will result in e.g. find-file' orcounsel-find-file' sorting files by last modification time.

@drorbemet

This comment has been minimized.

Show comment
Hide comment
@drorbemet

drorbemet Nov 13, 2015

Oh, thank you.

drorbemet commented Nov 13, 2015

Oh, thank you.

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