readline tab completion -- the whole line?

Discussion in 'Ruby' started by Kero, Dec 29, 2005.

  1. Kero

    Kero Guest

    Recently, a thread about tab completion showed me
    Readline.completion_proc = Proc new {|prefix| ... }

    and while that is an improvement for my little apps, I wonder whether the
    block can get more than the current word on the line, i.e.
    little> save lo[TAB]
    gives me the prefix (passed as param to the block) "lo", not e.g. "save lo"
    or ["save", "lo"] so basically I can not use the context in a nice way (use
    "localfile" in this case, not "load").

    I figured I can do
    Readline.basic_word_break_characters = ""
    after which I get the entire line (which I can then #split by hand).

    Am I missing something? Is readline (despite its weight) so primitive?

    Bye,
    Kero.
     
    Kero, Dec 29, 2005
    #1
    1. Advertising

  2. Currently, completion_proc seems to only be able to handle the current
    "word" being processed. You could hack basic_word_break_characters so
    that the whole line is fed into completion_proc, and do any string
    massaging in there, as you stated.

    There is somewhere in the ruby-talk archives a patch to have a
    two-argument version of completion_proc, but it doesn't seem to have
    gotten to the official distribution. It would have given both the
    current line and the current word.

    So yes, I guess your last judgment isn't completely wrong.

    DCA
     
    Daniel Calvelo, Dec 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edvard Majakari
    Replies:
    0
    Views:
    469
    Edvard Majakari
    Nov 18, 2003
  2. News Sympatico
    Replies:
    0
    Views:
    317
    News Sympatico
    May 21, 2005
  3. ziggs
    Replies:
    2
    Views:
    193
    Henry Robinson
    Apr 21, 2004
  4. Steven D'Aprano
    Replies:
    1
    Views:
    215
    Chris Angelico
    Nov 13, 2011
  5. Bill Atkins
    Replies:
    6
    Views:
    143
    Dave Baldwin
    Aug 11, 2005
Loading...

Share This Page