readline, rlcompleter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • michele.simionato@gmail.com

    #1

    readline, rlcompleter

    This a case where the documentation is lacking. The standard library
    documentation
    (http://www.python.org/dev/doc/devel/...completer.html) gives
    this example
    try:
    import readline
    except ImportError:
    print "Module readline not available."
    else:
    import rlcompleter
    readline.parse_ and_bind("tab: complete")

    but I don't find a list of recognized key bindings. For instance, can I
    would
    like to bind shift-tab to rlcompleter, is that possible? Can I use
    function
    keys? I did various attempt, but I did not succed :-(
    Is there any readline-guru here with some good pointers?
    Michele Simionato

  • David M. Cooke

    #2
    Re: readline, rlcompleter

    michele.simiona to@gmail.com writes:
    [color=blue]
    > This a case where the documentation is lacking. The standard library
    > documentation
    > (http://www.python.org/dev/doc/devel/...completer.html) gives
    > this example
    > try:
    > import readline
    > except ImportError:
    > print "Module readline not available."
    > else:
    > import rlcompleter
    > readline.parse_ and_bind("tab: complete")
    >
    > but I don't find a list of recognized key bindings. For instance, can I
    > would
    > like to bind shift-tab to rlcompleter, is that possible? Can I use
    > function
    > keys? I did various attempt, but I did not succed :-(
    > Is there any readline-guru here with some good pointers?
    > Michele Simionato[/color]

    Basically, you could use any key sequence that is sent to the terminal. So
    shift-tab is out (that's not sent as a key to any terminal program).

    Function keys would have to be specified as the key sequence sent by a
    function key ("\e[11~" for F1, for instance).

    Have a look at the readline info page, or the man page. The syntax of
    readline.parse_ and_bind is the same as that of an inputrc file.

    --
    |>|\/|<
    /--------------------------------------------------------------------------\
    |David M. Cooke
    |cookedm(at)phy sics(dot)mcmast er(dot)ca

    Comment

    • python

      #3
      Re: readline, rlcompleter

      There is a pretty complete (no pun intended) example in the standard
      cmd module

      <http://docs.python.org/lib/module-cmd.html>

      Check file cmd.py in your Python installation .../lib/pythonX.Y/cmd.py,
      specifically the methods Cmd.preloop() and Cmd.complete().

      Another, more elaborate example is in PySH at

      <http://unixnaut.com/skills/Languages/python/pysh.py>


      /Jean Brouwers

      PS) A version of readline for Windows is here

      <http://newcenturycompu ters.net/projects/readline.html>



      michele.simiona to@gmail.com wrote:[color=blue]
      > This a case where the documentation is lacking. The standard library
      > documentation
      > (http://www.python.org/dev/doc/devel/...completer.html)[/color]
      gives[color=blue]
      > this example
      > try:
      > import readline
      > except ImportError:
      > print "Module readline not available."
      > else:
      > import rlcompleter
      > readline.parse_ and_bind("tab: complete")
      >
      > but I don't find a list of recognized key bindings. For instance, can[/color]
      I[color=blue]
      > would like to bind shift-tab to rlcompleter, is that possible? Can I[/color]
      use[color=blue]
      > function keys? I did various attempt, but I did not succed :-(
      > Is there any readline-guru here with some good pointers?
      > Michele Simionato[/color]

      Comment

      • Mark Asbach

        #4
        Re: readline, rlcompleter

        Hi Michele,
        [color=blue]
        > readline.parse_ and_bind("tab: complete")
        >
        > but I don't find a list of recognized key bindings.[/color]

        The python readline module just wraps the GNU Readline Library, so you
        need to check the manuals of the latter. It's not that much text and
        you'll find the information needed at:



        Yours,

        Mark

        Comment

        Working...