[IPython-User] Making Control-D work when the line is not clear

Aaron Meurer asmeurer@gmail....
Tue Oct 18 20:49:26 CDT 2011


OK, the solution is kind of obvious.  I just need to add '"\\C-d":
"\\C-u\\C-k\\C-d"' to my readline_parse_and_bind.  Now, C-d clears the
line and then exits.  The only side effect is that it clears the
current "yank" to whatever is before my cursor, but I very rarely use
C-y, so this is no big deal for me.  The other side effect is that I
lose whatever I had typed in my terminal's scrollback, but I think I
can also live with this.

It definitely would be nice though if I could just make C-d raise
EOFError (without affecting the input text at all).  Would it be
possible to make it so readline commands can execute arbitrary code
internally?  I don't know enough about the architecture of IPython to
know if this would be possible or not.

Aaron Meurer

On Tue, Oct 18, 2011 at 6:28 PM, Fernando Perez <fperez.net@gmail.com> wrote:
> On Tue, Oct 18, 2011 at 5:17 PM, Aaron Meurer <asmeurer@gmail.com> wrote:
>>
>> All I found was the binding vi-eof-maybe, which I couldn't find any
>> documentation on, but if I set control-D to do it, it acts like enter
>> if text is on the line and like control D otherwise.  It's hard to
>> tell if this is what it's supposed to do or if IPython is just not
>> recognizing the EOF with other text.
>
> We don't look at the line, we simply get an EOFError exception from a
> raw_input() call.  So if it's not exiting, it's because readline isn't
> propagating an EOF condition.
>
> Cheers,
>
> f
>


More information about the IPython-User mailing list