Skip to content

Commit 54cd69c

Browse files
zaephflashcode
authored andcommitted
go.py 3.1.0: add regexp_search option, add cancel with /window scroll_bottom
Update changelog
1 parent d67b7e4 commit 54cd69c

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

python/go.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3+
# Copyright (C) 2025 Leo Vivier <zaeph@zaeph.net>
34
# Copyright (C) 2009-2023 Sébastien Helleu <flashcode@flashtux.org>
45
# Copyright (C) 2010 m4v <lambdae2@gmail.com>
56
# Copyright (C) 2011 stfn <stfnmd@googlemail.com>
@@ -21,6 +22,8 @@
2122
#
2223
# History:
2324
#
25+
# 2025-10-17, Leo Vivier <zaeph@zaeph.net>:
26+
# version 3.1.0: add regexp search and cancellation with scroll_bottom
2427
# 2024-05-30, Sébastien Helleu <flashcode@flashtux.org>:
2528
# version 3.0.1: refresh buffer input at the end of search
2629
# 2024-05-30, Sébastien Helleu <flashcode@flashtux.org>:
@@ -105,7 +108,7 @@
105108

106109
SCRIPT_NAME = 'go'
107110
SCRIPT_AUTHOR = 'Sébastien Helleu <flashcode@flashtux.org>'
108-
SCRIPT_VERSION = '3.0.1'
111+
SCRIPT_VERSION = '3.1.0'
109112
SCRIPT_LICENSE = 'GPL3'
110113
SCRIPT_DESC = 'Quick jump to buffers'
111114

@@ -148,6 +151,9 @@
148151
'color_name_highlight_selected': (
149152
'red,brown',
150153
'color for highlight in a selected buffer name'),
154+
'regexp_search': (
155+
'off',
156+
'search buffer matches using regexps'),
151157
'fuzzy_search': (
152158
'off',
153159
'search buffer matches using approximation'),
@@ -356,7 +362,10 @@ def go_matching_buffers(strinput):
356362
full_name = '%s.%s' % (
357363
weechat.infolist_string(infolist, 'plugin_name'),
358364
weechat.infolist_string(infolist, 'name'))
359-
matching = name.lower().find(strinput) >= 0
365+
if go_option_enabled('regexp_search'):
366+
matching = bool(re.search(strinput, name, re.IGNORECASE))
367+
else:
368+
matching = name.lower().find(strinput) >= 0
360369
if not matching and strinput[-1] == ' ':
361370
matching = name.lower().endswith(strinput.strip())
362371
if not matching and go_option_enabled('fuzzy_search'):
@@ -546,6 +555,10 @@ def go_command_run_buffer(data, buf, command):
546555

547556
def go_command_run_window(data, buf, command):
548557
"""Function called when a command "/window xxx" is run."""
558+
if command == '/window scroll_bottom':
559+
# cancel selection and return to input
560+
go_end(buf)
561+
return weechat.WEECHAT_RC_OK_EAT
549562
return weechat.WEECHAT_RC_OK_EAT
550563

551564

0 commit comments

Comments
 (0)