auto-completion history

2005-02-25 Thread porterboy
Hi Folks,

I have auto-completion set up in my python interpreter so that if I
hit the tab key it will complete a variable or a python command*. eg.
if I type
>>> imp
and if I then hit the tab key, the interpreter will complete it to...
>>> import

Now, I also use Matlab at the command line a lot and it has a nice
additional auto-completion feature, whereby, if you type a few letters
and hit the up-arrow, it will go back to the last command you typed
that began with those letters. If you keep hitting up-arrow it will
cycle through all the commands you typed beginning with these letters.
eg. if I type...

>>> import datetime
>>> import sys
>>> today = datetime.date.today()
>>> imp

After typing the last imp I hit up-arrow once I would like the history
to return to
>>> import sys
and if I hit twice, I would like to go to
>>> import datetime

Does a feature like this already exist in python???

Thanks

The PorterBoy - "Lovely day for a Guinness" 

ps...
* If you are unsure how to set up auto completion (UNIX only) ...

1. Include this line in your .tcshrc file (or equivalent in .bashrc):
   setenv PYTHONSTARTUP "$HOME/.pythonrc.py"
2. In the file ~/.pythonrc.py include the lines:
   import rlcompleter, readline
   readline.parse_and_bind('tab: complete')
   del rlcompleter, readline
3. For the effect to work, open a new terminal, and type python. If
you do not fire up a new session, python has no way to become aware of
your changes.
-- 
http://mail.python.org/mailman/listinfo/python-list


automatic nesting and indentation in emacs

2005-02-25 Thread porterboy
CONTEXT:
I am using Emacs to edit Python code and sometimes also Matlab code.
When I hit  in a loop of some sort, Emacs usually gets the
nesting indentation right, which is particularly important in Python.
To ensure this I have used python-mode.el and matlab.el modes in
emacs.

QUESTION:
If I suddenly decide I want an outer loop, do I have to manually
readjust the indentation of all the inner loops? Or can emacs do it
automatically? I know the Matlab in-built editor has a tool called
"smart-indent" which will automatically align highlighted text to have
the correct indentation. Does Emacs have something similar?

Thanks
The Porterboy - "Lovely day for a Guinness"
-- 
http://mail.python.org/mailman/listinfo/python-list