python / cpython

The Python programming language
https://www.python.org
Other
63.38k stars 30.35k forks source link

readline: consecutive rl_kill_word do not append #71868

Open ea1e44e8-1b00-4e2f-b93c-7846e7b52f06 opened 8 years ago

ea1e44e8-1b00-4e2f-b93c-7846e7b52f06 commented 8 years ago
BPO 27681
Nosy @vadmium, @qsantos

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['library', 'expert-IO'] title = 'readline: consecutive rl_kill_word do not append' updated_at = user = 'https://github.com/qsantos' ``` bugs.python.org fields: ```python activity = actor = 'qsantos' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)', 'IO'] creation = creator = 'qsantos' dependencies = [] files = [] hgrepos = [] issue_num = 27681 keywords = [] message_count = 3.0 messages = ['271964', '271966', '271967'] nosy_count = 2.0 nosy_names = ['martin.panter', 'qsantos'] pr_nums = [] priority = 'normal' resolution = 'third party' stage = None status = 'open' superseder = None type = None url = 'https://bugs.python.org/issue27681' versions = ['Python 2.7', 'Python 3.5'] ```

ea1e44e8-1b00-4e2f-b93c-7846e7b52f06 commented 8 years ago

In readline, "kill" basically means "cut" and "yank", "paste. When killing twice in a row, it tries to group the kills. This can be shown to work with rl_unix_word_rubout; with the default emacs keymap, type:

>> hello world

Then hit ^W (Control+W, rl_unix_word_rubout) twice, then ^Y (Control+Y, rl_yank). You should get back the two words.

Now, using rl_backward_kill_word (Meta ^H), twice, yanking only puts back the last killed word (here, "hello "). With rl_kill_word (^A for start of line, then ^D), twice, yanking also puts back only the last killed word (here, " world"). The expected behavior is to get back both words (there, "hello world").

The behavior appears in both CPython's REPL (2.7 and 3.5 at least) and in the readline module. Other programs (bash, pypy, irb) that use readline show the expected behavior, as well as zsh (with its own implementation of readline).

Granted, I can not really imagine and issue with a lowest priority.

vadmium commented 8 years ago

GDB also seems affected. The significance of this is it makes me suspect a bug in Readline’s callback-based “alternative interface”, as opposed to the simpler blocking interface. I know Python and GDB both use the callback API, and that Bash doesn’t.

You might have more luck taking this directly to Gnu Readline: https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html#Bugs

ea1e44e8-1b00-4e2f-b93c-7846e7b52f06 commented 8 years ago

I had not thought of checking gdb. Thanks for the information, I will look into that!