Re: Readline and/or easy command line history access [message #66235 is a reply to message #66231] |
Tue, 28 April 2009 01:53   |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
Michael Galloy wrote:
> Keflavich wrote:
>
>> Hi IDL folks,
>> I've asked a few experts but never received a satisfactory
>> answer. Is there any sort of readline support in IDL more advanced
>> than a simple command history? I can hit 'up' at the command line to
>> retrieve old commands, but this is tedious and sometimes difficult in
>> large interactive sessions. On the bash command line and in GNU-
>> readline supporting interfaces (e.g. python), it's possible to do
>> things like type the first few characters of a command and use 'up' to
>> scroll through commands in history that begin with those characters.
>>
>> On the bash command line, <control-r>, or 'reverse-i-search', is
>> approximately equivalent.
>>
>> The problem is that I use a lot of commands that are rather long -
>> e.g. plot commands to subsets of structs - and would prefer not to
>> retype them too often. Also, I often use multi-line commands for
>> procedures and functions that require a lot of keyword inputs, and
>> those are very painful to scroll through.
>
>
> There was this work by Allan Whiteford:
>
> http://bit.ly/Azxu7
>
> I think it should be possible to make your own IDL command line now in
> IDL 6.4+ using Callable IDL. Making something analogous to IPython for
> Python would be very useful.
>
> Mike
At the time I set an arbitrary limit and said that if five people were
interested I'd go to the effort of packaging it up in a form I'd be
happy to distribute. Unfortunately (perhaps fortunately) four people
expressed interest so I never bothered :).
My code is essentially a editline (hence readline if you prefer[1])
front end for IDL using callable IDL but running inside a DLM. This
caused some problems since the IDL interpreter isn't re-entrant but
nothing too serious. Writing a standalone application (i.e. non-DLM) is
harder if you want to be able to launch widgets and plot things. It
would require either a look at the IDL source or someone smarter (or
more patient) than me to figure out what all the longjmp type-calls (or
whatever they are using) are.
Anyway, if I compile the code using readline then I do get
reverse-i-search functionality as the OP asked for - editline doesn't
seem to do have that feature but I've never investigated it much as the
main thing I wanted was tab completion which works on:
Variable names
Structure tags
Compiled procedures/functions
Method names
Filenames
and contextually works out what it should complete when. It doesn't do
keyword completion or completion of non-compiled procedures since the
code isn't nearly as advanced as IDLWAVE.
All I really wanted was tab completion on structure tags and then
eventually method names when I had to start dealing with objects.
There are a few things I'd want to do to the code before making it
available publically. Is there sufficient interest for me to package
this up?
Thanks,
Allan
[1] I'm only discussing the trivial technical modifications necessary to
switch from editline to readline, this statement does not constitute
legal advice.
|
|
|