insanum / sncli

Simplenote CLI
MIT License
397 stars 34 forks source link

Any chance for 'sort notes by tags'? #34

Closed 097115 closed 7 years ago

097115 commented 7 years ago

Like, an additional yes/no option, and then by date or by alpha inside a tag?

samuelallan72 commented 7 years ago

This sounds like an interesting idea - I'll definitely look into it. I'm not sure how this would work though. Since notes have multiple tags, should the list of tags be sorted, and then the notes sorted by that? How are you thinking it should work exactly? :)

097115 commented 7 years ago

Since notes have multiple tags, should the list of tags be sorted, and then the notes sorted by that? How are you thinking it should work exactly? :)

My thinking was that since the note's tags can be arranged by a user manually (by entering those in a specific order), then the first tag should be given an advantage… What do you think?

samuelallan72 commented 7 years ago

@097115 I've added an implementation of sorting notes by tags in the sort_tags branch. Please try it out - feedback appreciated! I would also like suggestions for the default keybinding for sort by tags. (Remember that sort by title is a and by date is d.)

097115 commented 7 years ago

Now, that looks nice, thanks!

The only problem is that it seems to reset (sorting by tags switches off) after editing a tag or a note - i.e., after the sync process finishes. Don't know if it's a feature or a bug :).

As per the keybinding, C-t seems handy and logical for me: you sort with single-letter hotkeys and then toggle grouping on and off with a composite one :).

samuelallan72 commented 7 years ago

The only problem is that it seems to reset (sorting by tags switches off) after editing a tag or a note - i.e., after the sync process finishes. Don't know if it's a feature or a bug :).

Yes the sorting gets reset on sync - probably more of a bug than a feature.

As per the keybinding, C-t seems handy and logical for me: you sort with single-letter hotkeys and then toggle grouping on and off with a composite one :).

Wait maybe I misinterpreted what you were requesting. Currently the tags sort is implemented exactly the same as the other sorts - it just sorts the notes with the key being the tags list. Python sorts are stable though, so if you press d to sort by date, then the sort-by-tags, notes with the same tags will be sorted by date as well. That isn't by design though - just a by product of sorting twice.

097115 commented 7 years ago

Wait maybe I misinterpreted what you were requesting.

No, you didn't :). Everything's OK, really (except for that reset on sync may be), I was just suggesting some sort of explanation for the hotkey choice :).

samuelallan72 commented 7 years ago

@097115, just pushed a fix for the resetting sort order on sync to that branch. If you could test it out, that would be great! I'll merge to master as soon as I'm happy that it's stable.

097115 commented 7 years ago

It seems now that if sorting is set by "alpha" and by "tag", then "alpha" gets reseted after sync to "date" -- i.e., after sync sorting switches to by "date" and by "tag".

Also, cfg_sort_mode = alpha from .snclirc doesn't affect startup (but I don't really know if it's a new one, or it was always this way).

As for tag sorting it looks like OK.

samuelallan72 commented 7 years ago

@097115 pushed some fixes: tag sorting is now deterministic (ties broken by modified date), and it should use the configuration sort mode on startup now (including in list and dump modes).

097115 commented 7 years ago

Looks like you can't now sort by alpha and tag? If sorted by alpha, and you press a key for sort by tags, sncli switches to sorting by date and tags.

samuelallan72 commented 7 years ago

Yep that's right. I can't think of any other neat way to have a deterministic sort (so it doesn't 'reset' on sync). Unless we have two 'tags' sorting functions - one with secondary sort being date and the other being by title.

097115 commented 7 years ago

Well, that's kinda sad news…

samuelallan72 commented 7 years ago

@097115 how happy are you about the tag sorting? I think I like it like that feature as it is - simple and useful for finding untagged notes. When it's all resolved, I'll merge to master and close the issue. :)

samuelallan72 commented 7 years ago

Also, any opinions on whether notes without tags should be shown above or below those with tags? Currently notes without tags are below, but my logic is saying without tags should be first.

097115 commented 7 years ago

Well, not really: in the end, I use now the first iteration, which resets after sync - since I'm more used to alpha sorting, not date.

As for notes without tags, I agree with you, showing them first makes more sense.

samuelallan72 commented 7 years ago

Improved the ordering - tag sorting is now live (in master that is) as of commit https://github.com/insanum/sncli/commit/605818411ac79bf85c945dd579e14669c2fb8b24

1094 commented 5 years ago

My question is related to this and not actually an "issue" so I didn't want to open a new one: Is there a help file or something that lists all the different configurable items (like sorting) and their options (alpha, date, etc)?

samuelallan72 commented 5 years ago

@1094 unfortunately not sorry. The best place to start looking at this time is https://github.com/insanum/sncli/blob/master/simplenote_cli/config.py

Something that would be nice to have in the future is some actual documentation. A fork of this project made for nextcloud notes, nncli, has nice documentation which could be copied/adapted for sncli. See https://nncli.org/ and https://git.danielmoch.com/nncli/

1094 commented 5 years ago

Most of the config.py shows up in the help menu. Which is helpful to a point. After reading this thread, I took a look at the utils.py but with my limited (aka almost nil) knowledge of python that wasn't very useful.

I'll take a look nncli and see what I can gleam from that. Thanks.

samuelallan72 commented 5 years ago

@1094 which ones in particular are you looking for? I can perhaps help decipher the source code.

If it's the sorting mode, the relevant code is in https://github.com/insanum/sncli/blob/master/simplenote_cli/notes_db.py#L76 . Basically the options are "alpha", "date", and "tags"

1094 commented 5 years ago

Actually, I started my search because I wanted to sort notes in alphabetical order. Finding this thread just made me realize a) I have no idea what "alpha" means and that b) there are a number of setting and options for a program I use (multiple times everyday) and I have no idea what they are. These ideas got my curiosity going.