[IPython-user] [FWD] Ctrl-Z as EOF
Fernando.Perez at colorado.edu
Sat Oct 28 13:17:01 CDT 2006
Another one forwarded to the list, please note that you need to be subscribed
to post (we get way too much spam otherwise).
I'll reply on-list, sorry for the delay, this slipped in a pile of other email.
# ORIGINAL MESSAGE:
Ctrl-Z as EOF
Tim Roberts <timr at probo.com>
Wed, 18 Oct 2006 15:40:24 -0700
IPython <ipython-user at scipy.org>
I thought I had sent this in many months ago, but I do not see it.
After installing IPython on Win32, one has the benefit of the included
readline module at all times. However, the readline module causes one
change in behavior that Win32 Pythoners may find uncomfortable: when
using the interactive interpreter, Ctrl-Z no longer exits. Instead, it
is silently eaten up, as an undo with nothing to undo.
The following patch restores the EOF meaning when the buffer is empty,
which is the behavior I expect.
--- rlmain.py (revision 1833)
+++ rlmain.py (working copy)
@@ -673,6 +673,12 @@
+ def maybe_eof(self, e): # (C-z)
+ '''At start of line, return end of file. Otherwise, undo.'''
+ if len(self.line_buffer) == 0:
+ raise EOFError
def backward_delete_char(self, e): # (Rubout)
'''Delete the character behind the cursor. A numeric argument means
to kill the characters instead of deleting them.'''
@@ -1178,7 +1184,7 @@
- self._bind_key('Control-z', self.undo)
+ self._bind_key('Control-z', self.maybe_eof)
-- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.
More information about the IPython-user