de-vri-es / weechat-autosort

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

Sorting an IRC channel after all other buffers results in odd behaviour. #9

Closed de-vri-es closed 7 years ago

de-vri-es commented 7 years ago

The IRC buffer got sorted alphabetically with the IRC server buffers instead of appearing at the very end.

I could not reproduce it yet. The problem has appeared with irc.freenode.#i3, so I should test with that too.

Configuration where this appeared (with group_irc on):

autosort: Sorting rules:
   0: core = 0
   1: irc = 2
   2: *highmon* = 99
   3: *i3* = 99
   4: * = 1
   5: irc.server = 1
   6: irc.server.*.#* = 0
   7: irc.irc_raw = 0
   8: irc.server.*.#* = 0
autosort: Replacement patterns:
   0: perl.highmon -> highmon
   1: irc.freenode.#i3 -> i3

Renaming instead to Zi3 did sort it last, but that should not be required.

de-vri-es commented 7 years ago

Note that for me, these settings worked as expected:

autosort: Sorting rules:
    0: core = 0
    1: irc = 2
    2: i3 = 99
    3: * = 1
    4: irc.server = 1
    5: irc.irc_raw = 0
    6: irc.server.*.#* = 0
    7: irc.server.*.[*]status = 1
    8: irc.server.*.[*]* = 2
autosort: Replacement patterns:
    0: ## -> #
    1: irc.freenode.#i3 -> i3

Maybe there are some subtle Python version dependent behaviour. My weechat is using python 2.7.13. @squigglezworth: Could you check your python version?

de-vri-es commented 7 years ago

After some more debugging on irc, I think the observed behaviour can be explained.

The first replacement pattern used was freenode.#i3 -> i3. That caused the buffer name after replacement patterns were applied to be irc.i3. The group_irc option then turned that into irc.server.i3 before the sort rules were applied. In sort rules * doesn't match periods, so the sort rule *i3* never matched the correct buffer and it ended up being sorted alphabetically with the server buffers.

During debugging we did try a number of replacement patterns and sort rules, but apparently never the correct combination at the same time. With the replacement pattern freenode.#i3 -> i3 and group_irc = on, the correct sort rule would be irc.server.i3 = .... With group_irc= off it would be irc.i3 = ....

Alternatively, the replacement pattern irc.freenode.#i3 -> i3 can be used with the rule i3 = .... This doesn't behave exactly the same as the previous option, so both can be valid use cases.

It also got me thinking that a /autosort debug command to show the result of replacement patterns and sort rules might be useful, but thats a seperate issue. The same goes for allowing regexes or glob-style patterns in sort rules.