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