[Pythonmac-SIG] CommandHistoryPatch

Oliver Steele steele@cs.brandeis.edu
Sat, 16 Oct 1999 11:54:02 -0400


CommandHistoryPatch.py adds to the Python Interactive window of MacPython 
1.5.2c1 IDE two features that I've found useful in command shells and in
other IDEs.  (It probably works with earlier versions of MacPython, but I
haven't tested it with any versions other than 1.5.2c1.)

(1) Option-p (pi) replaces the current input text (everything after the
">>> " or "... " prompt) with the previous input text (the line or lines
after the previous ">>> " or "... " prompt).  Typing option-p repeatedly
cycles through all the previous inputs, from last to first, and then from
last to first again.

(2) Pressing the Return key to execute the entire input text, no matter
where in the text the selection is positioned.  For example, typing Return
when the insertion point is between the "+" and the "2" in the line
  >>> 1+2
prints the result "3", instead of ignoring the "2", asking for a
continuation line, and then displaying a message about a syntax error.

The patch can be downloaded from
<http://www.cs.brandeis.edu/~steele/sources/python.html>.

I recommend we think about including this in the IDE at some point, but it's
probably useful for folks to play around with it and weigh in on how well it
works for them first.  In particular, I'm unsure about option-p for the
"previous" command (it keeps you from typing pi, and the natural pair for
"next", option-n, doesn't easily produce a capturable keystroke), although
each alternative has its own issues (for example, cmd-p would work, but then
cmd-n is already taken...).