Git Product home page Git Product logo

weechat-autosort's Issues

Issues with custom sort when Slack channels are involved

autosort.py defaults works fine with Slack teams and channels.

But if I wish to sort my IRC servers like..
/autosort rules update 4 ${if:${plugin}==irc?${info:autosort_order,${server},bitlbee,lair,freenode,oftc,efnet,*}}
..all the Slack channels show up under the last Slack team.

See https://i.imgur.com/NwBc3Nc.png

I can fix this with another rule like:
/autosort rules update 5 ${script_or_plugin}==slack?${info:autosort_order,${server},googlecloud-community.slack.com,openobservatory.slack.com}

Perhaps I'm misreading the changelog or is this a bug?

3.7:
 * Make default rules work with bitlbee, matrix and slack.

Buffers with spaces in the name

Currently, autosort uses /buffer swap <name> <target number> for applying a sort order. This breaks when <name> contains spaces.

It would be better to use /buffer swap <number> <number> to avoid the issue.

Trying to sort my bitlbee stuff after everything else

Helpers:

16:15:25            weechat    | autosort: Helper variables:
16:15:25            weechat    |      bitlbee_last: ${if:${buffer.server}!=bitlbee}
16:15:25            weechat    |        core_first: ${if:${buffer.full_name}!=core.weechat}
16:15:25            weechat    |     hashless_name: ${info:autosort_replace,#,,${buffer.name}}
16:15:25            weechat    |         irc_first: ${if:${buffer.plugin.name}!=irc}
16:15:25            weechat    |          irc_last: ${if:${buffer.plugin.name}==irc}
16:15:25            weechat    |     irc_raw_first: ${if:${buffer.full_name}!=irc.irc_raw}
16:15:25            weechat    |      irc_raw_last: ${if:${buffer.full_name}==irc.irc_raw}

Rules:

16:15:36            weechat    | autosort: Sorting rules:
16:15:36            weechat    |     0: ${core_first}
16:15:36            weechat    |     1: ${bitlbee_last}
16:15:36            weechat    |     2: ${irc_first}
16:15:36            weechat    |     3: ${buffer.plugin.name}
16:15:36            weechat    |     4: ${irc_raw_first}
16:15:36            weechat    |     5: ${if:${plugin}==irc?${server}}
16:15:36            weechat    |     6: ${if:${plugin}==irc?${info:autosort_order,${type},server,*,channel,private}}
16:15:36            weechat    |     7: ${if:${plugin}==irc?${hashless_name}}
16:15:36            weechat    |     8: ${buffer.full_name}

However I still get bitlbee stuff first :(

Any help appreciated!

Plugin fails to load: AttributeError: 'str' object has no attribute 'decode'

When I try to load the plugin (using python3) I get the following error:

weechat     | python: loading script "/home/alem0lars/.weechat/python/autoload/autosort.py"
weechat     | python: registered script "autosort", version 2.7 (Automatically or manually keep your buffers sorted and grouped by server.)
weechat     | python: stdout/stderr: Traceback (most recent call last):
weechat     | python: stdout/stderr:   File "/home/alem0lars/.weechat/python/autoload/autosort.py", line 877, in <module>
weechat     | python: stdout/stderr:     on_config_changed()
weechat     | python: stdout/stderr:   File "/home/alem0lars/.weechat/python/autoload/autosort.py", line 691, in on_config_changed
weechat     | python: stdout/stderr:     on_buffers_changed()
weechat     | python: stdout/stderr:   File "/home/alem0lars/.weechat/python/autoload/autosort.py", line 675, in on_buffers_changed
weechat     | python: stdout/stderr:     buffers.sort(key=buffer_sort_key(config.rules))
weechat     | python: stdout/stderr:   File "/home/alem0lars/.weechat/python/autoload/autosort.py", line 450, in key
weechat     | python: stdout/stderr:     for word in preprocess(buffer[0].decode('utf-8'), config):
weechat     | python: stdout/stderr: AttributeError: 'str' object has no attribute 'decode'
weechat =!= | python: unable to parse file "/home/alem0lars/.weechat/python/autoload/autosort.py"

Unicode characters in buffer names

11:36 autosort: Individual evaluation results:
11:36 autosort: core.weechat: ['0', '0', '', '1', '', '1', 'weechat', 'core.weechat']
11:36 autosort: python.capitaines: ['1', '0', 'python', '1', '', '0', 'capitaines', 'python.capitaines']
11:36 autosort: python.capitainetrain: ['1', '0', 'python', '1', '', '0', 'capitainetrain', 'python.capitainetrain']
11:36 autosort: python.trainline: ['1', '0', 'python', '1', '', '0', 'trainline', 'python.trainline']
11:36 python: stdout/stderr: Traceback (most recent call last):
11:36 python: stdout/stderr:   File "/home/name/.weechat/python/autosort.py", line 688, in on_autosort_command
11:36 python: stdout/stderr:     'swap':   command_helper_swap,
11:36 python: stdout/stderr:   File "/home/name/.weechat/python/autosort.py", line 572, in call_command
11:36 python: stdout/stderr:     return child(buffer, command, tail)
11:36 python: stdout/stderr:   File "/home/name/.weechat/python/autosort.py", line 414, in command_debug
11:36 python: stdout/stderr:     log('{0}: {1}'.format(fullname, result))
11:36 python: stdout/stderr: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 21: ordinal not in range(128)
11:36 =!= python: error in function "on_autosort_command"

on_info_replace getting called with not enough arguments

I updated to WeeChat 2.4 [compiled on Feb 17 2019 08:49:01] from the weechat debian repo, and started getting a lot of the following message in the weechat buffer:

autosort: usage: ${info:autosort_replace,old,new,text}

on_info_replace is getting called with one argument, #.
I only have one other plugin, wee-slack.

So does anyone else see this?
If not, I'll try purging my settings and reinstalling.
If it's a general problem I can try to help debug.

'/help autosort' missing explanation of newer '${info:}' options

It appears that at least two of the newer ${info:} helper variables are not documented/explained in the output of /help autosort, leaving newer users to discover their existence from the embedded changelog in the script, and to divine the correct usage of these variables on their own.

3.5:
* Add ${info:autosort_escape,...} to escape arguments for other info hooks.
...
3.0:
...
* Add ${info:autosort_order,value,first,second,third} to ease writing sort rules.

Default sort config does not support buffers with commas in their name

The default sort config contains ${info:autosort_replace,#,,${buffer.name}} in the hashless_name helper.
If a buffer contains a comma in its name, then info:autosort_replace is given more than three parameter and an error is displayed: autosort: usage: ${info:autosort_replace,old,new,text}
I could not find any reliable way to escape the comma.

Sorting rules don't eval properly

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.

Getting lots of these in my logs after recent host upgrade

autosort: usage: ${info:autosort_replace,old,new,text}
autosort: usage: ${info:autosort_replace,old,new,text}
autosort: usage: ${info:autosort_replace,old,new,text}
autosort: usage: ${info:autosort_replace,old,new,text}
autosort: usage: ${info:autosort_replace,old,new,text}

Please advise!

Exception when running `/autosort helpers swap`

Running /autosort helpers swap causes a python exception:

2023-09-25 10:25 ▬!▬ python: error in function "on_autosort_command"
2023-09-25 10:26 autosort: Helper variables:
2023-09-25 10:26           core_first: ${info:autosort_replace,#,,${info:autosort_escape,${buffer.name}}}
2023-09-25 10:26        hashless_name: ${if:${buffer.full_name}!=core.weechat}
2023-09-25 10:26        irc_raw_first: ${if:${buffer.full_name}!=irc.irc_raw}
2023-09-25 10:26         irc_raw_last: ${if:${buffer.full_name}==irc.irc_raw}
2023-09-25 10:26     script_or_plugin: ${if:${script_name}?${script_name}:${plugin}}
2023-09-25 10:26 python: stdout/stderr (autosort): Traceback (most recent call last):
2023-09-25 10:26 python: stdout/stderr (autosort):   File "/home/maarten/.weechat/python/autoload/autosort.py", line 802, in on_autosort_command
2023-09-25 10:26 python: stdout/stderr (autosort):     return call_command(buffer, ['/autosort'], args, {
2023-09-25 10:26 python: stdout/stderr (autosort):            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25 10:26 python: stdout/stderr (autosort):   File "/home/maarten/.weechat/python/autoload/autosort.py", line 635, in call_command
2023-09-25 10:26 python: stdout/stderr (autosort):     return call_command(buffer, command, tail, child)
2023-09-25 10:26 python: stdout/stderr (autosort):            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25 10:26 python: stdout/stderr (autosort):   File "/home/maarten/.weechat/python/autoload/autosort.py", line 637, in call_command
2023-09-25 10:26 python: stdout/stderr (autosort):     return child(buffer, command, tail)
2023-09-25 10:26 python: stdout/stderr (autosort):            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25 10:26 python: stdout/stderr (autosort):   File "/home/maarten/.weechat/python/autoload/autosort.py", line 619, in command_helper_swap
2023-09-25 10:26 python: stdout/stderr (autosort):     config.helpers.swap(index_a, index_b)
2023-09-25 10:26 python: stdout/stderr (autosort):     ^^^^^^^^^^^^^^^^^^^
2023-09-25 10:26 python: stdout/stderr (autosort): AttributeError: 'dict' object has no attribute 'swap'

scripts buffer can't be sorted

I'd like to sort the "scripts" buffer to the top, right after core and fset buffer.
But for some reason it doesn't work. My ruleset is

0: core = 0
1: fset = 1
2: scripts = 2
3: irc.server = 3
4: irc = 4
5: * = 5

However, the scripts buffer is always sorted at the end of the list. I tried changing
that to

2: *scripts* = 2

but to no avail. What am I doing wrong?

Thanks,
Corinna

sorting by type - is it possible at all?

Hi!

I'm struggling with sorting rules configuration and was wondering if anyone can confirm if this is possible to setup with this plugin at all.

I'm trying to achieve following buffers order:

  1. All private chats/queries first
  2. Next, all channels starting with # (regardless of the network, or ordered by network - don't care)
  3. Next, all channels starting with &
  4. Next, all irc.server buffers
  5. Lastly the core window

My setup is as follows:

  1. Three IRC networks/servers, one of them is bitlbee
  2. Following rules configured:
0: irc.*.#* = 3
1: irc.*.&* = 4
2: irc.*.* = 2
3: irc.server = 15
4: core = 9999999999

group_irc is set to off.

Currently, above rules result in following order: [server buffers, 1st network, 2nd network, core window] which is not what I want.

Guessing from the source code, this does not work because python stops comparison on the first or second component, regardless how the last component is scored. For example, the sort() method receives following data:

12:25 autosort: Unsorted:
[[(9999999999, u'core'), (999999999, u'weechat')],
[(999999999, u'irc'), (15, u'server'), (999999999, u'bitlbee')],
[(999999999, u'irc'), (15, u'server'), (999999999, u'net1')],
 [(999999999, u'irc'), (15, u'server'), (999999999, u'znc-freenode')],
 [(999999999, u'irc'), (999999999, u'bitlbee'), (3, u'#twitter_abc')],
 [(999999999, u'irc'), (999999999, u'bitlbee'), (3, u'&bitlbee')],
 [(999999999, u'irc'), (999999999, u'bitlbee'), (3, u'&jabber')],
 [(999999999, u'irc'), (999999999, u'net1'), (3, u'#acsas')],
 [(999999999, u'irc'), (999999999, u'net1'), (3, u'#netdevops')],
 [(999999999, u'irc'), (999999999, u'net1'), (999999999, u'priv1')],
 [(999999999, u'irc'), (999999999, u'znc-freenode'), (3, u'#linux')],
 [(999999999, u'irc'), (999999999, u'znc-freenode'), (3, u'#salt')],
 [(999999999, u'irc'), (999999999, u'znc-freenode'), (3, u'#vim')],
 [(999999999, u'irc'), (999999999, u'znc-freenode'), (999999999, u'^priv3^')],
 [(999999999, u'irc'), (999999999, u'znc-freenode'), (999999999, u'someoneelse')]]

For reference, this was produced by adding following debug code:

def on_buffers_changed(*args, **kwargs):
    ''' Called whenever the buffer list changes. '''
    buffers = get_buffers()
    skey = buffer_sort_key(config.rules)
    unsorted = [skey(buf) for buf in buffers]
    log("Unsorted: {0}".format(unsorted))
    buffers.sort(key=buffer_sort_key(config.rules))
    for buf in buffers:
        log("result for %s: %s" % (buf, skey(buf)))
    apply_buffer_order(buffers)
    return weechat.WEECHAT_RC_OK

Is there any way to avoid it?

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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.