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