Title: Addition to readline module to get dictionary of keystrokes and commands
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: MLModel, anand.jeyahar, asvetlov, eric.araujo, steven.daprano
Priority: normal Keywords:

Created on 2010-04-21 20:02 by MLModel, last changed 2012-10-11 20:59 by anand.jeyahar.

Messages (3)
msg103905 - (view) Author: Mitchell Model (MLModel) Date: 2010-04-21 20:02
Requesting a function to be added to the readline module that produces a dictionary of the current keystroke bindings Also, one to write it to a file in readline init file format. This would be a big help for people interested in customizing the behavior of readline inside Python.
msg172090 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2012-10-05 15:05
A question came up on Python-ideas about readline apparently missing a standard function. See:

For debugging issues with readline, it would be be very useful to be able to query the current set of bindings. This would also help people avoid accidentally over-writing existing bindings.

I suggest emulating the three bash commands:

bind -p  # List functions and bindings in a form that can be reused as input.
bind -v  # As above for variable names and values.
bind -s  # As above for macros and values.
msg172692 - (view) Author: anand jeyahar (anand.jeyahar) Date: 2012-10-11 20:59
Here's what the original maintainer chet romney had to say about this functionality not being a part of readline, and should be implemented by the calling application. From Chet Ramey:
The answer is that this is very similar to the operate-and-get-next
feature bash adds to the readline interface. I am not inclined to add this to
readline in its current form because it manipulates state managed by
the calling application (rl_startup_hook) and requires that state to be
kept between calls to readline(). It's a feature that should be provided
by the calling application -- it's implementation is not complicated.
Date User Action Args
2012-10-11 20:59:37anand.jeyaharsetmessages: + msg172692
2012-10-11 08:45:39asvetlovsetnosy: + asvetlov
2012-10-11 08:25:12anand.jeyaharsetnosy: + anand.jeyahar
2012-10-05 15:05:09steven.dapranosetnosy: + steven.daprano

messages: + msg172090
versions: + Python 3.4, - Python 3.2
2010-07-11 14:38:42BreamoreBoysetversions: - Python 2.7
2010-04-21 20:05:28eric.araujosetnosy: + eric.araujo

versions: - Python 2.6, Python 3.1
2010-04-21 20:02:06MLModelcreate