[ < ] [ > ]   [ << ] [ 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.

4.1 Code Formatting  Making code look nice
4.2 Routine Info  Calling Sequence and Keyword List
4.3 Online Help  One key press from source to help
4.4 Completion  Completing routine names and Keywords
4.5 Routine Source  Finding routines, the easy way
4.6 Resolving Routines  Force the Shell to compile a routine
4.7 Code Templates  Frequent code constructs
4.8 Abbreviations  Abbreviations for common commands
4.9 Actions  Changing case, Padding, End checking
4.10 Documentation Header  Inserting a standard header
4.11 Motion Commands  Moving through the structure of a program
4.12 Miscellaneous Options  Things that fit nowhere else

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

4.1 Code Formatting

4.1.1 Code Indentation  Reflecting the logical structure
4.1.2 Continued Statement Indentation  
4.1.3 Comment Indentation  Special indentation for comment lines
4.1.4 Continuation Lines and Filling  Splitting statements over lines
4.1.5 Syntax Highlighting  Font-lock support
4.1.6 Octals and Highlighting  Why "123 causes problems

The IDL language, with its early roots in FORTRAN, modern implementation in C, and liberal borrowing of features of many vector 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). See section 4.9 Actions, for information how to impose additional formatting conventions on foreign code.

User Option: idlwave-main-block-indent (0)
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 (4)
Extra indentation applied to block lines. If you change this, you probably also want to change idlwave-end-offset.

User Option: idlwave-end-offset (-4)
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)

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(4). 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 4.4.2 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:

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 A.4 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 A.3 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 A.3 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 A.3.1 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 4.3 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, RSI provides extensive documentation. IDLWAVE can access an HTML version of this documentation very quickly and accurately. This is 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, which is not part of the standalone IDLWAVE distribution, is required. The necessary files can be downloaded from the maintainers webpage. There are a variety of options for displaying the HTML help: see below. Help for routines without HTML documentation is also available, using the routine documentation header and/or 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 name The name of a routine (function, procedure, method).
Keyword Parameter A keyword parameter of a routine.
System Variable System variables like !DPI.
System Variable Tags System variables tags like !D.X_SIZE.
IDL Statement Statements like PRO, REPEAT, COMPILE_OPT, etc.
Class name A class name in an OBJ_NEW call.
Class Init 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.

4.3.1 Help with HTML Documentation  
4.3.2 Help with Source  

[ < ] [ > ]   [ << ] [ 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. 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. This function is used to set the variable browse-url-browser-function locally for IDLWAVE help only. Customize this 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/, the author's help browser of choice) 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 new 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.

N.B. For Windows users: IDLWAVE can bring up RSI help directly in the Microsoft HTMLHelp documentation supplied with IDL: no additional help files are needed. Be sure to set idlwave-system-directory and the help file will be found automatically (or, alternatively, specify its location directly with idlwave-html-help-location). The variable idlwave-help-use-hh controls whether HTMLHelp is used, and which application is called to invoke it (HH is the default). The free helper application KEYHH (http://www.keyworks.net/keyhh.htm) can be used instead, and is preferrable, as it permits loading new help topics into the same help window. KEYHH must be downloaded and installed separately.

See section B. 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-help-location `/usr/local/etc'
The directory where the `idl_html_help' dir or `idl.chm' HTMLHelp files live.

User Option: idlwave-help-use-hh nil
If set to 'hh or 'keyhh, use Windows native HTMLHelp with the specified help application.

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? 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 4.4.5 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 TAB in the IDLWAVE Shell -- see section 5.2 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 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.

4.4.1 Case of Completed Words  CaseOFcomPletedWords
4.4.2 Object Method Completion and Class Ambiguity  obj->Method, what?
4.4.3 Object Method Completion in the Shell  
4.4.4 Class and Keyword Inheritance  obj->Method, _EXTRA=e
4.4.5 Structure Tag Completion  Completing state.Tag

[ < ] [ > ]   [ << ] [ 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, 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. All classes it inherits from are considered as well where appropriate.

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).

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. This is not enabled by default -- the variable idlwave-store-inquired-class can be used to turn it on.

User Option: idlwave-completion-show-classes (1)
Non-nil means show 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 (nil)
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 class text property.

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

4.4.3 Object Method Completion in the Shell

In the IDLWAVE Shell (see section 5. 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). Setting the variable idlwave-store-inquired-class can eliminate unnecessary repetitive queries for the object's class, and speed up completion.

[ < ] [ > ]   [ << ] [ 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 4.2 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 4.4.2 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 4.3 Online Help).

[ < ] [ > ]   [ << ] [ 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.

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.

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 A.3 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 A. Sources of Routine Info, for more information on the ways IDLWAVE collects data about routines, and how to update this information.

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

4.7 Code Templates

IDLWAVE can insert IDL code templates into the buffer. For a few templates, this is done with direct key bindings:

C-c C-c CASE statement template
C-c C-f FOR loop template
C-c C-r REPEAT loop template
C-c C-w WHILE loop template

All code templates are also available as abbreviations (see section 4.8 Abbreviations).

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

4.8 Abbreviations

Special abbreviations exist to enable rapid entry of commonly used commands. Emacs abbreviations are expanded by typing text into the buffer and pressing SPC or RET. The special abbreviations used to insert code templates all start with a `\' (the backslash), or, optionally, any other character set in idlwave-abbrev-start-char. IDLWAVE ensures that abbreviations are only expanded where they should be (i.e., not in a string or comment), and permits the point to be moved after an abbreviation expansion --- very useful for positioning the mark inside of parentheses, etc.

Special abbreviations are pre-defined for code templates and other useful items. To visit the full list of abbreviations, use M-x idlwave-list-abbrevs.

Template abbreviations:

\pr PROCEDURE template
\fu FUNCTION template
\c CASE statement template
\f FOR loop template
\r REPEAT loop template
\w WHILE loop template
\i IF statement template
\elif IF-ELSE statement template

String abbreviations:

\ap arg_present()
\b begin
\cb byte()
\cc complex()
\cd double()
\cf float()
\cl long()
\co common
\cs string()
\cx fix()
\e else
\ec endcase
\ee endelse
\ef endfor
\ei endif else if
\el endif else
\en endif
\er endrep
\es endswitch
\ew endwhile
\g goto,
\h help,
\ik if keyword_set() then
\iap if arg_present() then
\ine if n_elements() eq 0 then
\inn if n_elements() ne 0 then
\k keyword_set()
\n n_elements()
\np n_params()
\oi on_ioerror,
\or openr,
\ou openu,
\ow openw,
\p print,
\pt plot,
\re read,
\rf readf,
\rt return
\ru readu,
\s size()
\sc strcompress()
\sl strlowcase()
\sm strmid()
\sn strlen()
\sp strpos()
\sr strtrim()
\st strput()
\su strupcase()
\t then
\u until
\wc widget_control,
\wi widget_info()
\wu writeu,

You can easily add your own abbreviations or override existing abbrevs with define-abbrev in your mode hook, using the convenience function idlwave-define-abbrev:

(add-hook 'idlwave-mode-hook
          (lambda ()
            (idlwave-define-abbrev "wb" "widget_base()"
                     (idlwave-keyword-abbrev 1))
            (idlwave-define-abbrev "ine" "IF N_Elements() EQ 0 THEN"
                     (idlwave-keyword-abbrev 11))))

Notice how the abbreviation (here wb) and its expansion (widget_base()) are given as arguments, and the single argument to idlwave-keyword-abbrev (here 1) specifies how far back to move the point upon expansion (in this example, to put it between the parentheses).

The abbreviations are expanded in upper or lower case, depending upon the variables idlwave-abbrev-change-case and, for reserved word templates, idlwave-reserved-word-upcase (see section 4.9.3 Case Changes).

User Option: idlwave-abbrev-start-char ("\")
A single character string used to start abbreviations in abbrev mode. Beware of common characters which might naturally occur in sequence with abbreviation strings.

User Option: idlwave-abbrev-move (t)
Non-nil means the abbrev hook can move point, e.g. to end up between the parentheses of a function call.

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

4.9 Actions

Actions are special formatting commands which are executed automatically while you write code in order to check the structure of the program or to enforce coding standards. Most actions which have been implemented in IDLWAVE are turned off by default, assuming that the average user wants her code the way she writes it. But if you are a lazy typist and want your code to adhere to certain standards, actions can be helpful.

Actions can be applied in three ways:

User Option: idlwave-do-actions (nil)
Non-nil means performs actions when indenting. Individual action settings are described below and set separately.

4.9.1 Block Boundary Check  Is the END statement correct?
4.9.2 Padding Operators  Enforcing space around `=' etc
4.9.3 Case Changes  Enforcing upper case keywords

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

4.9.1 Block Boundary Check

Whenever you type an END statement, IDLWAVE finds the corresponding start of the block and the cursor blinks back to that location for a second. If you have typed a specific END, like ENDIF or ENDCASE, you get a warning if that terminator does not match the type of block it terminates.

Set the variable idlwave-expand-generic-end in order to have all generic END statements automatically expanded to the appropriate type. You can also type C-c ] to close the current block by inserting the appropriate END statement.

User Option: idlwave-show-block (t)
Non-nil means point blinks to block beginning for idlwave-show-begin.

User Option: idlwave-expand-generic-end (t)
Non-nil means expand generic END to ENDIF/ENDELSE/ENDWHILE etc.

User Option: idlwave-reindent-end (t)
Non-nil means re-indent line after END was typed.

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

4.9.2 Padding Operators

Some operators can be automatically surrounded by spaces. This can happen when the operator is typed, or later when the line is indented. IDLWAVE can pad the operators `&', `<', `>', `,', `=', and `->', but this feature is turned off by default. If you want to turn it on, customize the variables idlwave-surround-by-blank and idlwave-do-actions. You can also define similar actions for other operators by using the function idlwave-action-and-binding in the mode hook. For example, to enforce space padding of the `+' and `*' operators, try this in `.emacs'

(add-hook 'idlwave-mode-hook
  (lambda ()
     (setq idlwave-surround-by-blank t)  ; Turn this type of actions on
     (idlwave-action-and-binding "*" '(idlwave-surround 1 1))
     (idlwave-action-and-binding "+" '(idlwave-surround 1 1))))

User Option: idlwave-surround-by-blank (nil)
Non-nil means enable idlwave-surround. If non-nil, `=', `<', `>', `&', `,', `->' are surrounded with spaces by idlwave-surround.

User Option: idlwave-pad-keyword (t)
Non-nil means pad `=' for keywords like assignments.

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

4.9.3 Case Changes

Actions can be used to change the case of reserved words or expanded abbreviations by customizing the variables idlwave-abbrev-change-case and idlwave-reserved-word-upcase. If you want to change the case of additional words automatically, put something like the following into your `.emacs' file:

(add-hook 'idlwave-mode-hook
  (lambda ()
     ;;  Capitalize system vars
     (idlwave-action-and-binding idlwave-sysvar '(capitalize-word 1) t)
     ;;  Capitalize procedure name
     (idlwave-action-and-binding "\\<\\(pro\\|function\\)\\>[ \t]*\\<"
                                 '(capitalize-word 1) t)
     ;;  Capitalize common block name
     (idlwave-action-and-binding "\\<common\\>[ \t]+\\<" 
                                 '(capitalize-word 1) t)))

For more information, see the documentation string for the function idlwave-action-and-binding. For information on controlling the case of routines, keywords, classes, and methods as they are completed, see 4.4 Completion.

User Option: idlwave-abbrev-change-case (nil)
Non-nil means all abbrevs will be forced to either upper or lower case. Legal values are nil, t, and down.

User Option: idlwave-reserved-word-upcase (nil)
Non-nil means reserved words will be made upper case via abbrev expansion.

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

4.10 Documentation Header

The command C-c C-h inserts a standard routine header into the buffer, with the usual fields for documentation (a different header can be specified with idlwave-file-header). One of the keywords is `MODIFICATION HISTORY' under which the changes to a routine can be recorded. The command C-c C-m jumps to the `MODIFICATION HISTORY' of the current routine or file and inserts the user name with a timestamp.

User Option: idlwave-file-header
The doc-header template or a path to a file containing it.

User Option: idlwave-header-to-beginning-of-file (nil)
Non-nil means the documentation header will always be at start of file.

User Option: idlwave-timestamp-hook
The hook function used to update the timestamp of a function.

User Option: idlwave-doc-modifications-keyword
The modifications keyword to use with the log documentation commands.

User Option: idlwave-doclib-start
Regexp matching the start of a document library header.

User Option: idlwave-doclib-end
Regexp matching the start of a document library header.

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

4.11 Motion Commands

IDLWAVE supports both `Imenu' and `Func-menu', two packages which make it easy to jump to the definitions of functions and procedures in the current file with a pop-up selection. To bind `Imenu' to a mouse-press, use in your `.emacs':

(define-key global-map [S-down-mouse-3] 'imenu)

In addition, `Speedbar' support allows convenient navigation of a source tree of IDL routine files, quickly stepping to routine definitions. See Tools->Display Speedbar.

Several commands allow you to move quickly through the structure of an IDL program:

C-M-a Beginning of subprogram
C-M-e End of subprogram
C-c { Beginning of block (stay inside the block)
C-c } End of block (stay inside the block)
C-M-n Forward block (on same level)
C-M-p Backward block (on same level)
C-M-d Down block (enters a block)
C-M-u Backward up block (leaves a block)
C-c C-n Next Statement

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

4.12 Miscellaneous Options

User Option: idlwave-help-application
The external application providing reference help for programming.

User Option: idlwave-startup-message (t)
Non-nil means display a startup message when idlwave-mode' is first called.

User Option: idlwave-mode-hook
Normal hook. Executed when a buffer is put into idlwave-mode.

User Option: idlwave-load-hook
Normal hook. Executed when `idlwave.el' is loaded.

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

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html