help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Readline macro question


From: Robert E. Griffith
Subject: Re: Readline macro question
Date: Mon, 1 Aug 2022 15:39:11 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Thanks for the clarifications. FYI, it turned out well and now my cui does not print out the extra keystroke data that the macro 'returns' in addition to the user data.

--BobG

On 8/1/22 15:17, Chet Ramey wrote:
On 7/29/22 6:44 PM, Robert E. Griffith wrote:
Thanks Koichi Murase,  This opens up a whole new set of possibilities for me. For some reason I thought -x only executed external commands and I would not be able to change the environment.

Is there a way to get readline to return from inside the rl_print_line_and_clear function? Like simulating a \n? I tried appending a \n to READLINE_LINE but that did not cause it to return

That has the same effect as if you had entered ^V^M. Adding a character to
the line buffer does not make it appear in readline's input.


If not, I think I can use a macro that invokes a shell function and then has a \C-m to tell readline to return.

That is the most common idiom. You use a macro that contains the key
sequences you want to appear on readline's input, exactly as if they had
been read from the keyboard. If you bind a key sequence to a shell
command using `bind -x', you need to put that key sequence in the macro.

I can only invoke a readline function from within a macro string if that function has a keyseq bound to it?

Yes, there is no other way to invoke a bindable readline command.

    $ bind -x '"<someObscureKey>": fooFn'
    $ bind '"\eOP": "<someObscureKey>\C-m"'

Exactly.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]