comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: autocomplete
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: autocomplete [message #43304] Tue, 05 April 2005 16:25 Go to next message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 01 Apr 2005 15:56:08 +0200, maarten wrote:

> Thanks this is a major improvement!
> Is there however another option for the 'arrow up' question, because I
> am not really happy with M-r and having to repeat that many times.

I just discovered C-c M-r, which is comint's way of doing a search for
previous input based on the existing input, without any prompting.
This function `comint-previous-matching-input-from-input' could
probably be bound to up-arrow in the shell and give you what you want
without resorting to that hack of mine Matt mentioned.

JD
Re: autocomplete [message #43317 is a reply to message #43304] Mon, 04 April 2005 07:13 Go to previous messageGo to next message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
Maarten,

> I have however one (last) question that is not an IDL question, how do I
> increase the list of the history of commands. Right now it is set on 30 which
> is obviously not enough.

I have this in my loadfile.

(setq comint-input-ring-size 1024)


;comint-input-ring-size's value is 1024

;Documentation:
;Size of input history ring.



hth,
Matt




--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
Re: autocomplete [message #43319 is a reply to message #43317] Mon, 04 April 2005 01:45 Go to previous messageGo to next message
maarten is currently offline  maarten
Messages: 30
Registered: April 2002
Member
maarten wrote:
> Hello everybody,
>
> I was wondering whether it is possible to have some sort of
> autocompletion at the IDL prompt in Linux. When working in Matlab for
> example typing the first few letters of a command or file and pressing
> 'tab' results in automatic completing the rest. (the same way the
> xterminal works). Another very useful feature is that when the first few
> letters are typed, pressing 'arrow up' results in only history results
> that start with these letters. Is it possible to have this implemented
> in IDL, or are there any other 'terminal' like command lines that offer
> these features in which IDL can be run. At the moment I am running IDL
> at the command line under Linux.
> I hope someone knows whether this is possible, or that RSINC is working
> on something like this. Because in my opinion it would greatly improve IDL.
>
> Cheers maarten.
>

This is something I wished I knew it a few years ago, it is really
making life easy!
I have however one (last) question that is not an IDL question, how do I
increase the list of the history of commands. Right now it is set on 30
which is obviously not enough.
Sorry for asking emacs questions on the idl forum

cheers maarten
Re: autocomplete [message #43323 is a reply to message #43319] Fri, 01 April 2005 07:10 Go to previous messageGo to next message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
maarten <user@domain.invalid> writes:

> Thanks this is a major improvement!
> Is there however another option for the 'arrow up' question, because I am not
> really happy with M-r and having to repeat that many times.

Yeah, JD Smith implemented this for me a while ago.

put this in your .emacs to add up and down arrow functionality in the shell
;;********************************************************** ************
(add-hook 'idlwave-shell-mode-hook
(lambda ()
;; A cheat for quick function-only lookup in the shell.
(local-set-key [up] 'jds-history-search-up)
(local-set-key [down] 'jds-history-search-down)))

;;********************************************************** ************


Then make sure these functions are available I put them into another file and
make sure that's loaded at start up before I add the hooks above.

;;********************************************************** ************
;; Make arrows search on text between point and process-mark
(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 should help.

Matt

--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
Re: autocomplete [message #43324 is a reply to message #43323] Fri, 01 April 2005 05:56 Go to previous messageGo to next message
maarten is currently offline  maarten
Messages: 30
Registered: April 2002
Member
Thanks this is a major improvement!
Is there however another option for the 'arrow up' question, because I
am not really happy with M-r and having to repeat that many times.

cheers maarten

maarten wrote:
> Hello everybody,
>
> I was wondering whether it is possible to have some sort of
> autocompletion at the IDL prompt in Linux. When working in Matlab for
> example typing the first few letters of a command or file and pressing
> 'tab' results in automatic completing the rest. (the same way the
> xterminal works). Another very useful feature is that when the first few
> letters are typed, pressing 'arrow up' results in only history results
> that start with these letters. Is it possible to have this implemented
> in IDL, or are there any other 'terminal' like command lines that offer
> these features in which IDL can be run. At the moment I am running IDL
> at the command line under Linux.
> I hope someone knows whether this is possible, or that RSINC is working
> on something like this. Because in my opinion it would greatly improve IDL.
>
> Cheers maarten.
>
Re: autocomplete [message #43342 is a reply to message #43324] Wed, 30 March 2005 08:30 Go to previous messageGo to next message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 30 Mar 2005 10:48:11 +0200, maarten wrote:

> Hello everybody,
>
> I was wondering whether it is possible to have some sort of
> autocompletion at the IDL prompt in Linux. When working in Matlab for
> example typing the first few letters of a command or file and pressing
> 'tab' results in automatic completing the rest. (the same way the
> xterminal works). Another very useful feature is that when the first few
> letters are typed, pressing 'arrow up' results in only history results
> that start with these letters. Is it possible to have this implemented
> in IDL, or are there any other 'terminal' like command lines that offer
> these features in which IDL can be run. At the moment I am running IDL
> at the command line under Linux.
> I hope someone knows whether this is possible, or that RSINC is working
> on something like this. Because in my opinion it would greatly improve IDL.
>

As David points, out the Emacs mode IDLWAVE (idlwave.org) does this for
you, and more. In fact, the number of things IDLWAVE can complete is
quite remarkable, far more than the shell provide. From the IDLWAVE
manual):

The completion function is context sensitive and figures out what to
complete based location of the point. Here are example lines and what
M-TAB would try to complete when the cursor is on the position marked
with a `_':



plo_ Procedure
x = a_ Function
plot,xra_ Keyword of plot procedure
plot,x,y,/x_ Keyword of plot procedure
plot,min(_ Keyword of min function
obj -> a_ Object method (procedure)
a(2,3) = obj -> a_ Object method (function)
x = obj_new('IDL_ Class name
x = obj_new('MyCl',a_ Keyword to Init method in class MyCl
pro A_ Class name
pro _ Fill in Class:: of first method in this file
!v_ System variable
!version.t_ Structure tag of system variable
self.g_ Class structure tag in methods
state.w_ Structure tag, if tag completion enabled
name = 'a_ File name (default inside quotes)

When in the shell, completing:

c->[Tab] will actually query the shell for the type of object "c" is,
and based completions on that. In the next release, the same will be
true of structure tag completion in the shell.

Regarding the "up-arrow" trick in the shell, I posted some code to do
this inside of IDLWAVE last year, but in my opinion it is better to
use the built-in "comint" commands that Emacs provides for this. For
example, when I want to find an old command, I do

Meta-r tes[RET]

and get:

IDL> print,strpos('test',['t','s'])

This is a full regexp search. You can also browse your full command
history in a buffer as well: C-c C-l. Middle click an entry to insert
it (using search in this buffer is good as well: it give you the
context around your command to see if it is the correct one). The
history is kept from session to session.

Good luck,

JD
Re: autocomplete [message #43345 is a reply to message #43342] Wed, 30 March 2005 05:45 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
maarten writes:

> I was wondering whether it is possible to have some sort of
> autocompletion at the IDL prompt in Linux.

RSI's customers take on the onerous chore of keeping
the IDL interface updated. I think you will find everything
you want here:

http://www.idlwave.org/

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: autocomplete [message #43396 is a reply to message #43304] Wed, 06 April 2005 08:13 Go to previous message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
JD Smith <jdsmith@as.arizona.edu> writes:

> On Fri, 01 Apr 2005 15:56:08 +0200, maarten wrote:

> I just discovered C-c M-r, which is comint's way of doing a search for
> previous input based on the existing input, without any prompting.

Oh! look at that. I'll be replacing that right away. :) Not that I don't
love your hack....

Matt

--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDLWAVE xemacs Initialization problem
Next Topic: ION Question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 03:33:19 PDT 2025

Total time taken to generate the page: 1.84192 seconds