Skip to content

sorting ivy buffer by custom criteria #213

@drorbemet

Description

@drorbemet

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions