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

Home » Public Forums » archive » Re: Readline and/or easy command line history access
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Readline and/or easy command line history access [message #66251 is a reply to message #66249] Mon, 27 April 2009 06:30 Go to previous messageGo to previous message
Matt[2] is currently offline  Matt[2]
Messages: 69
Registered: March 2007
Member
Adam,

Keflavich <keflavich@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))


--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: slope_intercept
Next Topic: Re: slope_intercept

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

Current Time: Wed Oct 08 19:55:12 PDT 2025

Total time taken to generate the page: 0.00479 seconds