Fix TAB completion under libedit (uv/python-build-standalone)

TAB completion silently failed on interpreters linked against libedit
instead of GNU readline (e.g. the uv-managed python-build-standalone
interpreters now common on Debian/KDE setups). libedit ignores the GNU
readline binding 'tab: complete', so pressing TAB merely inserted a
literal tab character.

Detect the libedit backend via readline.__doc__ and emit the
libedit-specific binding 'bind ^I rl_complete' instead, keeping
'tab: complete' for genuine GNU readline.

Bump version to 2026.06.06.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Karl Voit 2026-06-06 23:00:44 +02:00
parent a763d7cd5e
commit 2993ab9443
2 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
PROG_VERSION = u"Time-stamp: <2025-05-14 16:02:13 vk>" PROG_VERSION = u"Time-stamp: <2026-06-06 12:00:00 vk>"
# TODO: # TODO:
# * fix parts marked with «FIXXME» # * fix parts marked with «FIXXME»
@ -404,8 +404,14 @@ def main():
# Register our completer function # Register our completer function
readline.set_completer(SimpleCompleter(vocabulary).complete) readline.set_completer(SimpleCompleter(vocabulary).complete)
# Use the tab key for completion # Use the tab key for completion. The binding syntax differs
readline.parse_and_bind('tab: complete') # between GNU readline and libedit (the latter is used e.g. by
# uv-managed / python-build-standalone interpreters). Without the
# libedit-specific binding, TAB just inserts a literal tab.
if 'libedit' in (readline.__doc__ or ''):
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')
tabcompletiondescription = '; complete ' + str(len(vocabulary)) + ' words with TAB' tabcompletiondescription = '; complete ' + str(len(vocabulary)) + ' words with TAB'

View file

@ -1,7 +1,7 @@
[project] [project]
name = "appendfilename" name = "appendfilename"
version = "2026.05.24.1" version = "2026.06.06.1"
description = "Intelligent appending text to file names, considering file extensions and file tags" description = "Intelligent appending text to file names, considering file extensions and file tags"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
readme = { file = "README.org", content-type = "text/plain" } readme = { file = "README.org", content-type = "text/plain" }