Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting rules don't eval properly #14

Closed
LenaicTerrier opened this issue Jan 16, 2019 · 6 comments
Closed

Sorting rules don't eval properly #14

LenaicTerrier opened this issue Jan 16, 2019 · 6 comments

Comments

@LenaicTerrier
Copy link

LenaicTerrier commented Jan 16, 2019

Hello,

I can't make autosort output something useful on debug, and it won't sort.

The install:

  • weechat version 1.6
  • autosort version 3.3

Here is an output of the rules (default I believe):

    0: ${core_first}
    1: ${irc_last}
    2: ${buffer.plugin.name}
    3: ${irc_raw_first}
    4: ${if:${plugin}==irc?${server}}
    5: ${if:${plugin}==irc?${info:autosort_order,${type},server,*,channel,private}}
    6: ${if:${plugin}==irc?${hashless_name}}
    7: ${buffer.full_name}

And here is a debug:

autosort: core.weechat: ['', '', '', '', '', '', '', 'core.weechat']
autosort: irc.s1.#c1: ['', '', 'irc', '', '', '', '', 'irc.s1.#c1']
autosort: irc.s1.q1: ['', '', 'irc', '', '', '', '', 'irc.s1.q1']
autosort: irc.s2.#c2: ['', '', 'irc', '', '', '', '', 'irc.s2.#c2']
autosort: irc.server.s1: ['', '', 'irc', '', '', '', '', 'irc.server.s1']
autosort: irc.server.s2: ['', '', 'irc', '', '', '', '', 'irc.server.s2']
autosort: irc.server.s3: ['', '', 'irc', '', '', '', '', 'irc.server.s3']
autosort: irc.s3.q2: ['', '', 'irc', '', '', '', '', 'irc.s3.q2']

The strings s1, s2, s3 are three servers weechat is connected to. The strings #c1 and #c2 are two canals weechat has joined. The stings q1 and q2 are two private chat with users (/query). They are anonymized but the output stays coherent except for alphabetical order.

Seems to me, the ${if:} expression isn't doing what it's supposed to do as the only two rules that output something are those who doesn't use the expression.

The other possibility being this is the normal behavior and then it's me who doesn't understand how to make the plugin work.

Thank you for you time.

Edit : I've played a bit with the rules. And I can confirm I can't make the if expression work. Doesn't output anything.

@de-vri-es
Copy link
Owner

Those indeed look like the default rules. The most likely cause is your weechat version. Version 1.6 is relatively old. If it is possible for you I would recommend updating weechat. I expect that will make the default rules work as intended.

However, it should still be possible to make it more or less work without if statements. For example, you could turn them into:

    0: ${core_first}
    1: ${irc_last}
    2: ${buffer.plugin.name}
    3: ${irc_raw_first}
    4: ${server}
    5: ${info:autosort_order,${type},server,*,channel,private}
    6: ${hashless_name}
    7: ${buffer.full_name}

Some of these will still be broken, but basic functionality should be there. The if statements in rule 4, 5 and 6 are mainly there to avoid doing stupid sorting on slack channels, but that's only a problem if you use the slack script.

@LenaicTerrier
Copy link
Author

Oh... Well that's not an option. I'm running Weechat on a Debian stable (stretch) server in a tmux terminal. The current version of Weechat on stable is 1.6. I can't really dive into unstable just for Weechat. I guess I will have unsorted buffers for a time.

@de-vri-es
Copy link
Owner

Did you try without the ${if:..} for rules 4, 5 and 6? Because I think it would work for most setups that way too.

@LenaicTerrier
Copy link
Author

LenaicTerrier commented Jan 17, 2019

No, mainly because the rules that don't use if use helpers that do.
Helpers are

core_first: ${if:${buffer.full_name}!=core.weechat}                                                                                        
hashless_name: ${info:autosort_replace,#,,${buffer.name}}                                                                                      
irc_first: ${if:${buffer.plugin.name}!=irc}                                                                                              
irc_last: ${if:${buffer.plugin.name}==irc}                                                                                                  
irc_raw_first: ${if:${buffer.full_name}!=irc.irc_raw}                                                                                        
irc_raw_last: ${if:${buffer.full_name}==irc.irc_raw} 

@de-vri-es
Copy link
Owner

True, those wont work, but it's mainly rule 4, 5 and 6 that should ensure the tree-like sorting of IRC buffers. The sorting of non-irc buffers might not be exactly what you want, but there are alternatives even for those.

@de-vri-es
Copy link
Owner

PR to scripts repo submitted: weechat/scripts#341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants