forked from jdtsmith/idlwave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidlwave.texi
4464 lines (3855 loc) · 182 KB
/
idlwave.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename idlwave
@settitle IDLWAVE User Manual
@dircategory Emacs
@direntry
* IDLWAVE: (idlwave). Major mode and shell for IDL files.
@end direntry
@synindex ky cp
@syncodeindex vr cp
@syncodeindex fn cp
@set VERSION 6.5
@set EDITION 6.5
@set IDLVERSION 8.3
@set NSYSROUTINES 2611
@set DATE Februare, 2014
@set AUTHOR J.D. Smith & Carsten Dominik
@set MAINTAINER J.D. Smith
@set IDLWAVEHOMEPAGE http://github.com/jdtsmith/idlwave
@c %**end of header
@finalout
@ifinfo
This file documents IDLWAVE, a major mode for editing IDL files with
Emacs, and interacting with an IDL shell run as a subprocess.
This is edition @value{EDITION} of the IDLWAVE User Manual for IDLWAVE
@value{VERSION}
Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2009, 2013, 2014 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover texts being ``A GNU
Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
license is included in the section entitled ``GNU Free Documentation
License'' in the Emacs manual.
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
this GNU Manual, like GNU software. Copies published by the Free
Software Foundation raise funds for GNU development.''
This document is part of a collection distributed under the GNU Free
Documentation License. If you want to distribute this document
separately from the collection, you can do so by adding a copy of the
license to the document, as described in section 6 of the license.
@end ifinfo
@titlepage
@title IDLWAVE User Manual
@subtitle Emacs major mode and shell for IDL
@subtitle Edition @value{EDITION}, @value{DATE}
@author by J.D. Smith & Carsten Dominik
@page
This is edition @value{EDITION} of the @cite{IDLWAVE User Manual} for
IDLWAVE version @value{VERSION}, @value{DATE}.
@sp 2
Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2009, 2013, 2014 Free Software Foundation, Inc.
@sp 2
@cindex Copyright, of IDLWAVE
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover texts being ``A GNU
Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
license is included in the section entitled ``GNU Free Documentation
License'' in the Emacs manual.
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
this GNU Manual, like GNU software. Copies published by the Free
Software Foundation raise funds for GNU development.''
This document is part of a collection distributed under the GNU Free
Documentation License. If you want to distribute this document
separately from the collection, you can do so by adding a copy of the
license to the document, as described in section 6 of the license.
@end titlepage
@contents
@page
@ifnottex
@node Top, Introduction, (dir), (dir)
IDLWAVE is a package which supports editing source code written in the
Interactive Data Language (IDL), and running IDL as an inferior shell.
@end ifnottex
@menu
* Introduction:: What IDLWAVE is, and what it is not
* IDLWAVE in a Nutshell:: One page quick-start guide
* Getting Started:: Tutorial
* The IDLWAVE Major Mode:: The mode for editing IDL programs
* The IDLWAVE Shell::
* Installation:: How to Install or Upgrade
* Acknowledgements::
* Sources of Routine Info:: How does IDLWAVE know about routine XYZ
* HTML Help Browser Tips::
* Configuration Examples:: The user is king
* Windows and MacOS:: What still works, and how
* Troubleshooting:: When good computers turn bad
* GNU Free Documentation License:: The license for this documentation.
* Index:: Fast access
@detailmenu
--- The Detailed Node Listing ---
Getting Started (Tutorial)
* Lesson I -- Development Cycle::
* Lesson II -- Customization::
* Lesson III -- User Catalog::
The IDLWAVE Major Mode
* Code Formatting:: Making code look nice
* Routine Info:: Calling Sequence and Keyword List
* Online Help:: One key press from source to help
* Completion:: Completing routine names and Keywords
* Routine Source:: Finding routines, the easy way
* Resolving Routines:: Force the Shell to compile a routine
* Code Templates:: Frequent code constructs
* Abbreviations:: Abbreviations for common commands
* Actions:: Changing case, Padding, End checking
* Doc Header:: Inserting a standard header
* Motion Commands:: Moving through the structure of a program
* Misc Options:: Things that fit nowhere else
Code Formatting
* Code Indentation:: Reflecting the logical structure
* Continued Statement Indentation::
* Comment Indentation:: Special indentation for comment lines
* Continuation Lines:: Splitting statements over lines
* Syntax Highlighting:: Font-lock support
* Octals and Highlighting:: Why "123 causes problems
Online Help
* Help with HTML Documentation::
* Help with Source::
Completion
* Case of Completed Words:: CaseOFcomPletedWords
* Object Method Completion and Class Ambiguity:: obj->Method, what?
* Object Method Completion in the Shell::
* Class and Keyword Inheritance:: obj->Method, _EXTRA=e
* Structure Tag Completion:: Completing state.Tag
Actions
* Block Boundary Check:: Is the END statement correct?
* Padding Operators:: Enforcing space around `=' etc
* Case Changes:: Enforcing upper case keywords
The IDLWAVE Shell
* Starting the Shell:: How to launch IDL as a subprocess
* Using the Shell:: Interactively working with the Shell
* Multi-Line Commands::
* Commands Sent to the Shell::
* Debugging IDL Programs::
* Examining Variables::
* Custom Expression Examination::
Debugging IDL Programs
* A Tale of Two Modes::
* Debug Key Bindings::
* Breakpoints and Stepping::
* Compiling Programs::
* Walking the Calling Stack::
* Electric Debug Mode::
Installation
* Installing IDLWAVE:: How to install the distribution
* Installing Online Help:: Where to get the additional files needed
Sources of Routine Info
* Routine Definitions:: Where IDL Routines are defined.
* Routine Information Sources:: So how does IDLWAVE know about...
* Catalogs::
* Load-Path Shadows:: Routines defined in several places
* Documentation Scan:: Scanning the IDL Manuals
Catalogs
* Library Catalogs::
* User Catalog::
@end detailmenu
@end menu
@node Introduction, IDLWAVE in a Nutshell, Top, Top
@chapter Introduction
@cindex Introduction
@cindex CORBA (Common Object Request Broker Architecture)
@cindex Interface Definition Language
@cindex Interactive Data Language
@cindex cc-mode.el
@cindex @file{idl.el}
@cindex @file{idl-shell.el}
@cindex Feature overview
IDLWAVE is a package which supports editing source files written in
the Interactive Data Language (IDL@footnote{IDL is a registered
trademark ITT Visual Information Solutions}
), and running IDL as an inferior shell@footnote{IDLWAVE can also be used
for editing source files for the related WAVE/CL language, but with only
limited support.}. It is a feature-rich replacement for the IDLDE
development environment included with IDL, and uses the full power of
Emacs to make editing and running IDL programs easier, quicker, and more
structured.
IDLWAVE consists of two main parts: a major mode for editing IDL
source files (@code{idlwave-mode}) and a mode for running the IDL
program as an inferior shell (@code{idlwave-shell-mode}). Although
one mode can be used without the other, both work together closely to
form a complete development environment. Here is a brief summary of
what IDLWAVE does:
@itemize @bullet
@item
Smart code indentation and automatic-formatting.
@item
Three level syntax highlighting support.
@item
Context-sensitive display of calling sequences and keywords for more
than 1000 native IDL routines, extendible to any additional number of
local routines, and already available with many pre-scanned libraries.
@item
Fast, context-sensitive online HTML help, or source-header help for
undocumented routines.
@item
Context sensitive completion of routine names, keywords, system
variables, class names and much more.
@item
Easy insertion of code templates and abbreviations of common constructs.
@item
Automatic corrections to enforce a variety of customizable coding
standards.
@item
Integrity checks and auto-termination of logical blocks.
@item
Routine name space conflict search with likelihood-of-use ranking.
@item
Support for @file{imenu} (Emacs) and @file{func-menu} (XEmacs).
@item
Documentation support.
@item
Running IDL as an inferior Shell with history search, command line
editing and all the completion and routine info capabilities present in
IDL source buffers.
@item
Full handling of debugging with breakpoints, with interactive setting
of break conditions, and easy stepping through code.
@item
Compilation, execution and interactive single-keystroke debugging of
programs directly from the source buffer.
@item
Quick, source-guided navigation of the calling stack, with variable
inspection, etc.
@item
Examining variables and expressions with a mouse click.
@item
And much, much more...
@end itemize
@ifnottex
@cindex Screenshots
Here are a number of screenshots showing IDLWAVE in action:
@itemize @bullet
@item
@uref{http://idlwave.org/screenshots/emacs_21_nav.gif,An IDLWAVE buffer}
@item
@uref{http://idlwave.org/screenshots/emacs_21_keys.gif,A keyword being completed}
@item
@uref{http://idlwave.org/screenshots/emacs_21_help.gif,Online help text.}
@item
@uref{http://idlwave.org/screenshots/emacs_21_ri.gif,Routine information displayed}
@item
@uref{http://idlwave.org/screenshots/emacs_21_bp.gif,Debugging code
stopped at a breakpoint}
@end itemize
@end ifnottex
IDLWAVE is the distant successor to the @file{idl.el} and
@file{idl-shell.el} files written by Chris Chase. The modes and files
had to be renamed because of a name space conflict with CORBA's
@code{idl-mode}, defined in Emacs in the file @file{cc-mode.el}.
In this manual, each section ends with a list of related user options.
Don't be confused by the sheer number of options available --- in most
cases the default settings are just fine. The variables are listed here
to make sure you know where to look if you want to change anything. For
a full description of what a particular variable does and how to
configure it, see the documentation string of that variable (available
with @kbd{C-h v}). Some configuration examples are also given in the
appendix.
@node IDLWAVE in a Nutshell, Getting Started, Introduction, Top
@chapter IDLWAVE in a Nutshell
@cindex Summary of important commands
@cindex IDLWAVE in a Nutshell
@cindex Nutshell, IDLWAVE in a
@subheading Editing IDL Programs
@multitable @columnfractions .15 .85
@item @key{TAB}
@tab Indent the current line relative to context.
@item @kbd{C-M-\}
@tab Re-indent all lines in the current region.
@item @kbd{C-M-q}
@tab Re-indent all lines in the current routine.
@item @kbd{C-u @key{TAB}}
@tab Re-indent all lines in the current statement.
@item @kbd{M-@key{RET}}
@tab Start a continuation line, splitting the current line at point.
@item @kbd{M-;}
@tab Start new comment at line beginning or after code, or (un)comment
highlighted region.
@item @kbd{M-q}
@tab Fill the current comment paragraph.
@item @kbd{C-c ?}
@tab Display calling sequence and keywords for the procedure or function call
at point.
@item @kbd{M-?}
@tab Load context sensitive online help for nearby routine, keyword, etc.
@item @kbd{M-@key{TAB}}
@tab Complete a procedure name, function name or keyword in the buffer.
@item @kbd{C-c C-i}
@tab Update IDLWAVE's knowledge about functions and procedures.
@item @kbd{C-c C-v}
@tab Visit the source code of a procedure/function.
@item @kbd{C-u C-c C-v}
@tab Visit the source code of a procedure/function in this buffer.
@item @kbd{C-c C-h}
@tab Insert a standard documentation header.
@item @kbd{C-c @key{RET}}
@tab Insert a new timestamp and history item in the documentation header.
@end multitable
@subheading Running the IDLWAVE Shell, Debugging Programs
@multitable @columnfractions .15 .85
@item @kbd{C-c C-s}
@tab Start IDL as a subprocess and/or switch to the shell buffer.
@item @key{Up}, @kbd{M-p}
@tab Cycle back through IDL command history.
@item @key{Down},@kbd{M-n}
@tab Cycle forward.
@item @kbd{@key{TAB}}
@tab Complete a procedure name, function name or keyword in the shell buffer.
@item @kbd{C-c C-d C-c}
@tab Save and compile the source file in the current buffer.
@item @kbd{C-c C-d C-e}
@tab Compile and run the current region.
@item @kbd{C-c C-d C-x}
@tab Go to next syntax error.
@item @kbd{C-c C-d C-v}
@tab Switch to electric debug mode.
@item @kbd{C-c C-d C-b}
@tab Set a breakpoint at the nearest viable source line.
@item @kbd{C-c C-d C-d}
@tab Clear the nearest breakpoint.
@item @kbd{C-c C-d [}
@tab Go to the previous breakpoint.
@item @kbd{C-c C-d ]}
@tab Go to the next breakpoint.
@item @kbd{C-c C-d C-p}
@tab Print the value of the expression near point in IDL.
@end multitable
@subheading Commonly used Settings in @file{.emacs}
@lisp
;; Change the indentation preferences
;; Start autoloading routine info after 2 idle seconds
(setq idlwave-init-rinfo-when-idle-after 2)
;; Pad operators with spaces
(setq idlwave-do-actions t
idlwave-surround-by-blank t)
;; Syntax Highlighting
(add-hook 'idlwave-mode-hook 'turn-on-font-lock)
;; Automatically start the shell when needed
(setq idlwave-shell-automatic-start t)
;; Bind debugging commands with CONTROL and SHIFT modifiers
(setq idlwave-shell-debug-modifiers '(control shift))
@end lisp
@html
<A NAME="TUTORIAL"></A>
@end html
@node Getting Started, The IDLWAVE Major Mode, IDLWAVE in a Nutshell, Top
@chapter Getting Started (Tutorial)
@cindex Quick-Start
@cindex Tutorial
@cindex Getting Started
@menu
* Lesson I -- Development Cycle::
* Lesson II -- Customization::
* Lesson III -- User Catalog::
@end menu
@node Lesson I -- Development Cycle, Lesson II -- Customization, Getting Started, Getting Started
@section Lesson I: Development Cycle
The purpose of this tutorial is to guide you through a very basic
development cycle using IDLWAVE. We will paste a simple program into
a buffer and use the shell to compile, debug and run it. On the way
we will use many of the important IDLWAVE commands. Note, however,
that IDLWAVE has many more capabilities than covered here, which can
be discovered by reading the entire manual, or hovering over the
shoulder of your nearest IDLWAVE guru for a few days.
It is assumed that you have access to Emacs or XEmacs with the full
IDLWAVE package including online help (@pxref{Installation}). We also
assume that you are familiar with Emacs and can read the nomenclature of
key presses in Emacs (in particular, @kbd{C} stands for @key{CONTROL}
and @kbd{M} for @key{META} (often the @key{ALT} key carries this
functionality)).
Open a new source file by typing:
@example
@kbd{C-x C-f tutorial.pro @key{RET}}
@end example
A buffer for this file will pop up, and it should be in IDLWAVE mode,
indicated in the mode line just below the editing window. Also, the
menu bar should contain @samp{IDLWAVE}.
Now cut-and-paste the following code, also available as
@file{tutorial.pro} in the IDLWAVE distribution.
@example
function daynr,d,m,y
;; compute a sequence number for a date
;; works 1901-2099.
if y lt 100 then y = y+1900
if m le 2 then delta = 1 else delta = 0
m1 = m + delta*12 + 1
y1 = y * delta
return, d + floor(m1*30.6)+floor(y1*365.25)+5
end
function weekday,day,month,year
;; compute weekday number for date
nr = daynr(day,month,year)
return, nr mod 7
end
pro plot_wday,day,month
;; Plot the weekday of a date in the first 10 years of this century.
years = 2000,+indgen(10)
wdays = intarr(10)
for i=0,n_elements(wdays)-1 do begin
wdays[i] = weekday(day,month,years[i])
end
plot,years,wdays,YS=2,YT="Wday (0=Sunday)"
end
@end example
The indentation probably looks funny, since it's different from the
settings you use, so use the @key{TAB} key in each line to
automatically line it up (or, more quickly, @emph{select} the entire
buffer with @kbd{C-x h}, and indent the whole region with
@kbd{C-M-\}). Notice how different syntactical elements are
highlighted in different colors, if you have set up support for
font-lock.
Let's check out two particular editing features of IDLWAVE. Place the
cursor after the @code{end} statement of the @code{for} loop and press
@key{SPC}. IDLWAVE blinks back to the beginning of the block and
changes the generic @code{end} to the specific @code{endfor}
automatically (as long as the variable @code{idlwave-expand-generic-end}
is turned on --- @pxref{Lesson II -- Customization}). Now place the
cursor in any line you would like to split and press @kbd{M-@key{RET}}.
The line is split at the cursor position, with the continuation @samp{$}
and indentation all taken care of. Use @kbd{C-/} to undo the last
change.
The procedure @code{plot_wday} is supposed to plot the day of the week
of a given date for the first 10 years of the 21st century. As in
most code, there are a few bugs, which we are going to use IDLWAVE to
help us fix.
First, let's launch the IDLWAVE shell. You do this with the command
@kbd{C-c C-s}. The Emacs window will split or another window will popup
to display IDL running in a shell interaction buffer. Type a few
commands like @code{print,!PI} to convince yourself that you can work
there just as well as in a terminal, or the IDLDE. Use the arrow keys
to cycle through your command history. Are we having fun now?
Now go back to the source window and type @kbd{C-c C-d C-c} to compile
the program. If you watch the shell buffer, you see that IDLWAVE types
@samp{.run "tutorial.pro"} for you. But the compilation fails because
there is a comma in the line @samp{years=...}. The line with the error
is highlighted and the cursor positioned at the error, so remove the
comma (you should only need to hit @kbd{Delete}!). Compile again, using
the same keystrokes as before. Notice that the file is automatically
saved for you. This time everything should work fine, and you should
see the three routines compile.
Now we want to use the command to plot the day of the week on January
1st. We could type the full command ourselves, but why do that? Go
back to the shell window, type @samp{plot_} and hit @key{TAB}. After
a bit of a delay (while IDLWAVE initializes its routine info database,
if necessary), the window will split to show all procedures it knows
starting with that string, and @w{@code{plot_wday}} should be one of
them. Saving the buffer alerted IDLWAVE about this new routine.
Click with the middle mouse button on @code{plot_wday} and it will be
copied to the shell buffer, or if you prefer, add @samp{w} to
@samp{plot_} to make it unambiguous (depending on what other routines
starting with @samp{plot_} you have installed on your system), hit
@key{TAB} again, and the full routine name will be completed. Now
provide the two arguments:
@example
plot_wday,1,1
@end example
@noindent and press @key{RET}. This fails with an error message telling
you the @code{YT} keyword to plot is ambiguous. What are the allowed
keywords again? Go back to the source window and put the cursor into
the `plot' line and press @kbd{C-c ?}. This shows the routine info
window for the plot routine, which contains a list of keywords, along
with the argument list. Oh, we wanted @code{YTITLE}. Fix that up.
Recompile with @kbd{C-c C-d C-c}. Jump back into the shell with
@kbd{C-c C-s}, press the @key{UP} arrow to recall the previous command
and execute again.
This time we get a plot, but it is pretty ugly --- the points are all
connected with a line. Hmm, isn't there a way for @code{plot} to use
symbols instead? What was that keyword? Position the cursor on the
plot line after a comma (where you'd normally type a keyword), and hit
@kbd{M-@key{Tab}}. A long list of plot's keywords appears. Aha,
there it is, @code{PSYM}. Middle click to insert it. An @samp{=}
sign is included for you too. Now what were the values of @code{PSYM}
supposed to be? With the cursor on or after the keyword, press
@kbd{M-?} for online help (alternatively, you could have right clicked
on the colored keyword itself in the completion list). A browser will
pop up showing the HTML documentation for the @code{PYSM} keyword.
OK, let's use diamonds=4. Fix this, recompile (you know the command
by now: @kbd{C-c C-d C-c}), go back to the shell (if it's vanished,
you know what to do: @kbd{C-c C-s}) and execute again. Now things
look pretty good.
Let's try a different day --- how about April fool's day?
@example
plot_wday,1,4
@end example
Oops, this looks very wrong. All April Fool's days cannot be Fridays!
We've got a bug in the program, perhaps in the @code{daynr} function.
Let's put a breakpoint on the last line there. Position the cursor on
the @samp{return, d+...} line and press @kbd{C-c C-d C-b}. IDL sets a
breakpoint (as you see in the shell window), and the break line is
indicated. Back to the shell buffer, re-execute the previous command.
IDL stops at the line with the breakpoint. Now hold down the SHIFT
key and click with the middle mouse button on a few variables there:
@samp{d}, @samp{y}, @samp{m}, @samp{y1}, etc. Maybe @code{d} isn't
the correct type. CONTROL-SHIFT middle-click on it for help. Well,
it's an integer, so that's not the problem. Aha, @samp{y1} is zero,
but it should be the year, depending on delta. Shift click
@samp{delta} to see that it's 0. Below, we see the offending line:
@samp{y1=y*delta...} the multiplication should have been a minus sign!
Hit @kbd{q} to exit the debugging mode, and fix the line to read:
@example
y1 = y - delta
@end example
Now remove all breakpoints: @kbd{C-c C-d C-a}. Recompile and rerun the
command. Everything should now work fine. How about those leap years?
Change the code to plot 100 years and see that every 28 years, the
sequence of weekdays repeats.
@node Lesson II -- Customization, Lesson III -- User Catalog, Lesson I -- Development Cycle, Getting Started
@section Lesson II: Customization
Emacs is probably the most customizable piece of software ever written,
and it would be a shame if you did not make use of this to adapt IDLWAVE
to your own preferences. Customizing Emacs or IDLWAVE is accomplished
by setting Lisp variables in the @file{.emacs} file in your home
directory --- but do not be dismayed; for the most part, you can just
copy and work from the examples given here.
Let's first use a boolean variable. These are variables which you turn
on or off, much like a checkbox. A value of @samp{t} means on, a value
of @samp{nil} means off. Copy the following line into your
@file{.emacs} file, exit and restart Emacs.
@lisp
(setq idlwave-reserved-word-upcase t)
@end lisp
When this option is turned on, each reserved word you type into an IDL
source buffer will be converted to upper case when you press @key{SPC}
or @key{RET} right after the word. Try it out! @samp{if} changes to
@samp{IF}, @samp{begin} to @samp{BEGIN}. If you don't like this
behavior, remove the option again from your @file{.emacs} file and
restart Emacs.
You likely have your own indentation preferences for IDL code. For
example, some may prefer to indent the main block of an IDL program
slightly from the margin and use only 3 spaces as indentation between
@code{BEGIN} and @code{END}. Try the following lines in @file{.emacs}:
@lisp
(setq idlwave-main-block-indent 1)
(setq idlwave-block-indent 3)
(setq idlwave-end-offset -3)
@end lisp
Restart Emacs, and re-indent the program we developed in the first part
of this tutorial with @kbd{C-c h} and @kbd{C-M-\}. You may want to keep
these lines in @file{.emacs}, with values adjusted to your likings. If
you want to get more information about any of these variables, type,
e.g., @kbd{C-h v idlwave-main-block-indent @key{RET}}. To find which
variables can be customized, look for items marked @samp{User Option:}
throughout this manual.
If you cannot seem to master this Lisp customization in @file{.emacs},
there is another, more user-friendly way to customize all the IDLWAVE
variables. You can access it through the IDLWAVE menu in one of the
@file{.pro} buffers, menu item @code{Customize->Browse IDLWAVE
Group}. Here you'll be presented with all the various variables grouped
into categories. You can navigate the hierarchy (e.g. @samp{IDLWAVE
Code Formatting->Idlwave Abbrev And Indent Action->Idlwave Expand
Generic End} to turn on @code{END} expansion), read about the variables,
change them, and `Save for Future Sessions'. Few of these variables
need customization, but you can exercise considerable control over
IDLWAVE's functionality with them.
You may also find the key bindings used for the debugging commands too
long and complicated. Often we have heard complaints along the lines
of, ``Do I really have to go through the finger gymnastics of @kbd{C-c
C-d C-c} to run a simple command?'' Due to Emacs rules and
conventions, shorter bindings cannot be set by default, but you can
easily enable them. First, there is a way to assign all debugging
commands in a single sweep to another simpler combination. The only
problem is that we have to use something which Emacs does not need for
other important commands. One good option is to execute debugging
commands by holding down @key{CONTROL} and @key{SHIFT} while pressing
a single character: @kbd{C-S-b} for setting a breakpoint, @kbd{C-S-c}
for compiling the current source file, @kbd{C-S-a} for deleting all
breakpoints (try it, it's easier). You can enable this with:
@lisp
(setq idlwave-shell-debug-modifiers '(shift control))
@end lisp
@noindent If you have a special keyboard with, for example, a
@key{SUPER} key, you could even shorten that:
@lisp
(setq idlwave-shell-debug-modifiers '(super))
@end lisp
@noindent to get compilation on @kbd{S-c}. Often, a modifier key like
@key{SUPER} or @key{HYPER} is bound or can be bound to an otherwise
unused key on your keyboard --- consult your system documentation.
You can also assign specific commands to keys. This you must do in the
@emph{mode-hook}, a special function which is run when a new IDLWAVE
buffer gets set up. The possibilities for key customization are
endless. Here we set function keys f4-f8 to common debugging commands.
@lisp
;; First for the source buffer
(add-hook 'idlwave-mode-hook
(lambda ()
(local-set-key [f4] 'idlwave-shell-retall)
(local-set-key [f5] 'idlwave-shell-break-here)
(local-set-key [f6] 'idlwave-shell-clear-current-bp)
(local-set-key [f7] 'idlwave-shell-cont)
(local-set-key [f8] 'idlwave-shell-clear-all-bp)))
;; Then for the shell buffer
(add-hook 'idlwave-shell-mode-hook
(lambda ()
(local-set-key [f4] 'idlwave-shell-retall)
(local-set-key [f5] 'idlwave-shell-break-here)
(local-set-key [f6] 'idlwave-shell-clear-current-bp)
(local-set-key [f7] 'idlwave-shell-cont)
(local-set-key [f8] 'idlwave-shell-clear-all-bp)))
@end lisp
@node Lesson III -- User Catalog, , Lesson II -- Customization, Getting Started
@section Lesson III: User and Library Catalogs
We have already used the routine info display in the first part of this
tutorial. This was the invoked using @kbd{C-c ?}, and displays
information about the IDL routine near the cursor position. Wouldn't it
be nice to have the same kind of information available for your own
routines and for the huge amount of code in major libraries like JHUPL
or the IDL-Astro library? In many cases, you may already have this
information. Files named @file{.idlwave_catalog} in library directories
contain scanned information on the routines in that directory; many
popular libraries ship with these ``library catalogs'' pre-scanned.
Users can scan their own routines in one of two ways: either using the
supplied tool to scan directories and build their own
@file{.idlwave_catalog} files, or using the built-in method to create a
single ``user catalog'', which we'll show here. @xref{Catalogs}, for
more information on choosing which method to use.
To build a user catalog, select @code{Routine Info/Select Catalog
Directories} from the IDLWAVE entry in the menu bar. If necessary,
start the shell first with @kbd{C-c C-s} (@pxref{Starting the Shell}).
IDLWAVE will find out about the IDL @code{!PATH} variable and offer a
list of directories on the path. Simply select them all (or whichever
you want --- directories with existing library catalogs will not be
selected by default) and click on the @samp{Scan&Save} button. Then
go for a cup of coffee while IDLWAVE collects information for each and
every IDL routine on your search path. All this information is
written to the file @file{.idlwave/idlusercat.el} in your home
directory and will from now on automatically load whenever you use
IDLWAVE. You may find it necessary to rebuild the catalog on occasion
as your local libraries change, or build a library catalog for those
directories instead. Invoke routine info (@kbd{C-c ?}) or completion
(@kbd{M-@key{TAB}}) on any routine or partial routine name you know to
be located in the library. E.g., if you have scanned the IDL-Astro
library:
@example
a=readf@key{M-@key{TAB}}
@end example
expands to `readfits('. Then try
@example
a=readfits(@key{C-c ?}
@end example
and you get:
@example
Usage: Result = READFITS(filename, header, heap)
...
@end example
I hope you made it until here. Now you are set to work with IDLWAVE.
On the way you will want to change other things, and to learn more
about the possibilities not discussed in this short tutorial. Read
the manual, look at the documentation strings of interesting variables
(with @kbd{C-h v idlwave<-variable-name> @key{RET}}) and ask the
remaining questions on the newsgroup @code{comp.lang.idl-pvwave}.
@node The IDLWAVE Major Mode, The IDLWAVE Shell, Getting Started, Top
@chapter The IDLWAVE Major Mode
@cindex IDLWAVE major mode
@cindex Major mode, @code{idlwave-mode}
The IDLWAVE major mode supports editing IDL source files. In this
chapter we describe the main features of the mode and how to customize
them.
@menu
* Code Formatting:: Making code look nice
* Routine Info:: Calling Sequence and Keyword List
* Online Help:: One key press from source to help
* Completion:: Completing routine names and Keywords
* Routine Source:: Finding routines, the easy way
* Resolving Routines:: Force the Shell to compile a routine
* Code Templates:: Frequent code constructs
* Abbreviations:: Abbreviations for common commands
* Actions:: Changing case, Padding, End checking
* Doc Header:: Inserting a standard header
* Motion Commands:: Moving through the structure of a program
* Misc Options:: Things that fit nowhere else
@end menu
@node Code Formatting, Routine Info, The IDLWAVE Major Mode, The IDLWAVE Major Mode
@section Code Formatting
@cindex Code formatting
@cindex Formatting, of code
@menu
* Code Indentation:: Reflecting the logical structure
* Continued Statement Indentation::
* Comment Indentation:: Special indentation for comment lines
* Continuation Lines:: Splitting statements over lines
* Syntax Highlighting:: Font-lock support
* Octals and Highlighting:: Why "123 causes problems
@end menu
The IDL language, with its early roots in FORTRAN, modern implementation
in C, and liberal borrowing of features of many vector and other
languages along its 30+ year history, has inherited an unusual mix of
syntax elements. Left to his or her own devices, a novice IDL
programmer will often conjure code which is very difficult to read and
impossible to adapt. Much can be gleaned from studying available IDL
code libraries for coding style pointers, but, due to the variety of IDL
syntax elements, replicating this style can be challenging at best.
Luckily, IDLWAVE understands the structure of IDL code very well, and
takes care of almost all formatting issues for you. After configuring
it to match your coding standards, you can rely on it to help keep your
code neat and organized.
@node Code Indentation, Continued Statement Indentation, Code Formatting, Code Formatting
@subsection Code Indentation
@cindex Code indentation
@cindex Indentation
Like all Emacs programming modes, IDLWAVE performs code indentation.
The @key{TAB} key indents the current line relative to context.
@key{LFD} insert a newline and indents the new line. The indentation is
governed by a number of variables. IDLWAVE indents blocks (between
@code{PRO}/@code{FUNCTION}/@code{BEGIN} and @code{END}), and
continuation lines.
@cindex Foreign code, adapting
@cindex Indentation, of foreign code
@kindex C-M-\
To re-indent a larger portion of code (e.g. when working with foreign
code written with different conventions), use @kbd{C-M-\}
(@code{indent-region}) after marking the relevant code. Useful marking
commands are @kbd{C-x h} (the entire file) or @kbd{C-M-h} (the current
subprogram). The command @kbd{C-M-q} reindents the entire current
routine. @xref{Actions}, for information how to impose additional
formatting conventions on foreign code.
@defopt idlwave-main-block-indent (@code{2})
Extra indentation for the main block of code. That is the block between
the FUNCTION/PRO statement and the END statement for that program
unit.
@end defopt
@defopt idlwave-block-indent (@code{3})
Extra indentation applied to block lines. If you change this, you
probably also want to change @code{idlwave-end-offset}.
@end defopt
@defopt idlwave-end-offset (@code{-3})
Extra indentation applied to block END lines. A value equal to negative
@code{idlwave-block-indent} will make END lines line up with the block
BEGIN lines.
@end defopt
@node Continued Statement Indentation, Comment Indentation, Code Indentation, Code Formatting
@subsection Continued Statement Indentation
@cindex Indentation, continued statement
@cindex Continued statement indentation
Continuation lines (following a line ending with @code{$}) can receive a
fixed indentation offset from the main level, but in several situations
IDLWAVE can use a special form of indentation which aligns continued
statements more naturally. Special indentation is calculated for
continued routine definition statements and calls, enclosing parentheses
(like function calls, structure/class definitions, explicit structures
or lists, etc.), and continued assignments. An attempt is made to line
up with the first non-whitespace character after the relevant opening
punctuation mark (@code{,},@code{(},@code{@{},@code{[},@code{=}). For
lines without any non-comment characters on the line with the opening
punctuation, the continued line(s) are aligned just past the
punctuation. An example:
@example
function foo, a, b, $
c, d
bar = sin( a + b + $
c + d)
end
@end example
@noindent
The only drawback to this special continued statement indentation is
that it consumes more space, e.g., for long function names or left hand
sides of an assignment:
@example
function thisfunctionnameisverylongsoitwillleavelittleroom, a, b, $
c, d
@end example
You can instruct IDLWAVE when to avoid using this special continuation
indentation by setting the variable
@code{idlwave-max-extra-continuation-indent}, which specifies the
maximum additional indentation beyond the basic indent to be
tolerated, otherwise defaulting to a fixed-offset from the enclosing
indent (the size of which offset is set in
@code{idlwave-continuation-indent}). As a special case, continuations
of routine calls without any arguments or keywords will @emph{not}
align the continued line, under the assumption that you continued
because you needed the space.
Also, since the indentation level can be somewhat dynamic in continued
statements with special continuation indentation, especially if
@code{idlwave-max-extra-continuation-indent} is small, the key
@kbd{C-u @key{TAB}} will re-indent all lines in the current statement.
Note that @code{idlwave-indent-to-open-paren}, if non-@code{nil},
overrides the @code{idlwave-max-extra-continuation-indent} limit, for
parentheses only, forcing them always to line up.
@defopt idlwave-continuation-indent (@code{2})
Extra indentation applied to normal continuation lines.
@end defopt
@defopt idlwave-max-extra-continuation-indent (@code{20})
The maximum additional indentation (over the basic continuation-indent)
that will be permitted for special continues. To effectively disable
special continuation indentation, set to @code{0}. To enable it
constantly, set to a large number (like @code{100}). Note that the
indentation in a long continued statement never decreases from line to
line, outside of nested parentheses statements.
@end defopt
@defopt idlwave-indent-to-open-paren (@code{t})
Non-@code{nil} means indent continuation lines to innermost open
parenthesis, regardless of whether the
@code{idlwave-max-extra-continuation-indent} limit is satisfied.
@end defopt
@node Comment Indentation, Continuation Lines, Continued Statement Indentation, Code Formatting
@subsection Comment Indentation
@cindex Comment indentation
@cindex Hanging paragraphs
@cindex Paragraphs, filling
@cindex Paragraphs, hanging
In IDL, lines starting with a @samp{;} are called @emph{comment lines}.
Comment lines are indented as follows:
@multitable @columnfractions .1 .90
@item @code{;;;}
@tab The indentation of lines starting with three semicolons remains
unchanged.
@item @code{;;}
@tab Lines starting with two semicolons are indented like the surrounding code.
@item @code{;}
@tab Lines starting with a single semicolon are indented to a minimum column.
@end multitable
@noindent
The indentation of comments starting in column 0 is never changed.
@defopt idlwave-no-change-comment
The indentation of a comment starting with this regexp will not be
changed.
@end defopt
@defopt idlwave-begin-line-comment
A comment anchored at the beginning of line.
@end defopt
@defopt idlwave-code-comment
A comment that starts with this regexp is indented as if it is a part of
IDL code.
@end defopt
@node Continuation Lines, Syntax Highlighting, Comment Indentation, Code Formatting
@subsection Continuation Lines and Filling
@cindex Continuation lines
@cindex Line splitting
@cindex String splitting
@cindex Splitting, of lines
@kindex M-@key{RET}
In IDL, a newline character terminates a statement unless preceded by a
@samp{$}. If you would like to start a continuation line, use
@kbd{M-@key{RET}}, which calls the command @code{idlwave-split-line}.
It inserts the continuation character @samp{$}, terminates the line and
indents the new line. The command @kbd{M-@key{RET}} can also be invoked
inside a string to split it at that point, in which case the @samp{+}
concatenation operator is used.
@cindex Filling
@cindex @code{auto-fill-mode}
@cindex Hanging paragraphs
When filling comment paragraphs, IDLWAVE overloads the normal filling
functions and uses a function which creates the hanging paragraphs
customary in IDL routine headers. When @code{auto-fill-mode} is turned
on (toggle with @kbd{C-c C-a}), comments will be auto-filled. If the
first line of a paragraph contains a match for
@code{idlwave-hang-indent-regexp} (a dash-space by default), subsequent
lines are positioned to line up after it, as in the following example.
@example
@group
;=================================
; x - an array containing
; lots of interesting numbers.
;
; y - another variable where
; a hanging paragraph is used
; to describe it.