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