commit: 93e590b81d0c390ef767c58d77b763045e14785c
parent ae3d6b3b15ae7dd86a0896eedbe4282a9795bd90
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 9 Oct 2020 08:31:40 +0200
.weechat: Bump
Diffstat:
4 files changed, 98 insertions(+), 42 deletions(-)
diff --git a/.weechat/irc.conf b/.weechat/irc.conf
@@ -193,7 +193,7 @@ freenode.local_hostname
freenode.usermode
freenode.command
freenode.command_delay
-freenode.autojoin = "#yoloswagsteam,#niuchat,#vis-editor,#sailfishos-porters,#pleroma-dev,#oshu,#litepub,#gentoo-proxy-maint,#gentoo-dev,#breizh-entropy,##abgilpqt+,#!/bin/mksh,#abyss,#abyss-chat,#aerc,#aerc-dev,#cairo,#ckule,#cmpwn,#elinks,#elixir-lang,#friendica,#gentoo-arm,#gentoo-council,#gentoo-desktop,#gentoo-dotnet,#gentoo-guru,#gentoo-hardened,#gulliver,#jbosnu,#kibou,#lainradio,#libressl,#litepub-chat,#lojban,#nntpchan,#openra,#opensmtpd,#pingus,#pleroma,#pleroma-dev-ux,#pleroma-fr,#pleroma-offtop,#pleroma-offtopic,#pleroma-topless,#qutebrowser,#sr.ht,#sway,#sway-devel,#waymonad,#webkit,#webkitgtk,#wio,#yoloswagteam,#mobilizon,##tty,#wayland,#zig,#crystal-lang,#gentoo-games,#actux,#apconf,#gentoo-llvm,#cat-v,#nemomobile,#sailfishos,#nemomobile-porters,#fedidb"
+freenode.autojoin = "#yoloswagsteam,#niuchat,#vis-editor,#sailfishos-porters,#pleroma-dev,#oshu,#litepub,#gentoo-proxy-maint,#gentoo-dev,#breizh-entropy,##abgilpqt+,#!/bin/mksh,#abyss,#abyss-chat,#aerc,#aerc-dev,#cairo,#ckule,#cmpwn,#elinks,#elixir-lang,#friendica,#gentoo-arm,#gentoo-council,#gentoo-desktop,#gentoo-dotnet,#gentoo-guru,#gentoo-hardened,#gulliver,#jbosnu,#kibou,#lainradio,#libressl,#litepub-chat,#lojban,#nntpchan,#openra,#opensmtpd,#pingus,#pleroma,#pleroma-dev-ux,#pleroma-fr,#pleroma-offtop,#pleroma-offtopic,#pleroma-topless,#qutebrowser,#sr.ht,#sway,#sway-devel,#waymonad,#webkit,#webkitgtk,#wio,#yoloswagteam,#mobilizon,##tty,#wayland,#zig,#crystal-lang,#gentoo-games,#actux,#apconf,#gentoo-llvm,#cat-v,#nemomobile,#sailfishos,#nemomobile-porters,#fedidb,#badwolf-browser,#kennylevinsen,#postmarketos,#postmarketos-devel,#apconf2020,#alpine-devel"
freenode.autorejoin
freenode.autorejoin_delay
freenode.connection_timeout
@@ -279,7 +279,7 @@ krustykrab.local_hostname
krustykrab.usermode
krustykrab.command
krustykrab.command_delay
-krustykrab.autojoin = "#volatile,#yggdrasil,#krustykrab,#lokinet,#anonet,#meta"
+krustykrab.autojoin = "#yggdrasil,#lokinet,#anonet,#meta"
krustykrab.autorejoin
krustykrab.autorejoin_delay
krustykrab.connection_timeout
@@ -537,7 +537,7 @@ OFTC.local_hostname
OFTC.usermode
OFTC.command
OFTC.command_delay
-OFTC.autojoin = "#llvm,#suckless"
+OFTC.autojoin = "#llvm"
OFTC.autorejoin
OFTC.autorejoin_delay
OFTC.connection_timeout
@@ -666,7 +666,7 @@ rizon.local_hostname
rizon.usermode
rizon.command
rizon.command_delay
-rizon.autojoin
+rizon.autojoin = "#bakabt"
rizon.autorejoin
rizon.autorejoin_delay
rizon.connection_timeout
@@ -1139,7 +1139,7 @@ pine64.local_hostname
pine64.usermode
pine64.command
pine64.command_delay
-pine64.autojoin = "#pine64,#rock64,#pinebook,#pinephone"
+pine64.autojoin = "#pine64,#rock64,#pinephone,#pinebook,#pinetab"
pine64.autorejoin
pine64.autorejoin_delay
pine64.connection_timeout
@@ -1526,7 +1526,7 @@ tilde.chat.local_hostname
tilde.chat.usermode
tilde.chat.command
tilde.chat.command_delay
-tilde.chat.autojoin = "#gemini"
+tilde.chat.autojoin = "#gemini,#solarpunk"
tilde.chat.autorejoin
tilde.chat.autorejoin_delay
tilde.chat.connection_timeout
diff --git a/.weechat/python/autosort.py b/.weechat/python/autosort.py
@@ -25,6 +25,15 @@
#
# Changelog:
+# 3,8:
+# * Fix relative sorting on script name in default rules.
+# * Document a useful property of stable sort algorithms.
+# 3.7:
+# * Make default rules work with bitlbee, matrix and slack.
+# 3.6:
+# * Add more documentation on provided info hooks.
+# 3.5:
+# * Add ${info:autosort_escape,...} to escape arguments for other info hooks.
# 3.4:
# * Fix rate-limit of sorting to prevent high CPU load and lock-ups.
# * Fix bug in parsing empty arguments for info hooks.
@@ -76,7 +85,7 @@ import weechat
SCRIPT_NAME = 'autosort'
SCRIPT_AUTHOR = 'Maarten de Vries <maarten@de-vri.es>'
-SCRIPT_VERSION = '3.4'
+SCRIPT_VERSION = '3.8'
SCRIPT_LICENSE = 'GPL3'
SCRIPT_DESC = 'Flexible automatic (or manual) buffer sorting based on eval expressions.'
@@ -169,22 +178,21 @@ class Config:
default_rules = json.dumps([
'${core_first}',
- '${irc_last}',
- '${buffer.plugin.name}',
+ '${info:autosort_order,${info:autosort_escape,${script_or_plugin}},core,*,irc,bitlbee,matrix,slack}',
+ '${script_or_plugin}',
'${irc_raw_first}',
- '${if:${plugin}==irc?${server}}',
- '${if:${plugin}==irc?${info:autosort_order,${type},server,*,channel,private}}',
- '${if:${plugin}==irc?${hashless_name}}',
+ '${server}',
+ '${info:autosort_order,${type},server,*,channel,private}',
+ '${hashless_name}',
'${buffer.full_name}',
])
default_helpers = json.dumps({
- 'core_first': '${if:${buffer.full_name}!=core.weechat}',
- '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}',
- 'hashless_name': '${info:autosort_replace,#,,${buffer.name}}',
+ 'core_first': '${if:${buffer.full_name}!=core.weechat}',
+ 'irc_raw_first': '${if:${buffer.full_name}!=irc.irc_raw}',
+ 'irc_raw_last': '${if:${buffer.full_name}==irc.irc_raw}',
+ 'hashless_name': '${info:autosort_replace,#,,${info:autosort_escape,${buffer.name}}}',
+ 'script_or_plugin': '${if:${script_name}?${script_name}:${plugin}}',
})
default_signal_delay = 5
@@ -746,6 +754,17 @@ def parse_args(args, max = None):
if args is None: break
return result, args
+def on_info_escape(pointer, name, arguments):
+ result = ''
+ for c in arguments:
+ if c == '\\':
+ result += '\\\\'
+ elif c == ',':
+ result += '\\,'
+ else:
+ result +=c
+ return result
+
def on_info_replace(pointer, name, arguments):
arguments, rest = parse_args(arguments, 3)
if rest or len(arguments) < 3:
@@ -910,12 +929,45 @@ Rename a helper variable.
Swap the expressions of two helper variables in the list.
+{*white}# Info hooks{reset}
+Autosort comes with a number of info hooks to add some extra functionality to regular weechat eval strings.
+Info hooks can be used in eval strings in the form of {cyan}${{info:some_hook,arguments}}{reset}.
+
+Commas and backslashes in arguments to autosort info hooks (except for {cyan}${{info:autosort_escape}}{reset}) must be escaped with a backslash.
+
+{*white}${{info:{brown}autosort_replace{white},{cyan}pattern{white},{cyan}replacement{white},{cyan}source{white}}}{reset}
+Replace all occurrences of {cyan}pattern{reset} with {cyan}replacement{reset} in the string {cyan}source{reset}.
+Can be used to ignore certain strings when sorting by replacing them with an empty string.
+
+For example: {cyan}${{info:autosort_replace,cat,dog,the dog is meowing}}{reset} expands to "the cat is meowing".
+
+{*white}${{info:{brown}autosort_order{white},{cyan}value{white},{cyan}option0{white},{cyan}option1{white},{cyan}option2{white},{cyan}...{white}}}
+Generate a zero-padded number that corresponds to the index of {cyan}value{reset} in the list of options.
+If one of the options is the special value {brown}*{reset}, then any value not explicitly mentioned will be sorted at that position.
+Otherwise, any value that does not match an option is assigned the highest number available.
+Can be used to easily sort buffers based on a manual sequence.
+
+For example: {cyan}${{info:autosort_order,${{server}},freenode,oftc,efnet}}{reset} will sort freenode before oftc, followed by efnet and then any remaining servers.
+Alternatively, {cyan}${{info:autosort_order,${{server}},freenode,oftc,*,efnet}}{reset} will sort any unlisted servers after freenode and oftc, but before efnet.
+
+{*white}${{info:{brown}autosort_escape{white},{cyan}text{white}}}{reset}
+Escape commas and backslashes in {cyan}text{reset} by prepending them with a backslash.
+This is mainly useful to pass arbitrary eval strings as arguments to other autosort info hooks.
+Otherwise, an eval string that expands to something with a comma would be interpreted as multiple arguments.
+
+For example, it can be used to safely pass buffer names to {cyan}${{info:autosort_replace}}{reset} like so:
+{cyan}${{info:autosort_replace,##,#,${{info:autosort_escape,${{buffer.name}}}}}}{reset}.
+
+
{*white}# Description
Autosort is a weechat script to automatically keep your buffers sorted. The sort
order can be customized by defining your own sort rules, but the default should
be sane enough for most people. It can also group IRC channel/private buffers
under their server buffer if you like.
+Autosort uses a stable sorting algorithm, meaning that you can manually move buffers
+to change their relative order, if they sort equal with your rule set.
+
{*white}# Sort rules{reset}
Autosort evaluates a list of eval expressions (see {*default}/help eval{reset}) and sorts the
buffers based on evaluated result. Earlier rules will be considered first. Only
@@ -934,17 +986,6 @@ readable. They can be used in the main sort rules as variables. For example,
a helper variable named `{cyan}foo{reset}` can be accessed in a main rule with the
string `{cyan}${{foo}}{reset}`.
-{*white}# Replacing substrings{reset}
-There is no default method for replacing text inside eval expressions. However,
-autosort adds a `replace` info hook that can be used inside eval expressions:
- {cyan}${{info:autosort_replace,from,to,text}}{reset}
-
-For example, to strip all hashes from a buffer name, you could write:
- {cyan}${{info:autosort_replace,#,,${{buffer.name}}}}{reset}
-
-You can escape commas and backslashes inside the arguments by prefixing them with
-a backslash.
-
{*white}# Automatic or manual sorting{reset}
By default, autosort will automatically sort your buffer list whenever a buffer
is opened, merged, unmerged or renamed. This should keep your buffers sorted in
@@ -973,15 +1014,29 @@ structure with the following setting (modify to suit your need):
command_completion = '%(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort)'
-info_replace_description = 'Replace all occurences of `from` with `to` in the string `text`.'
-info_replace_arguments = 'from,to,text'
+info_replace_description = (
+ 'Replace all occurrences of `pattern` with `replacement` in the string `source`. '
+ 'Can be used to ignore certain strings when sorting by replacing them with an empty string. '
+ 'See /help autosort for examples.'
+)
+info_replace_arguments = 'pattern,replacement,source'
info_order_description = (
- 'Get a zero padded index of a value in a list of possible values.'
- 'If the value is not found, the index for `*` is returned.'
- 'If there is no `*` in the list, the highest index + 1 is returned.'
+ 'Generate a zero-padded number that corresponds to the index of `value` in the list of options. '
+ 'If one of the options is the special value `*`, then any value not explicitly mentioned will be sorted at that position. '
+ 'Otherwise, any value that does not match an option is assigned the highest number available. '
+ 'Can be used to easily sort buffers based on a manual sequence. '
+ 'See /help autosort for examples.'
+)
+info_order_arguments = 'value,first,second,third,...'
+
+info_escape_description = (
+ 'Escape commas and backslashes in `text` by prepending them with a backslash. '
+ 'This is mainly useful to pass arbitrary eval strings as arguments to other autosort info hooks. '
+ 'Otherwise, an eval string that expands to something with a comma would be interpreted as multiple arguments.'
+ 'See /help autosort for examples.'
)
-info_order_arguments = 'value,first,second,third,...'
+info_escape_arguments = 'text'
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
@@ -1014,6 +1069,7 @@ if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
weechat.hook_config('autosort.*', 'on_config_changed', '')
weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '')
weechat.hook_command('autosort', command_description.format(**colors), '', '', command_completion, 'on_autosort_command', '')
+ weechat.hook_info('autosort_escape', info_escape_description, info_escape_arguments, 'on_info_escape', '')
weechat.hook_info('autosort_replace', info_replace_description, info_replace_arguments, 'on_info_replace', '')
weechat.hook_info('autosort_order', info_order_description, info_order_arguments, 'on_info_order', '')
diff --git a/.weechat/sec.conf b/.weechat/sec.conf
@@ -17,8 +17,8 @@ salt = on
[data]
__passphrase__ = on
-oftc = "F41AE380E584C540A88D3F4EB4367DC0DE6B1A470718E52A80FB7A1763C17D2DC97C0D2C945C6A84D6057DE50EF774404926E4F75FC1D5D2E799936322AA2931AEF7"
-freenode = "41A501061A3B8B21D3A40C8C0ED1315F09E15A67BCD96210F618A5D8A00AF73BB0D70643774E21B92361294DD57D12B2ACB70FF4738B9542C6211B3DB322EFED696634E0C6307EA8E9CC94"
-rizon = "FF38C723CEC6081D2900F5D771E7D00348FF95F075B4287A7CDB73A5839E903EB7065B4DC0B9982AC0FF53C7345E74F1CE3BFFEF4193FA2623376EE21D9402016842"
-twitch_tv = "99C9B8C45392528FE14E3CE5D39F96A4E285A35105FC446EA44BEABA906C5A3A603A9D61C0284C431568CEFF83DAE0F520F7946ADAAC2659DE9398CD868171127CDC01B13A28F0DDC9828F914D"
-gitter = "1278EB76D09E51215F665054E380A6BEB38310E98E5B42C8CB434984498B20B60709FA0E4F692DCC93F518D55557BC92B7700999BB1AF83B19F6DBEABEE97D91396FE1CAD4D231CA913098CE5134D565E5"
+oftc = "9D1FA039D66A379AA7D53DCFE4BAFAC8AD6107EFC9817D41DD2DD3C072AD5099B392253D112012DBEFBE0772811689BCE029C782344170C363837569DC2FB943B25C"
+freenode = "28F5949463CDB0B1FDFE7865860066A80988A2894AF1A85F4A0698351F13CC3868C446131FAD0FFE9681D1CBD5F7EBCA35E8FAFBF201C21097426B9EADD66B41E3791B2D7644E04E73F760"
+rizon = "BE95CF70769C46D9D671B11561D1E6A65A7BFF13F36AB8A4617A76770931B9B7AE464649515C270766C471621754068BC1EBC2E60AF88ACCE153540BD3FAA4A239C8"
+twitch_tv = "4A174553613E9B5CF9FBAE2B4428607CDECA9C0F9FA37180AC202A1DC0E2553BA03EE058B1D5848F44B5706F5E7E889470602F715A09E8C66E4AE82609314287B78F821AC80E4D419D2158CCB1"
+gitter = "0106EC6DA83F45E33365D53381250DFF239F4C3F5C62BDA3AF11FC6FA55E2E09CAC6C7F55B8687F49167E083CAE90DE63631637F25162351D248AED71ED53AD9491C63FF17C14E014B5293AA6ED4900240"
diff --git a/.weechat/weechat.conf b/.weechat/weechat.conf
@@ -339,16 +339,16 @@ title.type = window
[layout]
default.window = "1;0;20;1;-;-"
-default.window = "2;1;0;0;irc;server.freenode"
+default.window = "2;1;0;0;irc;server.tilde.chat"
default.window = "3;1;0;0;perl;highmon"
default.current = on
[notify]
+irc.krustykrab.#krustykrab = message
[filter]
irc_smart = on;*;irc_smart_filter;*
Mikaela__r = on;irc.freenode.##abgilpqt+;*;(?-i)^__r
-krustykrab_no_hl = on;irc.krustykrab.*;no_highlight;*
[key]
ctrl-? = "/input delete_previous_char"