orgzly / orgzly-android

Outliner for taking notes and managing to-do lists
https://www.orgzly.com
GNU General Public License v3.0
2.69k stars 306 forks source link

Search results: sort by last tag #463

Open memeplex opened 5 years ago

memeplex commented 5 years ago

This could be a simple solution addressing a use case related to some more complex feature requests (autocomplete tags on search expression, show category instead of notebook in search results).

The use case is: discriminate TODOs by context. Possible implementations are: keep a number of predefined searches (already possible), facilitate building dynamic searches (autocomplete tags, unimplemented), use categories (unimplemented), use notebooks (implemented by IMO quite useless for the task at hand).

Now, org mode allows to sort agenda views alphabetically by last tag. Since tags are already shown in search results by orgzly, the only missing part is to extend the search expression with something like o.tag. This way each context could get its own section in search results.

nevenz commented 5 years ago

Using just last tag might be too specific. Perhaps tags within each note could be first sorted, then search results sorted by that. I'm not sure how tricky would that be to implement.

But sorting by note's tags as they are listed should be easy to implement.

memeplex commented 5 years ago

It's too specific but it's also the way org mode does it. A long time ago, there was an inconclusive discussion (that even involved Carsten) about how to sort by tags. I don't know by whom or why, but later it was decided to do it by picking the last tag, as you can check by looking at the list of sorting strategies available for custom agenda commands. I guess the rationale is that the last tag is aligned to the right side of the agenda window, so you can easily discern chunks grouped by last tag. In any case, it's the convention followed by org mode so if you decide to make this more generic, please be sure to include this case.

Ypot commented 5 years ago

About "predefined searches". I thought too in something like that, for example a menu, with all the tags on it, where just by choosing one tag a search is done.

memeplex commented 5 years ago

@Ypot that's a different function, this is about sorting not filtering. But it's true that the main use of "sort by last tag" is a kind of discrimination between different chunks (signalled by the last tag, which is right aligned and thus clearly visible) which can alternatively be done by very quick tag filtering (I mean, not having to predefine a search for that). But I guess that is much harder to implement than simply adding a new order clause to the search syntax.

pstn commented 5 years ago

This feature would be very handy for a orgzly use-case of mine: Shopping lists. Sorting by tags would allow me an easy way to group up products that are in similar places in the supermarket.