de-vri-es / weechat-autosort

Automatically keep your buffers sorted.
GNU General Public License v3.0
76 stars 8 forks source link

Use a the score as the sort key rather than a list of tuples #3

Closed nijotz closed 8 years ago

nijotz commented 8 years ago

I'm using the wee-slack plugin and this autosort plugin was just plain not working. 'python' being the first word rather than 'irc' makes it so that the slack buffers are either all before the irc ones, or all after. Tracked it down to the buffer sort key function returning a list of tuples rather than a number. I have no idea how python sorts a list using a list of tuples as sort keys, but it wasn't working. Sort key functions should return numbers.

nijotz commented 8 years ago

Ending up solving this by just replacing the python section of the buffer name with irc.server

de-vri-es commented 8 years ago

Sorry for the late reply, I was away to Germany.

The returned list causes python to order the buffers lexicographically. It is a list of tuples to sort first on score and second on buffer name (when the score is equal). Replacing a prefix of the buffer name as you did is indeed the best way to sort buffers with a different prefix at the same level.