Fix typos (/Application -> /Applications)
[emacs.git] / man / idlwave.texi
blob94f59249892acca05262cb780636d6abcb6d7018
1 \input texinfo  @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename ../info/idlwave
4 @settitle IDLWAVE User Manual
5 @dircategory Emacs
6 @direntry
7 * IDLWAVE: (idlwave).   Major mode and shell for IDL files.
8 @end direntry
9 @synindex ky cp
10 @syncodeindex vr cp
11 @syncodeindex fn cp
12 @set VERSION 6.0
13 @set EDITION 6.0
14 @set IDLVERSION 6.2
15 @set NSYSROUTINES 1966
16 @set DATE Feb, 2006
17 @set AUTHOR J.D. Smith & Carsten Dominik
18 @set AUTHOREMAIL jdsmith@@as.arizona.edu
19 @set MAINTAINER J.D. Smith
20 @set MAINTAINEREMAIL jdsmith@@as.arizona.edu
21 @set IDLWAVEHOMEPAGE http://idlwave.org/
22 @c %**end of header
23 @finalout
25 @ifinfo 
26 This file documents IDLWAVE, a major mode for editing IDL files with
27 Emacs, and interacting with an IDL shell run as a subprocess.
29 This is edition @value{EDITION} of the IDLWAVE User Manual for IDLWAVE
30 @value{VERSION}
32 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
33           2006, 2007 Free Software Foundation, Inc.
35 Permission is granted to copy, distribute and/or modify this document
36 under the terms of the GNU Free Documentation License, Version 1.2 or
37 any later version published by the Free Software Foundation; with no
38 Invariant Sections, with the Front-Cover texts being ``A GNU
39 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
40 license is included in the section entitled ``GNU Free Documentation
41 License'' in the Emacs manual.
43 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
44 this GNU Manual, like GNU software.  Copies published by the Free
45 Software Foundation raise funds for GNU development.''
47 This document is part of a collection distributed under the GNU Free
48 Documentation License.  If you want to distribute this document
49 separately from the collection, you can do so by adding a copy of the
50 license to the document, as described in section 6 of the license.
51 @end ifinfo
53 @titlepage
54 @title IDLWAVE User Manual
55 @subtitle Emacs major mode and shell for IDL
56 @subtitle Edition @value{EDITION}, @value{DATE}
58 @author by J.D. Smith & Carsten Dominik
59 @page
60 This is edition @value{EDITION} of the @cite{IDLWAVE User Manual} for
61 IDLWAVE version @value{VERSION}, @value{DATE}.
62 @sp 2
63 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
64           2006, 2007 Free Software Foundation, Inc.
65 @sp 2
66 @cindex Copyright, of IDLWAVE
67 Permission is granted to copy, distribute and/or modify this document
68 under the terms of the GNU Free Documentation License, Version 1.2 or
69 any later version published by the Free Software Foundation; with no
70 Invariant Sections, with the Front-Cover texts being ``A GNU
71 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
72 license is included in the section entitled ``GNU Free Documentation
73 License'' in the Emacs manual.
75 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
76 this GNU Manual, like GNU software.  Copies published by the Free
77 Software Foundation raise funds for GNU development.''
79 This document is part of a collection distributed under the GNU Free
80 Documentation License.  If you want to distribute this document
81 separately from the collection, you can do so by adding a copy of the
82 license to the document, as described in section 6 of the license.
83 @end titlepage
84 @contents
86 @page
88 @ifnottex
90 @node Top, Introduction, (dir), (dir)
92 IDLWAVE is a package which supports editing source code written in the
93 Interactive Data Language (IDL), and running IDL as an inferior shell.
95 @end ifnottex
97 @menu
98 * Introduction::                What IDLWAVE is, and what it is not
99 * IDLWAVE in a Nutshell::       One page quick-start guide
100 * Getting Started::             Tutorial
101 * The IDLWAVE Major Mode::      The mode for editing IDL programs
102 * The IDLWAVE Shell::           The mode for running IDL as an inferior program
103 * Acknowledgements::            Who did what
104 * Sources of Routine Info::     How does IDLWAVE know about routine XYZ     
105 * HTML Help Browser Tips::      
106 * Configuration Examples::      The user is king
107 * Windows and MacOS::           What still works, and how
108 * Troubleshooting::             When good computers turn bad
109 * GNU Free Documentation License:: The license for this documentation.
110 * Index::                       Fast access
112 @detailmenu
113  --- The Detailed Node Listing ---
115 Getting Started (Tutorial)
117 * Lesson I -- Development Cycle::  
118 * Lesson II -- Customization::  
119 * Lesson III -- User Catalog::  
121 The IDLWAVE Major Mode
123 * Code Formatting::             Making code look nice
124 * Routine Info::                Calling Sequence and Keyword List
125 * Online Help::                 One key press from source to help
126 * Completion::                  Completing routine names and Keywords
127 * Routine Source::              Finding routines, the easy way
128 * Resolving Routines::          Force the Shell to compile a routine
129 * Code Templates::              Frequent code constructs
130 * Abbreviations::               Abbreviations for common commands
131 * Actions::                     Changing case, Padding, End checking
132 * Doc Header::                  Inserting a standard header
133 * Motion Commands::             Moving through the structure of a program
134 * Misc Options::                Things that fit nowhere else
136 Code Formatting
138 * Code Indentation::            Reflecting the logical structure
139 * Continued Statement Indentation::  
140 * Comment Indentation::         Special indentation for comment lines
141 * Continuation Lines::          Splitting statements over lines
142 * Syntax Highlighting::         Font-lock support
143 * Octals and Highlighting::     Why "123 causes problems
145 Online Help
147 * Help with HTML Documentation::  
148 * Help with Source::            
150 Completion
152 * Case of Completed Words::     CaseOFcomPletedWords
153 * Object Method Completion and Class Ambiguity::  obj->Method, what?
154 * Object Method Completion in the Shell::  
155 * Class and Keyword Inheritance::  obj->Method, _EXTRA=e
156 * Structure Tag Completion::    Completing state.Tag
158 Actions
160 * Block Boundary Check::        Is the END statement correct?
161 * Padding Operators::           Enforcing space around `=' etc
162 * Case Changes::                Enforcing upper case keywords
164 The IDLWAVE Shell
166 * Starting the Shell::          How to launch IDL as a subprocess
167 * Using the Shell::             Interactively working with the Shell
168 * Commands Sent to the Shell::  
169 * Debugging IDL Programs::      
170 * Examining Variables::         
171 * Custom Expression Examination::  
173 Debugging IDL Programs
175 * A Tale of Two Modes::         
176 * Debug Key Bindings::          
177 * Breakpoints and Stepping::    
178 * Compiling Programs::          
179 * Walking the Calling Stack::   
180 * Electric Debug Mode::         
182 Sources of Routine Info
184 * Routine Definitions::         Where IDL Routines are defined.
185 * Routine Information Sources::  So how does IDLWAVE know about...
186 * Catalogs::                    
187 * Load-Path Shadows::           Routines defined in several places
188 * Documentation Scan::          Scanning the IDL Manuals
190 Catalogs
192 * Library Catalogs::            
193 * User Catalog::                
195 @end detailmenu
196 @end menu
198 @node Introduction, IDLWAVE in a Nutshell, Top, Top
199 @chapter Introduction
200 @cindex Introduction
201 @cindex CORBA (Common Object Request Broker Architecture)
202 @cindex Interface Definition Language
203 @cindex Interactive Data Language
204 @cindex cc-mode.el
205 @cindex @file{idl.el}
206 @cindex @file{idl-shell.el}
207 @cindex Feature overview
209 IDLWAVE is a package which supports editing source files written in
210 the Interactive Data Language (IDL), and running IDL as an inferior shell@footnote{IDLWAVE can also be used
211 for editing source files for the related WAVE/CL language, but with only
212 limited support.}.  It is a feature-rich replacement for the IDLDE
213 development environment included with IDL, and uses the full power of
214 Emacs to make editing and running IDL programs easier, quicker, and more
215 structured.
217 IDLWAVE consists of two main parts: a major mode for editing IDL
218 source files (@code{idlwave-mode}) and a mode for running the IDL
219 program as an inferior shell (@code{idlwave-shell-mode}).  Although
220 one mode can be used without the other, both work together closely to
221 form a complete development environment. Here is a brief summary of
222 what IDLWAVE does:
224 @itemize @bullet
225 @item 
226 Smart code indentation and automatic-formatting.
227 @item
228 Three level syntax highlighting support.
229 @item 
230 Context-sensitive display of calling sequences and keywords for more
231 than 1000 native IDL routines, extendible to any additional number of
232 local routines, and already available with many pre-scanned libraries.
233 @item
234 Fast, context-sensitive online HTML help, or source-header help for
235 undocumented routines.
236 @item
237 Context sensitive completion of routine names, keywords, system
238 variables, class names and much more.
239 @item
240 Easy insertion of code templates and abbreviations of common constructs.
241 @item
242 Automatic corrections to enforce a variety of customizable coding
243 standards.
244 @item
245 Integrity checks and auto-termination of logical blocks.
246 @item
247 Routine name space conflict search with likelihood-of-use ranking.
248 @item
249 Support for @file{imenu} (Emacs) and @file{func-menu} (XEmacs).
250 @item
251 Documentation support.
252 @item
253 Running IDL as an inferior Shell with history search, command line
254 editing and all the completion and routine info capabilities present in
255 IDL source buffers.
256 @item
257 Full handling of debugging with breakpoints, with interactive setting
258 of break conditions, and easy stepping through code.
259 @item
260 Compilation, execution and interactive single-keystroke debugging of
261 programs directly from the source buffer.
262 @item
263 Quick, source-guided navigation of the calling stack, with variable
264 inspection, etc.
265 @item
266 Examining variables and expressions with a mouse click.
267 @item
268 And much, much more...
269 @end itemize
271 @ifnottex
272 @cindex Screenshots
273 Here are a number of screenshots showing IDLWAVE in action:
275 @itemize @bullet
276 @item
277 @uref{http://idlwave.org/screenshots/emacs_21_nav.gif,An IDLWAVE buffer}
278 @item
279 @uref{http://idlwave.org/screenshots/emacs_21_keys.gif,A keyword being completed}
280 @item
281 @uref{http://idlwave.org/screenshots/emacs_21_help.gif,Online help text.}
282 @item
283 @uref{http://idlwave.org/screenshots/emacs_21_ri.gif,Routine information displayed}
284 @item
285 @uref{http://idlwave.org/screenshots/emacs_21_bp.gif,Debugging code
286 stopped at a breakpoint}
287 @end itemize
288 @end ifnottex
290 IDLWAVE is the distant successor to the @file{idl.el} and
291 @file{idl-shell.el} files written by Chris Chase.  The modes and files
292 had to be renamed because of a name space conflict with CORBA's
293 @code{idl-mode}, defined in Emacs in the file @file{cc-mode.el}.
295 In this manual, each section ends with a list of related user options.
296 Don't be confused by the sheer number of options available --- in most
297 cases the default settings are just fine.  The variables are listed here
298 to make sure you know where to look if you want to change anything.  For
299 a full description of what a particular variable does and how to
300 configure it, see the documentation string of that variable (available
301 with @kbd{C-h v}).  Some configuration examples are also given in the
302 appendix.
304 @node IDLWAVE in a Nutshell, Getting Started, Introduction, Top
305 @chapter IDLWAVE in a Nutshell
306 @cindex Summary of important commands
307 @cindex IDLWAVE in a Nutshell
308 @cindex Nutshell, IDLWAVE in a
310 @subheading Editing IDL Programs
312 @multitable @columnfractions .15 .85
313 @item @key{TAB}
314 @tab Indent the current line relative to context.
315 @item @kbd{C-M-\}
316 @tab Re-indent all lines in the current region.
317 @item @kbd{C-M-q}
318 @tab Re-indent all lines in the current routine.
319 @item @kbd{C-u @key{TAB}}
320 @tab Re-indent all lines in the current statement.
321 @item @kbd{M-@key{RET}}
322 @tab Start a continuation line, splitting the current line at point.
323 @item @kbd{M-q}
324 @tab Fill the current comment paragraph.
325 @item @kbd{C-c ?}
326 @tab Display calling sequence and keywords for the procedure or function call
327 at point.
328 @item @kbd{M-?}
329 @tab Load context sensitive online help for nearby routine, keyword, etc.
330 @item @kbd{M-@key{TAB}}
331 @tab Complete a procedure name, function name or keyword in the buffer.
332 @item @kbd{C-c C-i}
333 @tab Update IDLWAVE's knowledge about functions and procedures.
334 @item @kbd{C-c C-v}
335 @tab Visit the source code of a procedure/function.
336 @item @kbd{C-u C-c C-v}
337 @tab Visit the source code of a procedure/function in this buffer.
338 @item @kbd{C-c C-h}
339 @tab Insert a standard documentation header.
340 @item @kbd{C-c @key{RET}}
341 @tab Insert a new timestamp and history item in the documentation header.
342 @end multitable
344 @subheading Running the IDLWAVE Shell, Debugging Programs
346 @multitable @columnfractions .15 .85
347 @item @kbd{C-c C-s}
348 @tab Start IDL as a subprocess and/or switch to the shell buffer.
349 @item @key{Up}, @kbd{M-p}
350 @tab Cycle back through IDL command history.
351 @item @key{Down},@kbd{M-n}
352 @tab Cycle forward.
353 @item @kbd{@key{TAB}}
354 @tab Complete a procedure name, function name or keyword in the shell buffer.
355 @item @kbd{C-c C-d C-c}
356 @tab Save and compile the source file in the current buffer.
357 @item @kbd{C-c C-d C-x}
358 @tab Go to next syntax error.
359 @item @kbd{C-c C-d C-v}
360 @tab Switch to electric debug mode.
361 @item @kbd{C-c C-d C-b}
362 @tab Set a breakpoint at the nearest viable source line.
363 @item @kbd{C-c C-d C-d}
364 @tab Clear the nearest breakpoint.
365 @item @kbd{C-c C-d [}
366 @tab Go to the previous breakpoint.
367 @item @kbd{C-c C-d ]}
368 @tab Go to the next breakpoint.
369 @item @kbd{C-c C-d C-p}
370 @tab Print the value of the expression near point in IDL.
371 @end multitable
373 @subheading Commonly used Settings in @file{.emacs}
374 @lisp
375 ;; Change the indentation preferences
376 ;; Start autoloading routine info after 2 idle seconds
377 (setq idlwave-init-rinfo-when-idle-after 2)
378 ;; Pad operators with spaces
379 (setq idlwave-do-actions t
380       idlwave-surround-by-blank t)
381 ;; Syntax Highlighting
382 (add-hook 'idlwave-mode-hook 'turn-on-font-lock)
383 ;; Automatically start the shell when needed
384 (setq idlwave-shell-automatic-start t)
385 ;; Bind debugging commands with CONTROL and SHIFT modifiers
386 (setq idlwave-shell-debug-modifiers '(control shift))
387 @end lisp
389 @html
390 <A NAME="TUTORIAL"></A>
391 @end html
393 @node Getting Started, The IDLWAVE Major Mode, IDLWAVE in a Nutshell, Top
394 @chapter Getting Started (Tutorial)
395 @cindex Quick-Start
396 @cindex Tutorial
397 @cindex Getting Started
399 @menu
400 * Lesson I -- Development Cycle::  
401 * Lesson II -- Customization::  
402 * Lesson III -- User Catalog::  
403 @end menu
405 @node  Lesson I -- Development Cycle, Lesson II -- Customization, Getting Started, Getting Started
406 @section Lesson I: Development Cycle
408 The purpose of this tutorial is to guide you through a very basic
409 development cycle using IDLWAVE.  We will paste a simple program into
410 a buffer and use the shell to compile, debug and run it.  On the way
411 we will use many of the important IDLWAVE commands.  Note, however,
412 that IDLWAVE has many more capabilities than covered here, which can
413 be discovered by reading the entire manual, or hovering over the
414 shoulder of your nearest IDLWAVE guru for a few days.
416 It is assumed that you have access to Emacs or XEmacs with the full
417 IDLWAVE package including online help.  We also assume that you are
418 familiar with Emacs and can read the nomenclature of key presses in
419 Emacs (in particular, @kbd{C} stands for @key{CONTROL} and @kbd{M} for
420 @key{META} (often the @key{ALT} key carries this functionality)).
422 Open a new source file by typing:
424 @example
425 @kbd{C-x C-f tutorial.pro @key{RET}}
426 @end example
428 A buffer for this file will pop up, and it should be in IDLWAVE mode,
429 indicated in the mode line just below the editing window.  Also, the
430 menu bar should contain @samp{IDLWAVE}.
432 Now cut-and-paste the following code, also available as
433 @file{tutorial.pro} in the IDLWAVE distribution.
435 @example
436 function daynr,d,m,y
437   ;; compute a sequence number for a date
438   ;; works 1901-2099.
439   if y lt 100 then y = y+1900
440   if m le 2 then delta = 1 else delta = 0
441   m1 = m + delta*12 + 1
442   y1 = y * delta
443   return, d + floor(m1*30.6)+floor(y1*365.25)+5
445      
446 function weekday,day,month,year
447   ;; compute weekday number for date
448   nr = daynr(day,month,year)
449   return, nr mod 7
451      
452 pro plot_wday,day,month
453   ;; Plot the weekday of a date in the first 10 years of this century.
454   years = 2000,+indgen(10)
455   wdays = intarr(10)
456   for i=0,n_elements(wdays)-1 do begin
457       wdays[i] =  weekday(day,month,years[i])
458   end
459   plot,years,wdays,YS=2,YT="Wday (0=Sunday)"
461 @end example
463 The indentation probably looks funny, since it's different from the
464 settings you use, so use the @key{TAB} key in each line to
465 automatically line it up (or, more quickly, @emph{select} the entire
466 buffer with @kbd{C-x h}, and indent the whole region with
467 @kbd{C-M-\}).  Notice how different syntactical elements are
468 highlighted in different colors, if you have set up support for
469 font-lock.
471 Let's check out two particular editing features of IDLWAVE.  Place the
472 cursor after the @code{end} statement of the @code{for} loop and press
473 @key{SPC}.  IDLWAVE blinks back to the beginning of the block and
474 changes the generic @code{end} to the specific @code{endfor}
475 automatically (as long as the variable @code{idlwave-expand-generic-end}
476 is turned on --- @pxref{Lesson II -- Customization}).  Now place the
477 cursor in any line you would like to split and press @kbd{M-@key{RET}}.
478 The line is split at the cursor position, with the continuation @samp{$}
479 and indentation all taken care of.  Use @kbd{C-/} to undo the last
480 change.
482 The procedure @code{plot_wday} is supposed to plot the day of the week
483 of a given date for the first 10 years of the 21st century.  As in
484 most code, there are a few bugs, which we are going to use IDLWAVE to
485 help us fix.
487 First, let's launch the IDLWAVE shell.  You do this with the command
488 @kbd{C-c C-s}.  The Emacs window will split or another window will popup
489 to display IDL running in a shell interaction buffer.  Type a few
490 commands like @code{print,!PI} to convince yourself that you can work
491 there just as well as in a terminal, or the IDLDE.  Use the arrow keys
492 to cycle through your command history.  Are we having fun now?
494 Now go back to the source window and type @kbd{C-c C-d C-c} to compile
495 the program.  If you watch the shell buffer, you see that IDLWAVE types
496 @samp{.run "tutorial.pro"} for you.  But the compilation fails because
497 there is a comma in the line @samp{years=...}.  The line with the error
498 is highlighted and the cursor positioned at the error, so remove the
499 comma (you should only need to hit @kbd{Delete}!).  Compile again, using
500 the same keystrokes as before.  Notice that the file is automatically
501 saved for you.  This time everything should work fine, and you should
502 see the three routines compile.
504 Now we want to use the command to plot the day of the week on January
505 1st.  We could type the full command ourselves, but why do that?  Go
506 back to the shell window, type @samp{plot_} and hit @key{TAB}.  After
507 a bit of a delay (while IDLWAVE initializes its routine info database,
508 if necessary), the window will split to show all procedures it knows
509 starting with that string, and @w{@code{plot_wday}} should be one of
510 them.  Saving the buffer alerted IDLWAVE about this new routine.
511 Click with the middle mouse button on @code{plot_wday} and it will be
512 copied to the shell buffer, or if you prefer, add @samp{w} to
513 @samp{plot_} to make it unambiguous (depending on what other routines
514 starting with @samp{plot_} you have installed on your system), hit
515 @key{TAB} again, and the full routine name will be completed.  Now
516 provide the two arguments:
518 @example
519 plot_wday,1,1
520 @end example
522 @noindent and press @key{RET}.  This fails with an error message telling
523 you the @code{YT} keyword to plot is ambiguous.  What are the allowed
524 keywords again?  Go back to the source window and put the cursor into
525 the `plot' line and press @kbd{C-c ?}.  This shows the routine info
526 window for the plot routine, which contains a list of keywords, along
527 with the argument list.  Oh, we wanted @code{YTITLE}.  Fix that up.
528 Recompile with @kbd{C-c C-d C-c}. Jump back into the shell with
529 @kbd{C-c C-s}, press the @key{UP} arrow to recall the previous command
530 and execute again.
532 This time we get a plot, but it is pretty ugly --- the points are all
533 connected with a line.  Hmm, isn't there a way for @code{plot} to use
534 symbols instead?  What was that keyword?  Position the cursor on the
535 plot line after a comma (where you'd normally type a keyword), and hit
536 @kbd{M-@key{Tab}}.  A long list of plot's keywords appears.  Aha,
537 there it is, @code{PSYM}.  Middle click to insert it.  An @samp{=}
538 sign is included for you too.  Now what were the values of @code{PSYM}
539 supposed to be?  With the cursor on or after the keyword, press
540 @kbd{M-?} for online help (alternatively, you could have right clicked
541 on the colored keyword itself in the completion list).  A browser will
542 pop up showing the HTML documentation for the @code{PYSM} keyword.
543 OK, let's use diamonds=4.  Fix this, recompile (you know the command
544 by now: @kbd{C-c C-d C-c}), go back to the shell (if it's vanished,
545 you know what to do: @kbd{C-c C-s}) and execute again.  Now things
546 look pretty good.
548 Let's try a different day --- how about April fool's day?
550 @example
551 plot_wday,1,4
552 @end example
554 Oops, this looks very wrong.  All April Fool's days cannot be Fridays!
555 We've got a bug in the program, perhaps in the @code{daynr} function.
556 Let's put a breakpoint on the last line there.  Position the cursor on
557 the @samp{return, d+...} line and press @kbd{C-c C-d C-b}.  IDL sets a
558 breakpoint (as you see in the shell window), and the break line is
559 indicated.  Back to the shell buffer, re-execute the previous command.
560 IDL stops at the line with the breakpoint.  Now hold down the SHIFT
561 key and click with the middle mouse button on a few variables there:
562 @samp{d}, @samp{y}, @samp{m}, @samp{y1}, etc.  Maybe @code{d} isn't
563 the correct type.  CONTROL-SHIFT middle-click on it for help.  Well,
564 it's an integer, so that's not the problem.  Aha, @samp{y1} is zero,
565 but it should be the year, depending on delta.  Shift click
566 @samp{delta} to see that it's 0.  Below, we see the offending line:
567 @samp{y1=y*delta...} the multiplication should have been a minus sign!
568 Hit @kbd{q} to exit the debugging mode, and fix the line to read:
570 @example
571 y1 = y - delta
572 @end example
574 Now remove all breakpoints: @kbd{C-c C-d C-a}.  Recompile and rerun the
575 command.  Everything should now work fine.  How about those leap years?
576 Change the code to plot 100 years and see that every 28 years, the
577 sequence of weekdays repeats.
579 @node  Lesson II -- Customization, Lesson III -- User Catalog, Lesson I -- Development Cycle, Getting Started
580 @section Lesson II: Customization
582 Emacs is probably the most customizable piece of software ever written,
583 and it would be a shame if you did not make use of this to adapt IDLWAVE
584 to your own preferences.  Customizing Emacs or IDLWAVE is accomplished
585 by setting Lisp variables in the @file{.emacs} file in your home
586 directory --- but do not be dismayed; for the most part, you can just
587 copy and work from the examples given here.
589 Let's first use a boolean variable.  These are variables which you turn
590 on or off, much like a checkbox. A value of @samp{t} means on, a value
591 of @samp{nil} means off.  Copy the following line into your
592 @file{.emacs} file, exit and restart Emacs.
594 @lisp
595 (setq idlwave-reserved-word-upcase t)
596 @end lisp
598 When this option is turned on, each reserved word you type into an IDL
599 source buffer will be converted to upper case when you press @key{SPC}
600 or @key{RET} right after the word.  Try it out!  @samp{if} changes to
601 @samp{IF}, @samp{begin} to @samp{BEGIN}.  If you don't like this
602 behavior, remove the option again from your @file{.emacs} file and
603 restart Emacs.
605 You likely have your own indentation preferences for IDL code.  For
606 example, some may prefer to indent the main block of an IDL program
607 slightly from the margin and use only 3 spaces as indentation between
608 @code{BEGIN} and @code{END}.  Try the following lines in @file{.emacs}:
610 @lisp
611 (setq idlwave-main-block-indent 1)
612 (setq idlwave-block-indent 3)
613 (setq idlwave-end-offset -3)
614 @end lisp
616 Restart Emacs, and re-indent the program we developed in the first part
617 of this tutorial with @kbd{C-c h} and @kbd{C-M-\}.  You may want to keep
618 these lines in @file{.emacs}, with values adjusted to your likings.  If
619 you want to get more information about any of these variables, type,
620 e.g., @kbd{C-h v idlwave-main-block-indent @key{RET}}.  To find which
621 variables can be customized, look for items marked @samp{User Option:}
622 throughout this manual.
624 If you cannot seem to master this Lisp customization in @file{.emacs},
625 there is another, more user-friendly way to customize all the IDLWAVE
626 variables.  You can access it through the IDLWAVE menu in one of the
627 @file{.pro} buffers, menu item @code{Customize->Browse IDLWAVE
628 Group}. Here you'll be presented with all the various variables grouped
629 into categories.  You can navigate the hierarchy (e.g. @samp{IDLWAVE
630 Code Formatting->Idlwave Abbrev And Indent Action->Idlwave Expand
631 Generic End} to turn on @code{END} expansion), read about the variables,
632 change them, and `Save for Future Sessions'.  Few of these variables
633 need customization, but you can exercise considerable control over
634 IDLWAVE's functionality with them.
636 You may also find the key bindings used for the debugging commands too
637 long and complicated.  Often we have heard complaints along the lines
638 of, ``Do I really have to go through the finger gymnastics of @kbd{C-c
639 C-d C-c} to run a simple command?''  Due to Emacs rules and
640 conventions, shorter bindings cannot be set by default, but you can
641 easily enable them.  First, there is a way to assign all debugging
642 commands in a single sweep to another simpler combination.  The only
643 problem is that we have to use something which Emacs does not need for
644 other important commands.  One good option is to execute debugging
645 commands by holding down @key{CONTROL} and @key{SHIFT} while pressing
646 a single character: @kbd{C-S-b} for setting a breakpoint, @kbd{C-S-c}
647 for compiling the current source file, @kbd{C-S-a} for deleting all
648 breakpoints (try it, it's easier).  You can enable this with:
650 @lisp
651 (setq idlwave-shell-debug-modifiers '(shift control))
652 @end lisp
654 @noindent If you have a special keyboard with, for example, a
655 @key{SUPER} key, you could even shorten that:
657 @lisp
658 (setq idlwave-shell-debug-modifiers '(super))
659 @end lisp
661 @noindent to get compilation on @kbd{S-c}.  Often, a modifier key like
662 @key{SUPER} or @key{HYPER} is bound or can be bound to an otherwise
663 unused key on your keyboard --- consult your system documentation.
665 You can also assign specific commands to keys.  This you must do in the
666 @emph{mode-hook}, a special function which is run when a new IDLWAVE
667 buffer gets set up.  The possibilities for key customization are
668 endless.  Here we set function keys f4-f8 to common debugging commands.
670 @lisp
671 ;; First for the source buffer
672 (add-hook 'idlwave-mode-hook
673    (lambda ()
674     (local-set-key [f4] 'idlwave-shell-retall)
675     (local-set-key [f5] 'idlwave-shell-break-here)
676     (local-set-key [f6] 'idlwave-shell-clear-current-bp)
677     (local-set-key [f7] 'idlwave-shell-cont)
678     (local-set-key [f8] 'idlwave-shell-clear-all-bp)))
679 ;; Then for the shell buffer
680 (add-hook 'idlwave-shell-mode-hook
681    (lambda ()
682     (local-set-key [f4] 'idlwave-shell-retall)
683     (local-set-key [f5] 'idlwave-shell-break-here)
684     (local-set-key [f6] 'idlwave-shell-clear-current-bp)
685     (local-set-key [f7] 'idlwave-shell-cont)
686     (local-set-key [f8] 'idlwave-shell-clear-all-bp)))
687 @end lisp
689 @node  Lesson III -- User Catalog,  , Lesson II -- Customization, Getting Started
690 @section Lesson III: User and Library Catalogs
692 We have already used the routine info display in the first part of this
693 tutorial.  This was the invoked using @kbd{C-c ?}, and displays
694 information about the IDL routine near the cursor position.  Wouldn't it
695 be nice to have the same kind of information available for your own
696 routines and for the huge amount of code in major libraries like JHUPL
697 or the IDL-Astro library?  In many cases, you may already have this
698 information.  Files named @file{.idlwave_catalog} in library directories
699 contain scanned information on the routines in that directory; many
700 popular libraries ship with these ``library catalogs'' pre-scanned.
701 Users can scan their own routines in one of two ways: either using the
702 supplied tool to scan directories and build their own
703 @file{.idlwave_catalog} files, or using the built-in method to create a
704 single ``user catalog'', which we'll show here.  @xref{Catalogs}, for
705 more information on choosing which method to use.
707 To build a user catalog, select @code{Routine Info/Select Catalog
708 Directories} from the IDLWAVE entry in the menu bar.  If necessary,
709 start the shell first with @kbd{C-c C-s} (@pxref{Starting the Shell}).
710 IDLWAVE will find out about the IDL @code{!PATH} variable and offer a
711 list of directories on the path.  Simply select them all (or whichever
712 you want --- directories with existing library catalogs will not be
713 selected by default) and click on the @samp{Scan&Save} button.  Then
714 go for a cup of coffee while IDLWAVE collects information for each and
715 every IDL routine on your search path.  All this information is
716 written to the file @file{.idlwave/idlusercat.el} in your home
717 directory and will from now on automatically load whenever you use
718 IDLWAVE.  You may find it necessary to rebuild the catalog on occasion
719 as your local libraries change, or build a library catalog for those
720 directories instead.  Invoke routine info (@kbd{C-c ?}) or completion
721 (@kbd{M-@key{TAB}}) on any routine or partial routine name you know to
722 be located in the library.  E.g., if you have scanned the IDL-Astro
723 library:
725 @example
726     a=readf@key{M-@key{TAB}}
727 @end example
729 expands to `readfits('.  Then try
731 @example
732     a=readfits(@key{C-c ?}
733 @end example
735 and you get:
737 @example
738 Usage:    Result = READFITS(filename, header, heap)
740 @end example
742 I hope you made it until here.  Now you are set to work with IDLWAVE.
743 On the way you will want to change other things, and to learn more
744 about the possibilities not discussed in this short tutorial.  Read
745 the manual, look at the documentation strings of interesting variables
746 (with @kbd{C-h v idlwave<-variable-name> @key{RET}}) and ask the
747 remaining questions on the newsgroup @code{comp.lang.idl-pvwave}.
749 @node The IDLWAVE Major Mode, The IDLWAVE Shell, Getting Started, Top
750 @chapter The IDLWAVE Major Mode
751 @cindex IDLWAVE major mode
752 @cindex Major mode, @code{idlwave-mode}
754 The IDLWAVE major mode supports editing IDL source files.  In this
755 chapter we describe the main features of the mode and how to customize
756 them.
758 @menu
759 * Code Formatting::             Making code look nice
760 * Routine Info::                Calling Sequence and Keyword List
761 * Online Help::                 One key press from source to help
762 * Completion::                  Completing routine names and Keywords
763 * Routine Source::              Finding routines, the easy way
764 * Resolving Routines::          Force the Shell to compile a routine
765 * Code Templates::              Frequent code constructs
766 * Abbreviations::               Abbreviations for common commands
767 * Actions::                     Changing case, Padding, End checking
768 * Doc Header::                  Inserting a standard header
769 * Motion Commands::             Moving through the structure of a program
770 * Misc Options::                Things that fit nowhere else
771 @end menu
773 @node Code Formatting, Routine Info, The IDLWAVE Major Mode, The IDLWAVE Major Mode
774 @section Code Formatting
775 @cindex Code formatting
776 @cindex Formatting, of code
778 @menu
779 * Code Indentation::            Reflecting the logical structure
780 * Continued Statement Indentation::  
781 * Comment Indentation::         Special indentation for comment lines
782 * Continuation Lines::          Splitting statements over lines
783 * Syntax Highlighting::         Font-lock support
784 * Octals and Highlighting::     Why "123 causes problems
785 @end menu
787 The IDL language, with its early roots in FORTRAN, modern
788 implementation in C, and liberal borrowing of features of many vector
789 and other languages along its 25+ year history, has inherited an
790 unusual mix of syntax elements.  Left to his or her own devices, a
791 novice IDL programmer will often conjure code which is very difficult
792 to read and impossible to adapt.  Much can be gleaned from studying
793 available IDL code libraries for coding style pointers, but, due to
794 the variety of IDL syntax elements, replicating this style can be
795 challenging at best.  Luckily, IDLWAVE understands the structure of
796 IDL code very well, and takes care of almost all formatting issues for
797 you.  After configuring it to match your coding standards, you can
798 rely on it to help keep your code neat and organized.
801 @node Code Indentation, Continued Statement Indentation, Code Formatting, Code Formatting
802 @subsection Code Indentation
803 @cindex Code indentation
804 @cindex Indentation
806 Like all Emacs programming modes, IDLWAVE performs code indentation.
807 The @key{TAB} key indents the current line relative to context.
808 @key{LFD} insert a newline and indents the new line.  The indentation is
809 governed by a number of variables.  IDLWAVE indents blocks (between
810 @code{PRO}/@code{FUNCTION}/@code{BEGIN} and @code{END}), and
811 continuation lines.
813 @cindex Foreign code, adapting
814 @cindex Indentation, of foreign code
815 @kindex C-M-\
816 To re-indent a larger portion of code (e.g. when working with foreign
817 code written with different conventions), use @kbd{C-M-\}
818 (@code{indent-region}) after marking the relevant code.  Useful marking
819 commands are @kbd{C-x h} (the entire file) or @kbd{C-M-h} (the current
820 subprogram).  The command @kbd{C-M-q} reindents the entire current
821 routine.  @xref{Actions}, for information how to impose additional
822 formatting conventions on foreign code.
824 @defopt idlwave-main-block-indent (@code{2}) 
825 Extra indentation for the main block of code.  That is the block between
826 the FUNCTION/PRO statement and the END statement for that program
827 unit.
828 @end defopt
830 @defopt idlwave-block-indent (@code{3})
831 Extra indentation applied to block lines.  If you change this, you
832 probably also want to change @code{idlwave-end-offset}.
833 @end defopt
835 @defopt idlwave-end-offset (@code{-3})
836 Extra indentation applied to block END lines.  A value equal to negative
837 @code{idlwave-block-indent} will make END lines line up with the block
838 BEGIN lines.
839 @end defopt
841 @node Continued Statement Indentation, Comment Indentation, Code Indentation, Code Formatting
842 @subsection Continued Statement Indentation
843 @cindex Indentation, continued statement
844 @cindex Continued statement indentation
845 Continuation lines (following a line ending with @code{$}) can receive a
846 fixed indentation offset from the main level, but in several situations
847 IDLWAVE can use a special form of indentation which aligns continued
848 statements more naturally.  Special indentation is calculated for
849 continued routine definition statements and calls, enclosing parentheses
850 (like function calls, structure/class definitions, explicit structures
851 or lists, etc.), and continued assignments.  An attempt is made to line
852 up with the first non-whitespace character after the relevant opening
853 punctuation mark (@code{,},@code{(},@code{@{},@code{[},@code{=}).  For
854 lines without any non-comment characters on the line with the opening
855 punctuation, the continued line(s) are aligned just past the
856 punctuation.  An example:
858 @example
859 function foo, a, b,  $
860               c, d
861   bar =  sin( a + b + $
862               c + d)
864 @end example
865 @noindent
867 The only drawback to this special continued statement indentation is
868 that it consumes more space, e.g., for long function names or left hand
869 sides of an assignment:
871 @example
872 function thisfunctionnameisverylongsoitwillleavelittleroom, a, b, $
873                                                             c, d
874 @end example
876 You can instruct IDLWAVE when to avoid using this special continuation
877 indentation by setting the variable
878 @code{idlwave-max-extra-continuation-indent}, which specifies the
879 maximum additional indentation beyond the basic indent to be
880 tolerated, otherwise defaulting to a fixed-offset from the enclosing
881 indent (the size of which offset is set in
882 @code{idlwave-continuation-indent}).  As a special case, continuations
883 of routine calls without any arguments or keywords will @emph{not}
884 align the continued line, under the assumption that you continued
885 because you needed the space.
887 Also, since the indentation level can be somewhat dynamic in continued
888 statements with special continuation indentation, especially if
889 @code{idlwave-max-extra-continuation-indent} is small, the key
890 @kbd{C-u @key{TAB}} will re-indent all lines in the current statement.
891 Note that @code{idlwave-indent-to-open-paren}, if non-@code{nil},
892 overrides the @code{idlwave-max-extra-continuation-indent} limit, for
893 parentheses only, forcing them always to line up.
896 @defopt idlwave-continuation-indent (@code{2})
897 Extra indentation applied to normal continuation lines.
898 @end defopt
900 @defopt idlwave-max-extra-continuation-indent (@code{20})
901 The maximum additional indentation (over the basic continuation-indent)
902 that will be permitted for special continues.  To effectively disable
903 special continuation indentation, set to @code{0}.  To enable it
904 constantly, set to a large number (like @code{100}).  Note that the
905 indentation in a long continued statement never decreases from line to
906 line, outside of nested parentheses statements.
907 @end defopt
909 @defopt idlwave-indent-to-open-paren (@code{t})
910 Non-@code{nil} means indent continuation lines to innermost open
911 parenthesis, regardless of whether the
912 @code{idlwave-max-extra-continuation-indent} limit is satisfied.
913 @end defopt
915 @node Comment Indentation, Continuation Lines, Continued Statement Indentation, Code Formatting
916 @subsection Comment Indentation
917 @cindex Comment indentation
918 @cindex Hanging paragraphs
919 @cindex Paragraphs, filling
920 @cindex Paragraphs, hanging
922 In IDL, lines starting with a @samp{;} are called @emph{comment lines}.
923 Comment lines are indented as follows:
925 @multitable @columnfractions .1 .90
926 @item @code{;;;}
927 @tab The indentation of lines starting with three semicolons remains
928 unchanged.
929 @item @code{;;}
930 @tab Lines starting with two semicolons are indented like the surrounding code.
931 @item @code{;}
932 @tab Lines starting with a single semicolon are indented to a minimum column.
933 @end multitable
935 @noindent
936 The indentation of comments starting in column 0 is never changed.
938 @defopt idlwave-no-change-comment
939 The indentation of a comment starting with this regexp will not be
940 changed.
941 @end defopt
943 @defopt idlwave-begin-line-comment
944 A comment anchored at the beginning of line.
945 @end defopt
947 @defopt idlwave-code-comment
948 A comment that starts with this regexp is indented as if it is a part of
949 IDL code.
950 @end defopt
952 @node Continuation Lines, Syntax Highlighting, Comment Indentation, Code Formatting
953 @subsection Continuation Lines and Filling
954 @cindex Continuation lines
955 @cindex Line splitting
956 @cindex String splitting
957 @cindex Splitting, of lines
959 @kindex M-@key{RET}
960 In IDL, a newline character terminates a statement unless preceded by a
961 @samp{$}.  If you would like to start a continuation line, use
962 @kbd{M-@key{RET}}, which calls the command @code{idlwave-split-line}.
963 It inserts the continuation character @samp{$}, terminates the line and
964 indents the new line.  The command @kbd{M-@key{RET}} can also be invoked
965 inside a string to split it at that point, in which case the @samp{+}
966 concatenation operator is used.
968 @cindex Filling
969 @cindex @code{auto-fill-mode}
970 @cindex Hanging paragraphs
971 When filling comment paragraphs, IDLWAVE overloads the normal filling
972 functions and uses a function which creates the hanging paragraphs
973 customary in IDL routine headers.  When @code{auto-fill-mode} is turned
974 on (toggle with @kbd{C-c C-a}), comments will be auto-filled.  If the
975 first line of a paragraph contains a match for
976 @code{idlwave-hang-indent-regexp} (a dash-space by default), subsequent
977 lines are positioned to line up after it, as in the following example.
979 @example
980 @group
981 ;=================================
982 ; x - an array containing
983 ;     lots of interesting numbers.
985 ; y - another variable where
986 ;     a hanging paragraph is used
987 ;     to describe it.
988 ;=================================
989 @end group
990 @end example
992 @kindex M-q
993 You can also refill a comment at any time paragraph with @kbd{M-q}.
994 Comment delimiting lines as in the above example, consisting of one or
995 more @samp{;} followed by one or more of the characters @samp{+=-_*},
996 are kept in place, as is.
998 @defopt idlwave-fill-comment-line-only (@code{t})
999 Non-@code{nil} means auto fill will only operate on comment lines.
1000 @end defopt
1002 @defopt idlwave-auto-fill-split-string (@code{t})
1003 Non-@code{nil} means auto fill will split strings with the IDL @samp{+}
1004 operator.
1005 @end defopt
1007 @defopt idlwave-split-line-string (@code{t})
1008 Non-@code{nil} means @code{idlwave-split-line} will split strings with
1009 @samp{+}.
1010 @end defopt
1012 @defopt idlwave-hanging-indent (@code{t})
1013 Non-@code{nil} means comment paragraphs are indented under the hanging
1014 indent given by @code{idlwave-hang-indent-regexp} match in the first
1015 line of the paragraph.
1016 @end defopt
1018 @defopt idlwave-hang-indent-regexp (@code{"- "})
1019 Regular expression matching the position of the hanging indent
1020 in the first line of a comment paragraph.
1021 @end defopt
1023 @defopt idlwave-use-last-hang-indent (@code{nil})
1024 Non-@code{nil} means use last match on line for
1025 @code{idlwave-indent-regexp}. 
1026 @end defopt
1028 @node Syntax Highlighting, Octals and Highlighting, Continuation Lines, Code Formatting
1029 @subsection Syntax Highlighting
1030 @cindex Syntax highlighting
1031 @cindex Highlighting of syntax
1032 @cindex Font lock
1034 Highlighting of keywords, comments, strings etc. can be accomplished
1035 with @code{font-lock}.  If you are using @code{global-font-lock-mode}
1036 (in Emacs), or have @code{font-lock} turned on in any other buffer in
1037 XEmacs, it should also automatically work in IDLWAVE buffers.  If you'd
1038 prefer invoking font-lock individually by mode, you can enforce it in
1039 @code{idlwave-mode} with the following line in your @file{.emacs}:
1041 @lisp
1042 (add-hook 'idlwave-mode-hook 'turn-on-font-lock)
1043 @end lisp
1045 @noindent IDLWAVE supports 3 increasing levels of syntax highlighting.
1046 The variable @code{font-lock-maximum-decoration} determines which level
1047 is selected.  Individual categories of special tokens can be selected
1048 for highlighting using the variable
1049 @code{idlwave-default-font-lock-items}.
1051 @defopt idlwave-default-font-lock-items
1052 Items which should be fontified on the default fontification level
1053 2. 
1054 @end defopt
1056 @node Octals and Highlighting,  , Syntax Highlighting, Code Formatting
1057 @subsection Octals and Highlighting
1058 @cindex Syntax highlighting, Octals
1059 @cindex Highlighting of syntax, Octals
1061 A rare syntax highlighting problem results from an extremely unfortunate
1062 notation for octal numbers in IDL: @code{"123}.  This unpaired quotation
1063 mark is very difficult to parse, given that it can be mixed on a single
1064 line with any number of strings.  Emacs will incorrectly identify this
1065 as a string, and the highlighting of following lines of code can be
1066 distorted, since the string is never terminated.
1068 One solution to this involves terminating the mistakenly identified
1069 string yourself by providing a closing quotation mark in a comment:
1071 @example
1072   string("305B) + $ ;" <--- for font-lock
1073    ' is an Angstrom.'
1074 @end example
1076 @noindent A far better solution is to abandon this notation for octals
1077 altogether, and use the more sensible alternative IDL provides:
1079 @example
1080    string('305'OB) + ' is an Angstrom.'
1081 @end example
1083 @noindent This simultaneously solves the font-lock problem and is more
1084 consistent with the notation for hexadecimal numbers, e.g. @code{'C5'XB}.
1086 @node Routine Info, Online Help, Code Formatting, The IDLWAVE Major Mode
1087 @section Routine Info
1088 @cindex Routine info
1089 @cindex Updating routine info
1090 @cindex Scanning buffers for routine info
1091 @cindex Buffers, scanning for routine info
1092 @cindex Shell, querying for routine info
1094 @kindex C-c C-i
1095 IDL comes bundled with more than one thousand procedures, functions
1096 and object methods, and large libraries typically contain hundreds or
1097 even thousands more (each with a few to tens of keywords and
1098 arguments).  This large command set can make it difficult to remember
1099 the calling sequence and keywords for the routines you use, but
1100 IDLWAVE can help.  It builds up routine information from a wide
1101 variety of sources; IDLWAVE in fact knows far more about the
1102 @samp{.pro} routines on your system than IDL itself!  It maintains a
1103 list of all built-in routines, with calling sequences and
1104 keywords@footnote{This list is created by scanning the IDL manuals and
1105 might contain (very few) errors.  Please report any errors to the
1106 maintainer, so that they can be fixed.}.  It also scans Emacs buffers
1107 for routine definitions, queries the IDLWAVE-Shell for information
1108 about routines currently compiled there, and automatically locates
1109 library and user-created catalogs.  This information is updated
1110 automatically, and so should usually be current.  To force a global
1111 update and refresh the routine information, use @kbd{C-c C-i}
1112 (@code{idlwave-update-routine-info}).
1114 @kindex C-c ?
1115 To display the information about a routine, press @kbd{C-c ?}, which
1116 calls the command @code{idlwave-routine-info}.  When the current cursor
1117 position is on the name or in the argument list of a procedure or
1118 function, information will be displayed about the routine.  For example,
1119 consider the indicated cursor positions in the following line:
1121 @example
1122 plot,x,alog(x+5*sin(x) + 2),
1123   |  |   |   |   |  |  |    |
1124   1  2   3   4   5  6  7    8
1125 @end example
1127 @cindex Default routine, for info and help
1128 On positions 1,2 and 8, information about the @samp{plot} procedure will
1129 be shown.  On positions 3,4, and 7, the @samp{alog} function will be
1130 described, while positions 5 and 6 will investigate the @samp{sin}
1131 function.  
1133 When you ask for routine information about an object method, and the
1134 method exists in several classes, IDLWAVE queries for the class of the
1135 object, unless the class is already known through a text property on the
1136 @samp{->} operator (@pxref{Object Method Completion and Class
1137 Ambiguity}), or by having been explicitly included in the call
1138 (e.g. @code{a->myclass::Foo}).
1140 @cindex Calling sequences
1141 @cindex Keywords of a routine
1142 @cindex Routine source information
1143 The description displayed contains the calling sequence, the list of
1144 keywords and the source location of this routine.  It looks like this:
1146 @example
1147 Usage:    XMANAGER, NAME, ID
1148 Keywords: BACKGROUND CATCH CLEANUP EVENT_HANDLER GROUP_LEADER
1149           JUST_REG MODAL NO_BLOCK
1150 Source:   SystemLib   [LCSB] /soft1/idl53/lib/xmanager.pro
1151 @end example
1153 @cindex Categories, of routines
1154 @cindex Load-path shadows
1155 @cindex Shadows, load-path
1156 @cindex IDL variable @code{!PATH}
1157 @cindex @code{!PATH}, IDL variable
1158 @cindex IDL variable @code{!DIR}
1159 @cindex @code{!DIR}, IDL variable
1161 If a definition of this routine exists in several files accessible to
1162 IDLWAVE, several @samp{Source} lines will point to the different
1163 files.  This may indicate that your routine is shadowing a system
1164 library routine, which may or may not be what you want
1165 (@pxref{Load-Path Shadows}).  The information about the calling
1166 sequence and keywords is derived from the first source listed.
1167 Library routines are available only if you have scanned your local IDL
1168 directories or are using pre-scanned libraries (@pxref{Catalogs}).
1169 The source entry consists of a @emph{source category}, a set of
1170 @emph{flags} and the path to the @emph{source file}.  The following
1171 default categories exist:
1173 @multitable @columnfractions .15 .85
1174 @item @i{System}
1175 @tab A system routine of unknown origin.  When the system library has
1176 been scanned as part of a catalog (@pxref{Catalogs}), this category
1177 will automatically split into the next two.
1178 @item @i{Builtin}
1179 @tab A builtin system routine with no source code available.
1180 @item @i{SystemLib}
1181 @tab A library system routine in the official lib directory @file{!DIR/lib}.
1182 @item @i{Obsolete}
1183 @tab A library routine in the official lib directory @file{!DIR/lib/obsolete}.
1184 @item @i{Library}
1185 @tab A routine in a file on IDL's search path @code{!PATH}.
1186 @item @i{Other}
1187 @tab Any other routine with a file not known to be on the search path.
1188 @item @i{Unresolved}
1189 @tab An otherwise unknown routine the shell lists as unresolved 
1190 (referenced, but not compiled).
1191 @end multitable
1193 Any routines discovered in library catalogs (@pxref{Library
1194 Catalogs}), will display the category assigned during creation,
1195 e.g. @samp{NasaLib}.  For routines not discovered in this way, you can
1196 create additional categories based on the routine's filename using the
1197 variable @code{idlwave-special-lib-alist}.
1199 @cindex Flags, in routine info
1200 @cindex Duplicate routines
1201 @cindex Multiply defined routines
1202 @cindex Routine definitions, multiple
1203 The flags @code{[LCSB]} indicate the source of the information IDLWAVE
1204 has regarding the file: from a library catalog (@w{@code{[L---]}}),
1205 from a user catalog (@w{@code{[-C--]}}, from the IDL Shell
1206 (@w{@code{[--S-]}}) or from an Emacs buffer (@w{@code{[---B]}}).
1207 Combinations are possible (a compiled library routine visited in a
1208 buffer might read @w{@code{[L-SB]}}).  If a file contains multiple
1209 definitions of the same routine, the file name will be prefixed with
1210 @samp{(Nx)} where @samp{N} is the number of definitions.
1212 @cindex Online Help from the routine info buffer
1213 @cindex Active text, in routine info
1214 @cindex Inserting keywords, from routine info
1215 @cindex Source file, access from routine info
1216 Some of the text in the @file{*Help*} routine info buffer will be active
1217 (it is highlighted when the mouse moves over it).  Typically, clicking
1218 with the right mouse button invokes online help lookup, and clicking
1219 with the middle mouse button inserts keywords or visits files:
1221 @multitable @columnfractions 0.15 0.85
1222 @item @i{Usage}
1223 @tab If online help is installed, a click with the @emph{right} mouse
1224 button on the @i{Usage:} line will access the help for the
1225 routine (@pxref{Online Help}).  
1226 @item @i{Keyword}
1227 @tab Online help about keywords is also available with the
1228 @emph{right} mouse button.  Clicking on a keyword with the @emph{middle}
1229 mouse button will insert this keyword in the buffer from where
1230 @code{idlwave-routine-info} was called.  Holding down @key{SHIFT} while
1231 clicking also adds the initial @samp{/}.
1232 @item @i{Source}
1233 @tab Clicking with the @emph{middle} mouse button on a @samp{Source} line
1234 finds the source file of the routine and visits it in another window.
1235 Another click on the same line switches back to the buffer from which
1236 @kbd{C-c ?} was called.  If you use the @emph{right} mouse button, the
1237 source will not be visited by a buffer, but displayed in the online help
1238 window.
1239 @item @i{Classes}
1240 @tab The @i{Classes} line is only included in the routine info window if
1241 the current class inherits from other classes.  You can click with the
1242 @emph{middle} mouse button to display routine info about the current
1243 method in other classes on the inheritance chain, if such a method
1244 exists there.
1245 @end multitable
1247 @defopt idlwave-resize-routine-help-window (@code{t})
1248 Non-@code{nil} means resize the Routine-info @file{*Help*} window to
1249 fit the content.
1250 @end defopt
1252 @defopt idlwave-special-lib-alist
1253 Alist of regular expressions matching special library directories.
1254 @end defopt
1256 @defopt idlwave-rinfo-max-source-lines (@code{5})
1257 Maximum number of source files displayed in the Routine Info window.
1258 @end defopt
1261 @html
1262 <A NAME="ONLINE_HELP"></A>
1263 @end html
1264 @node Online Help, Completion, Routine Info, The IDLWAVE Major Mode
1265 @section Online Help
1267 @cindex Online Help
1268 @cindex @file{idlw-help.txt}
1269 @cindex @file{idlw-help.el}
1270 @cindex Installing online help
1271 @cindex Online Help, Installation
1272 @cindex Speed, of online help
1273 @cindex XML Help Catalog
1275 For IDL system routines, extensive documentation is supplied with IDL.
1276 IDLWAVE can access the HTML version of this documentation very quickly
1277 and accurately, based on the local context.  This can be @emph{much}
1278 faster than using the IDL online help application, because IDLWAVE
1279 usually gets you to the right place in the documentation directly ---
1280 e.g. a specific keyword of a routine --- without any additional browsing
1281 and scrolling.
1283 For this online help to work, an HTML version of the IDL documentation
1284 is required.  Beginning with IDL 6.2, HTML documentation is distributed
1285 directly with IDL, along with an XML-based catalog of routine
1286 information.  By default, IDLWAVE automatically attempts to convert this
1287 XML catalog into a format Emacs can more easily understand, and caches
1288 this information in your @code{idlwave_config_directory}
1289 (@file{~/.idlwave/}, by default).  It also re-scans the XML catalog if
1290 it is newer than the current cached version.  You can force rescan with
1291 the menu entry @code{IDLWAVE->Routine Info->Rescan XML Help Catalog}.
1293 Before IDL 6.2, the HTML help was not distributed with IDL, and was not
1294 part of the standalone IDLWAVE distribution, but had to be downloaded
1295 separately.  This is no longer necessary: all help and routine
1296 information is supplied with IDL versions 6.2 and later.
1298 There are a variety of options for displaying the HTML help: see below.
1299 Help for routines without HTML documentation is also available, by using
1300 the routine documentation header and/or routine source.
1302 @kindex M-?
1303 In any IDL program (or, as with most IDLWAVE commands, in the IDL
1304 Shell), press @kbd{M-?} (@code{idlwave-context-help}), or click with
1305 @kbd{S-Mouse-3} to access context sensitive online help.  The following
1306 locations are recognized context for help:
1308 @cindex Context, for online help
1309 @multitable @columnfractions .25 .75
1310 @item @i{Routine names}
1311 @tab The name of a routine (function, procedure, method).
1312 @item @i{Keyword Parameters}
1313 @tab A keyword parameter of a routine.
1314 @item @i{System Variables}
1315 @tab System variables like @code{!DPI}.
1316 @item @i{System Variable Tags}
1317 @tab System variables tags like @code{!D.X_SIZE}.
1318 @item @i{IDL Statements}
1319 @tab Statements like @code{PRO}, @code{REPEAT}, @code{COMPILE_OPT}, etc.
1320 @item @i{IDL Controls}
1321 @tab Control structures like @code{FOR}, @code{SWITCH}, etc.
1322 @item @i{Class names}
1323 @tab A class name in an @code{OBJ_NEW} call.
1324 @item @i{Class Init Keywords}
1325 @tab Beyond the class name in an @code{OBJ_NEW} call.
1326 @item @i{Executive Command}
1327 @tab An executive command like @code{.RUN}.  Mostly useful in the shell.
1328 @item @i{Structure Tags}
1329 @tab Structure tags like @code{state.xsize}
1330 @item @i{Class Tags}
1331 @tab Class tags like @code{self.value}.
1332 @item @i{Default}
1333 @tab The routine that would be selected for routine info display.
1334 @end multitable
1336 @cindex @code{OBJ_NEW}, special online help
1337 Note that the @code{OBJ_NEW} function is special in that the help
1338 displayed depends on the cursor position.  If the cursor is on the
1339 @samp{OBJ_NEW}, this function is described.  If it is on the class
1340 name inside the quotes, the documentation for the class is pulled up.
1341 If the cursor is @emph{after} the class name, anywhere in the argument
1342 list, the documentation for the corresponding @code{Init} method and
1343 its keywords is targeted.
1345 Apart from an IDLWAVE buffer or shell, there are two more places from
1346 which online help can be accessed.
1348 @itemize @bullet
1349 @item
1350 Online help for routines and keywords can be accessed through the
1351 Routine Info display.  Click with @kbd{Mouse-3} on an item to see the
1352 corresponding help (@pxref{Routine Info}).
1353 @item
1354 When using completion and Emacs pops up a @file{*Completions*} buffer
1355 with possible completions, clicking with @kbd{Mouse-3} on a completion
1356 item invokes help on that item (@pxref{Completion}).  Items for which
1357 help is available in the online system documentation (vs. just the
1358 program source itself) will be emphasized (e.g. colored blue).
1359 @end itemize
1360 @noindent
1361 In both cases, a blue face indicates that the item is documented in
1362 the IDL manual, but an attempt will be made to visit non-blue items
1363 directly in the originating source file.
1366 @menu
1367 * Help with HTML Documentation::  
1368 * Help with Source::            
1369 @end menu
1371 @node Help with HTML Documentation, Help with Source, Online Help, Online Help
1372 @subsection Help with HTML Documentation
1373 @cindex HTML Help
1374 @cindex Help using HTML manuals
1375 @cindex IDL manual, HTML version
1376 @cindex IDL Assistant
1378 Help using the HTML documentation is invoked with the built-in Emacs
1379 command @code{browse-url}, which displays the relevant help topic in a
1380 browser of your choosing.  Beginning with version 6.2, IDL comes with
1381 the help browser @emph{IDL Assistant}, which it uses by default for
1382 displaying online help on all supported platforms.  This browser
1383 offers topical searches, an index, and is also now the default and
1384 recommended IDLWAVE help browser.  The variable
1385 @code{idlwave-help-use-assistant} controls whether this browser is
1386 used.  Note that, due to limitations in the Assistant, invoking help
1387 within IDLWAVE and @code{? topic} within IDL will result in two
1388 running copies of Assistant.
1390 Aside from the IDL Assistant, there are many possible browsers to choose
1391 among, with differing advantages and disadvantages.  The variable
1392 @code{idlwave-help-browser-function} controls which browser help is sent
1393 to (as long as @code{idlwave-help-use-assistant} is not set).  This
1394 function is used to set the variable @code{browse-url-browser-function}
1395 locally for IDLWAVE help only.  Customize the latter variable to see
1396 what choices of browsers your system offers.  Certain browsers like
1397 @code{w3} (bundled with many versions of Emacs) and @code{w3m}
1398 (@uref{http://emacs-w3m.namazu.org/}) are run within Emacs, and use
1399 Emacs buffers to display the HTML help.  This can be convenient,
1400 especially on small displays, and images can even be displayed in-line
1401 on newer Emacs versions.  However, better formatting results are often
1402 achieved with external browsers, like Mozilla.  IDLWAVE assumes any
1403 browser function containing "w3" is displayed in a local buffer.  If you
1404 are using another Emacs-local browser for which this is not true, set
1405 the variable @code{idlwave-help-browser-is-local}.
1407 With IDL 6.2 or later, it is important to ensure that the variable
1408 @code{idlwave-system-directory} is set (@pxref{Catalogs}).  One easy way
1409 to ensure this is to run the IDL Shell (@kbd{C-c C-s}).  It will be
1410 queried for this directory, and the results will be cached to file for
1411 subsequent use.
1413 @xref{HTML Help Browser Tips}, for more information on selecting and
1414 configuring a browser for use with IDL's HTML help system.
1416 @defopt idlwave-html-system-help-location @file{help/online_help}
1417 Relative directory of the system-supplied HTML help directory,
1418 considered with respect to @code{idlwave-system-directory}.  Relevant
1419 for IDL 6.2 and greater.  Should not change.
1420 @end defopt     
1422 @defopt idlwave-html-help-location @file{/usr/local/etc/}
1423 The directory where the @file{idl_html_help} HTML directory live.
1424 Obsolete and ignored for IDL 6.2 and greater
1425 (@code{idlwave-html-system-help-location} is used instead).
1426 @end defopt
1428 @defopt idlwave-help-use-assistant @code{t}
1429 If set, use the IDL Assistant if possible for online HTML help,
1430 otherwise use the browser function specified in
1431 @code{idlwave-help-browser-function}.
1432 @end defopt
1434 @defopt idlwave-help-browser-function
1435 The browser function to use to display IDLWAVE HTML help.  Should be
1436 one of the functions available for setting
1437 @code{browse-url-browser-function}, which see.
1438 @end defopt
1440 @defopt idlwave-help-browser-is-local
1441 Is the browser selected in @code{idlwave-help-browser-function} run in a
1442 local Emacs buffer or window?  Defaults to @code{t} if the function
1443 contains "-w3".
1444 @end defopt
1446 @defopt idlwave-help-link-face
1447 The face for links to IDLWAVE online help.
1448 @end defopt
1450 @node Help with Source,  , Help with HTML Documentation, Online Help
1451 @subsection Help with Source
1452 @cindex Help using routine source
1454 @cindex Source code, as online help
1455 @cindex DocLib header, as online help
1456 For routines which are not documented in an HTML manual (for example
1457 personal or library routines), the source code itself is used as help
1458 text.  If the requested information can be found in a (more or less)
1459 standard DocLib file header, IDLWAVE shows the header (scrolling down to
1460 a keyword, if appropriate).  Otherwise the routine definition statement
1461 (@code{pro}/@code{function}) is shown.  The doclib header sections which
1462 are searched for include @samp{NAME} and @samp{KEYWORDS}.  Localization
1463 support can be added by customizing the @code{idlwave-help-doclib-name}
1464 and @code{idlwave-help-doclib-keyword} variables.
1466 @cindex Structure tags, in online help
1467 @cindex Class tags, in online help
1468 Help is also available for class structure tags (@code{self.TAG}), and
1469 generic structure tags, if structure tag completion is enabled
1470 (@pxref{Structure Tag Completion}).  This is implemented by visiting the
1471 tag within the class or structure definition source itself.  Help is not
1472 available on built-in system class tags.
1474 The help window is normally displayed in the same frame, but can be
1475 popped-up in a separate frame.  The following commands can be used to
1476 navigate inside the help system for source files:
1478 @multitable  @columnfractions .15 .85
1479 @item @kbd{@key{SPACE}}
1480 @tab Scroll forward one page.
1481 @item @kbd{@key{RET}}
1482 @tab Scroll forward one line.
1483 @item @kbd{@key{DEL}}
1484 @tab Scroll back one page.
1485 @item @kbd{h}
1486 @tab Jump to DocLib Header of the routine whose source is displayed
1487 as help.
1488 @item @kbd{H}
1489 @tab Jump to the first DocLib Header in the file.
1490 @item @kbd{.} @r{(Dot)}
1491 @tab Jump back and forth between the routine definition (the
1492 @code{pro}/@code{function} statement) and the description of the help
1493 item in the DocLib header.
1494 @item @kbd{F}
1495 @tab Fontify the buffer like source code.  See the variable @code{idlwave-help-fontify-source-code}.
1496 @item @kbd{q}
1497 @tab Kill the help window.
1498 @end multitable
1501 @defopt idlwave-help-use-dedicated-frame (@code{nil})
1502 Non-@code{nil} means use a separate frame for Online Help if possible.
1503 @end defopt
1505 @defopt idlwave-help-frame-parameters
1506 The frame parameters for the special Online Help frame.
1507 @end defopt
1509 @defopt idlwave-max-popup-menu-items (@code{20})
1510 Maximum number of items per pane in pop-up menus.
1511 @end defopt
1513 @defopt idlwave-extra-help-function
1514 Function to call for help if the normal help fails.
1515 @end defopt
1517 @defopt idlwave-help-fontify-source-code (@code{nil})
1518 Non-@code{nil} means fontify source code displayed as help.
1519 @end defopt
1521 @defopt idlwave-help-source-try-header (@code{t})
1522 Non-@code{nil} means try to find help in routine header when
1523 displaying source file.
1524 @end defopt
1526 @defopt idlwave-help-doclib-name (@code{"name"})
1527 The case-insensitive heading word in doclib headers to locate the
1528 @emph{name} section.  Can be a regexp, e.g. @code{"\\(name\\|nom\\)"}.
1529 @end defopt
1531 @defopt idlwave-help-doclib-keyword (@code{"KEYWORD"})
1532 The case-insensitive heading word in doclib headers to locate the
1533 @emph{keywords} section.  Can be a regexp.
1534 @end defopt
1537 @node Completion, Routine Source, Online Help, The IDLWAVE Major Mode
1538 @section Completion
1539 @cindex Completion
1540 @cindex Keyword completion
1541 @cindex Method completion
1542 @cindex Object method completion
1543 @cindex Class name completion
1544 @cindex Function name completion
1545 @cindex Procedure name completion
1547 @kindex M-@key{TAB}
1548 @kindex C-c C-i
1549 IDLWAVE offers completion for class names, routine names, keywords,
1550 system variables, system variable tags, class structure tags, regular
1551 structure tags and file names.  As in many programming modes, completion
1552 is bound to @kbd{M-@key{TAB}} (or simply @kbd{@key{TAB}} in the IDLWAVE
1553 Shell --- @pxref{Using the Shell}).  Completion uses exactly the same
1554 internal information as routine info, so when necessary (rarely) it can
1555 be updated with @kbd{C-c C-i} (@code{idlwave-update-routine-info}).
1557 The completion function is context sensitive and figures out what to
1558 complete based on the location of the point.  Here are example lines and
1559 what @kbd{M-@key{TAB}} would try to complete when the cursor is on the
1560 position marked with a @samp{_}:
1562 @example
1563 plo_                    @r{Procedure}
1564 x = a_                  @r{Function}
1565 plot,xra_               @r{Keyword of @code{plot} procedure}
1566 plot,x,y,/x_            @r{Keyword of @code{plot} procedure}
1567 plot,min(_              @r{Keyword of @code{min} function}
1568 obj -> a_               @r{Object method (procedure)}
1569 a[2,3] = obj -> a_      @r{Object method (function)}
1570 x = obj_new('IDL_       @r{Class name}
1571 x = obj_new('MyCl',a_   @r{Keyword to @code{Init} method in class @code{MyCl}}
1572 pro A_                  @r{Class name}
1573 pro _                   @r{Fill in @code{Class::} of first method in this file}
1574 !v_                     @r{System variable}
1575 !version.t_             @r{Structure tag of system variable}
1576 self.g_                 @r{Class structure tag in methods}
1577 state.w_                @r{Structure tag, if tag completion enabled}
1578 name = 'a_              @r{File name (default inside quotes)}
1579 @end example
1581 @cindex Completion, ambiguity
1582 @cindex Completion, forcing function name
1583 The only place where completion is ambiguous is procedure/function
1584 @emph{keywords} versus @emph{functions}.  After @samp{plot,x,_}, IDLWAVE
1585 will always assume a keyword to @samp{plot}.  However, a function is
1586 also a possible completion here.  You can force completion of a function
1587 name at such a location by using a prefix arg: @kbd{C-u M-@key{TAB}}.
1589 Giving two prefix arguments (@kbd{C-u C-u M-@key{TAB}}) prompts for a
1590 regular expression to search among the commands to be completed.  As
1591 an example, completing a blank line in this way will allow you to
1592 search for a procedure matching a regexp.
1594 @cindex Scrolling the @file{*Completions*} window
1595 @cindex Completion, scrolling
1596 @cindex Completion, Online Help
1597 @cindex Online Help in @file{*Completions*} buffer
1598 If the list of completions is too long to fit in the
1599 @file{*Completions*} window, the window can be scrolled by pressing
1600 @kbd{M-@key{TAB}} repeatedly.  Online help (if installed) for each
1601 possible completion is available by clicking with @kbd{Mouse-3} on the
1602 item.  Items for which system online help (from the IDL manual) is
1603 available will be emphasized (e.g. colored blue).  For other items, the
1604 corresponding source code or DocLib header will be used as the help
1605 text.
1607 @cindex Completion, cancelling
1608 @cindex Cancelling completion
1609 Completion is not a blocking operation --- you are free to continue
1610 editing, enter commands, or simply ignore the @file{*Completions*}
1611 buffer during a completion operation.  If, however, the most recent
1612 command was a completion, @kbd{C-g} will remove the buffer and restore
1613 the window configuration.  You can also remove the buffer at any time
1614 with no negative consequences.
1616 @defopt idlwave-keyword-completion-adds-equal (@code{t})
1617 Non-@code{nil} means completion automatically adds @samp{=} after
1618 completed keywords.
1619 @end defopt
1621 @defopt idlwave-function-completion-adds-paren (@code{t})
1622 Non-@code{nil} means completion automatically adds @samp{(} after
1623 completed function.  A value of `2' means also add the closing
1624 parenthesis and position the cursor between the two.
1625 @end defopt
1627 @defopt idlwave-completion-restore-window-configuration (@code{t})
1628 Non-@code{nil} means restore window configuration after successful
1629 completion.
1630 @end defopt
1632 @defopt idlwave-highlight-help-links-in-completion (@code{t})
1633 Non-@code{nil} means highlight completions for which system help is
1634 available.
1635 @end defopt
1637 @menu
1638 * Case of Completed Words::     CaseOFcomPletedWords
1639 * Object Method Completion and Class Ambiguity::  obj->Method, what?
1640 * Object Method Completion in the Shell::  
1641 * Class and Keyword Inheritance::  obj->Method, _EXTRA=e
1642 * Structure Tag Completion::    Completing state.Tag
1643 @end menu
1645 @node  Case of Completed Words, Object Method Completion and Class Ambiguity, Completion, Completion
1646 @subsection Case of Completed Words
1647 @cindex Case of completed words
1648 @cindex Mixed case completion
1649 IDL is a case-insensitive language, so casing is a matter of style
1650 only.  IDLWAVE helps maintain a consistent casing style for completed
1651 items.  The case of the completed words is determined by what is
1652 already in the buffer.  As an exception, when the partial word being
1653 completed is all lower case, the completion will be lower case as
1654 well.  If at least one character is upper case, the string will be
1655 completed in upper case or mixed case, depending on the value of the
1656 variable @code{idlwave-completion-case}.  The default is to use upper
1657 case for procedures, functions and keywords, and mixed case for object
1658 class names and methods, similar to the conventions in the IDL
1659 manuals.  For instance, to enable mixed-case completion for routines
1660 in addition to classes and methods, you need an entry such as
1661 @code{(routine . preserve)} in that variable.  To enable total control
1662 over the case of completed items, independent of buffer context, set
1663 @code{idlwave-completion-force-default-case} to non-@code{nil}.
1665 @defopt idlwave-completion-case
1666 Association list setting the case (UPPER/lower/Capitalized/MixedCase...)
1667 of completed words.
1668 @end defopt
1670 @defopt idlwave-completion-force-default-case (@code{nil})
1671 Non-@code{nil} means completion will always honor the settings in
1672 @code{idlwave-completion-case}.  When nil (the default), entirely lower
1673 case strings will always be completed to lower case, no matter what the
1674 settings in @code{idlwave-completion-case}.
1675 @end defopt
1677 @defopt idlwave-complete-empty-string-as-lower-case (@code{nil})
1678 Non-@code{nil} means the empty string is considered lower case for
1679 completion.
1680 @end defopt
1682 @node  Object Method Completion and Class Ambiguity, Object Method Completion in the Shell, Case of Completed Words, Completion
1683 @subsection Object Method Completion and Class Ambiguity
1684 @cindex Object methods
1685 @cindex Class ambiguity
1686 @cindex @code{self} object, default class
1687 An object method is not uniquely determined without the object's class.
1688 Since the class is almost always omitted in the calling source (as
1689 required to obtain the true benefits of object-based programming),
1690 IDLWAVE considers all available methods in all classes as possible
1691 method name completions.  The combined list of keywords of the current
1692 method in @emph{all} known classes which contain that method will be
1693 considered for keyword completion.  In the @file{*Completions*} buffer,
1694 the matching classes will be shown next to each item (see option
1695 @code{idlwave-completion-show-classes}).  As a special case, the class
1696 of an object called @samp{self} is always taken to be the class of the
1697 current routine, when in an IDLWAVE buffer.  All inherits classes are
1698 considered as well.
1700 @cindex Forcing class query.
1701 @cindex Class query, forcing
1702 You can also call @code{idlwave-complete} with a prefix arg: @kbd{C-u
1703 M-@key{TAB}}.  IDLWAVE will then prompt you for the class in order to
1704 narrow down the number of possible completions.  The variable
1705 @code{idlwave-query-class} can be configured to make such prompting the
1706 default for all methods (not recommended), or selectively for very
1707 common methods for which the number of completing keywords would be too
1708 large (e.g. @code{Init,SetProperty,GetProperty}).  
1710 @cindex Saving object class on @code{->}
1711 @cindex @code{->}
1712 After you have specified the class for a particular statement (e.g. when
1713 completing the method), IDLWAVE can remember it for the rest of the
1714 editing session.  Subsequent completions in the same statement
1715 (e.g. keywords) can then reuse this class information.  This works by
1716 placing a text property on the method invocation operator @samp{->},
1717 after which the operator will be shown in a different face (bold by
1718 default).  The variable @code{idlwave-store-inquired-class} can be used
1719 to turn it off or on.
1721 @defopt idlwave-completion-show-classes (@code{1})
1722 Non-@code{nil} means show up to that many classes in
1723 @file{*Completions*} buffer when completing object methods and
1724 keywords.
1725 @end defopt
1727 @defopt idlwave-completion-fontify-classes (@code{t})
1728 Non-@code{nil} means fontify the classes in completions buffer.
1729 @end defopt
1731 @defopt idlwave-query-class (@code{nil})
1732 Association list governing query for object classes during completion.
1733 @end defopt
1735 @defopt idlwave-store-inquired-class (@code{t})
1736 Non-@code{nil} means store class of a method call as text property on
1737 @samp{->}.
1738 @end defopt
1740 @defopt idlwave-class-arrow-face
1741 Face to highlight object operator arrows @samp{->} which carry a saved
1742 class text property.
1743 @end defopt
1745 @node Object Method Completion in the Shell, Class and Keyword Inheritance, Object Method Completion and Class Ambiguity, Completion
1746 @subsection Object Method Completion in the Shell
1747 @cindex Method Completion in Shell
1748 In the IDLWAVE Shell (@pxref{The IDLWAVE Shell}), objects on which
1749 methods are being invoked have a special property: they must exist as
1750 variables, and so their class can be determined (for instance, using the
1751 @code{obj_class()} function).  In the Shell, when attempting completion,
1752 routine info, or online help within a method routine, a query is sent to
1753 determine the class of the object.  If this query is successful, the
1754 class found will be used to select appropriate completions, routine
1755 info, or help.  If unsuccessful, information from all known classes will
1756 be used (as in the buffer). 
1758 @node   Class and Keyword Inheritance, Structure Tag Completion, Object Method Completion in the Shell, Completion
1759 @subsection Class and Keyword Inheritance
1760 @cindex Inheritance, class
1761 @cindex Keyword inheritance
1762 @cindex Inheritance, keyword
1764 Class inheritance affects which methods are called in IDL.  An object of
1765 a class which inherits methods from one or more superclasses can
1766 override that method by defining its own method of the same name, extend
1767 the method by calling the method(s) of its superclass(es) in its
1768 version, or inherit the method directly by making no modifications.
1769 IDLWAVE examines class definitions during completion and routine
1770 information display, and records all inheritance information it finds.
1771 This information is displayed if appropriate with the calling sequence
1772 for methods (@pxref{Routine Info}), as long as variable
1773 @code{idlwave-support-inheritance} is non-@code{nil}.
1775 In many class methods, @emph{keyword} inheritance (@code{_EXTRA} and
1776 @code{_REF_EXTRA}) is used hand-in-hand with class inheritance and
1777 method overriding.  E.g., in a @code{SetProperty} method, this technique
1778 allows a single call @code{obj->SetProperty} to set properties up the
1779 entire class inheritance chain.  This is often referred to as
1780 @emph{chaining}, and is characterized by chained method calls like
1781 @w{@code{self->MySuperClass::SetProperty,_EXTRA=e}}.
1783 IDLWAVE can accommodate this special synergy between class and keyword
1784 inheritance: if @code{_EXTRA} or @code{_REF_EXTRA} is detected among a
1785 method's keyword parameters, all keywords of superclass versions of
1786 the method being considered can be included in completion.  There is
1787 of course no guarantee that this type of keyword chaining actually
1788 occurs, but for some methods it's a very convenient assumption.  The
1789 variable @code{idlwave-keyword-class-inheritance} can be used to
1790 configure which methods have keyword inheritance treated in this
1791 simple, class-driven way.  By default, only @code{Init} and
1792 @code{(Get|Set)Property} are.  The completion buffer will label
1793 keywords based on their originating class.
1795 @defopt idlwave-support-inheritance (@code{t})
1796 Non-@code{nil} means consider inheritance during completion, online help etc.
1797 @end defopt
1799 @defopt idlwave-keyword-class-inheritance 
1800 A list of regular expressions to match methods for which simple
1801 class-driven keyword inheritance will be used for Completion.
1802 @end defopt
1804 @node    Structure Tag Completion,  , Class and Keyword Inheritance, Completion
1805 @subsection Structure Tag Completion
1806 @cindex Completion, structure tag
1807 @cindex Structure tag completion
1809 In many programs, especially those involving widgets, large structures
1810 (e.g. the @samp{state} structure) are used to communicate among
1811 routines.  It is very convenient to be able to complete structure tags,
1812 in the same way as for instance variables (tags) of the @samp{self}
1813 object (@pxref{Object Method Completion and Class Ambiguity}).  Add-in
1814 code for structure tag completion is available in the form of a loadable
1815 completion module: @file{idlw-complete-structtag.el}.  Tag completion in
1816 structures is highly ambiguous (much more so than @samp{self}
1817 completion), so @code{idlw-complete-structtag} makes an unusual and very
1818 specific assumption: the exact same variable name is used to refer to
1819 the structure in all parts of the program.  This is entirely unenforced
1820 by the IDL language, but is a typical convention.  If you consistently
1821 refer to the same structure with the same variable name
1822 (e.g. @samp{state}), structure tags which are read from its definition
1823 in the same file can be used for completion.
1825 Structure tag completion is not enabled by default.  To enable it,
1826 simply add the following to your @file{.emacs}:
1828 @lisp
1829    (add-hook 'idlwave-load-hook 
1830              (lambda () (require 'idlw-complete-structtag)))
1831 @end lisp
1833 Once enabled, you'll also be able to access online help on the structure
1834 tags, using the usual methods (@pxref{Online Help}).  In addition,
1835 structure variables in the shell will be queried for tag names, similar
1836 to the way object variables in the shell are queried for method names.
1837 So, e.g.:
1839 @example
1840 IDL> st.[Tab]
1841 @end example
1843 @noindent will complete with all structure fields of the structure
1844 @code{st}.
1846 @node Routine Source, Resolving Routines, Completion, The IDLWAVE Major Mode
1847 @section Routine Source
1848 @cindex Routine source file
1849 @cindex Module source file
1850 @cindex Source file, of a routine
1851 @kindex C-c C-v
1852 In addition to clicking on a @i{Source:} line in the routine info
1853 window, there is another way to quickly visit the source file of a
1854 routine.  The command @kbd{C-c C-v} (@code{idlwave-find-module}) asks
1855 for a module name, offering the same default as
1856 @code{idlwave-routine-info} would have used, taken from nearby buffer
1857 contents.  In the minibuffer, specify a complete routine name (including
1858 any class part).  IDLWAVE will display the source file in another
1859 window, positioned at the routine in question.  You can also limit this
1860 to a routine in the current buffer only, with completion, and a
1861 context-sensitive default, by using a single prefix (@kbd{C-u C-c C-v})
1862 or the convenience binding @kbd{C-c C-t}.
1864 @cindex Buffers, killing
1865 @cindex Killing autoloaded buffers
1866 Since getting the source of a routine into a buffer is so easy with
1867 IDLWAVE, too many buffers visiting different IDL source files are
1868 sometimes created.  The special command @kbd{C-c C-k}
1869 (@code{idlwave-kill-autoloaded-buffers}) can be used to easily remove
1870 these buffers.
1872 @node Resolving Routines, Code Templates, Routine Source, The IDLWAVE Major Mode
1873 @section Resolving Routines
1874 @cindex @code{RESOLVE_ROUTINE}
1875 @cindex Compiling library modules
1876 @cindex Routines, resolving
1878 The key sequence @kbd{C-c =} calls the command @code{idlwave-resolve}
1879 and sends the line @samp{RESOLVE_ROUTINE, '@var{routine_name}'} to IDL
1880 in order to resolve (compile) it.  The default routine to be resolved is
1881 taken from context, but you get a chance to edit it.  Usually this is
1882 not necessary, since IDL automatically discovers routines on its path.
1884 @code{idlwave-resolve} is one way to get a library module within reach
1885 of IDLWAVE's routine info collecting functions.  A better way is to
1886 keep routine information available in catalogs (@pxref{Catalogs}).
1887 Routine info on modules will then be available without the need to
1888 compile the modules first, and even without a running shell.
1890 @xref{Sources of Routine Info}, for more information on the ways IDLWAVE
1891 collects data about routines, and how to update this information.
1893 @node Code Templates, Abbreviations, Resolving Routines, The IDLWAVE Major Mode
1894 @section Code Templates
1895 @cindex Code templates
1896 @cindex Templates
1898 IDLWAVE can insert IDL code templates into the buffer.  For a few
1899 templates, this is done with direct key bindings:
1901 @multitable @columnfractions .15 .85
1902 @item @kbd{C-c C-c}
1903 @tab @code{CASE} statement template
1904 @item @kbd{C-c C-f}
1905 @tab @code{FOR} loop template
1906 @item @kbd{C-c C-r}
1907 @tab @code{REPEAT} loop template
1908 @item @kbd{C-c C-w}
1909 @tab @code{WHILE} loop template
1910 @end multitable
1912 All code templates are also available as abbreviations
1913 (@pxref{Abbreviations}).
1915 @node Abbreviations, Actions, Code Templates, The IDLWAVE Major Mode
1916 @section Abbreviations
1917 @cindex Abbreviations
1919 Special abbreviations exist to enable rapid entry of commonly used
1920 commands.  Emacs abbreviations are expanded by typing text into the
1921 buffer and pressing @key{SPC} or @key{RET}.  The special abbreviations
1922 used to insert code templates all start with a @samp{\} (the backslash),
1923 or, optionally, any other character set in
1924 @code{idlwave-abbrev-start-char}. IDLWAVE ensures that abbreviations are
1925 only expanded where they should be (i.e., not in a string or comment),
1926 and permits the point to be moved after an abbreviation expansion ---
1927 very useful for positioning the mark inside of parentheses, etc.
1929 Special abbreviations are pre-defined for code templates and other
1930 useful items.  To visit the full list of abbreviations, use @kbd{M-x
1931 idlwave-list-abbrevs}.
1933 Template abbreviations:
1935 @multitable @columnfractions .15 .85
1936 @item @code{\pr}
1937 @tab @code{PROCEDURE} template
1938 @item @code{\fu}
1939 @tab @code{FUNCTION} template
1940 @item @code{\c}
1941 @tab @code{CASE} statement template
1942 @item @code{\f}
1943 @tab @code{FOR} loop template
1944 @item @code{\r}
1945 @tab @code{REPEAT} loop template
1946 @item @code{\w}
1947 @tab @code{WHILE} loop template
1948 @item @code{\i}
1949 @tab @code{IF} statement template
1950 @item @code{\elif}
1951 @tab @code{IF-ELSE} statement template
1952 @end multitable
1954 String abbreviations:
1956 @multitable @columnfractions .15 .85
1957 @item @code{\ap}
1958 @tab @code{arg_present()}
1959 @item @code{\b}
1960 @tab @code{begin}
1961 @item @code{\cb}
1962 @tab @code{byte()}
1963 @item @code{\cc}
1964 @tab @code{complex()}
1965 @item @code{\cd}
1966 @tab @code{double()}
1967 @item @code{\cf}
1968 @tab @code{float()}
1969 @item @code{\cl}
1970 @tab @code{long()}
1971 @item @code{\co}
1972 @tab @code{common}
1973 @item @code{\cs}
1974 @tab @code{string()}
1975 @item @code{\cx}
1976 @tab @code{fix()}
1977 @item @code{\e}
1978 @tab @code{else}
1979 @item @code{\ec}
1980 @tab @code{endcase}
1981 @item @code{\ee}
1982 @tab @code{endelse}
1983 @item @code{\ef}
1984 @tab @code{endfor}
1985 @item @code{\ei}
1986 @tab @code{endif else if}
1987 @item @code{\el}
1988 @tab @code{endif else}
1989 @item @code{\en}
1990 @tab @code{endif}
1991 @item @code{\er}
1992 @tab @code{endrep}
1993 @item @code{\es}
1994 @tab @code{endswitch}
1995 @item @code{\ew}
1996 @tab @code{endwhile}
1997 @item @code{\g}
1998 @tab @code{goto,}
1999 @item @code{\h}
2000 @tab @code{help,}
2001 @item @code{\ik}
2002 @tab @code{if keyword_set() then}
2003 @item @code{\iap}
2004 @tab @code{if arg_present() then}
2005 @item @code{\ine}
2006 @tab @code{if n_elements() eq 0 then}
2007 @item @code{\inn}
2008 @tab @code{if n_elements() ne 0 then}
2009 @item @code{\k}
2010 @tab @code{keyword_set()}
2011 @item @code{\n}
2012 @tab @code{n_elements()}
2013 @item @code{\np}
2014 @tab @code{n_params()}
2015 @item @code{\oi}
2016 @tab @code{on_ioerror,}
2017 @item @code{\or}
2018 @tab @code{openr,}
2019 @item @code{\ou}
2020 @tab @code{openu,}
2021 @item @code{\ow}
2022 @tab @code{openw,}
2023 @item @code{\p}
2024 @tab @code{print,}
2025 @item @code{\pt}
2026 @tab @code{plot,}
2027 @item @code{\pv}
2028 @tab @code{ptr_valid()}
2029 @item @code{\re}
2030 @tab @code{read,}
2031 @item @code{\rf}
2032 @tab @code{readf,}
2033 @item @code{\rt}
2034 @tab @code{return}
2035 @item @code{\ru}
2036 @tab @code{readu,}
2037 @item @code{\s}
2038 @tab @code{size()}
2039 @item @code{\sc}
2040 @tab @code{strcompress()}
2041 @item @code{\sl}
2042 @tab @code{strlowcase()}
2043 @item @code{\sm}
2044 @tab @code{strmid()}
2045 @item @code{\sn}
2046 @tab @code{strlen()}
2047 @item @code{\sp}
2048 @tab @code{strpos()}
2049 @item @code{\sr}
2050 @tab @code{strtrim()}
2051 @item @code{\st}
2052 @tab @code{strput()}
2053 @item @code{\su}
2054 @tab @code{strupcase()}
2055 @item @code{\t}
2056 @tab @code{then}
2057 @item @code{\u}
2058 @tab @code{until}
2059 @item @code{\wc}
2060 @tab @code{widget_control,}
2061 @item @code{\wi}
2062 @tab @code{widget_info()}
2063 @item @code{\wu}
2064 @tab @code{writeu,}
2065 @end multitable
2067 @noindent You can easily add your own abbreviations or override existing
2068 abbrevs with @code{define-abbrev} in your mode hook, using the
2069 convenience function @code{idlwave-define-abbrev}:
2071 @lisp
2072 (add-hook 'idlwave-mode-hook
2073           (lambda ()
2074             (idlwave-define-abbrev "wb" "widget_base()"
2075                      (idlwave-keyword-abbrev 1))
2076             (idlwave-define-abbrev "ine" "IF N_Elements() EQ 0 THEN"
2077                      (idlwave-keyword-abbrev 11))))
2078 @end lisp
2080 Notice how the abbreviation (here @emph{wb}) and its expansion
2081 (@emph{widget_base()}) are given as arguments, and the single argument to
2082 @code{idlwave-keyword-abbrev} (here @emph{1}) specifies how far back to
2083 move the point upon expansion (in this example, to put it between the
2084 parentheses).
2086 The abbreviations are expanded in upper or lower case, depending upon
2087 the variables @code{idlwave-abbrev-change-case} and, for reserved word
2088 templates, @code{idlwave-reserved-word-upcase} (@pxref{Case Changes}).
2090 @defopt idlwave-abbrev-start-char (@code{"\"})
2091 A single character string used to start abbreviations in abbrev mode.
2092 Beware of common characters which might naturally occur in sequence with
2093 abbreviation strings.
2094 @end defopt
2096 @defopt idlwave-abbrev-move (@code{t})
2097 Non-@code{nil} means the abbrev hook can move point, e.g. to end up
2098 between the parentheses of a function call.
2099 @end defopt
2101 @node Actions, Doc Header, Abbreviations, The IDLWAVE Major Mode
2102 @section Actions
2103 @cindex Actions
2104 @cindex Coding standards, enforcing
2106 @emph{Actions} are special formatting commands which are executed
2107 automatically while you write code in order to check the structure of
2108 the program or to enforce coding standards.  Most actions which have
2109 been implemented in IDLWAVE are turned off by default, assuming that the
2110 average user wants her code the way she writes it.  But if you are a
2111 lazy typist and want your code to adhere to certain standards, actions
2112 can be helpful.
2114 Actions can be applied in three ways:
2116 @itemize @bullet
2117 @item
2118 Some actions are applied directly while typing.  For example, pressing
2119 @samp{=} can run a check to make sure that this operator is surrounded
2120 by spaces and insert these spaces if necessary.  Pressing @key{SPC}
2121 after a reserved word can call a command to change the word to upper
2122 case.
2123 @item
2124 When a line is re-indented with @key{TAB}, actions can be applied to the
2125 entire line.  To enable this, the variable @code{idlwave-do-actions}
2126 must be non-@code{nil}.
2127 @item
2128 @cindex Foreign code, adapting
2129 @cindex Actions, applied to foreign code
2130 Actions can also be applied to a larger piece of code, e.g. to convert
2131 foreign code to your own style.  To do this, mark the relevant part of
2132 the code and execute @kbd{M-x expand-region-abbrevs}.  Useful marking
2133 commands are @kbd{C-x h} (the entire file) or @kbd{C-M-h} (the current
2134 subprogram). @xref{Code Indentation}, for information how to adjust the
2135 indentation of the code.
2136 @end itemize
2138 @defopt idlwave-do-actions (@code{nil})
2139 Non-@code{nil} means performs actions when indenting.  Individual action
2140 settings are described below and set separately.
2141 @end defopt
2143 @menu
2144 * Block Boundary Check::        Is the END statement correct?
2145 * Padding Operators::           Enforcing space around `=' etc
2146 * Case Changes::                Enforcing upper case keywords
2147 @end menu
2149 @node Block Boundary Check, Padding Operators, Actions, Actions
2150 @subsection Block Boundary Check
2151 @cindex Block boundary check
2152 @cindex @code{END} type checking
2153 @cindex @code{END}, automatic insertion
2154 @cindex @code{END}, expanding
2155 @cindex Block, closing
2156 @cindex Closing a block
2158 Whenever you type an @code{END} statement, IDLWAVE finds the
2159 corresponding start of the block and the cursor blinks back to that
2160 location for a second.  If you have typed a specific @code{END}, like
2161 @code{ENDIF} or @code{ENDCASE}, you get a warning if that terminator
2162 does not match the type of block it terminates.
2164 Set the variable @code{idlwave-expand-generic-end} in order to have all
2165 generic @code{END} statements automatically expanded to the appropriate
2166 type.  You can also type @kbd{C-c ]} to close the current block by
2167 inserting the appropriate @code{END} statement.
2169 @defopt idlwave-show-block (@code{t})
2170 Non-@code{nil} means point blinks to block beginning for
2171 @code{idlwave-show-begin}.
2172 @end defopt
2174 @defopt idlwave-expand-generic-end (@code{t})
2175 Non-@code{nil} means expand generic END to ENDIF/ENDELSE/ENDWHILE etc.
2176 @end defopt
2178 @defopt idlwave-reindent-end (@code{t})
2179 Non-@code{nil} means re-indent line after END was typed.
2180 @end defopt
2182 @node Padding Operators, Case Changes, Block Boundary Check, Actions
2183 @subsection Padding Operators
2184 @cindex Padding operators with spaces
2185 @cindex Operators, padding with spaces
2186 @cindex Space, around operators
2188 Some operators can be automatically surrounded by spaces.  This can
2189 happen when the operator is typed, or later when the line is indented.
2190 IDLWAVE can pad the operators @samp{<}, @samp{>}, @samp{,}, @samp{=},
2191 and @samp{->}, as well as the modified assignment operators
2192 (@samp{AND=}, @samp{OR=}, etc.).  This feature is turned off by default.
2193 If you want to turn it on, customize the variables
2194 @code{idlwave-surround-by-blank} and @code{idlwave-do-actions} and turn
2195 both on.  You can also define similar actions for other operators by
2196 using the function @code{idlwave-action-and-binding} in the mode hook.
2197 For example, to enforce space padding of the @samp{+} and @samp{*}
2198 operators (outside of strings and comments, of course), try this in
2199 @file{.emacs}
2201 @lisp
2202 (add-hook 'idlwave-mode-hook
2203   (lambda ()
2204      (setq idlwave-surround-by-blank t)  ; Turn this type of actions on
2205      (idlwave-action-and-binding "*" '(idlwave-surround 1 1))
2206      (idlwave-action-and-binding "+" '(idlwave-surround 1 1))))
2207 @end lisp
2209 Note that the modified assignment operators which begin with a word
2210 (@samp{AND=}, @samp{OR=}, @samp{NOT=}, etc.) require a leading space to
2211 be recognized (e.g @code{vAND=4} would be interpreted as a variable
2212 @code{vAND}).  Also note that, since e.g., @code{>} and @code{>=} are
2213 both valid operators, it is impossible to surround both by blanks while
2214 they are being typed.  Similarly with @code{&} and @code{&&}.  For
2215 these, a compromise is made: the padding is placed on the left, and if
2216 the longer operator is keyed in, on the right as well (otherwise you
2217 must insert spaces to pad right yourself, or press simply press Tab to
2218 repad everything if @code{idlwave-do-actions} is on).
2220 @defopt idlwave-surround-by-blank (@code{nil})
2221 Non-@code{nil} means enable @code{idlwave-surround}.  If non-@code{nil},
2222 @samp{=}, @samp{<}, @samp{>}, @samp{&}, @samp{,}, @samp{->}, and the
2223 modified assignment operators (@samp{AND=}, @samp{OR=}, etc.) are
2224 surrounded with spaces by @code{idlwave-surround}.
2225 @end defopt
2227 @defopt idlwave-pad-keyword (@code{t})
2228 Non-@code{nil} means space-pad the @samp{=} in keyword assignments.
2229 @end defopt
2231 @node Case Changes,  , Padding Operators, Actions
2232 @subsection Case Changes
2233 @cindex Case changes
2234 @cindex Upcase, enforcing for reserved words
2235 @cindex Downcase, enforcing for reserved words
2237 Actions can be used to change the case of reserved words or expanded
2238 abbreviations by customizing the variables
2239 @code{idlwave-abbrev-change-case} and
2240 @code{idlwave-reserved-word-upcase}.  If you want to change the case of
2241 additional words automatically, put something like the following into
2242 your @file{.emacs} file:
2244 @lisp
2245 (add-hook 'idlwave-mode-hook
2246   (lambda ()
2247      ;;  Capitalize system vars
2248      (idlwave-action-and-binding idlwave-sysvar '(capitalize-word 1) t)
2249      ;;  Capitalize procedure name
2250      (idlwave-action-and-binding "\\<\\(pro\\|function\\)\\>[ \t]*\\<"
2251                                  '(capitalize-word 1) t)
2252      ;;  Capitalize common block name
2253      (idlwave-action-and-binding "\\<common\\>[ \t]+\\<" 
2254                                  '(capitalize-word 1) t)))
2255 @end lisp
2257 For more information, see the documentation string for the function
2258 @code{idlwave-action-and-binding}.  For information on controlling the
2259 case of routines, keywords, classes, and methods as they are completed, see
2260 @ref{Completion}.
2262 @defopt idlwave-abbrev-change-case (@code{nil})
2263 Non-@code{nil} means all abbrevs will be forced to either upper or lower
2264 case.  Valid values are @code{nil}, @code{t}, and @code{down}.
2265 @end defopt
2267 @defopt idlwave-reserved-word-upcase (@code{nil})
2268 Non-@code{nil} means reserved words will be made upper case via abbrev
2269 expansion.
2270 @end defopt
2273 @node Doc Header, Motion Commands, Actions, The IDLWAVE Major Mode
2274 @section Documentation Header
2275 @cindex Documentation header
2276 @cindex DocLib header
2277 @cindex Modification timestamp
2278 @cindex Header, for file documentation
2279 @cindex Timestamp, in doc header.
2280 @cindex Changelog, in doc header.
2282 @kindex C-c C-h
2283 @kindex C-c C-m
2284 The command @kbd{C-c C-h} inserts a standard routine header into the
2285 buffer, with the usual fields for documentation (a different header can
2286 be specified with @code{idlwave-file-header}).  One of the keywords is
2287 @samp{MODIFICATION HISTORY} under which the changes to a routine can be
2288 recorded.  The command @kbd{C-c C-m} jumps to the @samp{MODIFICATION
2289 HISTORY} of the current routine or file and inserts the user name with a
2290 timestamp.
2292 @defopt idlwave-file-header
2293 The doc-header template or a path to a file containing it.
2294 @end defopt
2296 @defopt idlwave-header-to-beginning-of-file (@code{nil})
2297 Non-@code{nil} means the documentation header will always be at start
2298 of file.
2299 @end defopt
2301 @defopt idlwave-timestamp-hook
2302 The hook function used to update the timestamp of a function.
2303 @end defopt
2305 @defopt idlwave-doc-modifications-keyword
2306 The modifications keyword to use with the log documentation commands.
2307 @end defopt
2309 @defopt idlwave-doclib-start
2310 Regexp matching the start of a document library header.
2311 @end defopt
2313 @defopt idlwave-doclib-end
2314 Regexp matching the start of a document library header.
2315 @end defopt
2317 @node Motion Commands, Misc Options, Doc Header, The IDLWAVE Major Mode
2318 @section Motion Commands
2319 @cindex Motion commands
2320 @cindex Program structure, moving through
2321 @cindex Code structure, moving through
2322 @cindex @file{Func-menu}, XEmacs package
2323 @cindex @file{Imenu}, Emacs package
2324 @cindex Function definitions, jumping to
2325 @cindex Procedure definitions, jumping to
2327 IDLWAVE supports both @file{Imenu} and @file{Func-menu}, two packages
2328 which make it easy to jump to the definitions of functions and
2329 procedures in the current file with a pop-up selection.  To bind
2330 @file{Imenu} to a mouse-press, use in your @file{.emacs}:
2332 @lisp
2333 (define-key global-map [S-down-mouse-3] 'imenu)
2334 @end lisp
2336 @cindex @file{Speedbar}, Emacs package
2338 In addition, @file{Speedbar} support allows convenient navigation of a
2339 source tree of IDL routine files, quickly stepping to routine
2340 definitions.  See @code{Tools->Display Speedbar}.
2342 Several commands allow you to move quickly through the structure of an
2343 IDL program:
2345 @multitable @columnfractions .15 .85
2346 @item @kbd{C-M-a}
2347 @tab Beginning of subprogram
2348 @item @kbd{C-M-e}
2349 @tab End of subprogram
2350 @item @kbd{C-c @{}
2351 @tab Beginning of block (stay inside the block)
2352 @item @kbd{C-c @}}
2353 @tab End of block (stay inside the block)
2354 @item @kbd{C-M-n}
2355 @tab Forward block (on same level)
2356 @item @kbd{C-M-p}
2357 @tab Backward block (on same level)
2358 @item @kbd{C-M-d}
2359 @tab Down block (enters a block)
2360 @item @kbd{C-M-u}
2361 @tab Backward up block (leaves a block)
2362 @item @kbd{C-c C-n}
2363 @tab Next Statement
2364 @end multitable
2367 @node Misc Options,  , Motion Commands, The IDLWAVE Major Mode
2368 @section Miscellaneous Options
2369 @cindex Hooks
2371 @defopt idlwave-help-application
2372 The external application providing reference help for programming.
2373 @end defopt
2375 @defopt idlwave-startup-message (@code{t})
2376 Non-@code{nil} means display a startup message when @code{idlwave-mode}'
2377 is first called.
2378 @end defopt
2380 @defopt idlwave-mode-hook
2381 Normal hook.  Executed when a buffer is put into @code{idlwave-mode}.
2382 @end defopt
2384 @defopt idlwave-load-hook
2385 Normal hook.  Executed when @file{idlwave.el} is loaded.
2386 @end defopt
2388 @node The IDLWAVE Shell, Acknowledgements, The IDLWAVE Major Mode, Top
2389 @chapter The IDLWAVE Shell
2390 @cindex IDLWAVE shell
2391 @cindex Major mode, @code{idlwave-shell-mode}
2392 @cindex IDL, as Emacs subprocess
2393 @cindex Subprocess of Emacs, IDL
2394 @cindex Comint, Emacs package
2395 @cindex Windows
2396 @cindex MacOS
2398 The IDLWAVE shell is an Emacs major mode which permits running the IDL
2399 program as an inferior process of Emacs, and works closely with the
2400 IDLWAVE major mode in buffers.  It can be used to work with IDL
2401 interactively, to compile and run IDL programs in Emacs buffers and to
2402 debug these programs.  The IDLWAVE shell is built on @file{comint}, an
2403 Emacs packages which handles the communication with the IDL program.
2404 Unfortunately, IDL for Windows does not have command-prompt versions and
2405 thus do not allow the interaction with Emacs --- so the IDLWAVE shell
2406 currently only works under Unix and MacOSX.
2408 @menu
2409 * Starting the Shell::          How to launch IDL as a subprocess
2410 * Using the Shell::             Interactively working with the Shell
2411 * Commands Sent to the Shell::  
2412 * Debugging IDL Programs::      
2413 * Examining Variables::         
2414 * Custom Expression Examination::  
2415 @end menu
2417 @node Starting the Shell, Using the Shell, The IDLWAVE Shell, The IDLWAVE Shell
2418 @section Starting the Shell
2419 @cindex Starting the shell
2420 @cindex Shell, starting
2421 @cindex Dedicated frame, for shell buffer
2422 @cindex Frame, for shell buffer
2423 @cindex Subprocess of Emacs, IDL
2425 @kindex C-c C-s
2426 The IDLWAVE shell can be started with the command @kbd{M-x
2427 idlwave-shell}.  In @code{idlwave-mode} the function is bound to
2428 @kbd{C-c C-s}.  It creates a buffer @file{*idl*} which is used to
2429 interact with the shell.  If the shell is already running, @kbd{C-c
2430 C-s} will simply switch to the shell buffer.  The command @kbd{C-c
2431 C-l} (@code{idlwave-shell-recenter-shell-window}) displays the shell
2432 window without selecting it.  The shell can also be started
2433 automatically when another command tries to send a command to it.  To
2434 enable auto start, set the variable
2435 @code{idlwave-shell-automatic-start} to @code{t}.
2437 In order to create a separate frame for the IDLWAVE shell buffer, call
2438 @code{idlwave-shell} with a prefix argument: @kbd{C-u C-c C-s} or
2439 @kbd{C-u C-c C-l}.  If you always want a dedicated frame for the shell
2440 window, configure the variable
2441 @code{idlwave-shell-use-dedicated-frame}. 
2443 To launch a quick IDLWAVE shell directly from a shell prompt without
2444 an IDLWAVE buffer (e.g., as a replacement for running inside an
2445 xterm), define a system alias with the following content:
2447 @example
2448 emacs -geometry 80x32 -eval "(idlwave-shell 'quick)"
2449 @end example
2451 Replace the @samp{-geometry 80x32} option with @samp{-nw} if you prefer
2452 the Emacs process to run directly inside the terminal window.
2454 @cindex ENVI
2455 @cindex IDL> Prompt
2457 To use IDLWAVE with ENVI or other custom packages which change the
2458 @samp{IDL> } prompt, you must change the
2459 @code{idlwave-shell-prompt-pattern}, which defaults to @samp{"^ ?IDL>
2460 "}.  Normally, you can just replace the @samp{IDL} in this expression
2461 with the prompt you see.  A suitable pattern which matches the prompt
2462 for both ENVI and IDL simultaneously is @samp{"^ ?\\(ENVI\\|IDL\\)> "}.
2464 @defopt idlwave-shell-explicit-file-name (@file{idl})
2465 This is the command to run IDL.
2466 @end defopt
2468 @defopt idlwave-shell-command-line-options
2469 A list of command line options for calling the IDL program.
2470 @end defopt
2472 @defopt idlwave-shell-prompt-pattern
2473 Regexp to match IDL prompt at beginning of a line.
2474 @end defopt
2476 @defopt idlwave-shell-process-name
2477 Name to be associated with the IDL process.
2478 @end defopt
2480 @defopt idlwave-shell-automatic-start  (@code{nil})
2481 Non-@code{nil} means attempt to invoke idlwave-shell if not already
2482 running.
2483 @end defopt
2485 @defopt idlwave-shell-initial-commands
2486 Initial commands, separated by newlines, to send to IDL.
2487 @end defopt
2489 @defopt idlwave-shell-save-command-history (@code{t})
2490 Non-@code{nil} means preserve command history between sessions.
2491 @end defopt
2493 @defopt idlwave-shell-command-history-file (@file{~/.idlwave/.idlwhist})
2494 The file in which the command history of the idlwave shell is saved.
2495 Unless it's an absolute path, it goes in
2496 @code{idlwave-config-directory}.
2497 @end defopt
2498   
2499 @defopt idlwave-shell-use-dedicated-frame (@code{nil})
2500 Non-@code{nil} means IDLWAVE should use a special frame to display the
2501 shell buffer.
2502 @end defopt
2504 @defopt idlwave-shell-use-dedicated-window (@code{nil})
2505 Non-@code{nil} means use a dedicated window for the shell, taking care
2506 not it replace it with other buffers.
2507 @end defopt
2509 @defopt idlwave-shell-frame-parameters
2510 The frame parameters for a dedicated idlwave-shell frame.
2511 @end defopt
2513 @defopt idlwave-shell-raise-frame (@code{t})
2514 Non-@code{nil} means `idlwave-shell' raises the frame showing the shell
2515 window.
2516 @end defopt
2518 @defopt idlwave-shell-temp-pro-prefix
2519 The prefix for temporary IDL files used when compiling regions.
2520 @end defopt
2522 @cindex Hooks
2523 @defopt idlwave-shell-mode-hook
2524 Hook for customizing @code{idlwave-shell-mode}.
2525 @end defopt
2527 @node Using the Shell, Commands Sent to the Shell, Starting the Shell, The IDLWAVE Shell
2528 @section Using the Shell
2529 @cindex Comint
2530 @cindex Shell, basic commands
2532 The IDLWAVE shell works in the same fashion as other shell modes in
2533 Emacs.  It provides command history, command line editing and job
2534 control.  The @key{UP} and @key{DOWN} arrows cycle through the input
2535 history just like in an X terminal@footnote{This is different from
2536 normal Emacs/Comint behavior, but more like an xterm.  If you prefer the
2537 default comint functionality, check the variable
2538 @code{idlwave-shell-arrows-do-history}.}.  The history is preserved
2539 between emacs and IDL sessions.  Here is a list of commonly used
2540 commands:
2542 @multitable @columnfractions .12 .88
2543 @item @key{UP}, @key{M-p}
2544 @tab Cycle backwards in input history
2545 @item @key{DOWN}, @key{M-n}
2546 @tab Cycle forwards in input history
2547 @item @kbd{M-r}
2548 @tab Previous input matching a regexp
2549 @item @kbd{M-s}
2550 @tab Next input matching a regexp
2551 @item @kbd{return}
2552 @tab Send input or copy line to current prompt
2553 @item @kbd{C-c C-a}
2554 @tab Beginning of line; skip prompt
2555 @item @kbd{C-c C-u}
2556 @tab Kill input to beginning of line
2557 @item @kbd{C-c C-w}
2558 @tab Kill word before cursor
2559 @item @kbd{C-c C-c}
2560 @tab Send ^C
2561 @item @kbd{C-c C-z}
2562 @tab Send ^Z
2563 @item @kbd{C-c C-\}
2564 @tab Send ^\
2565 @item @kbd{C-c C-o}
2566 @tab Delete last batch of process output
2567 @item @kbd{C-c C-r}
2568 @tab Show last batch of process output
2569 @item @kbd{C-c C-l}
2570 @tab List input history
2571 @end multitable
2573 In addition to these standard @file{comint} commands,
2574 @code{idlwave-shell-mode} provides many of the same commands which
2575 simplify writing IDL code available in IDLWAVE buffers.  This includes
2576 abbreviations, online help, and completion.  See @ref{Routine Info} and
2577 @ref{Online Help} and @ref{Completion} for more information on these
2578 commands.
2580 @cindex Completion, in the shell
2581 @cindex Routine info, in the shell
2582 @cindex Online Help, in the shell
2583 @multitable @columnfractions .12 .88
2584 @item @kbd{@key{TAB}}
2585 @tab  Completion of file names (between quotes and after executive
2586 commands @samp{.run} and @samp{.compile}), routine names, class names,
2587 keywords, system variables, system variable tags etc.
2588 (@code{idlwave-shell-complete}).
2589 @item @kbd{M-@key{TAB}}
2590 @tab Same as @key{TAB}
2591 @item @kbd{C-c ?}
2592 @tab Routine Info display (@code{idlwave-routine-info})
2593 @item @kbd{M-?}
2594 @tab IDL online help on routine (@code{idlwave-routine-info-from-idlhelp})
2595 @item @kbd{C-c C-i}
2596 @tab Update routine info from buffers and shell
2597 (@code{idlwave-update-routine-info})
2598 @item @kbd{C-c C-v}
2599 @tab Find the source file of a routine (@code{idlwave-find-module})
2600 @item @kbd{C-c C-t}
2601 @tab Find the source file of a routine in the currently visited file 
2602 (@code{idlwave-find-module-this-file}).
2603 @item @kbd{C-c =}
2604 @tab Compile a library routine (@code{idlwave-resolve})
2605 @end multitable
2607 @defopt idlwave-shell-arrows-do-history (@code{t})
2608 Non-@code{nil} means @key{UP} and @key{DOWN} arrows move through command
2609 history like xterm.
2610 @end defopt
2612 @defopt idlwave-shell-comint-settings
2613 Alist of special settings for the comint variables in the IDLWAVE Shell.
2614 @end defopt
2616 @defopt idlwave-shell-file-name-chars
2617 The characters allowed in file names, as a string.  Used for file name
2618 completion.
2619 @end defopt
2621 @defopt idlwave-shell-graphics-window-size
2622 Size of IDL graphics windows popped up by special IDLWAVE command.
2623 @end defopt
2625 @cindex Input mode
2626 @cindex Character input mode (Shell)
2627 @cindex Line input mode (Shell)
2628 @cindex Magic spells, for input mode
2629 @cindex Spells, magic
2630 IDLWAVE works in line input mode: You compose a full command line, using
2631 all the power Emacs gives you to do this.  When you press @key{RET}, the
2632 whole line is sent to IDL.  Sometimes it is necessary to send single
2633 characters (without a newline), for example when an IDL program is
2634 waiting for single character input with the @code{GET_KBRD} function.
2635 You can send a single character to IDL with the command @kbd{C-c C-x}
2636 (@code{idlwave-shell-send-char}).  When you press @kbd{C-c C-y}
2637 (@code{idlwave-shell-char-mode-loop}), IDLWAVE runs a blocking loop
2638 which accepts characters and immediately sends them to IDL.  The loop
2639 can be exited with @kbd{C-g}.  It terminates also automatically when the
2640 current IDL command is finished.  Check the documentation of the two
2641 variables described below for a way to make IDL programs trigger
2642 automatic switches of the input mode.
2644 @defopt idlwave-shell-use-input-mode-magic (@code{nil})
2645 Non-@code{nil} means IDLWAVE should check for input mode spells in
2646 output.
2647 @end defopt
2649 @defopt idlwave-shell-input-mode-spells
2650 The three regular expressions which match the magic spells for input
2651 modes.
2652 @end defopt
2654 @node Commands Sent to the Shell, Debugging IDL Programs, Using the Shell, The IDLWAVE Shell
2655 @section Commands Sent to the Shell
2656 @cindex Commands in shell, showing
2657 @cindex Showing commands in shell
2659 The IDLWAVE buffers and shell interact very closely.  In addition to the
2660 normal commands you enter at the @code{IDL>} prompt, many other special
2661 commands are sent to the shell, sometimes as a direct result of invoking
2662 a key command, menu item, or toolbar button, but also automatically, as
2663 part of the normal flow of information updates between the buffer and
2664 shell.
2666 The commands sent include @code{breakpoint}, @code{.step} and other
2667 debug commands (@pxref{Debugging IDL Programs}), @code{.run} and other
2668 compilation statements (@pxref{Compiling Programs}), examination
2669 commands like @code{print} and @code{help} (@pxref{Examining
2670 Variables}), and other special purpose commands designed to keep
2671 information on the running shell current.
2673 By default, much of this background shell input and output is hidden
2674 from the user, but this is configurable.  The custom variable
2675 @code{idlwave-abbrev-show-commands} allows you to configure which
2676 commands sent to the shell are shown there.  For a related customization
2677 for separating the output of @emph{examine} commands, see @ref{Examining
2678 Variables}.
2680 @defopt idlwave-shell-show-commands (@code{'(run misc breakpoint)})
2681 A list of command types to echo in the shell when sent.  Possible values
2682 are @code{run} for @code{.run}, @code{.compile} and other run commands,
2683 @code{misc} for lesser used commands like @code{window},
2684 @code{retall},@code{close}, etc., @code{breakpoint} for breakpoint
2685 setting and clearing commands, and @code{debug} for other debug,
2686 stepping, and continue commands.  In addition, if the variable is set to
2687 the single symbol @code{'everything}, all the copious shell input is
2688 displayed (which is probably only useful for debugging purposes).
2689 N.B. For hidden commands which produce output by side-effect, that
2690 output remains hidden (e.g., stepping through a @code{print} command).
2691 As a special case, any error message in the output will be displayed
2692 (e.g., stepping to an error).
2693 @end defopt
2695 @node Debugging IDL Programs, Examining Variables, Commands Sent to the Shell, The IDLWAVE Shell
2696 @section Debugging IDL Programs
2697 @cindex Debugging
2698 @cindex Keybindings for debugging
2699 @cindex Toolbar
2701 Programs can be compiled, run, and debugged directly from the source
2702 buffer in Emacs, walking through arbitrarily deeply nested code,
2703 printing expressions and skipping up and down the calling stack along
2704 the way.  IDLWAVE makes compiling and debugging IDL programs far less
2705 cumbersome by providing a full-featured, key/menu/toolbar-driven
2706 interface to commands like @code{breakpoint}, @code{.step},
2707 @code{.run}, etc.  It can even perform complex debug operations not
2708 natively supported by IDL (like continuing to the line at the cursor).
2710 The IDLWAVE shell installs key bindings both in the shell buffer and
2711 in all IDL code buffers of the current Emacs session, so debug
2712 commands work in both places (in the shell, commands operate on the
2713 last file compiled).  On Emacs versions which support it, a debugging
2714 toolbar is also installed.  The toolbar display can be toggled with
2715 @kbd{C-c C-d C-t} (@code{idlwave-shell-toggle-toolbar}).
2718 @defopt idlwave-shell-use-toolbar (@code{t})
2719 Non-@code{nil} means use the debugging toolbar in all IDL related
2720 buffers.
2721 @end defopt
2723 @menu
2724 * A Tale of Two Modes::         
2725 * Debug Key Bindings::          
2726 * Breakpoints and Stepping::    
2727 * Compiling Programs::          
2728 * Walking the Calling Stack::   
2729 * Electric Debug Mode::         
2730 @end menu
2733 @node A Tale of Two Modes, Debug Key Bindings, Debugging IDL Programs, Debugging IDL Programs
2734 @subsection A Tale of Two Modes
2735 @cindex Electric Debug Mode
2736 @cindex Debugging Interface
2738 The many debugging, compiling, and examination commands provided in
2739 IDLWAVE are available simultaneously through two different interfaces:
2740 the original, multi-key command interface, and the new Electric Debug
2741 Mode.  The functionality they offer is similar, but the way you interact
2742 with them is quite different.  The main difference is that, in Electric
2743 Debug Mode, the source buffers are made read-only, and single
2744 key-strokes are used to step through, examine expressions, set and
2745 remove breakpoints, etc.  The same variables, prefix arguments, and
2746 settings apply to both versions, and both can be used interchangeably.
2747 By default, when breakpoints are hit, Electric Debug Mode is enabled.
2748 The traditional interface is described first.  @xref{Electric Debug
2749 Mode}, for more on that mode.  Note that electric debug mode can be
2750 prevented from activating automatically by customizing the variable
2751 @code{idlwave-shell-automatic-electric-debug}.
2753 @node Debug Key Bindings, Breakpoints and Stepping, A Tale of Two Modes, Debugging IDL Programs
2754 @subsection Debug Key Bindings
2755 @kindex C-c C-d
2756 @cindex Key bindings
2758 The standard debugging key bindings are always available by default on
2759 the prefix key @kbd{C-c C-d}, so, for example, setting a breakpoint is
2760 done with @kbd{C-c C-d C-b}, and compiling a source file with @kbd{C-c
2761 C-d C-c}.  You can also easily configure IDLWAVE to use one or more
2762 modifier keys not in use by other commands, in lieu of the prefix
2763 @kbd{C-c C-d} (though these bindings will typically also be available
2764 --- see @code{idlwave-shell-activate-prefix-keybindings}).  For
2765 example, if you include in @file{.emacs}:
2767 @lisp
2768 (setq idlwave-shell-debug-modifiers '(control shift))
2769 @end lisp
2771 @noindent a breakpoint can then be set by pressing @kbd{b} while holding down
2772 @kbd{shift} and @kbd{control} keys, i.e. @kbd{C-S-b}.  Compiling a
2773 source file will be on @kbd{C-S-c}, deleting a breakpoint @kbd{C-S-d},
2774 etc.  In the remainder of this chapter we will assume that the
2775 @kbd{C-c C-d} bindings are active, but each of these bindings will
2776 have an equivalent shortcut if modifiers are given in the
2777 @code{idlwave-shell-debug-modifiers} variable (@pxref{Lesson II --
2778 Customization}).  A much simpler and faster form of debugging for
2779 running code is also available by default --- see @ref{Electric Debug
2780 Mode}.
2782 @defopt idlwave-shell-prefix-key (@kbd{C-c C-d})
2783 The prefix key for the debugging map
2784 @code{idlwave-shell-mode-prefix-map}.
2785 @end defopt
2787 @defopt idlwave-shell-activate-prefix-keybindings (@code{t})
2788 Non-@code{nil} means debug commands will be bound to the prefix
2789 key, like @kbd{C-c C-d C-b}.
2790 @end defopt
2792 @defopt idlwave-shell-debug-modifiers (@code{nil})
2793 List of modifier keys to use for additional, alternative binding of
2794 debugging commands in the shell and source buffers.  Can be one or
2795 more of @code{control}, @code{meta}, @code{super}, @code{hyper},
2796 @code{alt}, and @code{shift}.
2797 @end defopt
2799 @node Breakpoints and Stepping, Compiling Programs, Debug Key Bindings, Debugging IDL Programs
2800 @subsection Breakpoints and Stepping
2801 @cindex Breakpoints
2802 @cindex Stepping
2803 @cindex Execution, controlled
2805 @kindex C-c C-d C-b
2806 @kindex C-c C-d C-b
2807 IDLWAVE helps you set breakpoints and step through code.  Setting a
2808 breakpoint in the current line of the source buffer is accomplished
2809 with @kbd{C-c C-d C-b} (@code{idlwave-shell-break-here}).  With a
2810 prefix arg of 1 (i.e. @kbd{C-1 C-c C-d C-b}), the breakpoint gets a
2811 @code{/ONCE} keyword, meaning that it will be deleted after first use.
2812 With a numeric prefix greater than one (e.g. @kbd{C-4 C-c C-d C-b}),
2813 the breakpoint will only be active the @code{nth} time it is hit.
2814 With a single non-numeric prefix (i.e. @kbd{C-u C-c C-d C-b}), prompt
2815 for a condition --- an IDL expression to be evaluated and trigger the
2816 breakpoint only if true.  To clear the breakpoint in the current line,
2817 use @kbd{C-c C-d C-d} (@code{idlwave-clear-current-bp}).  When
2818 executed from the shell window, the breakpoint where IDL is currently
2819 stopped will be deleted.  To clear all breakpoints, use @kbd{C-c C-d
2820 C-a} (@code{idlwave-clear-all-bp}).  Breakpoints can also be disabled
2821 and re-enabled: @kbd{C-c C-d C-\}
2822 (@code{idlwave-shell-toggle-enable-current-bp}).  
2824 Breakpoint lines are highlighted or indicated with an icon in the source
2825 code (different icons for conditional, after, and other break types).
2826 Disabled breakpoints are @emph{grayed out} by default.  Note that IDL
2827 places breakpoints as close as possible on or after the line you
2828 specify.  IDLWAVE queries the shell for the actual breakpoint location
2829 which was set, so the exact line you specify may not be marked.  You can
2830 re-sync the breakpoint list and update the display at any time (e.g., if
2831 you add or remove some on the command line) using @kbd{C-c C-d C-l}.  
2833 In recent IDLWAVE versions, the breakpoint line is highlighted when the
2834 mouse is moved over it, and a tooltip pops up describing the break
2835 details.  @kbd{Mouse-3} on the breakpoint line pops up a menu of
2836 breakpoint actions, including clearing, disabling, and adding or
2837 changing break conditions or ``after'' break count.
2839 Once the program has stopped somewhere, you can step through it.  The
2840 most important stepping commands are @kbd{C-c C-d C-s} to execute one
2841 line of IDL code ("step into"); @kbd{C-c C-d C-n} to step a single line,
2842 treating procedure and function calls as a single step ("step over");
2843 @kbd{C-c C-d C-h} to continue execution to the line at the cursor and
2844 @kbd{C-c C-d C-r} to continue execution.  @xref{Commands Sent to the
2845 Shell}, for information on displaying or hiding the breakpoint and
2846 stepping commands the shell receives.  Here is a summary of the
2847 breakpoint and stepping commands:
2849 @multitable @columnfractions .23 .77
2850 @item @kbd{C-c C-d C-b}
2851 @tab Set breakpoint (@code{idlwave-shell-break-here})
2852 @item @kbd{C-c C-d C-i}
2853 @tab Set breakpoint in module named here (@code{idlwave-shell-break-in})
2854 @item @kbd{C-c C-d C-d}
2855 @tab Clear current breakpoint (@code{idlwave-shell-clear-current-bp})
2856 @item @kbd{C-c C-d C-a}
2857 @tab Clear all breakpoints (@code{idlwave-shell-clear-all-bp})
2858 @item @kbd{C-c C-d [}
2859 @tab Go to the previous breakpoint (@code{idlwave-shell-goto-previous-bp})
2860 @item @kbd{C-c C-d ]}
2861 @tab Go to the next breakpoint (@code{idlwave-shell-goto-next-bp})
2862 @item @kbd{C-c C-d C-\}
2863 @tab Disable/Enable current breakpoint (@code{idlwave-shell-toggle-enable-current-bp})
2864 @item @kbd{C-c C-d C-j}
2865 @tab Set a breakpoint at the beginning of the enclosing routine.
2866 @item @kbd{C-c C-d C-s}
2867 @tab Step, into function calls (@code{idlwave-shell-step})
2868 @item @kbd{C-c C-d C-n}
2869 @tab Step, over function calls (@code{idlwave-shell-stepover})
2870 @item @kbd{C-c C-d C-k}
2871 @tab Skip one statement (@code{idlwave-shell-skip})
2872 @item @kbd{C-c C-d C-u}
2873 @tab Continue to end of block (@code{idlwave-shell-up})
2874 @item @kbd{C-c C-d C-m}
2875 @tab Continue to end of function (@code{idlwave-shell-return})
2876 @item @kbd{C-c C-d C-o}
2877 @tab Continue past end of function (@code{idlwave-shell-out})
2878 @item @kbd{C-c C-d C-h}
2879 @tab Continue to line at cursor position (@code{idlwave-shell-to-here})
2880 @item @kbd{C-c C-d C-r}
2881 @tab Continue execution to next breakpoint, if any (@code{idlwave-shell-cont})
2882 @item @kbd{C-c C-d C-up}
2883 @tab Show higher level in calling stack (@code{idlwave-shell-stack-up})
2884 @item @kbd{C-c C-d C-down}
2885 @tab Show lower level in calling stack (@code{idlwave-shell-stack-down})
2886 @end multitable
2888 All of these commands have equivalents in Electric Debug Mode, which
2889 provides faster single-key access (@pxref{Electric Debug Mode}).
2891 The line where IDL is currently stopped, at breakpoints, halts, and
2892 errors, etc., is marked with a color overlay or arrow, depending on the
2893 setting in @code{idlwave-shell-mark-stop-line}.  If an overlay face is
2894 used to mark the stop line (as it is by default), when stepping through
2895 code, the face color is temporarily changed to gray, until IDL completes
2896 the next command and moves to the new line.
2898 @defopt idlwave-shell-mark-breakpoints (@code{t})
2899 Non-@code{nil} means mark breakpoints in the source file buffers.  The
2900 value indicates the preferred method.  Valid values are @code{nil},
2901 @code{t}, @code{face}, and @code{glyph}.
2902 @end defopt
2904 @defopt idlwave-shell-breakpoint-face
2905 The face for breakpoint lines in the source code if
2906 @code{idlwave-shell-mark-breakpoints} has the value @code{face}.
2907 @end defopt
2909 @defopt idlwave-shell-breakpoint-popup-menu (@code{t})
2910 Whether to pop-up a menu and present a tooltip description on
2911 breakpoint lines.
2912 @end defopt
2914 @defopt idlwave-shell-mark-stop-line (@code{t})
2915 Non-@code{nil} means mark the source code line where IDL is currently
2916 stopped.  The value specifies the preferred method.  Valid values are
2917 @code{nil}, @code{t}, @code{arrow}, and @code{face}.
2918 @end defopt
2920 @defopt idlwave-shell-overlay-arrow (@code{">"})
2921 The overlay arrow to display at source lines where execution halts, if
2922 configured in @code{idlwave-shell-mark-stop-line}.
2923 @end defopt
2925 @defopt idlwave-shell-stop-line-face
2926 The face which highlights the source line where IDL is stopped, if
2927 configured in @code{idlwave-shell-mark-stop-line}.
2928 @end defopt
2931 @node Compiling Programs, Walking the Calling Stack, Breakpoints and Stepping, Debugging IDL Programs
2932 @subsection Compiling Programs
2933 @cindex Compiling programs
2934 @cindex Programs, compiling
2935 @cindex Default command line, executing
2936 @cindex Executing a default command line
2938 @kindex C-c C-d C-c
2939 In order to compile the current buffer under the IDLWAVE shell, press
2940 @kbd{C-c C-d C-c} (@code{idlwave-save-and-run}).  This first saves the
2941 current buffer and then sends the command @samp{.run path/to/file} to the 
2942 shell.  You can also execute @kbd{C-c C-d C-c} from the shell buffer, in 
2943 which case the most recently compiled buffer will be saved and
2944 re-compiled.
2946 When developing or debugging a program, it is often necessary to execute
2947 the same command line many times.  A convenient way to do this is
2948 @kbd{C-c C-d C-y} (@code{idlwave-shell-execute-default-command-line}).
2949 This command first resets IDL from a state of interrupted execution by
2950 closing all files and returning to the main interpreter level.  Then a
2951 default command line is send to the shell.  To edit the default command
2952 line, call @code{idlwave-shell-execute-default-command-line} with a
2953 prefix argument: @kbd{C-u C-c C-d C-y}.  If no default command line has
2954 been set (or you give two prefix arguments), the last command on the
2955 @code{comint} input history is sent.
2957 @node Walking the Calling Stack, Electric Debug Mode, Compiling Programs, Debugging IDL Programs
2958 @subsection Walking the Calling Stack
2959 @cindex Calling stack, walking
2961 While debugging a program, it can be very useful to check the context in
2962 which the current routine was called, for instance to help understand
2963 the value of the arguments passed.  To do so conveniently you need to
2964 examine the calling stack.  If execution is stopped somewhere deep in a
2965 program, you can use the commands @kbd{C-c C-d C-@key{UP}}
2966 (@code{idlwave-shell-stack-up}) and @kbd{C-c C-d C-@key{DOWN}}
2967 (@code{idlwave-shell-stack-down}), or the corresponding toolbar buttons,
2968 to move up or down through the calling stack.  The mode line of the
2969 shell window will indicate the position within the stack with a label
2970 like @samp{[-3:MYPRO]}.  The line of IDL code at that stack position
2971 will be highlighted.  If you continue execution, IDLWAVE will
2972 automatically return to the current level. @xref{Examining Variables},
2973 for information how to examine the value of variables and expressions on
2974 higher calling stack levels.
2976 @html
2977 <A NAME="EDEBUG"></A>
2978 @end html
2979 @node Electric Debug Mode,  , Walking the Calling Stack, Debugging IDL Programs
2980 @subsection Electric Debug Mode
2981 @cindex Electric Debug Mode
2982 @cindex @samp{*Debugging*}
2984 Even with a convenient debug key prefix enabled, repetitive stepping,
2985 variable examination (@pxref{Examining Variables}), and other debugging
2986 activities can be awkward and slow using commands which require multiple
2987 keystrokes.  Luckily, there's a better way, inspired by the lisp e-debug
2988 mode, and available through the @emph{Electric Debug Mode}.  By default,
2989 as soon as a breakpoint is hit, this minor mode is enabled.  The buffer
2990 showing the line where execution has halted is switched to Electric
2991 Debug Mode.  This mode is visible as @samp{*Debugging*} in the mode
2992 line, and a different face (violet by default, if color is available)
2993 for the line stopped at point.  The buffer is made read-only and
2994 single-character bindings for the most commonly used debugging commands
2995 are enabled.  These character commands (a list of which is available
2996 with @kbd{C-?}) are:
2998 @multitable @columnfractions .2 .8
2999 @item @kbd{a}
3000 @tab Clear all breakpoints (@code{idlwave-shell-clear-all-bp})
3001 @item @kbd{b}
3002 @tab Set breakpoint, @kbd{C-u b} for a conditional break, @kbd{C-n b} for nth hit (@code{idlwave-shell-break-here})
3003 @item @kbd{d}
3004 @tab Clear current breakpoint (@code{idlwave-shell-clear-current-bp})
3005 @item @kbd{e}
3006 @tab Prompt for expression to print (@code{idlwave-shell-clear-current-bp}).
3007 @item @kbd{h}
3008 @tab Continue to the line at cursor position (@code{idlwave-shell-to-here})
3009 @item @kbd{i}
3010 @tab Set breakpoint in module named here (@code{idlwave-shell-break-in})
3011 @item @kbd{[}
3012 @tab Go to the previous breakpoint in the file (@code{idlwave-shell-goto-previous-bp})
3013 @item @kbd{]}
3014 @tab Go to the next breakpoint in the file
3015 (@code{idlwave-shell-goto-next-bp})
3016 @item @kbd{\}
3017 @tab Disable/Enable current breakpoint (@code{idlwave-shell-toggle-enable-current-bp})
3018 @item @kbd{j}
3019 @tab Set breakpoint at beginning of enclosing routine (@code{idlwave-shell-break-this-module})
3020 @item @kbd{k}
3021 @tab Skip one statement (@code{idlwave-shell-skip})
3022 @item @kbd{m}
3023 @tab Continue to end of function (@code{idlwave-shell-return})
3024 @item @kbd{n}
3025 @tab Step, over function calls (@code{idlwave-shell-stepover})
3026 @item @kbd{o}
3027 @tab Continue past end of function (@code{idlwave-shell-out})
3028 @item @kbd{p}
3029 @tab Print expression near point or in region with @kbd{C-u p} (@code{idlwave-shell-print})
3030 @item @kbd{q}
3031 @tab End the debugging session and return to the Shell's main level
3032 (@code{idlwave-shell-retall})
3033 @item @kbd{r}
3034 @tab Continue execution to next breakpoint, if any (@code{idlwave-shell-cont})
3035 @item @kbd{s} or @kbd{@key{SPACE}}
3036 @tab Step, into function calls (@code{idlwave-shell-step})
3037 @item @kbd{t}
3038 @tab Print a calling-level traceback in the shell
3039 @item @kbd{u}
3040 @tab Continue to end of block (@code{idlwave-shell-up})
3041 @item @kbd{v}
3042 @tab Turn Electric Debug Mode off
3043 (@code{idlwave-shell-electric-debug-mode})
3044 @item @kbd{x}
3045 @tab Examine expression near point (or in region with @kbd{C-u x})
3046 with shortcut of examine type.
3047 @item @kbd{z}
3048 @tab Reset IDL (@code{idlwave-shell-reset})
3049 @item @kbd{+} or @kbd{=}
3050 @tab Show higher level in calling stack (@code{idlwave-shell-stack-up})
3051 @item @kbd{-} or @kbd{_}
3052 @tab Show lower level in calling stack (@code{idlwave-shell-stack-down})
3053 @item @kbd{?}
3054 @tab Help on expression near point or in region with @kbd{C-u ?}
3055 (@code{idlwave-shell-help-expression})
3056 @item @kbd{C-?}
3057 @tab Show help on the commands available.
3058 @end multitable
3060 Most single-character electric debug bindings use the final keystroke
3061 of the equivalent multiple key commands (which are of course also
3062 still available), but some differ (e.g. @kbd{e},@kbd{t},@kbd{q},@kbd{x}).
3063 Some have additional convenience bindings (like @kbd{@key{SPACE}} for
3064 stepping).  All prefix and other argument options described in this
3065 section for the commands invoked by electric debug bindings are still
3066 valid.  For example, @kbd{C-u b} sets a conditional breakpoint, just
3067 as it did with @kbd{C-u C-c C-d C-b}.
3069 You can toggle the electric debug mode at any time in a buffer using
3070 @kbd{C-c C-d C-v} (@kbd{v} to turn it off while in the mode), or from
3071 the Debug menu.  Normally the mode will be enabled and disabled at the
3072 appropriate times, but occasionally you might want to edit a file
3073 while still debugging it, or switch to the mode for conveniently
3074 setting lots of breakpoints.
3076 To quickly abandon a debugging session and return to normal editing at
3077 the Shell's main level, use @kbd{q} (@code{idlwave-shell-retall}).
3078 This disables electric debug mode in all IDLWAVE buffers@footnote{Note
3079 that this binding is not symmetric: @kbd{C-c C-d C-q} is bound to
3080 @code{idlwave-shell-quit}, which quits your IDL session.}.  Help is
3081 available for the command shortcuts with @kbd{C-?}.  If you find this
3082 mode gets in your way, you can keep it from automatically activating
3083 by setting the variable @code{idlwave-shell-automatic-electric-debug}
3084 to @code{nil}, or @code{'breakpoint}.  If you'd like the convenient
3085 electric debug shortcuts available also when run-time errors are
3086 encountered, set to @code{t}.
3088 @defopt idlwave-shell-automatic-electric-debug (@code{'breakpoint})
3089 Whether to enter electric debug mode automatically when a breakpoint
3090 or run-time error is encountered, and then disable it in all buffers
3091 when the $MAIN$ level is reached (either through normal program
3092 execution, or retall).  In addition to @code{nil} for never, and
3093 @code{t} for both breakpoints and errors, this can be
3094 @code{'breakpoint} (the default) to enable it only at breakpoint
3095 halts.
3096 @end defopt
3098 @defopt idlwave-shell-electric-stop-color (Violet)
3099 Default color of the stopped line overlay when in electric debug mode.
3100 @end defopt        
3102 @defopt idlwave-shell-electric-stop-line-face 
3103 The face to use for the stopped line.  Defaults to a face similar to the
3104 modeline, with color @code{idlwave-shell-electric-stop-color}.
3105 @end defopt
3107 @defopt idlwave-shell-electric-zap-to-file (@code{t})
3108 If set, when entering electric debug mode, select the window displaying
3109 the file where point is stopped.  This takes point away from the shell
3110 window, but is useful for immediate stepping, etc.
3111 @end defopt
3113 @html
3114 <A NAME="EXAMINE"></A>
3115 @end html
3116 @node Examining Variables, Custom Expression Examination, Debugging IDL Programs, The IDLWAVE Shell
3117 @section Examining Variables
3118 @cindex @code{PRINT} expressions
3119 @cindex @code{HELP}, on expressions
3120 @cindex Expressions, printing & help
3121 @cindex Examining expressions
3122 @cindex Printing expressions
3123 @cindex Mouse binding to print expressions
3125 @kindex C-c C-d C-p
3126 Do you find yourself repeatedly typing, e.g. @code{print,n_elements(x)},
3127 and similar statements to remind yourself of the
3128 type/size/structure/value/etc. of variables and expressions in your code
3129 or at the command line?  IDLWAVE has a suite of special commands to
3130 automate these types of variable or expression examinations.  They work
3131 by sending statements to the shell formatted to include the indicated
3132 expression, and can be accessed in several ways.
3134 These @emph{examine} commands can be used in the shell or buffer at any
3135 time (as long as the shell is running), and are very useful when
3136 execution is stopped in a buffer due to a triggered breakpoint or error,
3137 or while composing a long command in the IDLWAVE shell.  In the latter
3138 case, the command is sent to the shell and its output is visible, but
3139 point remains unmoved in the command being composed --- you can inspect
3140 the constituents of a command you're building without interrupting the
3141 process of building it!  You can even print arbitrary expressions from
3142 older input or output further up in the shell window --- any expression,
3143 variable, number, or function you see can be examined.
3145 If the variable @code{idlwave-shell-separate-examine-output} is
3146 non-@code{nil} (the default), all examine output will be sent to a
3147 special @file{*Examine*} buffer, rather than the shell.  The output of
3148 prior examine commands is saved in this buffer.  In this buffer @key{c}
3149 clears the contents, and @key{q} hides the buffer.
3151 The two most basic examine commands are bound to @kbd{C-c C-d C-p}, to
3152 print the expression at point, and @kbd{C-c C-d ?}, to invoke help on
3153 this expression@footnote{Available as @kbd{p} and @kbd{?} in Electric
3154 Debug Mode (@pxref{Electric Debug Mode})}.  The expression at point is
3155 either an array expression or a function call, or the contents of a pair
3156 of parentheses.  The chosen expression is highlighted, and
3157 simultaneously the resulting output is highlighted in the shell or
3158 separate output buffer.  Calling the above commands with a prefix
3159 argument will use the current region as expression instead of using the
3160 one at point. which can be useful for examining complicated, multi-line
3161 expressions.  Two prefix arguments (@kbd{C-u C-u C-c C-d C-p}) will
3162 prompt for an expression to print directly.  By default, when invoking
3163 print, only an initial portion of long arrays will be printed, up to
3164 @code{idlwave-shell-max-print-length}.
3166 For added speed and convenience, there are mouse bindings which allow
3167 you to click on expressions and examine their values.  Use
3168 @kbd{S-Mouse-2} to print an expression and @kbd{C-M-Mouse-2} to invoke
3169 help (i.e. you need to hold down @key{META} and @key{CONTROL} while
3170 clicking with the middle mouse button).  If you simply click, the
3171 nearest expression will be selected in the same manner as described
3172 above.  You can also @emph{drag} the mouse in order to highlight
3173 exactly the specific expression or sub-expression you want to examine.
3174 For custom expression examination, and the powerful customizable
3175 pop-up examine selection, @xref{Custom Expression Examination}.
3177 @cindex Printing expressions, on calling stack
3178 @cindex Restrictions for expression printing
3179 The same variable inspection commands work both in the IDL Shell and
3180 IDLWAVE buffers, and even for variables at higher levels of the calling
3181 stack.  For instance, if you're stopped at a breakpoint in a routine,
3182 you can examine the values of variables and expressions inside its
3183 calling routine, and so on, all the way up through the calling stack.
3184 Simply step up the stack, and print variables as you see them
3185 (@pxref{Walking the Calling Stack}, for information on stepping back
3186 through the calling stack).  The following restrictions apply for all
3187 levels except the current:
3189 @itemize @bullet
3190 @item
3191 Array expressions must use the @samp{[ ]} index delimiters.  Identifiers
3192 with a @samp{( )} will be interpreted as function calls.
3193 @item
3194 @cindex ROUTINE_NAMES, IDL procedure
3195 N.B.: printing values of expressions on higher levels of the calling
3196 stack uses the @emph{unsupported} IDL routine @code{ROUTINE_NAMES},
3197 which may or may not be available in future versions of IDL.  Caveat
3198 Examinor.
3199 @end itemize
3201 @defopt idlwave-shell-expression-face
3202 The face for @code{idlwave-shell-expression-overlay}.
3203 Allows you to choose the font, color and other properties for
3204 the expression printed by IDL.
3205 @end defopt
3207 @defopt idlwave-shell-output-face
3208 The face for @code{idlwave-shell-output-overlay}.  
3209 Allows to choose the font, color and other properties for the most
3210 recent output of IDL when examining an expression."
3211 @end defopt
3213 @defopt idlwave-shell-separate-examine-output (@code{t})
3214 If non-@code{nil}, re-direct the output of examine commands to a special
3215 @file{*Examine*} buffer, instead of in the shell itself. 
3216 @end defopt
3218 @defopt idlwave-shell-max-print-length (200)
3219 The maximum number of leading array entries to print, when examining
3220 array expressions.
3221 @end defopt
3223 @node Custom Expression Examination,  , Examining Variables, The IDLWAVE Shell
3224 @section Custom Expression Examination
3225 @cindex Expressions, custom examination
3226 @cindex Custom expression examination
3228 The variety of possible variable and expression examination commands is
3229 endless (just look, for instance, at the keyword list to
3230 @code{widget_info()}).  Rather than attempt to include them all, IDLWAVE
3231 provides two easy methods to customize your own commands, with a special
3232 mouse examine command, and two macros for generating your own examine
3233 key and mouse bindings.
3235 The most powerful and flexible mouse examine command of all is
3236 available on @kbd{C-S-Mouse-2}.  Just as for all the other mouse
3237 examine commands, it permits click or drag expression selection, but
3238 instead of sending hard-coded commands to the shell, it pops-up a
3239 customizable selection list of examine functions to choose among,
3240 configured with the @code{idlwave-shell-examine-alist}
3241 variable@footnote{In Electric Debug Mode (@pxref{Electric Debug
3242 Mode}), the key @kbd{x} provides a single-character shortcut interface
3243 to the same examine functions for the expression at point or marked by
3244 the region.}.  This variable is a list of key-value pairs (an
3245 @emph{alist} in Emacs parlance), where the key gives a name to be
3246 shown for the examine command, and the value is the command strings
3247 itself, in which the text @code{___} (three underscores) will be
3248 replaced by the selected expression before being sent to the shell.
3249 An example might be key @code{Structure Help} with value
3250 @code{help,___,/STRUCTURE}.  In that case, you'd be prompted with
3251 @emph{Structure Help}, which might send something like
3252 @code{help,var,/STRUCTURE} to the shell for output.
3253 @code{idlwave-shell-examine-alist} comes configured by default with a
3254 large list of examine commands, but you can easily customize it to add
3255 your own.
3257 In addition to configuring the functions available to the pop-up mouse
3258 command, you can easily create your own customized bindings to inspect
3259 expressions using the two convenience macros
3260 @code{idlwave-shell-examine} and @code{idlwave-shell-mouse-examine}.
3261 These create keyboard or mouse-based custom inspections of variables,
3262 sharing all the same properties of the built-in examine commands.
3263 Both functions take a single string argument sharing the syntax of the
3264 @code{idlwave-shell-examine-alist} values, e.g.:
3266 @lisp
3267 (add-hook 'idlwave-shell-mode-hook
3268           (lambda ()
3269             (idlwave-shell-define-key-both [s-down-mouse-2] 
3270                                  (idlwave-shell-mouse-examine 
3271                                   "print, size(___,/DIMENSIONS)"))
3272             (idlwave-shell-define-key-both [f9] (idlwave-shell-examine
3273                                        "print, size(___,/DIMENSIONS)"))
3274             (idlwave-shell-define-key-both [f10] (idlwave-shell-examine 
3275                                         "print,size(___,/TNAME)"))
3276             (idlwave-shell-define-key-both [f11] (idlwave-shell-examine
3277                                         "help,___,/STRUCTURE"))))
3278 @end lisp                                        
3279             
3280 @noindent Now pressing @key{f9}, or middle-mouse dragging with the
3281 @key{SUPER} key depressed, will print the dimensions of the nearby or
3282 highlighted expression.  Pressing @key{f10} will give the type string,
3283 and @key{f11} will show the contents of a nearby structure.  As you can
3284 see, the possibilities are only marginally finite.
3286 @defopt idlwave-shell-examine-alist
3287 An alist of examine commands in which the keys name the command and
3288 are displayed in the selection pop-up, and the values are custom IDL
3289 examine command strings to send, after all instances of @code{___}
3290 (three underscores) are replaced by the indicated expression.
3291 @end defopt
3293 @node Acknowledgements, Sources of Routine Info, The IDLWAVE Shell, Top
3294 @chapter Acknowledgements
3295 @cindex Acknowledgements
3296 @cindex Maintainer, of IDLWAVE
3297 @cindex Authors, of IDLWAVE
3298 @cindex Contributors, to IDLWAVE
3299 @cindex Email address, of Maintainer
3300 @cindex Thanks
3302 @noindent
3303 The main contributors to the IDLWAVE package have been:
3305 @itemize @minus
3306 @item
3307 @uref{mailto:chase@@att.com, @b{Chris Chase}}, the original author.
3308 Chris wrote @file{idl.el} and @file{idl-shell.el} and maintained them
3309 for several years.
3311 @item
3312 @uref{mailto:dominik@@astro.uva.nl, @b{Carsten Dominik}} was in charge
3313 of the package from version 3.0, during which time he overhauled almost
3314 everything, modernized IDLWAVE with many new features, and developed the
3315 manual.
3317 @item 
3318 @uref{mailto:jdsmith@@as.arizona.edu, @b{J.D. Smith}}, the current
3319 maintainer, as of version 4.10, helped shape object method completion
3320 and most new features introduced in versions 4.x, and introduced many
3321 new features for IDLWAVE versions 5.x and 6.x.
3322 @end itemize
3324 @noindent
3325 The following people have also contributed to the development of IDLWAVE
3326 with patches, ideas, bug reports and suggestions.
3328 @itemize @minus
3329 @item
3330 Ulrik Dickow <dickow__at__nbi.dk>
3331 @item
3332 Eric E. Dors <edors__at__lanl.gov>
3333 @item
3334 Stein Vidar H. Haugan <s.v.h.haugan__at__astro.uio.no>
3335 @item
3336 David Huenemoerder <dph__at__space.mit.edu>
3337 @item
3338 Kevin Ivory <Kevin.Ivory__at__linmpi.mpg.de>
3339 @item
3340 Dick Jackson <dick__at__d-jackson.com>
3341 @item
3342 Xuyong Liu <liu__at__stsci.edu>
3343 @item
3344 Simon Marshall <Simon.Marshall__at__esrin.esa.it>
3345 @item
3346 Craig Markwardt <craigm__at__cow.physics.wisc.edu>
3347 @item
3348 Laurent Mugnier <mugnier__at__onera.fr>
3349 @item
3350 Lubos Pochman <lubos__at__rsinc.com>
3351 @item
3352 Bob Portmann <portmann__at__al.noaa.gov>
3353 @item
3354 Patrick M. Ryan <pat__at__jaameri.gsfc.nasa.gov>
3355 @item
3356 Marty Ryba <ryba__at__ll.mit.edu>
3357 @item
3358 Phil Williams <williams__at__irc.chmcc.org>
3359 @item
3360 Phil Sterne <sterne__at__dublin.llnl.gov>
3361 @item
3362 Paul Sorenson <aardvark62__at__msn.com>
3363 @end itemize
3365 Doug Dirks was instrumental in providing the crucial IDL XML catalog to
3366 support HTML help with IDL v6.2 and later, and Ali Bahrami provided
3367 scripts and documentation to interface with the IDL Assistant.
3369 @noindent
3370 Thanks to everyone!
3372 @node Sources of Routine Info, HTML Help Browser Tips, Acknowledgements, Top
3373 @appendix Sources of Routine Info
3375 @cindex Sources of routine information
3376 In @ref{Routine Info} and @ref{Completion} we showed how IDLWAVE
3377 displays the calling sequence and keywords of routines, and completes
3378 routine names and keywords.  For these features to work, IDLWAVE must
3379 know about the accessible routines.
3381 @menu
3382 * Routine Definitions::         Where IDL Routines are defined.
3383 * Routine Information Sources::  So how does IDLWAVE know about...
3384 * Catalogs::                    
3385 * Load-Path Shadows::           Routines defined in several places
3386 * Documentation Scan::          Scanning the IDL Manuals
3387 @end menu
3389 @node Routine Definitions, Routine Information Sources, Sources of Routine Info, Sources of Routine Info
3390 @appendixsec Routine Definitions
3391 @cindex Routine definitions
3392 @cindex IDL variable @code{!PATH}
3393 @cindex @code{!PATH}, IDL variable
3394 @cindex @code{CALL_EXTERNAL}, IDL routine
3395 @cindex @code{LINKIMAGE}, IDL routine
3396 @cindex External routines
3398 @noindent Routines which can be used in an IDL program can be defined in
3399 several places:
3401 @enumerate
3402 @item 
3403 @emph{Builtin routines} are defined inside IDL itself.  The source code
3404 of such routines is not available, but instead are learned about through
3405 the IDL documentation.
3406 @item
3407 Routines which are @emph{part of the current program}, are defined in a
3408 file explicitly compiled by the user.  This file may or may not be
3409 located on the IDL search path.
3410 @item 
3411 @emph{Library routines} are defined in files located on IDL's search
3412 path.  When a library routine is called for the first time, IDL will
3413 find the source file and compile it dynamically.  A special sub-category
3414 of library routines are the @emph{system routines} distributed with IDL,
3415 and usually available in the @file{lib} subdirectory of the IDL
3416 distribution.
3417 @item
3418 External routines written in other languages (like Fortran or C) can be
3419 called with @code{CALL_EXTERNAL}, linked into IDL via @code{LINKIMAGE},
3420 or included as dynamically loaded modules (DLMs).  Currently IDLWAVE
3421 cannot provide routine info and completion for such external routines,
3422 except by querying the Shell for calling information (DLMs only).
3423 @end enumerate
3425 @node Routine Information Sources, Catalogs, Routine Definitions, Sources of Routine Info
3426 @appendixsec Routine Information Sources
3427 @cindex Routine info sources
3428 @cindex Builtin list of routines
3429 @cindex Updating routine info
3430 @cindex Scanning buffers for routine info
3431 @cindex Buffers, scanning for routine info
3432 @cindex Shell, querying for routine info
3434 @noindent To maintain the most comprehensive information about all IDL
3435 routines on a system, IDLWAVE collects data from many sources:
3437 @enumerate
3439 @item
3440 It has a @emph{builtin list} with information about the routines IDL
3441 ships with.  IDLWAVE @value{VERSION} is distributed with a list of
3442 @value{NSYSROUTINES} routines, reflecting IDL version
3443 @value{IDLVERSION}.  As of IDL v6.2, the routine info is distributed
3444 directly with IDL in the form of an XML catalog which IDLWAVE scans.
3445 Formerly, this list was created by scanning the IDL manuals to produce
3446 the file @file{idlw-rinfo.el}.
3448 @item 
3449 IDLWAVE @emph{scans} all its @emph{buffers} in the current Emacs session
3450 for routine definitions.  This is done automatically when routine
3451 information or completion is first requested by the user.  Each new
3452 buffer and each buffer saved after making changes is also scanned. The
3453 command @kbd{C-c C-i} (@code{idlwave-update-routine-info}) can be used
3454 at any time to rescan all buffers.
3456 @item
3457 If you have an IDLWAVE-Shell running in the Emacs session, IDLWAVE will
3458 @emph{query the shell} for compiled routines and their arguments.  This
3459 happens automatically when routine information or completion is first
3460 requested by the user.  Each time an Emacs buffer is compiled with
3461 @kbd{C-c C-d C-c}, the routine info for that file is queried.  Though
3462 rarely necessary, the command @kbd{C-c C-i}
3463 (@code{idlwave-update-routine-info}) can be used to explicitly update
3464 the shell routine data.
3466 @item
3467 Many popular libraries are distributed with routine information already
3468 scanned into @emph{library catalogs} (@pxref{Library Catalogs}).  These
3469 per-directory catalog files can also be built by the user with the
3470 supplied @file{idlwave_catalog} tool.  They are automatically discovered
3471 by IDLWAVE.
3473 @item
3474 IDLWAVE can scan selected directories of source files and store the
3475 result in a single @emph{user catalog} file which will be
3476 automatically loaded just like @file{idlw-rinfo.el}. @xref{User
3477 Catalog}, for information on how to scan files in this way.
3478 @end enumerate
3480 Loading all the routine and catalog information can be a time consuming
3481 process, especially over slow networks.  Depending on the system and
3482 network configuration it could take up to 30 seconds (though locally on
3483 fast systems is usually only a few seconds).  In order to minimize the
3484 wait time upon your first completion or routine info command in a
3485 session, IDLWAVE uses Emacs idle time to do the initialization in six
3486 steps, yielding to user input in between.  If this gets into your way,
3487 set the variable @code{idlwave-init-rinfo-when-idle-after} to 0 (zero).
3488 The more routines documented in library and user catalogs, the slower
3489 the loading will be, so reducing this number can help alleviate any long
3490 load times.
3492 @defopt idlwave-init-rinfo-when-idle-after (@code{10})
3493 Seconds of idle time before routine info is automatically initialized.
3494 @end defopt
3496 @defopt idlwave-scan-all-buffers-for-routine-info (@code{t})
3497 Non-@code{nil} means scan all buffers for IDL programs when updating
3498 info.
3499 @end defopt
3501 @defopt idlwave-query-shell-for-routine-info (@code{t})
3502 Non-@code{nil} means query the shell for info about compiled routines.
3503 @end defopt
3505 @defopt idlwave-auto-routine-info-updates
3506 Controls under what circumstances routine info is updated automatically.
3507 @end defopt
3509 @html
3510 <A NAME="CATALOGS"></A>
3511 @end html
3512 @node Catalogs, Load-Path Shadows, Routine Information Sources, Sources of Routine Info
3513 @appendixsec Catalogs
3514 @cindex Catalogs
3516 @emph{Catalogs} are files containing scanned information on individual
3517 routines, including arguments and keywords, calling sequence, file path,
3518 class and procedure vs. function type, etc.  They represent a way of
3519 extending the internal built-in information available for IDL system
3520 routines (@pxref{Routine Info}) to other source collections.
3522 Starting with version 5.0, there are two types of catalogs available
3523 with IDLWAVE.  The traditional @emph{user catalog} and the newer
3524 @emph{library catalogs}.  Although they can be used interchangeably, the
3525 library catalogs are more flexible, and preferred.  There are few
3526 occasions when a user catalog might be preferred --- read below.  Both
3527 types of catalogs can coexist without causing problems.
3529 To facilitate the catalog systems, IDLWAVE stores information it gathers
3530 from the shell about the IDL search paths, and can write this
3531 information out automatically, or on-demand (menu @code{Debug->Save Path
3532 Info}).  On systems with no shell from which to discover the path
3533 information (e.g. Windows), a library path must be specified in
3534 @code{idlwave-library-path} to allow library catalogs to be located, and
3535 to setup directories for user catalog scan (@pxref{User Catalog} for
3536 more on this variable).  Note that, before the shell is running, IDLWAVE
3537 can only know about the IDL search path by consulting the file pointed
3538 to by @code{idlwave-path-file} (@file{~/.idlwave/idlpath.el}, by
3539 default).  If @code{idlwave-auto-write-path} is enabled (which is the
3540 default), the paths are written out whenever the IDLWAVE shell is
3541 started.
3543 @defopt idlwave-auto-write-path  (@code{t})
3544 Write out information on the !PATH and !DIR paths from IDL automatically
3545 when they change and when the Shell is closed.  These paths are needed
3546 to locate library catalogs.
3547 @end defopt
3549 @defopt idlwave-library-path
3550 IDL library path for Windows and MacOS.  Under Unix/MacOSX, will be
3551 obtained from the Shell when run.
3552 @end defopt
3554 @defopt idlwave-system-directory
3555 The IDL system directory for Windows and MacOS.  Also needed for
3556 locating HTML help and the IDL Assistant for IDL v6.2 and later.  Under
3557 Unix/MacOSX, will be obtained from the Shell and recorded, if run.
3558 @end defopt
3560 @defopt idlwave-config-directory (@file{~/.idlwave})
3561 Default path where IDLWAVE saves configuration information, a user
3562 catalog (if any), and a cached scan of the XML catalog (IDL v6.2 and
3563 later).
3564 @end defopt
3566 @menu
3567 * Library Catalogs::            
3568 * User Catalog::                
3569 @end menu
3571 @html
3572 <A NAME="LIBRARY_CATALOGS"></A>
3573 @end html
3574 @node Library Catalogs, User Catalog, Catalogs, Catalogs
3575 @appendixsubsec Library Catalogs
3576 @cindex @file{.idlwave_catalog}
3577 @cindex Library catalogs
3578 @cindex @code{idlwave_catalog}
3580 Library catalogs consist of files named @file{.idlwave_catalog} stored
3581 in directories containing @code{.pro} routine files.  They are
3582 discovered on the IDL search path and loaded automatically when routine
3583 information is read.  Each catalog file documents the routines found in
3584 that directory --- one catalog per directory.  Every catalog has a
3585 library name associated with it (e.g. @emph{AstroLib}).  This name will
3586 be shown briefly when the catalog is found, and in the routine info of
3587 routines it documents.
3589 Many popular libraries of routines are shipped with IDLWAVE catalog
3590 files by default, and so will be automatically discovered.  Library
3591 catalogs are scanned externally to Emacs using a tool provided with
3592 IDLWAVE.  Each catalog can be re-scanned independently of any other.
3593 Catalogs can easily be made available system-wide with a common source
3594 repository, providing uniform routine information, and lifting the
3595 burden of scanning from the user (who may not even know they're using a
3596 scanned catalog).  Since all catalogs are independent, they can be
3597 re-scanned automatically to gather updates, e.g. in a @file{cron} job.
3598 Scanning is much faster than with the built-in user catalog method.  One
3599 minor disadvantage: the entire IDL search path is scanned for catalog
3600 files every time IDLWAVE starts up, which might be slow if accessing IDL
3601 routines over a slow network.
3603 A Perl tool to create library catalogs is distributed with IDLWAVE:
3604 @code{idlwave_catalog}.  It can be called quite simply:
3605 @example
3606 idlwave_catalog MyLib
3607 @end example
3609 @noindent This will scan all directories recursively beneath the current and
3610 populate them with @file{.idlwave_catalog} files, tagging the routines
3611 found there with the name library ``MyLib''.  The full usage
3612 information:
3614 @example
3615 Usage: idlwave_catalog  [-l] [-v] [-d] [-s] [-f] [-h] libname
3616        libname - Unique name of the catalog (4 or more alphanumeric
3617                  characters).
3618             -l - Scan local directory only, otherwise recursively
3619                  catalog all directories at or beneath this one.
3620             -v - Print verbose information.
3621             -d - Instead of scanning, delete all .idlwave_catalog files
3622                  here or below.
3623             -s - Be silent.
3624             -f - Force overwriting any catalogs found with a different
3625                  library name.
3626             -h - Print this usage.
3627 @end example
3629 To re-load the library catalogs on the IDL path, force a system routine
3630 info update using a single prefix to @code{idlwave-update-routine-info}:
3631 @kbd{C-u C-c C-i}.
3633 @defopt idlwave-use-library-catalogs  (@code{t})
3634 Whether to search for and load library catalogs.  Disable if load
3635 performance is a problem and/or the catalogs are not needed.
3636 @end defopt
3638 @node User Catalog,  , Library Catalogs, Catalogs
3639 @appendixsubsec User Catalog
3640 @cindex User catalog
3641 @cindex IDL library routine info
3642 @cindex Windows
3643 @cindex MacOS
3644 @cindex IDL variable @code{!DIR}
3645 @cindex @code{!DIR}, IDL variable
3647 The user catalog is the old routine catalog system.  It is produced
3648 within Emacs, and stored in a single file in the user's home directory
3649 (@file{.idlwave/idlusercat.el} by default).  Although library catalogs
3650 are more flexible, there may be reasons to prefer a user catalog
3651 instead, including:
3653 @itemize @bullet
3654 @item The scan is internal to Emacs, so you don't need a working Perl
3655 installation, as you do for library catalogs.
3656 @item Can be used to scan directories for which the user has no write 
3657 privileges.
3658 @item Easy widget-based path selection.
3659 @end itemize
3661 However, no routine info is available in the user catalog by default;
3662 the user must actively complete a scan.  In addition, this type of
3663 catalog is all or nothing: if a single routine changes, the entire
3664 catalog must be rescanned to update it.  Creating the user catalog is
3665 also much slower than scanning library catalogs.
3667 You can scan any of the directories on the currently known path.  Under
3668 Windows and MacOS (not OSX), you need to specify the IDL search path in
3669 the variable @code{idlwave-library-path}, and the location of the IDL
3670 directory (the value of the @code{!DIR} system variable) in the variable
3671 @code{idlwave-system-directory}, like this@footnote{The initial @samp{+}
3672 leads to recursive expansion of the path, just like in IDL}:
3674 @lisp
3675 (setq idlwave-library-path
3676         '("+c:/RSI/IDL56/lib/" "+c:/user/me/idllibs"))
3677 (setq idlwave-system-directory "c:/RSI/IDL56/")
3678 @end lisp
3680 @noindent Under GNU/Linux and UNIX, these values will be automatically
3681 gathered from the IDLWAVE shell, if run.
3683 The command @kbd{M-x idlwave-create-user-catalog-file} (or the menu item
3684 @samp{IDLWAVE->Routine Info->Select Catalog Directories}) can then be
3685 used to create a user catalog.  It brings up a widget in which you can
3686 select some or all directories on the search path.  Directories which
3687 already contain a library catalog are marked with @samp{[LIB]}, and need
3688 not be scanned (although there is no harm if you do so, other than the
3689 additional memory used for the duplication).
3691 After selecting directories, click on the @w{@samp{[Scan & Save]}}
3692 button in the widget to scan all files in the selected directories and
3693 write out the resulting routine information.  In order to update the
3694 library information using the directory selection, call the command
3695 @code{idlwave-update-routine-info} with a double prefix argument:
3696 @w{@kbd{C-u C-u C-c C-i}}.  This will rescan files in the previously
3697 selected directories, write an updated version of the user catalog file
3698 and rebuild IDLWAVE's internal lists.  If you give three prefix
3699 arguments @w{@kbd{C-u C-u C-u C-c C-i}}, updating will be done with a
3700 background job@footnote{Unix systems only, I think.}.  You can continue
3701 to work, and the library catalog will be re-read when it is ready.  If
3702 you find you need to update the user catalog often, you should consider
3703 building a library catalog for your routines instead (@pxref{Library
3704 Catalogs}).
3706 @defopt idlwave-special-lib-alist
3707 Alist of regular expressions matching special library directories for
3708 labeling in routine-info display.
3709 @end defopt
3711 @node Load-Path Shadows, Documentation Scan, Catalogs, Sources of Routine Info
3712 @appendixsec Load-Path Shadows
3713 @cindex Load-path shadows
3714 @cindex Shadows, load-path
3715 @cindex Duplicate routines
3716 @cindex Multiply defined routines
3717 @cindex Routine definitions, multiple
3718 @cindex Application, testing for shadowing
3719 @cindex Buffer, testing for shadowing
3721 IDLWAVE can compile a list of routines which are (re-)defined in more
3722 than one file.  Since one definition will hide (shadow) the others
3723 depending on which file is compiled first, such multiple definitions are
3724 called "load-path shadows".  IDLWAVE has several routines to scan for
3725 load path shadows.  The output is placed into the special buffer
3726 @file{*Shadows*}.  The format of the output is identical to the source
3727 section of the routine info buffer (@pxref{Routine Info}).  The
3728 different definitions of a routine are ordered by @emph{likelihood of
3729 use}.  So the first entry will be most likely the one you'll get if an
3730 unsuspecting command uses that routine.  Before listing shadows, you
3731 should make sure that routine info is up-to-date by pressing @kbd{C-c
3732 C-i}.  Here are the different routines (also available in the Menu
3733 @samp{IDLWAVE->Routine Info}):
3735 @table @asis
3736 @item @kbd{M-x idlwave-list-buffer-load-path-shadows}
3737 This commands checks the names of all routines defined in the current
3738 buffer for shadowing conflicts with other routines accessible to
3739 IDLWAVE.  The command also has a key binding: @kbd{C-c C-b}
3740 @item @kbd{M-x idlwave-list-shell-load-path-shadows}.
3741 Checks all routines compiled under the shell for shadowing.  This is
3742 very useful when you have written a complete application.  Just compile
3743 the application, use @code{RESOLVE_ALL} to compile any routines used by
3744 your code, update the routine info inside IDLWAVE with @kbd{C-c C-i} and
3745 then check for shadowing.
3746 @item @kbd{M-x idlwave-list-all-load-path-shadows}
3747 This command checks all routines accessible to IDLWAVE for conflicts.
3748 @end table
3750 For these commands to work fully you need to scan the entire load path
3751 in either a user or library catalog.  Also, IDLWAVE should be able to
3752 distinguish between the system library files (normally installed in
3753 @file{/usr/local/rsi/idl/lib}) and any site specific or user specific
3754 files.  Therefore, such local files should not be installed inside the
3755 @file{lib} directory of the IDL directory.  This is also advisable for
3756 many other reasons.
3758 @cindex Windows
3759 @cindex MacOS
3760 @cindex IDL variable @code{!DIR}
3761 @cindex @code{!DIR}, IDL variable
3762 Users of Windows and MacOS (not X) also must set the variable
3763 @code{idlwave-system-directory} to the value of the @code{!DIR} system
3764 variable in IDL.  IDLWAVE appends @file{lib} to the value of this
3765 variable and assumes that all files found on that path are system
3766 routines.
3768 Another way to find out if a specific routine has multiple definitions
3769 on the load path is routine info display (@pxref{Routine Info}).
3771 @node Documentation Scan,  , Load-Path Shadows, Sources of Routine Info
3772 @appendixsec Documentation Scan 
3773 @cindex @file{get_html_rinfo}
3774 @cindex @file{idlw-rinfo.el}
3775 @cindex Scanning the documentation
3776 @cindex Perl program, to create @file{idlw-rinfo.el}
3778 @strong{Starting with version 6.2, IDL is distributed directly with HTML
3779 online help, and an XML-based catalog of routine information}.  This
3780 makes scanning the manuals with the tool @file{get_html_rinfo}, and the
3781 @file{idlw-rinfo.el} file it produced, as described here, entirely
3782 unnecessary.  The information is left here for users wishing to produce
3783 a catalog of older IDL versions' help.
3786 IDLWAVE derives its knowledge about system routines from the IDL
3787 manuals.  The file @file{idlw-rinfo.el} contains the routine information
3788 for the IDL system routines, and links to relevant sections of the HTML
3789 documentation.  The Online Help feature of IDLWAVE requires HTML
3790 versions of the IDL manuals to be available; the HTML documentation is
3791 not distributed with IDLWAVE by default, but must be downloaded
3792 separately.
3794 The HTML files and related images can be produced from the
3795 @file{idl.chm} HTMLHelp file distributed with IDL using the free
3796 Microsoft HTML Help Workshop.  If you are lucky, the maintainer of
3797 IDLWAVE will always have access to the newest version of IDL and provide
3798 updates.  The IDLWAVE distribution also contains the Perl program
3799 @file{get_html_rinfo} which constructs the @file{idlw-rinfo.el} file by
3800 scanning the HTML documents produced from the IDL documentation.
3801 Instructions on how to use @file{get_html_rinfo} are in the program
3802 itself.
3804 @node HTML Help Browser Tips, Configuration Examples, Sources of Routine Info, Top
3805 @appendix HTML Help Browser Tips
3806 @cindex Browser Tips
3808 There are a wide variety of possible browsers to use for displaying
3809 the online HTML help available with IDLWAVE (starting with version
3810 5.0). Since IDL v6.2, a single cross-platform HTML help browser, the
3811 @emph{IDL Assistant} is distributed with IDL.  If this help browser is
3812 available, it is the preferred choice, and the default.  The variable
3813 @code{idlwave-help-use-assistant}, enabled by default, controls
3814 whether this help browser is used.  If you use the IDL Assistant, the
3815 tips here are not relevant.
3817 Since IDLWAVE runs on a many different system types, a single browser
3818 configuration is not possible, but choices abound.  On many systems,
3819 the default browser configured in @code{browse-url-browser-function},
3820 and hence inherited by default by
3821 @code{idlwave-help-browser-function}, is Netscape.  Unfortunately, the
3822 HTML manuals decompiled from the original source contain formatting
3823 structures which Netscape 4.x does not handle well, though they are
3824 still readable.  A much better choice is Mozilla, or one of the
3825 Mozilla-derived browsers such as
3826 @uref{http://galeon.sourceforge.net/,Galeon} (GNU/Linux),
3827 @uref{http://www.mozilla.org/projects/camino/,Camino} (MacOSX), or
3828 @uref{http://www.mozilla.org/projects/firebird/,Firebird} (all
3829 platforms).  Newer versions of Emacs provide a browser-function choice
3830 @code{browse-url-gnome-moz} which uses the Gnome-configured browser.
3832 Note that the HTML files decompiled from the help sources contain
3833 specific references to the @samp{Symbol} font, which by default is not
3834 permitted in normal encodings (it's invalid, technically).  Though it
3835 only impacts a few symbols, you can trick Mozilla-based browsers into
3836 recognizing @samp{Symbol} by following the directions
3837 @uref{http://hutchinson.belmont.ma.us/tth/Xfonts.html, here}.  With
3838 this fix in place, HTML help pages look almost identical to their PDF
3839 equivalents (yet can be bookmarked, browsed as history, searched,
3840 etc.).
3842 @noindent Individual platform recommendations:
3844 @itemize @bullet
3845 @item Unix/MacOSX: The @uref{http://www.w3m.org,@code{w3m}} browser
3846 and its associated
3847 @uref{http://emacs-w3m.namazu.org/,@code{emacs-w3m}} emacs mode
3848 provide in-buffer browsing with image display, and excellent speed and
3849 formatting.  Both the Emacs mode and the browser itself must be
3850 downloaded separately.  To use this browser, include
3852 @lisp
3853 (setq idlwave-help-browser-function 'w3m-browse-url)
3854 @end lisp
3856 in your @file{.emacs}.  Setting a few other nice @code{w3m} options
3857 cuts down on screen clutter:
3859 @lisp
3860 (setq w3m-use-tab nil
3861       w3m-use-header-line nil
3862       w3m-use-toolbar nil)
3863 @end lisp
3865 If you use a dedicated frame for help, you might want to add the
3866 following, to get consistent behavior with the @kbd{q} key:
3868 @lisp
3869 ;; Close my help window when w3m closes.
3870 (defadvice w3m-close-window (after idlwave-close activate)
3871   (if (boundp 'idlwave-help-frame)
3872       (idlwave-help-quit)))
3873 @end lisp
3875 Note that you can open the file in an external browser from within
3876 @code{w3m} using @kbd{M}.
3877 @end itemize
3879 @node Configuration Examples, Windows and MacOS, HTML Help Browser Tips, Top
3880 @appendix Configuration Examples
3881 @cindex Configuration examples
3882 @cindex Example configuration
3883 @cindex @file{.emacs}
3884 @cindex Default settings, of options
3885 @cindex Interview, with the maintainer
3887 @noindent
3888 @b{Question:} You have all these complicated configuration options in
3889 your package, but which ones do @emph{you} as the maintainer actually
3890 set in your own configuration?
3892 @noindent
3893 @b{Answer:} Not many, beyond custom key bindings.  I set most defaults
3894 the way that seems best.  However, the default settings do not turn on
3895 features which:
3897 @itemize @minus
3898 @item
3899 are not self-evident (i.e. too magic) when used by an unsuspecting user.
3900 @item
3901 are too intrusive.
3902 @item
3903 will not work properly on all Emacs installations.
3904 @item
3905 break with widely used standards.
3906 @item
3907 use function or other non-standard keys.
3908 @item
3909 are purely personal customizations, like additional key bindings, and
3910 library names.
3911 @end itemize
3913 @noindent To see what I mean, here is the @emph{entire} configuration
3914 the old maintainer had in his @file{.emacs}:
3916 @lisp
3917 (setq idlwave-shell-debug-modifiers '(control shift)
3918       idlwave-store-inquired-class t
3919       idlwave-shell-automatic-start t
3920       idlwave-main-block-indent 2
3921       idlwave-init-rinfo-when-idle-after 2
3922       idlwave-help-dir "~/lib/emacs/idlwave"
3923       idlwave-special-lib-alist '(("/idl-astro/" . "AstroLib")
3924                                   ("/jhuapl/" . "JHUAPL-Lib")
3925                                   ("/dominik/lib/idl/" . "MyLib")))
3926 @end lisp
3928 However, if you are an Emacs power-user and want IDLWAVE to work
3929 completely differently, you can change almost every aspect of it.  Here
3930 is an example of a much more extensive configuration of IDLWAVE.  The
3931 user is King!
3933 @example
3934 ;;; Settings for IDLWAVE mode
3936 (setq idlwave-block-indent 3)           ; Indentation settings
3937 (setq idlwave-main-block-indent 3)
3938 (setq idlwave-end-offset -3)
3939 (setq idlwave-continuation-indent 1)
3940 (setq idlwave-begin-line-comment "^;[^;]")  ; Leave ";" but not ";;" 
3941                                             ; anchored at start of line.
3942 (setq idlwave-surround-by-blank t)      ; Turn on padding ops =,<,>
3943 (setq idlwave-pad-keyword nil)          ; Remove spaces for keyword '='
3944 (setq idlwave-expand-generic-end t)     ; convert END to ENDIF etc...
3945 (setq idlwave-reserved-word-upcase t)   ; Make reserved words upper case
3946                                         ; (with abbrevs only)
3947 (setq idlwave-abbrev-change-case nil)   ; Don't force case of expansions
3948 (setq idlwave-hang-indent-regexp ": ")  ; Change from "- " for auto-fill
3949 (setq idlwave-show-block nil)           ; Turn off blinking to begin
3950 (setq idlwave-abbrev-move t)            ; Allow abbrevs to move point
3951 (setq idlwave-query-class '((method-default . nil) ; No query for method
3952                             (keyword-default . nil); or keyword completion
3953                             ("INIT" . t)           ; except for these
3954                             ("CLEANUP" . t)
3955                             ("SETPROPERTY" .t)
3956                             ("GETPROPERTY" .t)))
3958 ;; Using w3m for help (must install w3m and emacs-w3m)
3959 (autoload 'w3m-browse-url "w3m" "Interface for w3m on Emacs." t)
3960 (setq idlwave-help-browser-function 'w3m-browse-url
3961       w3m-use-tab nil ; no tabs, location line, or toolbar
3962       w3m-use-header-line nil
3963       w3m-use-toolbar nil)
3965 ;; Close my help window or frame when w3m closes with `q'
3966 (defadvice w3m-close-window (after idlwave-close activate)
3967   (if (boundp 'idlwave-help-frame)
3968       (idlwave-help-quit)))
3970 ;; Some setting can only be done from a mode hook.  Here is an example:
3971 (add-hook 'idlwave-mode-hook
3972   (lambda ()
3973     (setq case-fold-search nil)          ; Make searches case sensitive
3974     ;; Run other functions here
3975     (font-lock-mode 1)                   ; Turn on font-lock mode
3976     (idlwave-auto-fill-mode 0)           ; Turn off auto filling
3977     (setq idlwave-help-browser-function 'browse-url-w3)
3979     ;; Pad with 1 space (if -n is used then make the
3980     ;; padding a minimum of n spaces.)  The defaults use -1
3981     ;; instead of 1.
3982     (idlwave-action-and-binding "=" '(idlwave-expand-equal 1 1))
3983     (idlwave-action-and-binding "<" '(idlwave-surround 1 1))
3984     (idlwave-action-and-binding ">" '(idlwave-surround 1 1 '(?-)))
3985     (idlwave-action-and-binding "&" '(idlwave-surround 1 1))
3987     ;; Only pad after comma and with exactly 1 space
3988     (idlwave-action-and-binding "," '(idlwave-surround nil 1))
3989     (idlwave-action-and-binding "&" '(idlwave-surround 1 1))
3991     ;; Pad only after `->', remove any space before the arrow
3992     (idlwave-action-and-binding "->"  '(idlwave-surround 0 -1 nil 2))
3994     ;; Set some personal bindings
3995     ;; (In this case, makes `,' have the normal self-insert behavior.)
3996     (local-set-key "," 'self-insert-command)
3997     (local-set-key [f5] 'idlwave-shell-break-here)
3998     (local-set-key [f6] 'idlwave-shell-clear-current-bp)
4000     ;; Create a newline, indenting the original and new line.
4001     ;; A similar function that does _not_ reindent the original
4002     ;; line is on "\C-j" (The default for emacs programming modes).
4003     (local-set-key "\n" 'idlwave-newline)
4004     ;; (local-set-key "\C-j" 'idlwave-newline) ; My preference.
4006     ;; Some personal abbreviations
4007     (define-abbrev idlwave-mode-abbrev-table  
4008       (concat idlwave-abbrev-start-char "wb") "widget_base()"
4009       (idlwave-keyword-abbrev 1))
4010     (define-abbrev idlwave-mode-abbrev-table  
4011       (concat idlwave-abbrev-start-char "on") "obj_new()"
4012       (idlwave-keyword-abbrev 1))
4013     ))
4015 ;;; Settings for IDLWAVE SHELL mode
4017 (setq idlwave-shell-overlay-arrow "=>")        ; default is ">"
4018 (setq idlwave-shell-use-dedicated-frame t)     ; Make a dedicated frame
4019 (setq idlwave-shell-prompt-pattern "^WAVE> ")  ; default is "^IDL> "
4020 (setq idlwave-shell-explicit-file-name "wave")
4021 (setq idlwave-shell-process-name "wave")
4022 (setq idlwave-shell-use-toolbar nil)           ; No toolbar
4024 ;; Most shell interaction settings can be done from the shell-mode-hook.
4025 (add-hook 'idlwave-shell-mode-hook
4026           (lambda ()
4027             ;; Set up some custom key and mouse examine commands
4028             (idlwave-shell-define-key-both [s-down-mouse-2] 
4029                                  (idlwave-shell-mouse-examine 
4030                                   "print, size(___,/DIMENSIONS)"))
4031             (idlwave-shell-define-key-both [f9] (idlwave-shell-examine
4032                                        "print, size(___,/DIMENSIONS)"))
4033             (idlwave-shell-define-key-both [f10] (idlwave-shell-examine 
4034                                         "print,size(___,/TNAME)"))
4035             (idlwave-shell-define-key-both [f11] (idlwave-shell-examine
4036                                         "help,___,/STRUCTURE"))))
4037 @end example
4039 @html
4040 <A NAME="WIN_MAC"></A>
4041 @end html
4042 @node Windows and MacOS, Troubleshooting, Configuration Examples, Top
4043 @appendix Windows and MacOS
4044 @cindex Windows
4045 @cindex MacOS
4046 @cindex MacOSX
4048 IDLWAVE was developed on a UNIX system.  However, thanks to the
4049 portability of Emacs, much of IDLWAVE does also work under different
4050 operating systems like Windows (with NTEmacs or NTXEmacs) or MacOS.
4052 The only real problem is that there is no command-line version of IDL
4053 for Windows or MacOS(<=9) with which IDLWAVE can interact.  As a
4054 result, the IDLWAVE Shell does not work and you have to rely on IDLDE
4055 to run and debug your programs.  However, editing IDL source files
4056 with Emacs/IDLWAVE works with all bells and whistles, including
4057 routine info, completion and fast online help.  Only a small amount of
4058 additional information must be specified in your @file{.emacs} file:
4059 the path names which, on a UNIX system, are automatically gathered by
4060 talking to the IDL program.
4062 Here is an example of the additional configuration needed for a Windows
4063 system.  I am assuming that IDLWAVE has been installed in
4064 @w{@samp{C:\Program Files\IDLWAVE}} and that IDL is installed in
4065 @w{@samp{C:\RSI\IDL62}}.
4067 @lisp
4068 ;; location of the lisp files (only needed if IDLWAVE is not part of
4069 ;; your default X/Emacs installation)
4070 (setq load-path (cons "c:/program files/IDLWAVE" load-path))
4072 ;; The location of the IDL library directories, both standard,  and your own.
4073 ;; note that the initial "+" expands the path recursively
4074 (setq idlwave-library-path
4075         '("+c:/RSI/IDL55/lib/" "+c:/path/to/my/idllibs" ))
4077 ;; location of the IDL system directory (try "print,!DIR")
4078 (setq idlwave-system-directory "c:/RSI/IDL62/")
4080 @end lisp
4082 @noindent Furthermore, Windows sometimes tries to outsmart you --- make
4083 sure you check the following things:
4085 @itemize @bullet
4086 @item When you download the IDLWAVE distribution, make sure you save the 
4087 file under the names @file{idlwave.tar.gz}.
4088 @item M-TAB switches among running programs --- use Esc-TAB
4089 instead.
4090 @item Other issues as yet unnamed...
4091 @end itemize
4093 Windows users who'd like to make use of IDLWAVE's context-aware HTML
4094 help can skip the browser and use the HTMLHelp functionality directly.
4095 @xref{Help with HTML Documentation}.
4097 @html
4098 <A NAME="TROUBLE"></A>
4099 @end html
4100 @node Troubleshooting, GNU Free Documentation License, Windows and MacOS, Top
4101 @appendix Troubleshooting
4102 @cindex Troubleshooting
4104 Although IDLWAVE usually installs and works without difficulty, a few
4105 common problems and their solutions are documented below.
4107 @enumerate
4109 @item @strong{Whenever an IDL error occurs or a breakpoint is hit, I get
4110 errors or strange behavior when I try to type anything into some of my
4111 IDLWAVE buffers.}
4113 This is a @emph{feature}, not an error.  You're in @emph{Electric
4114 Debug Mode} (@pxref{Electric Debug Mode}).  You should see
4115 @code{*Debugging*} in the mode-line.  The buffer is read-only and all
4116 debugging and examination commands are available as single keystrokes;
4117 @kbd{C-?} lists these shortcuts.  Use @kbd{q} to quit the mode, and
4118 customize the variable @code{idlwave-shell-automatic-electric-debug}
4119 if you prefer not to enter electric debug on breakpoints@dots{} but
4120 you really should try it before you disable it!  You can also
4121 customize this variable to enter debug mode when errors are
4122 encountered.  
4124 @item @strong{I get errors like @samp{Searching for program: no such
4125 file or directory, idl} when attempting to start the IDL shell.}
4127 IDLWAVE needs to know where IDL is in order to run it as a process.
4128 By default, it attempts to invoke it simply as @samp{idl}, which
4129 presumes such an executable is on your search path.  You need to
4130 ensure @samp{idl} is on your @samp{$PATH}, or specify the full
4131 pathname to the idl program with the variable
4132 @code{idlwave-shell-explicit-file-name}.  Note that you may need to
4133 set your shell search path in two places when running Emacs as an Aqua
4134 application with MacOSX; see the next topic.
4136 @item @strong{IDLWAVE is disregarding my @samp{IDL_PATH} which I set
4137 under MacOSX}
4139 If you run Emacs directly as an Aqua application, rather than from the
4140 console shell, the environment is set not from your usual shell
4141 configuration files (e.g. @file{.cshrc}), but from the file
4142 @file{~/.MacOSX/environment.plist}.  Either include your path settings
4143 there, or start Emacs and IDLWAVE from the shell.
4145 @item @strong{I get errors like @samp{Symbol's function is void:
4146 overlayp}}
4148 You don't have the @samp{fsf-compat} package installed, which IDLWAVE
4149 needs to run under XEmacs.  Install it, or find an XEmacs distribution
4150 which includes it by default.
4152 @item @strong{I'm getting errors like @samp{Symbol's value as variable is void:
4153 cl-builtin-gethash} on completion or routine info.}
4155 This error arises if you upgraded Emacs from 20.x to 21.x without
4156 re-installing IDLWAVE.  Old Emacs and new Emacs are not byte-compatible
4157 in compiled lisp files.  Presumably, you kept the original .elc files in
4158 place, and this is the source of the error.  If you recompile (or just
4159 "make; make install") from source, it should resolve this problem.
4160 Another option is to recompile the @file{idlw*.el} files by hand using
4161 @kbd{M-x byte-compile-file}.  
4163 @item @strong{@kbd{M-@key{TAB}} doesn't complete words, it switches
4164 windows on my desktop.}
4166 Your system is trapping @kbd{M-@key{TAB}} and using it for its own
4167 nefarious purposes: Emacs never sees the keystrokes.  On many Unix
4168 systems, you can reconfigure your window manager to use another key
4169 sequence for switching among windows.  Another option is to use the
4170 equivalent sequence @kbd{@key{ESC}-@key{TAB}}.
4172 @item @strong{When stopping at breakpoints or errors, IDLWAVE does not
4173 seem to highlight the relevant line in the source.}
4175 IDLWAVE scans for error and halt messages and highlights the stop
4176 location in the correct file.  However, if you've changed the system
4177 variable @samp{!ERROR_STATE.MSG_PREFIX}, it is unable to parse these
4178 message correctly.  Don't do that.
4180 @item @strong{IDLWAVE doesn't work correctly when using ENVI.}
4182 Though IDLWAVE was not written with ENVI in mind, it works just fine
4183 with it, as long as you update the prompt it's looking for (@samp{IDL>
4184 } by default).  You can do this with the variable
4185 @code{idlwave-shell-prompt-pattern} (@pxref{Starting the Shell}), e.g.,
4186 in your @file{.emacs}:
4188 @lisp
4189 (setq idlwave-shell-prompt-pattern "^\r? ?\\(ENVI\\|IDL\\)> ")
4190 @end lisp
4192 @item @strong{Attempts to set breakpoints fail: no breakpoint is
4193 indicated in the IDLWAVE buffer.}
4195 IDL changed its breakpoint reporting format starting with IDLv5.5.  The
4196 first version of IDLWAVE to support the new format is IDLWAVE v4.10.  If
4197 you have an older version and are using IDL >v5.5, you need to upgrade,
4198 and/or make sure your recent version of IDLWAVE is being found on the
4199 Emacs load-path (see the next entry).  You can list the version being
4200 used with @kbd{C-h v idlwave-mode-version @key{RET}}.
4202 @item @strong{I installed a new version of IDLWAVE, but the old
4203 version is still being used} or @strong{IDLWAVE works, but when I
4204 tried to install the optional modules @file{idlw-roprompt.el} or
4205 @file{idlw-complete-structtag}, I get errors like @samp{Cannot open
4206 load file}}.
4208 The problem is that your Emacs is not finding the version of IDLWAVE you
4209 installed.  Many Emacsen come with an older bundled copy of IDLWAVE
4210 (e.g. v4.7 for Emacs 21.x), which is likely what's being used instead.
4211 You need to make sure your Emacs @emph{load-path} contains the directory
4212 where IDLWAVE is installed (@file{/usr/local/share/emacs/site-lisp}, by
4213 default), @emph{before} Emacs' default search directories.  You can
4214 accomplish this by putting the following in your @file{.emacs}:
4216 @lisp
4217 (setq load-path (cons "/usr/local/share/emacs/site-lisp" load-path))
4218 @end lisp
4220 @noindent You can check on your load-path value using @kbd{C-h v
4221 load-path @key{RET}}, and @kbd{C-h m} in an IDLWAVE buffer should show
4222 you the version Emacs is using.
4224 @item @strong{IDLWAVE is screwing up the formatting of my @file{.idl} files.}
4226 Actually, this isn't IDLWAVE at all, but @samp{idl-mode}, an unrelated
4227 programming mode for CORBA's Interface Definition Language (you should
4228 see @samp{(IDL)}, not @samp{(IDLWAVE)} in the mode-line).  One
4229 solution: don't name your file @file{.idl}, but rather @file{.pro}.
4230 Another solution: make sure @file{.idl} files load IDLWAVE instead of
4231 @samp{idl-mode} by adding the following to your @file{.emacs}:
4233 @lisp
4234 (setcdr (rassoc 'idl-mode auto-mode-alist) 'idlwave-mode)
4235 @end lisp
4237 @item @strong{The routine info for my local routines is out of date!}
4239 IDLWAVE collects routine info from various locations (@pxref{Routine
4240 Information Sources}).  Routines in files visited in a buffer or
4241 compiled in the shell should be up to date.  For other routines, the
4242 information is only as current as the most recent scan.  If you have a
4243 rapidly changing set of routines, and you'd like the latest routine
4244 information to be available for it, one powerful technique is to make
4245 use of the library catalog tool, @samp{idlwave_catalog}.  Simply add a
4246 line to your @samp{cron} file (@samp{crontab -e} will let you edit this
4247 on some systems), like this
4249 @example
4250 45 3 * * 1-5 (cd /path/to/myidllib; /path/to/idlwave_catalog MyLib)
4251 @end example
4253 @noindent where @samp{MyLib} is the name of your library.  This will
4254 rescan all @file{.pro} files at or below @file{/path/to/myidllib} every
4255 week night at 3:45am.  You can even scan site-wide libraries with this
4256 method, and the most recent information will be available to all users.
4257 Since the scanning is very fast, there is very little impact.
4259 @item @strong{All the Greek-font characters in the HTML help are
4260 displayed as Latin characters!}
4262 Unfortunately, the HTMLHelp files RSI provides attempt to switch to
4263 @samp{Symbol} font to display Greek characters, which is not really an
4264 permitted method for doing this in HTML.  There is a "workaround" for
4265 some browsers: @xref{HTML Help Browser Tips}.
4267 @item @strong{In the shell, my long commands are truncated at 256 characters!}
4269 This actually happens when running IDL in an XTerm as well.  There are
4270 a couple of workarounds: @code{define_key,/control,'^d'} (e.g. in
4271 your @file{$IDL_STARTUP} file) will disable the @samp{EOF} character
4272 and give you a 512 character limit.  You won't be able to use
4273 @key{C-d} to quit the shell, however.  Another possibility is
4274 @code{!EDIT_INPUT=0}, which gives you an @emph{infinite} limit (OK, a
4275 memory-bounded limit), but disables the processing of background
4276 widget events (those with @code{/NO_BLOCK} passed to @code{XManager}).
4278 @item @strong{When I invoke IDL HTML help on a routine, the page which
4279 is loaded is one page off, e.g. for @code{CONVERT_COORD}, I get
4280 @code{CONTOUR}.}
4282 You have a mismatch between your help index and the HTML help package
4283 you downloaded.  You need to ensure you download a ``downgrade kit'' if
4284 you are using anything older than the latest HTML help package.  A new
4285 help package appears with each IDL release (assuming the documentation
4286 is updated).  
4287 Starting with IDL 6.2, the HTML help and its catalog are
4288 distributed with IDL, and so should never be inconsistent.
4290 @item @strong{I get errors such as @samp{void-variable
4291 browse-url-browser-function} or similar when attempting to load IDLWAVE
4292 under XEmacs.}
4294 You don't have the @samp{browse-url} (or other required) XEmacs package.
4295 Unlike GNU Emacs, XEmacs distributes many packages separately from the
4296 main program.  IDLWAVE is actually among these, but is not always the
4297 most up to date.  When installing IDLWAVE as an XEmacs package, it
4298 should prompt you for required additional packages.  When installing it
4299 from source, it won't and you'll get this error.  The easiest solution
4300 is to install all the packages when you install XEmacs (the so-called
4301 @samp{sumo} bundle).  The minimum set of XEmacs packages required by
4302 IDLWAVE is @samp{fsf-compat, xemacs-base, mail-lib}.
4304 @end enumerate
4306 @node GNU Free Documentation License, Index, Troubleshooting, Top
4307 @appendix GNU Free Documentation License
4308 @include doclicense.texi
4310 @node Index,  , GNU Free Documentation License, Top
4311 @unnumbered Index
4312 @printindex cp
4314 @bye
4316 @ignore
4317    arch-tag: f1d73958-1423-4127-b8aa-f7b953d64492
4318 @end ignore