Re: Readline and/or easy command line history access [message #66231] |
Tue, 28 April 2009 07:39  |
Keflavich
Messages: 19 Registered: May 2008
|
Junior Member |
|
|
> 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?
I'm interested. Even tab completion for structs would be a huge
improvement.
Adam
|
|
|
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.
|
|
|
Re: Readline and/or easy command line history access [message #66238 is a reply to message #66235] |
Mon, 27 April 2009 15:08   |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
On Apr 27, 4:39 pm, Christopher Thom <ct...@oddjob.uchicago.edu>
wrote:
> Quoth JDS:
>
>> As for Matthew's customization, recent versions of Emacs have a new
>> command C-c M-r to do just what this .emacs stuff does (so it's no
>> longer needed). For an easier binding, I'd probably stay away from
>> the up arrow for this (multi-line editing is built-in to the coming
>> IDLWAVE release), but might try:
>
> Wait, there's a new IDLWAVE version? When is the release?
>
>> P.S. IDLWAVE is now working with the upcoming IDL help system, with
>> direct linking to keyword help sections, etc.
>
> By upcoming help system, do you mean the one that is currently in 7.0, or
> will they change the help system once again? I'm still using the 6.4 era
> help system, but would *love* a reintegrated idlwave/help system!!
It's the same help system, but slightly tweaked to allow IDLWAVE to
work better with it. Once 7.1 is out, I'll make the release. I've
also accumulated a couple of years of small fixes/additions. If
anyone is testing the IDL pre-release and would like to test IDLWAVE
with it, let me know.
JD
|
|
|
Re: Readline and/or easy command line history access [message #66242 is a reply to message #66238] |
Mon, 27 April 2009 13:39   |
Christopher Thom
Messages: 66 Registered: October 2006
|
Member |
|
|
Quoth JDS:
> As for Matthew's customization, recent versions of Emacs have a new
> command C-c M-r to do just what this .emacs stuff does (so it's no
> longer needed). For an easier binding, I'd probably stay away from
> the up arrow for this (multi-line editing is built-in to the coming
> IDLWAVE release), but might try:
Wait, there's a new IDLWAVE version? When is the release?
> P.S. IDLWAVE is now working with the upcoming IDL help system, with
> direct linking to keyword help sections, etc.
By upcoming help system, do you mean the one that is currently in 7.0, or
will they change the help system once again? I'm still using the 6.4 era
help system, but would *love* a reintegrated idlwave/help system!!
cheers
chris
|
|
|
Re: Readline and/or easy command line history access [message #66245 is a reply to message #66242] |
Mon, 27 April 2009 12:55   |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
On Apr 27, 9:30 am, sav...@nsidc.org wrote:
> Adam,
>
> Keflavich <keflav...@gmail.com> writes:
>> 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.
>
> I'm not sure what you're using either the IDE or idlwave-shell, but JD Smith
> wrote idlwave-shell routines for exactly this. Just drop these into you
> .emacs file.
>
> Hope this helps.
>
> Matt
>
> ;; Set up some functions that we need to define before we can use them.
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;
>
> ;; the actual author is
> ;; JD Smith <jdsmith@****.edu>
>
> ;; These commands make the up/down arrows do regular expression searches that
> ;; include whatever is already on the idlwave-shell's command line.
> ;; So if you did a plot command ten commands ago, you would put plot on the
> ;; shell line.
> ;; IDL> plot,
> ;; and then hit the up arrow* to get to the command
> ;; *(if you bind this commmand to the up arrow like we do later in this file)
>
> (defvar jds-search-regexp nil)
>
> (defun jds-search-pre-command-hook ()
> (unless (or (eq this-command 'jds-history-search-up)
> (eq this-command 'jds-history-search-down))
> (remove-hook 'pre-command-hook 'jds-search-pre-command-hook t)
> (setq jds-search-regexp nil)))
>
> (defun jds-history-search (dir)
> (when (null jds-search-regexp)
> (let ((str (buffer-substring (point) (save-excursion (comint-bol nil)
> (point)))))
> (if (or (string= str "") (not (looking-at "\\s-*$")))
> (setq jds-search-regexp ".")
> ;; This is what JDS had.
> ;; (setq jds-search-regexp (concat "^" (regexp-quote str)))
> (setq jds-search-regexp (regexp-quote str)))
> (add-hook 'pre-command-hook 'jds-search-pre-command-hook nil t)))
> (comint-previous-matching-input jds-search-regexp dir))
>
> (defun jds-history-search-up ()
> (interactive)
> (jds-history-search 1))
>
> (defun jds-history-search-down ()
> (interactive)
> (jds-history-search -1))
This a just a subset of the command line searching already built into
IDLWAVE (courtesy of COMINT mode). I use M-r to search back using any
regular expression, C-c C-l to show a selectable list of prior
commands, middle click on any old input line in the shell to paste it
to the current, etc.
As for Matthew's customization, recent versions of Emacs have a new
command C-c M-r to do just what this .emacs stuff does (so it's no
longer needed). For an easier binding, I'd probably stay away from
the up arrow for this (multi-line editing is built-in to the coming
IDLWAVE release), but might try:
(add-hook 'idlwave-shell-mode-hook
(lambda ()
(local-set-key [M-up] 'comint-previous-matching-input-from-input)
(local-set-key [M-down] 'comint-next-matching-input-from-input)))
to have Meta-up and Meta-down do this. Note that it works on input up
to the cursor, so position your cursor on a long command to cap the
section you want to search, and fire. Successive searches will do the
right thing.
JD
P.S. IDLWAVE is now working with the upcoming IDL help system, with
direct linking to keyword help sections, etc.
|
|
|
Re: Readline and/or easy command line history access [message #66248 is a reply to message #66245] |
Mon, 27 April 2009 08:42   |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Gins wrote:
> On Apr 27, 7:30 am, sav...@nsidc.org wrote:
>> Adam,
>>
>> Keflavich <keflav...@gmail.com> writes:
>>> 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.
>> I'm not sure what you're using either the IDE or idlwave-shell, but JD Smith
>> wrote idlwave-shell routines for exactly this. Just drop these into you
>> .emacs file.
>>
>> Hope this helps.
>>
>> Matt
>
> Thanks Matt, but I use the command line only. I'm a VI user in
> general, so the learning curve to get emacs running would be a bit
> extreme.
>
>
>
> Mike, the link you posted didn't have any code posted, but it linked
> to something called 'tecla' that appeared to have something like what
> I wanted. However, I tried it and it doesn't work as advertised. It
> also dies on a keyboard interrupt, making it pretty useless.
>
> Where can I find out more about callable IDL? It sounds pretty
> interesting, but a quick through the help only told me what it was,
> not how to use it. Do you think it's feasible to use, e.g., the bash
> command line as a frontend for IDL using callable idl? That seems
> like the ideal situation, though I'm not sure it makes sense in terms
> of keeping variables accessible to a session.
>
> And yes, my intent is to have an IPython equivalent for IDL, though
> even the default python terminal includes readline support.
>
> Adam
Callable IDL is the internal C API for IDL for writing a C program that
calls into IDL. This goes the opposite direction of a DLM; a DLM is a C
module using the internal API called from IDL.
Check the External Developer Guide in the online help for more information.
Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
|
|
|
Re: Readline and/or easy command line history access [message #66249 is a reply to message #66248] |
Mon, 27 April 2009 08:31   |
Keflavich
Messages: 19 Registered: May 2008
|
Junior Member |
|
|
On Apr 27, 7:30 am, sav...@nsidc.org wrote:
> Adam,
>
> Keflavich <keflav...@gmail.com> writes:
>> 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.
>
> I'm not sure what you're using either the IDE or idlwave-shell, but JD Smith
> wrote idlwave-shell routines for exactly this. Just drop these into you
> .emacs file.
>
> Hope this helps.
>
> Matt
Thanks Matt, but I use the command line only. I'm a VI user in
general, so the learning curve to get emacs running would be a bit
extreme.
Mike, the link you posted didn't have any code posted, but it linked
to something called 'tecla' that appeared to have something like what
I wanted. However, I tried it and it doesn't work as advertised. It
also dies on a keyboard interrupt, making it pretty useless.
Where can I find out more about callable IDL? It sounds pretty
interesting, but a quick through the help only told me what it was,
not how to use it. Do you think it's feasible to use, e.g., the bash
command line as a frontend for IDL using callable idl? That seems
like the ideal situation, though I'm not sure it makes sense in terms
of keeping variables accessible to a session.
And yes, my intent is to have an IPython equivalent for IDL, though
even the default python terminal includes readline support.
Adam
|
|
|
|
|
Re: Readline and/or easy command line history access [message #66339 is a reply to message #66231] |
Fri, 01 May 2009 03:48  |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
Gins wrote:
>> 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?
>
>
> I'm interested. Even tab completion for structs would be a huge
> improvement.
>
> Adam
Adam,
I'll try to do something over the weekend.
Thanks,
Allan
|
|
|
Re: Readline and/or easy command line history access [message #66346 is a reply to message #66231] |
Thu, 30 April 2009 14:35  |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On Apr 28, 10:39 am, Gins <keflav...@gmail.com> wrote:
>> 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?
>
> I'm interested. Even tab completion for structs would be a huge
> improvement.
>
> Adam
I'd suggest writing your commands into your favorite text
editor and copy and pasting them into the IDL command line
(one or more at a time).
I found out that this simple system works very well for me...
Ciao,
Paolo
|
|
|