[Top] [Contents] [Index] [ ? ]

IDLWAVE User Manual

IDLWAVE is a package which supports editing source code written in the Interactive Data Language (IDL), and running IDL as an inferior shell.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Introduction

IDLWAVE is a package which supports editing source files written in the Interactive Data Language (IDL(1)), and running IDL as an inferior shell(2). It is a feature-rich replacement for the IDLDE development environment included with IDL, and uses the full power of Emacs to make editing and running IDL programs easier, quicker, and more structured.

IDLWAVE consists of two main parts: a major mode for editing IDL source files (idlwave-mode) and a mode for running the IDL program as an inferior shell (idlwave-shell-mode). Although one mode can be used without the other, both work together closely to form a complete development environment. Here is a brief summary of what IDLWAVE does:

Here are a number of screenshots showing IDLWAVE in action:

IDLWAVE is the distant successor to the `idl.el' and `idl-shell.el' files written by Chris Chase. The modes and files had to be renamed because of a name space conflict with CORBA's idl-mode, defined in Emacs in the file `cc-mode.el'.

In this manual, each section ends with a list of related user options. Don't be confused by the sheer number of options available -- in most cases the default settings are just fine. The variables are listed here to make sure you know where to look if you want to change anything. For a full description of what a particular variable does and how to configure it, see the documentation string of that variable (available with C-h v). Some configuration examples are also given in the appendix.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. IDLWAVE in a Nutshell

Editing IDL Programs

TAB

Indent the current line relative to context.

C-M-\

Re-indent all lines in the current region.

C-M-q

Re-indent all lines in the current routine.

C-u TAB

Re-indent all lines in the current statement.

M-RET

Start a continuation line, splitting the current line at point.

M-q

Fill the current comment paragraph.

C-c ?

Display calling sequence and keywords for the procedure or function call at point.

M-?

Load context sensitive online help for nearby routine, keyword, etc.

M-TAB

Complete a procedure name, function name or keyword in the buffer.

C-c C-i

Update IDLWAVE's knowledge about functions and procedures.

C-c C-v

Visit the source code of a procedure/function.

C-u C-c C-v

Visit the source code of a procedure/function in this buffer.

C-c C-h

Insert a standard documentation header.

C-c RET

Insert a new timestamp and history item in the documentation header.

Running the IDLWAVE Shell, Debugging Programs

C-c C-s

Start IDL as a subprocess and/or switch to the shell buffer.

Up, M-p

Cycle back through IDL command history.

Down,M-n

Cycle forward.

TAB

Complete a procedure name, function name or keyword in the shell buffer.

C-c C-d C-c

Save and compile the source file in the current buffer.

C-c C-d C-x

Go to next syntax error.

C-c C-d C-v

Switch to electric debug mode.

C-c C-d C-b

Set a breakpoint at the nearest viable source line.

C-c C-d C-d

Clear the nearest breakpoint.

C-c C-d [

Go to the previous breakpoint.

C-c C-d ]

Go to the next breakpoint.

C-c C-d C-p

Print the value of the expression near point in IDL.

Commonly used Settings in `.emacs'

 
;; Change the indentation preferences
;; Start autoloading routine info after 2 idle seconds
(setq idlwave-init-rinfo-when-idle-after 2)
;; Pad operators with spaces
(setq idlwave-do-actions t
      idlwave-surround-by-blank t)
;; Syntax Highlighting
(add-hook 'idlwave-mode-hook 'turn-on-font-lock)
;; Automatically start the shell when needed
(setq idlwave-shell-automatic-start t)
;; Bind debugging commands with CONTROL and SHIFT modifiers
(setq idlwave-shell-debug-modifiers '(control shift))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Getting Started (Tutorial)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Lesson I: Development Cycle

The purpose of this tutorial is to guide you through a very basic development cycle using IDLWAVE. We will paste a simple program into a buffer and use the shell to compile, debug and run it. On the way we will use many of the important IDLWAVE commands. Note, however, that IDLWAVE has many more capabilities than covered here, which can be discovered by reading the entire manual, or hovering over the shoulder of your nearest IDLWAVE guru for a few days.

It is assumed that you have access to Emacs or XEmacs with the full IDLWAVE package including online help (see section Installation). We also assume that you are familiar with Emacs and can read the nomenclature of key presses in Emacs (in particular, C stands for CONTROL and M for META (often the ALT key carries this functionality)).

Open a new source file by typing:

 
C-x C-f tutorial.pro RET

A buffer for this file will pop up, and it should be in IDLWAVE mode, indicated in the mode line just below the editing window. Also, the menu bar should contain `IDLWAVE'.

Now cut-and-paste the following code, also available as `tutorial.pro' in the IDLWAVE distribution.

 
function daynr,d,m,y
  ;; compute a sequence number for a date
  ;; works 1901-2099.
  if y lt 100 then y = y+1900
  if m le 2 then delta = 1 else delta = 0
  m1 = m + delta*12 + 1
  y1 = y * delta
  return, d + floor(m1*30.6)+floor(y1*365.25)+5
end
     
function weekday,day,month,year
  ;; compute weekday number for date
  nr = daynr(day,month,year)
  return, nr mod 7
end
     
pro plot_wday,day,month
  ;; Plot the weekday of a date in the first 10 years of this century.
  years = 2000,+indgen(10)
  wdays = intarr(10)
  for i=0,n_elements(wdays)-1 do begin
      wdays[i] =  weekday(day,month,years[i])
  end
  plot,years,wdays,YS=2,YT="Wday (0=Sunday)"
end

The indentation probably looks funny, since it's different from the settings you use, so use the TAB key in each line to automatically line it up (or, more quickly, select the entire buffer with C-x h, and indent the whole region with C-M-\). Notice how different syntactical elements are highlighted in different colors, if you have set up support for font-lock.

Let's check out two particular editing features of IDLWAVE. Place the cursor after the end statement of the for loop and press SPC. IDLWAVE blinks back to the beginning of the block and changes the generic end to the specific endfor automatically (as long as the variable idlwave-expand-generic-end is turned on -- see section Lesson II: Customization). Now place the cursor in any line you would like to split and press M-RET. The line is split at the cursor position, with the continuation `$' and indentation all taken care of. Use C-/ to undo the last change.

The procedure plot_wday is supposed to plot the day of the week of a given date for the first 10 years of the 21st century. As in most code, there are a few bugs, which we are going to use IDLWAVE to help us fix.

First, let's launch the IDLWAVE shell. You do this with the command C-c C-s. The Emacs window will split or another window will popup to display IDL running in a shell interaction buffer. Type a few commands like print,!PI to convince yourself that you can work there just as well as in a terminal, or the IDLDE. Use the arrow keys to cycle through your command history. Are we having fun now?

Now go back to the source window and type C-c C-d C-c to compile the program. If you watch the shell buffer, you see that IDLWAVE types `.run "tutorial.pro"' for you. But the compilation fails because there is a comma in the line `years=...'. The line with the error is highlighted and the cursor positioned at the error, so remove the comma (you should only need to hit Delete!). Compile again, using the same keystrokes as before. Notice that the file is automatically saved for you. This time everything should work fine, and you should see the three routines compile.

Now we want to use the command to plot the day of the week on January 1st. We could type the full command ourselves, but why do that? Go back to the shell window, type `plot_' and hit TAB. After a bit of a delay (while IDLWAVE initializes its routine info database, if necessary), the window will split to show all procedures it knows starting with that string, and plot_wday should be one of them. Saving the buffer alerted IDLWAVE about this new routine. Click with the middle mouse button on plot_wday and it will be copied to the shell buffer, or if you prefer, add `w' to `plot_' to make it unambiguous (depending on what other routines starting with `plot_' you have installed on your system), hit TAB again, and the full routine name will be completed. Now provide the two arguments:

 
plot_wday,1,1

and press RET. This fails with an error message telling you the YT keyword to plot is ambiguous. What are the allowed keywords again? Go back to the source window and put the cursor into the `plot' line and press C-c ?. This shows the routine info window for the plot routine, which contains a list of keywords, along with the argument list. Oh, we wanted YTITLE. Fix that up. Recompile with C-c C-d C-c. Jump back into the shell with C-c C-s, press the UP arrow to recall the previous command and execute again.

This time we get a plot, but it is pretty ugly -- the points are all connected with a line. Hmm, isn't there a way for plot to use symbols instead? What was that keyword? Position the cursor on the plot line after a comma (where you'd normally type a keyword), and hit M-Tab. A long list of plot's keywords appears. Aha, there it is, PSYM. Middle click to insert it. An `=' sign is included for you too. Now what were the values of PSYM supposed to be? With the cursor on or after the keyword, press M-? for online help (alternatively, you could have right clicked on the colored keyword itself in the completion list). A browser will pop up showing the HTML documentation for the PYSM keyword. OK, let's use diamonds=4. Fix this, recompile (you know the command by now: C-c C-d C-c), go back to the shell (if it's vanished, you know what to do: C-c C-s) and execute again. Now things look pretty good.

Let's try a different day -- how about April fool's day?

 
plot_wday,1,4

Oops, this looks very wrong. All April Fool's days cannot be Fridays! We've got a bug in the program, perhaps in the daynr function. Let's put a breakpoint on the last line there. Position the cursor on the `return, d+...' line and press C-c C-d C-b. IDL sets a breakpoint (as you see in the shell window), and the break line is indicated. Back to the shell buffer, re-execute the previous command. IDL stops at the line with the breakpoint. Now hold down the SHIFT key and click with the middle mouse button on a few variables there: `d', `y', `m', `y1', etc. Maybe d isn't the correct type. CONTROL-SHIFT middle-click on it for help. Well, it's an integer, so that's not the problem. Aha, `y1' is zero, but it should be the year, depending on delta. Shift click `delta' to see that it's 0. Below, we see the offending line: `y1=y*delta...' the multiplication should have been a minus sign! Hit q to exit the debugging mode, and fix the line to read:

 
y1 = y - delta

Now remove all breakpoints: C-c C-d C-a. Recompile and rerun the command. Everything should now work fine. How about those leap years? Change the code to plot 100 years and see that every 28 years, the sequence of weekdays repeats.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Lesson II: Customization

Emacs is probably the most customizable piece of software ever written, and it would be a shame if you did not make use of this to adapt IDLWAVE to your own preferences. Customizing Emacs or IDLWAVE is accomplished by setting Lisp variables in the `.emacs' file in your home directory -- but do not be dismayed; for the most part, you can just copy and work from the examples given here.

Let's first use a boolean variable. These are variables which you turn on or off, much like a checkbox. A value of `t' means on, a value of `nil' means off. Copy the following line into your `.emacs' file, exit and restart Emacs.

 
(setq idlwave-reserved-word-upcase t)

When this option is turned on, each reserved word you type into an IDL source buffer will be converted to upper case when you press SPC or RET right after the word. Try it out! `if' changes to `IF', `begin' to `BEGIN'. If you don't like this behavior, remove the option again from your `.emacs' file and restart Emacs.

You likely have your own indentation preferences for IDL code. For example, some may prefer to indent the main block of an IDL program slightly from the margin and use only 3 spaces as indentation between BEGIN and END. Try the following lines in `.emacs':

 
(setq idlwave-main-block-indent 1)
(setq idlwave-block-indent 3)
(setq idlwave-end-offset -3)

Restart Emacs, and re-indent the program we developed in the first part of this tutorial with C-c h and C-M-\. You may want to keep these lines in `.emacs', with values adjusted to your likings. If you want to get more information about any of these variables, type, e.g., C-h v idlwave-main-block-indent RET. To find which variables can be customized, look for items marked `User Option:' throughout this manual.

If you cannot seem to master this Lisp customization in `.emacs', there is another, more user-friendly way to customize all the IDLWAVE variables. You can access it through the IDLWAVE menu in one of the `.pro' buffers, menu item Customize->Browse IDLWAVE Group. Here you'll be presented with all the various variables grouped into categories. You can navigate the hierarchy (e.g. `IDLWAVE Code Formatting->Idlwave Abbrev And Indent Action->Idlwave Expand Generic End' to turn on END expansion), read about the variables, change them, and `Save for Future Sessions'. Few of these variables need customization, but you can exercise considerable control over IDLWAVE's functionality with them.

You may also find the key bindings used for the debugging commands too long and complicated. Often we have heard complaints along the lines of, "Do I really have to go through the finger gymnastics of C-c C-d C-c to run a simple command?" Due to Emacs rules and conventions, shorter bindings cannot be set by default, but you can easily enable them. First, there is a way to assign all debugging commands in a single sweep to another simpler combination. The only problem is that we have to use something which Emacs does not need for other important commands. One good option is to execute debugging commands by holding down CONTROL and SHIFT while pressing a single character: C-S-b for setting a breakpoint, C-S-c for compiling the current source file, C-S-a for deleting all breakpoints (try it, it's easier). You can enable this with:

 
(setq idlwave-shell-debug-modifiers '(shift control))

If you have a special keyboard with, for example, a SUPER key, you could even shorten that:

 
(setq idlwave-shell-debug-modifiers '(super))

to get compilation on S-c. Often, a modifier key like SUPER or HYPER is bound or can be bound to an otherwise unused key on your keyboard -- consult your system documentation.

You can also assign specific commands to keys. This you must do in the mode-hook, a special function which is run when a new IDLWAVE buffer gets set up. The possibilities for key customization are endless. Here we set function keys f4-f8 to common debugging commands.

 
;; First for the source buffer
(add-hook 'idlwave-mode-hook
   (lambda ()
    (local-set-key [f4] 'idlwave-shell-retall)
    (local-set-key [f5] 'idlwave-shell-break-here)
    (local-set-key [f6] 'idlwave-shell-clear-current-bp)
    (local-set-key [f7] 'idlwave-shell-cont)
    (local-set-key [f8] 'idlwave-shell-clear-all-bp)))
;; Then for the shell buffer
(add-hook 'idlwave-shell-mode-hook
   (lambda ()
    (local-set-key [f4] 'idlwave-shell-retall)
    (local-set-key [f5] 'idlwave-shell-break-here)
    (local-set-key [f6] 'idlwave-shell-clear-current-bp)
    (local-set-key [f7] 'idlwave-shell-cont)
    (local-set-key [f8] 'idlwave-shell-clear-all-bp)))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Lesson III: User and Library Catalogs

We have already used the routine info display in the first part of this tutorial. This was the invoked using C-c ?, and displays information about the IDL routine near the cursor position. Wouldn't it be nice to have the same kind of information available for your own routines and for the huge amount of code in major libraries like JHUPL or the IDL-Astro library? In many cases, you may already have this information. Files named `.idlwave_catalog' in library directories contain scanned information on the routines in that directory; many popular libraries ship with these "library catalogs" pre-scanned. Users can scan their own routines in one of two ways: either using the supplied tool to scan directories and build their own `.idlwave_catalog' files, or using the built-in method to create a single "user catalog", which we'll show here. See section Catalogs, for more information on choosing which method to use.

To build a user catalog, select Routine Info/Select Catalog Directories from the IDLWAVE entry in the menu bar. If necessary, start the shell first with C-c C-s (see section Starting the Shell). IDLWAVE will find out about the IDL !PATH variable and offer a list of directories on the path. Simply select them all (or whichever you want -- directories with existing library catalogs will not be selected by default) and click on the `Scan&Save' button. Then go for a cup of coffee while IDLWAVE collects information for each and every IDL routine on your search path. All this information is written to the file `.idlwave/idlusercat.el' in your home directory and will from now on automatically load whenever you use IDLWAVE. You may find it necessary to rebuild the catalog on occasion as your local libraries change, or build a library catalog for those directories instead. Invoke routine info (C-c ?) or completion (M-TAB) on any routine or partial routine name you know to be located in the library. E.g., if you have scanned the IDL-Astro library:

 
    a=readfM-TAB

expands to `readfits('. Then try

 
    a=readfits(C-c ?

and you get:

 
Usage:    Result = READFITS(filename, header, heap)
...

I hope you made it until here. Now you are set to work with IDLWAVE. On the way you will want to change other things, and to learn more about the possibilities not discussed in this short tutorial. Read the manual, look at the documentation strings of interesting variables (with C-h v idlwave<-variable-name> RET) and ask the remaining questions on the newsgroup comp.lang.idl-pvwave.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. The IDLWAVE Major Mode

The IDLWAVE major mode supports editing IDL source files. In this chapter we describe the main features of the mode and how to customize them.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Code Formatting

The IDL language, with its early roots in FORTRAN, modern implementation in C, and liberal borrowing of features of many vector and other languages along its 25+ year history, has inherited an unusual mix of syntax elements. Left to his or her own devices, a novice IDL programmer will often conjure code which is very difficult to read and impossible to adapt. Much can be gleaned from studying available IDL code libraries for coding style pointers, but, due to the variety of IDL syntax elements, replicating this style can be challenging at best. Luckily, IDLWAVE understands the structure of IDL code very well, and takes care of almost all formatting issues for you. After configuring it to match your coding standards, you can rely on it to help keep your code neat and organized.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.1 Code Indentation

Like all Emacs programming modes, IDLWAVE performs code indentation. The TAB key indents the current line relative to context. LFD insert a newline and indents the new line. The indentation is governed by a number of variables. IDLWAVE indents blocks (between PRO/FUNCTION/BEGIN and END), and continuation lines.

To re-indent a larger portion of code (e.g. when working with foreign code written with different conventions), use C-M-\ (indent-region) after marking the relevant code. Useful marking commands are C-x h (the entire file) or C-M-h (the current subprogram). The command C-M-q reindents the entire current routine. See section Actions, for information how to impose additional formatting conventions on foreign code.

User Option: idlwave-main-block-indent (2)

Extra indentation for the main block of code. That is the block between the FUNCTION/PRO statement and the END statement for that program unit.

User Option: idlwave-block-indent (3)

Extra indentation applied to block lines. If you change this, you probably also want to change idlwave-end-offset.

User Option: idlwave-end-offset (-3)

Extra indentation applied to block END lines. A value equal to negative idlwave-block-indent will make END lines line up with the block BEGIN lines.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.2 Continued Statement Indentation

Continuation lines (following a line ending with $) can receive a fixed indentation offset from the main level, but in several situations IDLWAVE can use a special form of indentation which aligns continued statements more naturally. Special indentation is calculated for continued routine definition statements and calls, enclosing parentheses (like function calls, structure/class definitions, explicit structures or lists, etc.), and continued assignments. An attempt is made to line up with the first non-whitespace character after the relevant opening punctuation mark (,,(,{,[,=). For lines without any non-comment characters on the line with the opening punctuation, the continued line(s) are aligned just past the punctuation. An example:

 
function foo, a, b,  $
              c, d
  bar =  sin( a + b + $
              c + d)
end

The only drawback to this special continued statement indentation is that it consumes more space, e.g., for long function names or left hand sides of an assignment:

 
function thisfunctionnameisverylongsoitwillleavelittleroom, a, b, $
                                                            c, d

You can instruct IDLWAVE when to avoid using this special continuation indentation by setting the variable idlwave-max-extra-continuation-indent, which specifies the maximum additional indentation beyond the basic indent to be tolerated, otherwise defaulting to a fixed-offset from the enclosing indent (the size of which offset is set in idlwave-continuation-indent). As a special case, continuations of routine calls without any arguments or keywords will not align the continued line, under the assumption that you continued because you needed the space.

Also, since the indentation level can be somewhat dynamic in continued statements with special continuation indentation, especially if idlwave-max-extra-continuation-indent is small, the key C-u TAB will re-indent all lines in the current statement. Note that idlwave-indent-to-open-paren, if non-nil, overrides the idlwave-max-extra-continuation-indent limit, for parentheses only, forcing them always to line up.

User Option: idlwave-continuation-indent (2)

Extra indentation applied to normal continuation lines.

User Option: idlwave-max-extra-continuation-indent (20)

The maximum additional indentation (over the basic continuation-indent) that will be permitted for special continues. To effectively disable special continuation indentation, set to 0. To enable it constantly, set to a large number (like 100). Note that the indentation in a long continued statement never decreases from line to line, outside of nested parentheses statements.

User Option: idlwave-indent-to-open-paren (t)

Non-nil means indent continuation lines to innermost open parenthesis, regardless of whether the idlwave-max-extra-continuation-indent limit is satisfied.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.3 Comment Indentation

In IDL, lines starting with a `;' are called comment lines. Comment lines are indented as follows:

;;;

The indentation of lines starting with three semicolons remains unchanged.

;;

Lines starting with two semicolons are indented like the surrounding code.

;

Lines starting with a single semicolon are indented to a minimum column.

The indentation of comments starting in column 0 is never changed.

User Option: idlwave-no-change-comment

The indentation of a comment starting with this regexp will not be changed.

User Option: idlwave-begin-line-comment

A comment anchored at the beginning of line.

User Option: idlwave-code-comment

A comment that starts with this regexp is indented as if it is a part of IDL code.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.4 Continuation Lines and Filling

In IDL, a newline character terminates a statement unless preceded by a `$'. If you would like to start a continuation line, use M-RET, which calls the command idlwave-split-line. It inserts the continuation character `$', terminates the line and indents the new line. The command M-RET can also be invoked inside a string to split it at that point, in which case the `+' concatenation operator is used.

When filling comment paragraphs, IDLWAVE overloads the normal filling functions and uses a function which creates the hanging paragraphs customary in IDL routine headers. When auto-fill-mode is turned on (toggle with C-c C-a), comments will be auto-filled. If the first line of a paragraph contains a match for idlwave-hang-indent-regexp (a dash-space by default), subsequent lines are positioned to line up after it, as in the following example.

 
;=================================
; x - an array containing
;     lots of interesting numbers.
;
; y - another variable where
;     a hanging paragraph is used
;     to describe it.
;=================================

You can also refill a comment at any time paragraph with M-q. Comment delimiting lines as in the above example, consisting of one or more `;' followed by one or more of the characters `+=-_*', are kept in place, as is.

User Option: idlwave-fill-comment-line-only (t)

Non-nil means auto fill will only operate on comment lines.

User Option: idlwave-auto-fill-split-string (t)

Non-nil means auto fill will split strings with the IDL `+' operator.

User Option: idlwave-split-line-string (t)

Non-nil means idlwave-split-line will split strings with `+'.

User Option: idlwave-hanging-indent (t)

Non-nil means comment paragraphs are indented under the hanging indent given by idlwave-hang-indent-regexp match in the first line of the paragraph.

User Option: idlwave-hang-indent-regexp ("- ")

Regular expression matching the position of the hanging indent in the first line of a comment paragraph.

User Option: idlwave-use-last-hang-indent (nil)

Non-nil means use last match on line for idlwave-indent-regexp.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.5 Syntax Highlighting

Highlighting of keywords, comments, strings etc. can be accomplished with font-lock. If you are using global-font-lock-mode (in Emacs), or have font-lock turned on in any other buffer in XEmacs, it should also automatically work in IDLWAVE buffers. If you'd prefer invoking font-lock individually by mode, you can enforce it in idlwave-mode with the following line in your `.emacs':

 
(add-hook 'idlwave-mode-hook 'turn-on-font-lock)

IDLWAVE supports 3 increasing levels of syntax highlighting. The variable font-lock-maximum-decoration determines which level is selected. Individual categories of special tokens can be selected for highlighting using the variable idlwave-default-font-lock-items.

User Option: idlwave-default-font-lock-items

Items which should be fontified on the default fontification level 2.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.6 Octals and Highlighting

A rare syntax highlighting problem results from an extremely unfortunate notation for octal numbers in IDL: "123. This unpaired quotation mark is very difficult to parse, given that it can be mixed on a single line with any number of strings. Emacs will incorrectly identify this as a string, and the highlighting of following lines of code can be distorted, since the string is never terminated.

One solution to this involves terminating the mistakenly identified string yourself by providing a closing quotation mark in a comment:

 
  string("305B) + $ ;" <--- for font-lock
   ' is an Angstrom.'

A far better solution is to abandon this notation for octals altogether, and use the more sensible alternative IDL provides:

 
   string('305'OB) + ' is an Angstrom.'

This simultaneously solves the font-lock problem and is more consistent with the notation for hexadecimal numbers, e.g. 'C5'XB.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Routine Info

IDL comes bundled with more than one thousand procedures, functions and object methods, and large libraries typically contain hundreds or even thousands more (each with a few to tens of keywords and arguments). This large command set can make it difficult to remember the calling sequence and keywords for the routines you use, but IDLWAVE can help. It builds up routine information from a wide variety of sources; IDLWAVE in fact knows far more about the `.pro' routines on your system than IDL itself! It maintains a list of all built-in routines, with calling sequences and keywords(3). It also scans Emacs buffers for routine definitions, queries the IDLWAVE-Shell for information about routines currently compiled there, and automatically locates library and user-created catalogs. This information is updated automatically, and so should usually be current. To force a global update and refresh the routine information, use C-c C-i (idlwave-update-routine-info).

To display the information about a routine, press C-c ?, which calls the command idlwave-routine-info. When the current cursor position is on the name or in the argument list of a procedure or function, information will be displayed about the routine. For example, consider the indicated cursor positions in the following line:

 
plot,x,alog(x+5*sin(x) + 2),
  |  |   |   |   |  |  |    |
  1  2   3   4   5  6  7    8

On positions 1,2 and 8, information about the `plot' procedure will be shown. On positions 3,4, and 7, the `alog' function will be described, while positions 5 and 6 will investigate the `sin' function.

When you ask for routine information about an object method, and the method exists in several classes, IDLWAVE queries for the class of the object, unless the class is already known through a text property on the `->' operator (see section Object Method Completion and Class Ambiguity), or by having been explicity included in the call (e.g. a->myclass::Foo).

The description displayed contains the calling sequence, the list of keywords and the source location of this routine. It looks like this:

 
Usage:    XMANAGER, NAME, ID
Keywords: BACKGROUND CATCH CLEANUP EVENT_HANDLER GROUP_LEADER
          JUST_REG MODAL NO_BLOCK
Source:   SystemLib   [LCSB] /soft1/idl53/lib/xmanager.pro

If a definition of this routine exists in several files accessible to IDLWAVE, several `Source' lines will point to the different files. This may indicate that your routine is shadowing a system library routine, which may or may not be what you want (see section Load-Path Shadows). The information about the calling sequence and keywords is derived from the first source listed. Library routines are available only if you have scanned your local IDL directories or are using pre-scanned libraries (see section Catalogs). The source entry consists of a source category, a set of flags and the path to the source file. The following default categories exist:

System

A system routine of unknown origin. When the system library has been scanned as part of a catalog (see section Catalogs), this category will automatically split into the next two.

Builtin

A builtin system routine with no source code available.

SystemLib

A library system routine in the official lib directory `!DIR/lib'.

Obsolete

A library routine in the official lib directory `!DIR/lib/obsolete'.

Library

A routine in a file on IDL's search path !PATH.

Other

Any other routine with a file not known to be on the search path.

Unresolved

An otherwise unkown routine the shell lists as unresolved (referenced, but not compiled).

Any routines discovered in library catalogs (see section Library Catalogs), will display the category assigned during creation, e.g. `NasaLib'. For routines not discovered in this way, you can create additional categories based on the routine's filename using the variable idlwave-special-lib-alist.

The flags [LCSB] indicate the source of the information IDLWAVE has regarding the file: from a library catalog ([L---]), from a user catalog ([-C--], from the IDL Shell ([--S-]) or from an Emacs buffer ([---B]). Combinations are possible (a compiled library routine visited in a buffer might read [L-SB]). If a file contains multiple definitions of the same routine, the file name will be prefixed with `(Nx)' where `N' is the number of definitions.

Some of the text in the `*Help*' routine info buffer will be active (it is highlighted when the mouse moves over it). Typically, clicking with the right mouse button invokes online help lookup, and clicking with the middle mouse button inserts keywords or visits files:

Usage

If online help is installed, a click with the right mouse button on the Usage: line will access the help for the routine (see section Online Help).

Keyword

Online help about keywords is also available with the right mouse button. Clicking on a keyword with the middle mouse button will insert this keyword in the buffer from where idlwave-routine-info was called. Holding down SHIFT while clicking also adds the initial `/'.

Source

Clicking with the middle mouse button on a `Source' line finds the source file of the routine and visits it in another window. Another click on the same line switches back to the buffer from which C-c ? was called. If you use the right mouse button, the source will not be visited by a buffer, but displayed in the online help window.

Classes

The Classes line is only included in the routine info window if the current class inherits from other classes. You can click with the middle mouse button to display routine info about the current method in other classes on the inheritance chain, if such a method exists there.

User Option: idlwave-resize-routine-help-window (t)

Non-nil means resize the Routine-info `*Help*' window to fit the content.

User Option: idlwave-special-lib-alist

Alist of regular expressions matching special library directories.

User Option: idlwave-rinfo-max-source-lines (5)

Maximum number of source files displayed in the Routine Info window.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Online Help

For IDL system routines, extensive documentation is supplied with IDL. IDLWAVE can access the HTML version of this documentation very quickly and accurately, based on the local context. This can be much faster than using the IDL online help application, because IDLWAVE usually gets you to the right place in the documentation directly -- e.g. a specific keyword of a routine -- without any additional browsing and scrolling.

For this online help to work, an HTML version of the IDL documentation is required. Beginning with IDL 6.2, HTML documentation is distributed directly with IDL, along with an XML-based catalog of routine information. By default, IDLWAVE automatically attempts to convert this XML catalog into a format Emacs can more easily understand, and caches this information in your idlwave_config_directory (`~/.idlwave/', by default). It also re-scans the XML catalog if it is newer than the current cached version. You can force rescan with the menu entry IDLWAVE->Routine Info->Rescan XML Help Catalog.

Before IDL 6.2, the HTML help was not distributed with IDL, and was not part of the standalone IDLWAVE distribution, but had to be downloaded separately. This is no longer necessary: all help and routine information is supplied with IDL versions 6.2 and later.

There are a variety of options for displaying the HTML help: see below. Help for routines without HTML documentation is also available, by using the routine documentation header and/or routine source.

In any IDL program (or, as with most IDLWAVE commands, in the IDL Shell), press M-? (idlwave-context-help), or click with S-Mouse-3 to access context sensitive online help. The following locations are recognized context for help:

Routine names

The name of a routine (function, procedure, method).

Keyword Parameters

A keyword parameter of a routine.

System Variables

System variables like !DPI.

System Variable Tags

System variables tags like !D.X_SIZE.

IDL Statements

Statements like PRO, REPEAT, COMPILE_OPT, etc.

IDL Controls

Control structures like FOR, SWITCH, etc.

Class names

A class name in an OBJ_NEW call.

Class Init Keywords

Beyond the class name in an OBJ_NEW call.

Executive Command

An executive command like .RUN. Mostly useful in the shell.

Structure Tags

Structure tags like state.xsize

Class Tags

Class tags like self.value.

Default

The routine that would be selected for routine info display.

Note that the OBJ_NEW function is special in that the help displayed depends on the cursor position. If the cursor is on the `OBJ_NEW', this function is described. If it is on the class name inside the quotes, the documentation for the class is pulled up. If the cursor is after the class name, anywhere in the argument list, the documentation for the corresponding Init method and its keywords is targeted.

Apart from an IDLWAVE buffer or shell, there are two more places from which online help can be accessed.

In both cases, a blue face indicates that the item is documented in the IDL manual, but an attempt will be made to visit non-blue items directly in the originating source file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.1 Help with HTML Documentation

Help using the HTML documentation is invoked with the built-in Emacs command browse-url, which displays the relevant help topic in a browser of your choosing. Beginning with version 6.2, IDL comes with the help browser IDL Assistant, which it uses by default for displaying online help on all supported platforms. This browser offers topical searches, an index, and is also now the default and recommended IDLWAVE help browser. The variable idlwave-help-use-assistant controls whether this browser is used. Note that, due to limitations in the Assistant, invoking help within IDLWAVE and ? topic within IDL will result in two running copies of Assistant.

Aside from the IDL Assistant, there are many possible browsers to choose among, with differing advantages and disadvantages. The variable idlwave-help-browser-function controls which browser help is sent to (as long as idlwave-help-use-assistant is not set). This function is used to set the variable browse-url-browser-function locally for IDLWAVE help only. Customize the latter variable to see what choices of browsers your system offers. Certain browsers like w3 (bundled with many versions of Emacs) and w3m (http://emacs-w3m.namazu.org/) are run within Emacs, and use Emacs buffers to display the HTML help. This can be convenient, especially on small displays, and images can even be displayed in-line on newer Emacs versions. However, better formatting results are often achieved with external browsers, like Mozilla. IDLWAVE assumes any browser function containing "w3" is displayed in a local buffer. If you are using another Emacs-local browser for which this is not true, set the variable idlwave-help-browser-is-local.

With IDL 6.2 or later, it is important to ensure that the variable idlwave-system-directory is set (see section Catalogs). One easy way to ensure this is to run the IDL Shell (C-c C-s). It will be queried for this directory, and the results will be cached to file for subsequent use.

See section HTML Help Browser Tips, for more information on selecting and configuring a browser for use with IDL's HTML help system.

User Option: idlwave-html-system-help-location `help/online_help'

Relative directory of the system-supplied HTML help directory, considered with respect to idlwave-system-directory. Relevant for IDL 6.2 and greater. Should not change.

User Option: idlwave-html-help-location `/usr/local/etc/'

The directory where the `idl_html_help' HTML directory live. Obsolete and ignored for IDL 6.2 and greater (idlwave-html-system-help-location is used instead).

User Option: idlwave-help-use-assistant t

If set, use the IDL Assistant if possible for online HTML help, otherwise use the browser function specified in idlwave-help-browser-function.

User Option: idlwave-help-browser-function

The browser function to use to display IDLWAVE HTML help. Should be one of the functions available for setting browse-url-browser-function, which see.

User Option: idlwave-help-browser-is-local

Is the browser selected in idlwave-help-browser-function run in a local Emacs buffer or window? Defaults to t if the function contains "-w3".

User Option: idlwave-help-link-face

The face for links to IDLWAVE online help.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.2 Help with Source

For routines which are not documented in an HTML manual (for example personal or library routines), the source code itself is used as help text. If the requested information can be found in a (more or less) standard DocLib file header, IDLWAVE shows the header (scrolling down to a keyword, if appropriate). Otherwise the routine definition statement (pro/function) is shown. The doclib header sections which are searched for include `NAME' and `KEYWORDS'. Localization support can be added by customizing the idlwave-help-doclib-name and idlwave-help-doclib-keyword variables.

Help is also available for class structure tags (self.TAG), and generic structure tags, if structure tag completion is enabled (see section Structure Tag Completion). This is implemented by visiting the tag within the class or structure definition source itself. Help is not available on built-in system class tags.

The help window is normally displayed in the same frame, but can be popped-up in a separate frame. The following commands can be used to navigate inside the help system for source files:

SPACE

Scroll forward one page.

RET

Scroll forward one line.

DEL

Scroll back one page.

h

Jump to DocLib Header of the routine whose source is displayed as help.

H

Jump to the first DocLib Header in the file.

. (Dot)

Jump back and forth between the routine definition (the pro/function statement) and the description of the help item in the DocLib header.

F

Fontify the buffer like source code. See the variable idlwave-help-fontify-source-code.

q

Kill the help window.

User Option: idlwave-help-use-dedicated-frame (nil)

Non-nil means use a separate frame for Online Help if possible.

User Option: idlwave-help-frame-parameters

The frame parameters for the special Online Help frame.

User Option: idlwave-max-popup-menu-items (20)

Maximum number of items per pane in pop-up menus.

User Option: idlwave-extra-help-function

Function to call for help if the normal help fails.

User Option: idlwave-help-fontify-source-code (nil)

Non-nil means fontify source code displayed as help.

User Option: idlwave-help-source-try-header (t)

Non-nil means try to find help in routine header when displaying source file.

User Option: idlwave-help-doclib-name ("name")

The case-insensitive heading word in doclib headers to locate the name section. Can be a regexp, e.g. "\\(name\\|nom\\)".

User Option: idlwave-help-doclib-keyword ("KEYWORD")

The case-insensitive heading word in doclib headers to locate the keywords section. Can be a regexp.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Completion

IDLWAVE offers completion for class names, routine names, keywords, system variables, system variable tags, class structure tags, regular structure tags and file names. As in many programming modes, completion is bound to M-TAB (or simply TAB in the IDLWAVE Shell -- see section Using the Shell). Completion uses exactly the same internal information as routine info, so when necessary (rarely) it can be updated with C-c C-i (idlwave-update-routine-info).

The completion function is context sensitive and figures out what to complete based on the 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)

The only place where completion is ambiguous is procedure/function keywords versus functions. After `plot,x,_', IDLWAVE will always assume a keyword to `plot'. However, a function is also a possible completion here. You can force completion of a function name at such a location by using a prefix arg: C-u M-TAB.

Giving two prefix arguments (C-u C-u M-TAB) prompts for a regular expression to search among the commands to be completed. As an example, completing a blank line in this way will allow you to search for a procedure matching a regexp.

If the list of completions is too long to fit in the `*Completions*' window, the window can be scrolled by pressing M-TAB repeatedly. Online help (if installed) for each possible completion is available by clicking with Mouse-3 on the item. Items for which system online help (from the IDL manual) is available will be emphasized (e.g. colored blue). For other items, the corresponding source code or DocLib header will be used as the help text.

Completion is not a blocking operation -- you are free to continue editing, enter commands, or simply ignore the `*Completions*' buffer during a completion operation. If, however, the most recent command was a completion, C-g will remove the buffer and restore the window configuration. You can also remove the buffer at any time with no negative consequences.

User Option: idlwave-keyword-completion-adds-equal (t)

Non-nil means completion automatically adds `=' after completed keywords.

User Option: idlwave-function-completion-adds-paren (t)

Non-nil means completion automatically adds `(' after completed function. A value of `2' means also add the closing parenthesis and position the cursor between the two.

User Option: idlwave-completion-restore-window-configuration (t)

Non-nil means restore window configuration after successful completion.

User Option: idlwave-highlight-help-links-in-completion (t)

Non-nil means highlight completions for which system help is available.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.1 Case of Completed Words

IDL is a case-insensitive language, so casing is a matter of style only. IDLWAVE helps maintain a consistent casing style for completed items. The case of the completed words is determined by what is already in the buffer. As an exception, when the partial word being completed is all lower case, the completion will be lower case as well. If at least one character is upper case, the string will be completed in upper case or mixed case, depending on the value of the variable idlwave-completion-case. The default is to use upper case for procedures, functions and keywords, and mixed case for object class names and methods, similar to the conventions in the IDL manuals. For instance, to enable mixed-case completion for routines in addition to classes and methods, you need an entry such as (routine . preserve) in that variable. To enable total control over the case of completed items, independent of buffer context, set idlwave-completion-force-default-case to non-nil.

User Option: idlwave-completion-case

Association list setting the case (UPPER/lower/Capitalized/MixedCase...) of completed words.

User Option: idlwave-completion-force-default-case (nil)

Non-nil means completion will always honor the settings in idlwave-completion-case. When nil (the default), entirely lower case strings will always be completed to lower case, no matter what the settings in idlwave-completion-case.

User Option: idlwave-complete-empty-string-as-lower-case (nil)

Non-nil means the empty string is considered lower case for completion.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.2 Object Method Completion and Class Ambiguity

An object method is not uniquely determined without the object's class. Since the class is almost always omitted in the calling source (as required to obtain the true benefits of object-based programming), IDLWAVE considers all available methods in all classes as possible method name completions. The combined list of keywords of the current method in all known classes which contain that method will be considered for keyword completion. In the `*Completions*' buffer, the matching classes will be shown next to each item (see option idlwave-completion-show-classes). As a special case, the class of an object called `self' is always taken to be the class of the current routine, when in an IDLWAVE buffer. All inherits classes are considered as well.

You can also call idlwave-complete with a prefix arg: C-u M-TAB. IDLWAVE will then prompt you for the class in order to narrow down the number of possible completions. The variable idlwave-query-class can be configured to make such prompting the default for all methods (not recommended), or selectively for very common methods for which the number of completing keywords would be too large (e.g. Init,SetProperty,GetProperty).

After you have specified the class for a particular statement (e.g. when completing the method), IDLWAVE can remember it for the rest of the editing session. Subsequent completions in the same statement (e.g. keywords) can then reuse this class information. This works by placing a text property on the method invocation operator `->', after which the operator will be shown in a different face (bold by default). The variable idlwave-store-inquired-class can be used to turn it off or on.

User Option: idlwave-completion-show-classes (1)

Non-nil means show up to that many classes in `*Completions*' buffer when completing object methods and keywords.

User Option: idlwave-completion-fontify-classes (t)

Non-nil means fontify the classes in completions buffer.

User Option: idlwave-query-class (nil)

Association list governing query for object classes during completion.

User Option: idlwave-store-inquired-class (t)

Non-nil means store class of a method call as text property on `->'.

User Option: idlwave-class-arrow-face

Face to highlight object operator arrows `->' which carry a saved class text property.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.3 Object Method Completion in the Shell

In the IDLWAVE Shell (see section The IDLWAVE Shell), objects on which methods are being invoked have a special property: they must exist as variables, and so their class can be determined (for instance, using the obj_class() function). In the Shell, when attempting completion, routine info, or online help within a method routine, a query is sent to determine the class of the object. If this query is successful, the class found will be used to select appropriate completions, routine info, or help. If unsuccessful, information from all known classes will be used (as in the buffer).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.4 Class and Keyword Inheritance

Class inheritance affects which methods are called in IDL. An object of a class which inherits methods from one or more superclasses can override that method by defining its own method of the same name, extend the method by calling the method(s) of its superclass(es) in its version, or inherit the method directly by making no modifications. IDLWAVE examines class definitions during completion and routine information display, and records all inheritance information it finds. This information is displayed if appropriate with the calling sequence for methods (see section Routine Info), as long as variable idlwave-support-inheritance is non-nil.

In many class methods, keyword inheritance (_EXTRA and _REF_EXTRA) is used hand-in-hand with class inheritance and method overriding. E.g., in a SetProperty method, this technique allows a single call obj->SetProperty to set properties up the entire class inheritance chain. This is often referred to as chaining, and is characterized by chained method calls like self->MySuperClass::SetProperty,_EXTRA=e.

IDLWAVE can accomodate this special synergy between class and keyword inheritance: if _EXTRA or _REF_EXTRA is detected among a method's keyword parameters, all keywords of superclass versions of the method being considered can be included in completion. There is of course no guarantee that this type of keyword chaining actually occurrs, but for some methods it's a very convenient assumption. The variable idlwave-keyword-class-inheritance can be used to configure which methods have keyword inheritance treated in this simple, class-driven way. By default, only Init and (Get|Set)Property are. The completion buffer will label keywords based on their originating class.

User Option: idlwave-support-inheritance (t)

Non-nil means consider inheritance during completion, online help etc.

User Option: idlwave-keyword-class-inheritance

A list of regular expressions to match methods for which simple class-driven keyword inheritance will be used for Completion.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.5 Structure Tag Completion

In many programs, especially those involving widgets, large structures (e.g. the `state' structure) are used to communicate among routines. It is very convenient to be able to complete structure tags, in the same way as for instance variables (tags) of the `self' object (see section Object Method Completion and Class Ambiguity). Add-in code for structure tag completion is available in the form of a loadable completion module: `idlw-complete-structtag.el'. Tag completion in structures is highly ambiguous (much more so than `self' completion), so idlw-complete-structtag makes an unusual and very specific assumption: the exact same variable name is used to refer to the structure in all parts of the program. This is entirely unenforced by the IDL language, but is a typical convention. If you consistently refer to the same structure with the same variable name (e.g. `state'), structure tags which are read from its definition in the same file can be used for completion.

Structure tag completion is not enabled by default. To enable it, simply add the following to your `.emacs':

 
   (add-hook 'idlwave-load-hook 
             (lambda () (require 'idlw-complete-structtag)))

Once enabled, you'll also be able to access online help on the structure tags, using the usual methods (see section Online Help). In addition, structure variables in the shell will be queried for tag names, similar to the way object variables in the shell are queried for method names. So, e.g.:

 
IDL> st.[Tab]

will complete with all structure fields of the structure st.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5 Routine Source

In addition to clicking on a Source: line in the routine info window, there is another way to quickly visit the source file of a routine. The command C-c C-v (idlwave-find-module) asks for a module name, offering the same default as idlwave-routine-info would have used, taken from nearby buffer contents. In the minibuffer, specify a complete routine name (including any class part). IDLWAVE will display the source file in another window, positioned at the routine in question. You can also limit this to a routine in the current buffer only, with completion, and a context-sensitive default, by using a single prefix (C-u C-c C-v) or the convenience binding C-c C-t.

Since getting the source of a routine into a buffer is so easy with IDLWAVE, too many buffers visiting different IDL source files are sometimes created. The special command C-c C-k (idlwave-kill-autoloaded-buffers) can be used to easily remove these buffers.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.6 Resolving Routines

The key sequence C-c = calls the command idlwave-resolve and sends the line `RESOLVE_ROUTINE, 'routine_name'' to IDL in order to resolve (compile) it. The default routine to be resolved is taken from context, but you get a chance to edit it. Usually this is not necessary, since IDL automatically discovers routines on its path.

idlwave-resolve is one way to get a library module within reach of IDLWAVE's routine info collecting functions. A better way is to keep routine information available in catalogs (see section Catalogs). Routine info on modules will then be available without the need to compile the modules first, and even without a running shell.

See section Sources of Routine Info, for more information on the ways IDLWAVE collects data about routines, and how to update this information.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]   &