Add 2007 to copyright years.
[bpt/emacs.git] / man / ada-mode.texi
CommitLineData
00ce3714 1\input texinfo @c -*-texinfo-*-
f895bc1f 2@setfilename ../info/ada-mode
00ce3714
GM
3@settitle Ada Mode
4
18f952d5 5@copying
b65d8176 6Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004,
4e6835db 72005, 2006, 2007 Free Software Foundation, Inc.
00ce3714 8
18f952d5 9@quotation
8ba00a55 10Permission is granted to copy, distribute and/or modify this document
678e7c71 11under the terms of the GNU Free Documentation License, Version 1.2 or
8ba00a55
GM
12any later version published by the Free Software Foundation; with the
13Invariant Sections being ``The GNU Manifesto'', ``Distribution'' and
14``GNU GENERAL PUBLIC LICENSE'', with the Front-Cover texts being ``A GNU
15Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
16license is included in the section entitled ``GNU Free Documentation
17License'' in the Emacs manual.
00ce3714 18
8ba00a55
GM
19(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
20this GNU Manual, like GNU software. Copies published by the Free
21Software Foundation raise funds for GNU development.''
00ce3714 22
8ba00a55
GM
23This document is part of a collection distributed under the GNU Free
24Documentation License. If you want to distribute this document
25separately from the collection, you can do so by adding a copy of the
26license to the document, as described in section 6 of the license.
18f952d5
KB
27@end quotation
28@end copying
8ba00a55 29
18f952d5
KB
30@dircategory Emacs
31@direntry
11e52000 32* Ada mode: (ada-mode). Emacs mode for editing and compiling Ada code.
18f952d5 33@end direntry
00ce3714
GM
34
35@titlepage
36@sp 10
37@title{Ada Mode}
38@sp 2
11e52000
JB
39@subtitle An Emacs major mode for programming in Ada
40@subtitle Ada Mode Version 3.7
00ce3714 41@sp 2
00ce3714
GM
42@page
43@vskip 0pt plus 1filll
18f952d5 44@insertcopying
00ce3714
GM
45@end titlepage
46
11e52000
JB
47@c fixme; title page doesn't show up in ada-mode.info; why bother with
48@c it?
8ba00a55 49
00ce3714
GM
50@node Top, Overview, (dir), (dir)
51
52@menu
53* Overview::
11e52000
JB
54* Installation:: Installing Ada mode on your system
55* Customization:: Setting up Ada mode to your taste
56* Compiling Executing:: Working with your application within Emacs
57* Project files:: Describing the organization of your project
58* Compiling Examples:: A small tutorial
59* Moving Through Ada Code:: Moving easily through Ada sources
60* Identifier completion:: Finishing words automatically
61* Automatic Smart Indentation:: Indenting your code automatically as you type
62* Formatting Parameter Lists:: Formatting subprograms' parameter lists
00ce3714 63 automatically
11e52000
JB
64* Automatic Casing:: Adjusting the case of words automatically
65* Statement Templates:: Inserting code templates
66* Comment Handling:: Reformatting comments easily
de803500 67* Index::
00ce3714
GM
68@end menu
69
70
00ce3714
GM
71@node Overview, Installation, Top, Top
72@chapter Overview
00ce3714 73
11e52000
JB
74The Emacs mode for programming in Ada helps the user in understanding
75existing code and facilitates writing new code.
00ce3714 76
11e52000
JB
77When the Gnu Ada compiler GNAT is used, the cross-reference
78information output by the compiler is used to provide powerful code
79navigation (jump to definition, find all uses, etc).
00ce3714 80
11e52000
JB
81When you open a file with a file extension of @file{.ads} or
82@file{.adb}, Emacs will automatically load and activate Ada mode.
00ce3714 83
11e52000
JB
84Ada mode works without any customization, if you are using the GNAT
85compiler (@url{https://libre2.adacore.com/}) and the GNAT default
86naming convention.
00ce3714 87
11e52000
JB
88You must customize a few things if you are using a different compiler
89or file naming convention; @xref{Other compiler}, @xref{Non-standard
90file names}.
91
92In addition, you may want to customize the indentation,
93capitalization, and other things; @xref{Other customization}.
94
95Finally, for large Ada projects, you will want to set up an Emacs
96Ada mode project file for each project; @xref{Project files}. Note
97that these are different from the GNAT project files used by gnatmake
98and other GNAT commands.
99
100See the Emacs info manual, section 'Running Debuggers Under Emacs',
101for general information on debugging.
00ce3714 102
11e52000
JB
103@node Installation, Customization, Overview, Top
104@chapter Installation
105
106Ada mode is part of the standard Emacs distribution; if you use that,
107no files need to be installed.
108
109Ada mode is also available as a separate distribution, from the Emacs
110Ada mode website
111@uref{http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html}. The
112separate distribution may be more recent.
113
114For installing the separate distribution, see the @file{README} file
115in the distribution.
116
117To see what version of Ada mode you have installed, do @key{M-x
118ada-mode-version}.
119
120The following files are provided with the Ada mode distribution:
00ce3714
GM
121
122@itemize @bullet
11e52000 123
2e78ad14 124@item
11e52000
JB
125@file{ada-mode.el}: The main file for Ada mode, providing indentation,
126formatting of parameter lists, moving through code, comment handling
127and automatic casing.
128
2e78ad14 129@item
11e52000
JB
130@file{ada-prj.el}: GUI editing of Ada mode project files, using Emacs
131widgets.
00ce3714 132
11e52000
JB
133@item
134@file{ada-stmt.el}: Ada statement templates.
00ce3714 135
11e52000
JB
136@item
137@file{ada-xref.el}: GNAT cross-references, completion of identifiers,
138and compilation. Also provides project files (which are not
139GNAT-specific).
00ce3714 140
11e52000 141@end itemize
00ce3714 142
11e52000
JB
143@node Customization, Compiling Executing, Installation, Top
144@chapter Customizing Ada mode
00ce3714 145
11e52000
JB
146Here we assume you are familiar with setting variables in Emacs,
147either thru 'customize' or in elisp (in your @file{.emacs} file). For
148a basic introduction to customize, elisp, and Emacs in general, see
149the tutorial in
744e59f6
RC
150@iftex
151@cite{The GNU Emacs Manual}.
152@end iftex
153@ifhtml
154@cite{The GNU Emacs Manual}.
155@end ifhtml
156@ifinfo
157@ref{Top, , The GNU Emacs Manual, emacs, The GNU Emacs Manual}.
158@end ifinfo
00ce3714 159
11e52000
JB
160These global Emacs settings are strongly recommended (put them in your
161.emacs):
00ce3714 162
11e52000
JB
163@example
164(global-font-lock-mode t)
165(transient-mark-mode t)
166@end example
00ce3714 167
11e52000
JB
168@samp{(global-font-lock-mode t)} turns on syntax
169highlighting for all buffers (it is off by default because it may be
170too slow for some machines).
00ce3714 171
11e52000 172@samp{(transient-mark-mode t)} highlights selected text.
00ce3714 173
11e52000 174See the Emacs help for each of these variables for more information.
00ce3714 175
11e52000
JB
176@menu
177* Non-standard file names::
178* Other compiler::
179* Other customization::
180@end menu
00ce3714 181
11e52000
JB
182@node Non-standard file names, Other compiler, Customization, Customization
183@section Non-standard file names
00ce3714 184
11e52000
JB
185By default, Ada mode is configured to use the GNAT file naming
186convention, where file names are a simple modification of the Ada
187names, and the extension for specs and bodies are
188@samp{.ads} and @samp{.adb}, respectively.
00ce3714 189
11e52000
JB
190Ada mode uses the file extentions to allow moving from a package body
191to the corresponding spec and back.
00ce3714 192
11e52000
JB
193Ada mode supports a list of alternative file extensions for specs and bodies.
194
195For instance, if your spec and bodies files are called
196@file{@var{unit}_s.ada} and @file{@var{unit}_b.ada}, respectively, you
197can add the following to your @file{.emacs} file:
00ce3714 198
00ce3714 199@example
11e52000 200(ada-add-extensions "_s.ada" "_b.ada")
00ce3714 201@end example
00ce3714 202
11e52000
JB
203You can define additional extensions:
204
205@example
206(ada-add-extensions ".ads" "_b.ada")
207(ada-add-extensions ".ads" ".body")
208@end example
209
210This means that whenever Ada mode looks for the body for a file
211whose extension is @file{.ads}, it will take the first available file
212that ends with either @file{.adb}, @file{_b.ada} or
213@file{.body}.
214
215Simililarly, if Ada mode is looking for a spec, it will look for
216@file{.ads} or @file{_s.ada}.
217
218If the filename is not derived from the Ada name following the GNAT
219convention, things are a little more complicated. You then need to
220rewrite the function @code{ada-make-filename-from-adaname}. Doing that
221is beyond the scope of this manual; see the current definitions in
222@file{ada-mode.el} and @file{ada-xref.el} for examples.
223
224@node Other compiler, Other customization, Non-standard file names, Customization
225@section Other compiler
226
227By default, Ada mode is configured to use the Gnu Ada compiler GNAT.
228
229To use a different Ada compiler, you must specify the command lines
230used to run that compiler, either in lisp variables or in Emacs
231Ada mode project files. See @ref{Project file variables} for the list
232of project variables, and the corresponding lisp variables.
233
234@node Other customization, , Other compiler, Customization
235@section Other customization
236
237All user-settable Ada mode variables can be set via the menu
238@samp{Ada | Customize}. Click on the @samp{Help} button there for help
239on using customize.
00ce3714
GM
240
241To modify a specific variable, you can directly call the function
11e52000
JB
242@code{customize-variable}; just type @kbd{M-x customize-variable
243@key{RET} @var{variable-name} @key{RET}}).
00ce3714 244
11e52000
JB
245Alternately, you can specify variable settings in the Emacs
246configuration file, @file{.emacs}. This file is coded in Emacs lisp,
247and the syntax to set a variable is the following:
00ce3714
GM
248@example
249(setq variable-name value)
250@end example
251
11e52000
JB
252@node Compiling Executing, Project files, Customization, Top
253@chapter Compiling Executing
00ce3714 254
11e52000
JB
255Ada projects can be compiled, linked, and executed using commands on
256the Ada menu. All of these commands can be customized via a project
257file (@pxref{Project files}), but the defaults are sufficient for using
258the GNAT compiler for simple projects (single files, or several files
259in a single directory).
00ce3714 260
11e52000
JB
261Even when no project file is used, the GUI project editor (menu
262@key{Ada | Project | Edit}) shows the settings of the various project
263file variables referenced here.
2e78ad14 264
11e52000
JB
265@menu
266* Compile commands::
267* Compiler errors::
268@end menu
00ce3714 269
11e52000
JB
270@node Compile commands, Compiler errors, Compiling Executing, Compiling Executing
271@section Compile commands
2e78ad14 272
11e52000
JB
273Here are the commands for building and using an Ada project, as
274listed in the Ada menu.
2e78ad14 275
11e52000
JB
276In multi-file projects, there must be one file that is the main
277program. That is given by the @code{main_unit} project file variable;
278it defaults to the current file if not yet set, but is also set by the
279``set main and build'' command.
00ce3714 280
11e52000 281@table @code
00ce3714 282
11e52000
JB
283@item Check file
284Compiles the current file in syntax check mode, by running
285@code{check_cmd} defined in the current project file. This typically
286runs faster than full compile mode, speeding up finding and fixing
287compilation errors.
00ce3714 288
11e52000 289This sets @code{main_unit} only if it has not been set yet.
00ce3714 290
11e52000
JB
291@item Compile file
292Compiles the current file, by running @code{comp_cmd} from the current
293project file.
00ce3714 294
11e52000 295This does not set @code{main_unit}.
00ce3714 296
11e52000
JB
297@item Set main and Build
298Sets @code{main_unit} to the current file, then executes the Build
299command.
00ce3714 300
11e52000
JB
301@item Show main
302Display @code{main_unit} in the message buffer.
303
304@item Build
305Compiles all obsolete units of the current @code{main_unit}, and links
306@code{main_unit}, by running @code{make_cmd} from the current project.
307
308This sets @code{main_unit} only if it has not been set yet.
309
310@item Run
311Executes the main program in a shell, displayed in a separate Emacs
312buffer. This runs @code{run_cmd} from the current project. The
313execution buffer allows for interactive input/output.
314
315To modify the run command, in particular to provide or change the
316command line arguments, type @key{C-u} before invoking the command.
317
318This command is not available for a cross-compilation toolchain.
00ce3714
GM
319
320@end table
11e52000
JB
321It is important when using these commands to understand how
322@code{main_unit} is used and changed.
00ce3714 323
11e52000
JB
324Build runs 'gnatmake' on the main unit. During a typical edit/compile
325session, this is the only command you need to invoke, which is why it
326is bound to @key{C-c C-c}. It will compile all files needed by the
327main unit, and display compilation errors in any of them.
00ce3714 328
11e52000
JB
329Note that Build can be invoked from any Ada buffer; typically you will
330be fixing errors in files other than the main, but you don't have to
331switch back to the main to invoke the compiler again.
00ce3714 332
11e52000
JB
333Novices and students typically work on single-file Ada projects. In
334this case, @key{C-c C-m} will normally be the only command needed; it
335will build the current file, rather than the last-built main.
00ce3714 336
11e52000
JB
337There are three ways to change @code{main_unit}:
338
339@enumerate
2e78ad14 340@item
11e52000
JB
341Invoke @key{Ada | Set main and Build}, which sets @code{main_unit} to
342the current file.
00ce3714 343
2e78ad14 344@item
11e52000
JB
345Invoke @key{Ada | Project | Edit}, edit @code{main_unit} and
346@code{main}, and click @key{[save]}
347
2e78ad14 348@item
11e52000
JB
349Invoke @key{Ada | Project | Load}, and load a project file that specifies @code{main_unit}
350
351@end enumerate
352
353@node Compiler errors, , Compile commands, Compiling Executing
354@section Compiler errors
355
356The @code{Check file}, @code{Compile file}, and @code{Build} commands
357all place compilation errors in a separate buffer named
358@code{*compilation*}.
359
360Each line in this buffer will become active: you can simply click on
361it with the middle button of the mouse, or move point to it and press
362@key{RET}. Emacs will then display the relevant source file and put
363point on the line and column where the error was found.
364
365You can also press the @kbd{C-x `} key (@code{next-error}), and Emacs
366will jump to the first error. If you press that key again, it will
367move you to the second error, and so on.
368
369Some error messages might also include references to other files. These
370references are also clickable in the same way, or put point after the
371line number and press @key{RET}.
372
373@node Project files, Compiling Examples, Compiling Executing, Top
374@chapter Project files
375
376An Emacs Ada mode project file specifies what directories hold sources
377for your project, and allows you to customize the compilation commands
378and other things on a per-project basis.
379
380Note that Ada mode project files @samp{*.adp} are different than GNAT
381compiler project files @samp{*.gpr}.
382
383@menu
384* Project File Overview::
385* GUI Editor::
386* Project file variables::
387@end menu
388
389@node Project File Overview, GUI Editor, Project files, Project files
390@section Project File Overview
391
392Project files have a simple syntax; they may be edited directly. Each
393line specifies a project variable name and its value, separated by ``='':
394@example
395src_dir=/Projects/my_project/src_1
396src_dir=/Projects/my_project/src_2
397@end example
398
399Some variables (like @code{src_dir}) are lists; multiple occurances
400are concatenated.
401
402There must be no space between the variable name and ``='', and no
403trailing spaces.
404
405Alternately, a GUI editor for project files is available (@pxref{GUI
406Editor}). It uses Emacs widgets, similar to Emacs customize.
407
408The GUI editor also provides a convenient way to view current project
409settings, if they have been modified using menu commands rather than
410by editing the project file.
411
412After the first Ada mode build command is invoked, there is always a
413current project file, given by the lisp variable
414@code{ada-prj-default-project-file}. Currently, the only way to show
415the current project file is to invoke the GUI editor.
416
417To find the project file the first time, Ada mode uses the following
418search algorithm:
419
420@itemize @bullet
2e78ad14 421@item
11e52000
JB
422If @code{ada-prj-default-project-file} is set, use that.
423
2e78ad14 424@item
11e52000
JB
425Otherwise, search for a file in the current directory with
426the same base name as the Ada file, but extension given by
427@code{ada-prj-file-extension} (default @code{".adp"}).
428
2e78ad14 429@item
11e52000
JB
430If not found, search for @file{*.adp} in the current directory; if
431several are found, prompt the user to select one.
432
2e78ad14 433@item
11e52000
JB
434If none are found, use @file{default.adp} in the current directory (even
435if it does not exist).
436
00ce3714
GM
437@end itemize
438
11e52000
JB
439This algorithm always sets @code{ada-prj-default-project-file}, even
440when the file does not actually exist.
441
442To change the project file before or after the first one is found,
443invoke @key{Ada | Project | Load ...}.
444
445Or, in lisp, evaluate @code{ada-set-default-project-file "/path/file.adp"}.
446This sets @code{ada-prj-default-project-file}, and reads the project file.
447
448@node GUI Editor, Project file variables, Project File Overview, Project files
449@section GUI Editor
450
451The project file editor is invoked with the menu @samp{Ada | Projects
452| Edit}.
453
454Once in the buffer for editing the project file, you can save your
455modification using the @samp{[save]} button at the bottom of the
456buffer, or the @kbd{C-x C-s} binding. To cancel your modifications,
457kill the buffer or click on the @samp{[cancel]} button.
458
459@node Project file variables, , GUI Editor, Project files
460@section Project file variables
461
462The following variables can be defined in a project file; some can
463also be defined in lisp variables.
464
465To set a project variable that is a list, specify each element of the
466list on a separate line in the project file.
467
468Any project variable can be referenced in other project variables,
469using a shell-like notation. For instance, if the variable
470@code{comp_cmd} contains @code{$@{comp_opt@}}, the value of the
471@code{comp_opt} variable will be substituted when @code{comp_cmd} is
472used.
473
474Most project variables have defaults that can be changed by setting
475lisp variables; the table below identifies the lisp variable for each
476project variable. Lisp variables corresponding to project variables
477that are lists are lisp lists.
478
479Here is the list of variables. In the default values, the current
480directory @code{"."} is the project file directory.
481
482@c defined in ada-xref-set-default-prj-values; same order here
483@table @asis
484@item @code{build_dir} [default: @code{"."}]
485The compile commands will be issued in this directory.
486
487@item @code{src_dir} [default: @code{"."}]
488A list of directories to search for source files, both for compile
489commands and source navigation.
490
491@item @code{obj_dir} [default: @code{"."}]
492A list of directories to search for library files. Ada mode searches
493this list for the @samp{.ali} files generated by GNAT that contain
494cross-reference information.
495
496The compiler commands must place the @samp{.ali} files in one of these
497directories; the default commands do that.
498
499@item @code{casing} [default: @code{("~/.emacs_case_exceptions")}
500List of files containing casing exceptions. See the help on
501@code{ada-case-exception-file} for more info.
502@c FIXME: section on case exceptions
503
504Lisp variable: @code{ada-case-exception-file}.
505
506@item @code{comp_opt} [default: @code{"-gnatq -gnatQ"}]
507Holds user compiler options; used in the default compile commands. The
508default value tells gnatmake to generate library files for
509cross-referencing even when there are errors.
510
511If source code for the project is in multiple directories, the
512appropriate compiler options must be added here. @ref{Set source
513search path} for examples of this. Alternately, GNAT project files may
514be used; @ref{Use GNAT project file}.
515
516Lisp variable: @code{ada-prj-default-comp-opt}.
517
518@item @code{bind_opt} [default: @code{""}]
519Holds user binder options; used in the default build commands.
520
521Lisp variable: @code{ada-prj-default-bind-opt}.
522
523@item @code{link_opt} [default: @code{""}]
524Holds user linker options; used in the default build commands.
525
526Lisp variable: @code{ada-prj-default-link-opt}.
527
528@item @code{gnatmake_opt} [default: @code{"-g"}]
529Holds user gnatmake options; used in the default build commands.
530
531If a GNAT project file is used (for example @file{project.gpr}), this
532option should be set to @code{-Pproject.gpr}.
533
534Lisp variable: @code{ada-prj-default-gnatmake-opt}.
535
536@item @code{gnatfind_opt} [default: @code{"-rf"}]
537Holds user gnatfind options; used in the default find commands.
538
539Lisp variable: @code{ada-prj-gnatfind-switches}.
540
541@item @code{main} [default: current file]
542Specifies the name of the executable file for the project; used in the
543default build commands.
544
545@item @code{main_unit} [default: current Ada unit]
546Specifies the name of the main Ada unit for the project; used in the
547default build commands.
548
549@item @code{cross_prefix} [default: @code{""}]
550Name of target machine in a cross-compilation environment. Used in
551default compile and build commands.
552
553@item @code{remote_machine} [default: @code{""}]
554Name of the machine to log into before issuing the compile and build
555commands. If this variable is empty, the command will be run on the
556local machine.
557
558@item @code{comp_cmd} [default: @code{"$@{cross_prefix@}gnatmake -u -c $@{gnatmake_opt@} $@{full_current@} -cargs $@{comp_opt@}"}]
559Command used to compile a single file.
560The name of the file is substituted for @code{full_current}.
561
562Lisp variable: @code{ada-prj-default-comp-cmd}.
563
564@item @code{check_cmd} [default: @code{"$@{cross_prefix@}gnatmake -u -c -gnatc $@{gnatmake_opt@} $@{full_current@} -cargs $@{comp_opt@}"}]
565Command used to syntax check a single file.
566The name of the file is substituted for @code{full_current}.
567
568Lisp variable: @code{ada-prj-default-check-cmd}
00ce3714 569
11e52000
JB
570@item @code{make_cmd} [default: @code{"$@{cross_prefix@}gnatmake -o $@{main@} $@{main_unit@} $@{gnatmake_opt@} -cargs $@{comp_opt@} -bargs $@{bind_opt@} -largs $@{link_opt@}"}]
571Command used to build the application.
572
573Lisp variable: @code{ada-prj-default-make-cmd}.
574
575@item @code{run_cmd} [default: @code{"./$@{main@}"}]
576Command used to run the application.
577
578@item @code{debug_pre_cmd} [default: @code{"cd $@{build_dir@}"}]
579Command executed before @code{debug_cmd}.
580
581@item @code{debug_cmd} [default: @code{"$@{cross_prefix@}gdb $@{main@}"}]
582Command used to debug the application
583
584Lisp variable: @code{ada-prj-default-debugger}.
585
586@item @code{debug_post_cmd} [default: @code{""}]
587Command executed after @code{debug_cmd}.
588
589@end table
590
591@node Compiling Examples, Moving Through Ada Code, Project files, Top
592@chapter Compiling Examples
593
594We present several small projects, and walk thru the process of
595compiling, linking, and running them.
596
597The first example illustrates more Ada mode features than the others;
598you should work thru that example before doing the others.
599
600All of these examples assume you are using GNAT.
601
602The source for these examples is available on the Emacs Ada mode
603website mentioned in @xref{Installation}.
604
605@menu
606* No project files:: Just menus
607* Set compiler options:: A basic Ada mode project file
608* Set source search path:: Source in multiple directories
609* Use GNAT project file::
610@end menu
611
612@node No project files, Set compiler options, Compiling Examples, Compiling Examples
613@section No project files
614This example uses no project files.
615
616First, create a directory @file{Example_1}, containing:
617
618@file{hello.adb}:
619
620@example
621with Ada.Text_IO;
622procedure Hello
623is begin
624 Put_Line("Hello from hello.adb");
625end Hello;
626@end example
627
628Yes, this is missing ``use Ada.Text_IO;'' - we want to demonstrate
629compiler error handling.
630
631@file{hello_2.adb}:
632
633@example
634with Hello_Pkg;
635procedure Hello_2
636is begin
637 Hello_Pkg.Say_Hello;
638end Hello_2;
639@end example
640
641@file{hello_pkg.ads}:
642
643@example
644package Hello_Pkg is
645 procedure Say_Hello;
646end Hello_Pkg;
647@end example
648
649@file{hello_pkg.adb}:
650
651@example
652with Ada.Text_IO;
653package Hello_Pkg is
654 procedure Say_Hello
655 is begin
656 Ada.Text_IO.Put_Line ("Hello from hello_pkg.adb");
657 end Say_Hello;
658end Hello_Pkg;
659@end example
660
661Yes, this is missing the keyword @code{body}; another compiler error
662example.
663
664In buffer @file{hello.adb}, invoke @key{Ada | Check file}. You should
665get a @code{*compilation*} buffer containing something like (the
666directory paths will be different):
667
668@example
669cd c:/Examples/Example_1/
670gnatmake -u -c -gnatc -g c:/Examples/Example_1/hello.adb -cargs -gnatq -gnatQ
671gcc -c -Ic:/Examples/Example_1/ -gnatc -g -gnatq -gnatQ -I- c:/Examples/Example_1/hello.adb
672hello.adb:4:04: "Put_Line" is not visible
673hello.adb:4:04: non-visible declaration at a-textio.ads:264
674hello.adb:4:04: non-visible declaration at a-textio.ads:260
675gnatmake: "c:/Examples/Example_1/hello.adb" compilation error
676@end example
677
678If you have enabled font-lock, the lines with actual errors (starting
679with @file{hello.adb}) are highlighted, with the file name in red.
680
681Now type @key{C-x `} (on a PC keyboard, @key{`} is next to @key{1}).
682Or you can click the middle mouse button on the first error line. The
683compilation buffer scrolls to put the first error on the top line, and
684point is put at the place of the error in the @file{hello.adb} buffer.
685
686To fix the error, change the line to be
687
688@example
689 Ada.Text_IO.Put_Line ("hello from hello.adb"):
690@end example
691
692Now invoke @key{Ada | Show main}; this displays @file{Ada mode main_unit: hello}.
693
694Now (in buffer @file{hello.adb}), invoke @key{Ada | Build}. You are
695prompted to save the file (if you haven't already). Then the
696compilation buffer is displayed again, containing:
697
698@example
699cd c:/Examples/Example_1/
700gnatmake -o hello hello -g -cargs -gnatq -gnatQ -bargs -largs
701gcc -c -g -gnatq -gnatQ hello.adb
702gnatbind -x hello.ali
703gnatlink hello.ali -o hello.exe -g
704@end example
705
706The compilation has succeeded without errors; @file{hello.exe} now
707exists in the same directory as @file{hello.adb}.
708
709Now invoke @key{Ada | Run}. A @file{*run*} buffer is displayed,
710containing
711
712@example
713Hello from hello.adb
714
715Process run finished
716@end example
717
718That completes the first part of this example.
719
720Now we will compile a multi-file project. Open the file
721@file{hello_2.adb}, and invoke @key{Ada | Set main and Build}. This
722finds an error in @file{hello_pkg.adb}:
723
724@example
725cd c:/Examples/Example_1/
726gnatmake -o hello_2 hello_2 -g -cargs -gnatq -gnatQ -bargs -largs
727gcc -c -g -gnatq -gnatQ hello_pkg.adb
728hello_pkg.adb:2:08: keyword "body" expected here [see file name]
729gnatmake: "hello_pkg.adb" compilation error
730@end example
731
732This demonstrates that gnatmake finds the files needed by the main
733program. However, it cannot find files in a different directory,
734unless you use an Emacs Ada mode project file to specify the other directories;
735@xref{Set source search path}, or a GNAT project file; @ref{Use GNAT
736project file}.
737
738Invoke @key{Ada | Show main}; this displays @file{Ada mode main_unit: hello_2}.
739
740Move to the error with @key{C-x `}, and fix the error by adding @code{body}:
741
742@example
743package body Hello_Pkg is
744@end example
745
746Now, while still in @file{hello_pkg.adb}, invoke @key{Ada | Build}.
747gnatmake successfully builds @file{hello_2}. This demonstrates that
748Emacs has remembered the main file, in the project variable
749@code{main_unit}, and used it for the Build command.
750
751Finally, again while in @file{hello_pkg.adb}, invoke @key{Ada | Run}.
752The @code{*run*} buffer displays @code{Hello from hello_pkg.adb}.
753
754One final point. If you switch back to buffer @file{hello.adb}, and
755invoke @key{Ada | Run}, @file{hello_2.exe} will be run. That is
756because @code{main_unit} is still set to @code{hello_2}, as you can
757see when you invoke @key{Ada | Project | Edit}.
758
759There are three ways to change @code{main_unit}:
760
761@enumerate
2e78ad14 762@item
11e52000
JB
763Invoke @key{Ada | Set main and Build}, which sets @code{main_unit} to
764the current file.
00ce3714 765
2e78ad14 766@item
11e52000
JB
767Invoke @key{Ada | Project | Edit}, edit @code{main_unit} and
768@code{main}, and click @key{[save]}
00ce3714 769
2e78ad14 770@item
11e52000 771Invoke @key{Ada | Project | Load}, and load a project file that specifies @code{main_unit}
00ce3714 772
11e52000 773@end enumerate
00ce3714 774
11e52000
JB
775@node Set compiler options, Set source search path, No project files, Compiling Examples
776@section Set compiler options
00ce3714 777
11e52000
JB
778This example illustrates using an Emacs Ada mode project file to set a
779compiler option.
00ce3714 780
11e52000
JB
781If you have files from @file{Example_1} open in Emacs, you should
782close them so you don't get confused. Use menu @key{File | Close
783(current buffer)}.
784
785In directory @file{Example_2}, create these files:
00ce3714 786
11e52000 787@file{hello.adb}:
00ce3714
GM
788
789@example
11e52000
JB
790with Ada.Text_IO;
791procedure Hello
792is begin
793 Put_Line("Hello from hello.adb");
794end Hello;
00ce3714
GM
795@end example
796
11e52000
JB
797This is the same as @file{hello.adb} from @file{Example_1}. It has two
798errors; missing ``use Ada.Text_IO;'', and no space between
799@code{Put_Line} and its argument list.
00ce3714 800
11e52000 801@file{hello.adp}:
00ce3714 802
11e52000
JB
803@example
804comp_opt=-gnatyt
805@end example
806
807This tells the GNAT compiler to check for token spacing; in
808particular, there must be a space preceding a parenthesis.
809
810In buffer @file{hello.adb}, invoke @key{Ada | Project | Load...}, and
811select @file{Example_2/hello.adp}.
812
813Then, again in buffer @file{hello.adb}, invoke @key{Ada | Set main and
814Build}. You should get a @code{*compilation*} buffer containing
815something like (the directory paths will be different):
816
817@example
818cd c:/Examples/Example_2/
819gnatmake -o hello hello -g -cargs -gnatyt -bargs -largs
820gcc -c -g -gnatyt hello.adb
821hello.adb:4:04: "Put_Line" is not visible
822hello.adb:4:04: non-visible declaration at a-textio.ads:264
823hello.adb:4:04: non-visible declaration at a-textio.ads:260
824hello.adb:4:12: (style) space required
825gnatmake: "hello.adb" compilation error
826@end example
827
828Compare this to the compiler output in @ref{No project files}; the
829gnatmake option @code{-cargs -gnatq -gnatQ} has been replaced by
830@code{-cargs -gnaty}, and an additional error is reported in
831@file{hello.adb} on line 4. This shows that @file{hello.adp} is being
832used to set the compiler options.
833
834Fixing the error, linking and running the code proceed as in @ref{No
835project files}.
836
837@node Set source search path, Use GNAT project file, Set compiler options, Compiling Examples
838@section Set source search path
839
840In this example, we show how to deal with files in more than one
841directory. We start with the same code as in @ref{No project files}; create those
842files (with the errors present)
843
844Create the directory @file{Example_3}, containing:
845
846@file{hello_pkg.ads}:
847
848@example
849package Hello_Pkg is
850 procedure Say_Hello;
851end Hello_Pkg;
852@end example
853
854@file{hello_pkg.adb}:
855
856@example
857with Ada.Text_IO;
858package Hello_Pkg is
859 procedure Say_Hello
860 is begin
861 Ada.Text_IO.Put_Line ("Hello from hello_pkg.adb");
862 end Say_Hello;
863end Hello_Pkg;
864@end example
865
866These are the same files from example 1; @file{hello_pkg.adb} has an
867error on line 2.
868
869In addition, create a directory @file{Example_3/Other}, containing these files:
870
871@file{Other/hello_3.adb}:
872
873@example
874with Hello_Pkg;
875with Ada.Text_IO; use Ada.Text_IO;
876procedure Hello_3
877is begin
878 Hello_Pkg.Say_Hello;
879 Put_Line ("From hello_3");
880end Hello_3;
881@end example
882
883There are no errors in this file.
884
885@file{Other/other.adp}:
886
887@example
888src_dir=..
889comp_opt=-I..
890@end example
891
892Note that there must be no trailing spaces.
893
894In buffer @file{hello_3.adb}, invoke @key{Ada | Project | Load...}, and
895select @file{Example_3/Other/other.adp}.
896
897Then, again in @file{hello_3.adb}, invoke @key{Ada | Set main and
898Build}. You should get a @code{*compilation*} buffer containing
899something like (the directory paths will be different):
900
901@example
902cd c:/Examples/Example_3/Other/
903gnatmake -o hello_3 hello_3 -g -cargs -I.. -bargs -largs
904gcc -c -g -I.. hello_3.adb
905gcc -c -I./ -g -I.. -I- C:\Examples\Example_3\hello_pkg.adb
906hello_pkg.adb:2:08: keyword "body" expected here [see file name]
907gnatmake: "C:\Examples\Example_3\hello_pkg.adb" compilation error
908@end example
909
910Compare the @code{-cargs} option to the compiler output in @ref{Set
911compiler options}; this shows that @file{other.adp} is being used to
912set the compiler options.
913
914Move to the error with @key{C-x `}. Ada mode searches the list of
915directories given by @code{src_dir} for the file mentioned in the
916compiler error message.
917
918Fixing the error, linking and running the code proceed as in @ref{No
919project files}.
920
921@node Use GNAT project file, , Set source search path, Compiling Examples
922@section Use GNAT project file
923
924In this example, we show how to use a GNAT project file.
925
926Create the directory @file{Example_4}, containing:
927
928@file{hello_pkg.ads}:
929
930@example
931package Hello_Pkg is
932 procedure Say_Hello;
933end Hello_Pkg;
934@end example
935
936@file{hello_pkg.adb}:
937
938@example
939with Ada.Text_IO;
940package Hello_Pkg is
941 procedure Say_Hello
942 is begin
943 Ada.Text_IO.Put_Line ("Hello from hello_pkg.adb");
944 end Say_Hello;
945end Hello_Pkg;
946@end example
947
948These are the same files from example 1; @file{hello_pkg.adb} has an
949error on line 2.
950
951In addition, create a directory @file{Example_4/Gnat_Project},
952containing these files:
953
954@file{Other/hello_4.adb}:
955
956@example
957with Hello_Pkg;
958with Ada.Text_IO; use Ada.Text_IO;
959procedure Hello_4
960is begin
961 Hello_Pkg.Say_Hello;
962 Put_Line ("From hello_4");
963end Hello_4;
964@end example
965
966There are no errors in this file.
967
968@file{Gnat_Project/hello_4.adp}:
969
970@example
971src_dir=..
972gnatmake_opt=-Phello_4.gpr
973@end example
974
975@file{Gnat_Project/hello_4.gpr}:
976
977@example
978Project Hello_4 is
979 for Source_Dirs use (".", "..");
980end Hello_4;
981@end example
982
983In buffer @file{hello_4.adb}, invoke @key{Ada | Project | Load...}, and
984select @file{Example_4/Gnat_Project/hello_4.adp}.
985
986Then, again in @file{hello_4.adb}, invoke @key{Ada | Set main and
987Build}. You should get a @code{*compilation*} buffer containing
988something like (the directory paths will be different):
989
990@example
991cd c:/Examples/Example_4/Gnat_Project/
992gnatmake -o hello_4 hello_4 -Phello_4.gpr -cargs -gnatq -gnatQ -bargs -largs
993gcc -c -g -gnatyt -gnatq -gnatQ -I- -gnatA c:\Examples\Example_4\Gnat_Project\hello_4.adb
994gcc -c -g -gnatyt -gnatq -gnatQ -I- -gnatA c:\Examples\Example_4\hello_pkg.adb
995hello_pkg.adb:2:08: keyword "body" expected here [see file name]
996gnatmake: "c:\examples\example_4\hello_pkg.adb" compilation error
997@end example
998
999Compare the @code{gcc} options to the compiler output in @ref{Set
1000compiler options}; this shows that @file{hello_4.gpr} is being used to
1001set the compiler options.
1002
1003Fixing the error, linking and running the code proceed as in @ref{No
1004project files}.
1005
1006@node Moving Through Ada Code, Identifier completion, Compiling Examples, Top
00ce3714
GM
1007@chapter Moving Through Ada Code
1008@c -----------------------------------------------------------------------
1009
11e52000
JB
1010There are several easy to use commands to navigate through Ada code. All
1011these functions are available through the Ada menu, and you can also
1012use the following key bindings or the command names. Some of these
1013menu entries are available only if the GNAT compiler is used, since
1014the implementation relies on the GNAT cross-referencing information.
00ce3714
GM
1015
1016@table @kbd
11e52000 1017@item M-C-e
de803500 1018@findex ada-next-procedure
2e78ad14
RS
1019Move to the next function/procedure/task, which ever comes next
1020(@code{ada-next-procedure}).
11e52000 1021@item M-C-a
de803500 1022@findex ada-previous-procedure
2e78ad14
RS
1023Move to previous function/procedure/task
1024(@code{ada-previous-procedure}).
1025@item M-x ada-next-package
de803500 1026@findex ada-next-package
00ce3714 1027Move to next package.
11e52000
JB
1028@item M-x ada-previous-package
1029@findex ada-previous-package
00ce3714 1030Move to previous package.
2e78ad14 1031@item C-c C-a
de803500 1032@findex ada-move-to-start
2e78ad14
RS
1033Move to matching start of @code{end} (@code{ada-move-to-start}). If
1034point is at the end of a subprogram, this command jumps to the
1035corresponding @code{begin} if the user option
11e52000
JB
1036@code{ada-move-to-declaration} is @code{nil} (default), otherwise it jumps to
1037the subprogram declaration.
2e78ad14 1038@item C-c C-e
de803500 1039@findex ada-move-to-end
2e78ad14
RS
1040Move point to end of current block (@code{ada-move-to-end}).
1041@item C-c o
1042Switch between corresponding spec and body file
11e52000
JB
1043(@code{ff-find-other-file}). If point is in a subprogram, position
1044point on the corresponding declaration or body in the other file.
00ce3714 1045@item C-c c-d
de803500 1046@findex ada-goto-declaration
11e52000
JB
1047Move from any reference to its declaration, for from a declaration to
1048its body (for procedures, tasks, private and incomplete types).
2e78ad14 1049@item C-c C-r
de803500 1050@findex ada-find-references
11e52000
JB
1051Runs the @file{gnatfind} command to search for all references to the
1052identifier surrounding point (@code{ada-find-references}). Use
2e78ad14
RS
1053@kbd{C-x `} (@code{next-error}) to visit each reference (as for
1054compilation errors).
00ce3714
GM
1055@end table
1056
11e52000
JB
1057If the @code{ada-xref-create-ali} variable is non-@code{nil}, Emacs
1058will try to run GNAT for you whenever cross-reference information is
1059needed, and is older than the current source file.
00ce3714 1060
11e52000 1061@node Identifier completion, Automatic Smart Indentation, Moving Through Ada Code, Top
00ce3714 1062@chapter Identifier completion
00ce3714 1063
11e52000
JB
1064Emacs and Ada mode provide two general ways for the completion of
1065identifiers. This is an easy way to type faster: you just have to type
1066the first few letters of an identifiers, and then loop through all the
00ce3714
GM
1067possible completions.
1068
11e52000
JB
1069The first method is general for Emacs. It works by parsing all open
1070files for possible completions.
00ce3714 1071
2e78ad14
RS
1072For instance, if the words @samp{my_identifier}, @samp{my_subprogram}
1073are the only words starting with @samp{my} in any of the opened files,
1074then you will have this scenario:
1075
11e52000 1076@example
00ce3714 1077You type: my@key{M-/}
2e78ad14
RS
1078Emacs inserts: @samp{my_identifier}
1079If you press @key{M-/} once again, Emacs replaces @samp{my_identifier} with
1080@samp{my_subprogram}.
1081Pressing @key{M-/} once more will bring you back to @samp{my_identifier}.
11e52000 1082@end example
00ce3714 1083
11e52000 1084This is a very fast way to do completion, and the casing of words will
00ce3714
GM
1085also be respected.
1086
11e52000
JB
1087The second method (@key{C-TAB}) is specific to Ada mode and the GNAT
1088compiler. Emacs will search the cross-information for possible
1089completions.
00ce3714 1090
11e52000
JB
1091The main advantage is that this completion is more accurate: only
1092existing identifier will be suggested.
00ce3714 1093
11e52000
JB
1094On the other hand, this completion is a little bit slower and requires
1095that you have compiled your file at least once since you created that
00ce3714
GM
1096identifier.
1097
00ce3714 1098@table @kbd
2e78ad14 1099@item C-@key{TAB}
de803500 1100@findex ada-complete-identifier
11e52000 1101Complete current identifier using cross-reference information.
00ce3714 1102@item M-/
2e78ad14 1103Complete identifier using buffer information (not Ada-specific).
00ce3714
GM
1104@end table
1105
11e52000 1106@node Automatic Smart Indentation, Formatting Parameter Lists, Identifier completion, Top
00ce3714 1107@chapter Automatic Smart Indentation
00ce3714 1108
11e52000
JB
1109Ada mode comes with a full set of rules for automatic indentation. You
1110can also configure the indentation, via the following variables:
00ce3714 1111
2e78ad14
RS
1112@table @asis
1113@item @code{ada-broken-indent} (default value: 2)
1114Number of columns to indent the continuation of a broken line.
00ce3714 1115
2e78ad14 1116@item @code{ada-indent} (default value: 3)
11e52000 1117Number of columns for default indentation.
00ce3714 1118
2e78ad14
RS
1119@item @code{ada-indent-record-rel-type} (default value: 3)
1120Indentation for @code{record} relative to @code{type} or @code{use}.
00ce3714 1121
2e78ad14
RS
1122@item @code{ada-indent-return} (default value: 0)
1123Indentation for @code{return} relative to @code{function} (if
1124@code{ada-indent-return} is greater than 0), or the open parenthesis
11e52000 1125(if @code{ada-indent-return} is negative or 0). Note that in the second
2e78ad14
RS
1126case, when there is no open parenthesis, the indentation is done
1127relative to @code{function} with the value of @code{ada-broken-indent}.
00ce3714 1128
2e78ad14
RS
1129@item @code{ada-label-indent} (default value: -4)
1130Number of columns to indent a label.
00ce3714 1131
2e78ad14
RS
1132@item @code{ada-stmt-end-indent} (default value: 0)
1133Number of columns to indent a statement @code{end} keyword on a separate line.
00ce3714 1134
2e78ad14
RS
1135@item @code{ada-when-indent} (default value: 3)
1136Indentation for @code{when} relative to @code{exception} or @code{case}.
00ce3714 1137
2e78ad14
RS
1138@item @code{ada-indent-is-separate} (default value: t)
1139Non-@code{nil} means indent @code{is separate} or @code{is abstract} if on a single line.
00ce3714 1140
2e78ad14
RS
1141@item @code{ada-indent-to-open-paren} (default value: t)
1142Non-@code{nil} means indent according to the innermost open parenthesis.
00ce3714 1143
11e52000
JB
1144@item @code{ada-indent-after-return} (default value: t)
1145Non-@code{nil} means that the current line will also be re-indented
1146before inserting a newline, when you press @key{RET}.
00ce3714
GM
1147@end table
1148
11e52000
JB
1149Most of the time, the indentation will be automatic, i.e when you
1150press @key{RET}, the cursor will move to the correct column on the
00ce3714
GM
1151next line.
1152
11e52000 1153You can also indent single lines, or the current region, with @key{TAB}.
00ce3714 1154
2e78ad14
RS
1155Another mode of indentation exists that helps you to set up your
1156indentation scheme. If you press @kbd{C-c @key{TAB}}, Ada mode will do
1157the following:
1158
00ce3714 1159@itemize @bullet
2e78ad14
RS
1160@item
1161Reindent the current line, as @key{TAB} would do.
1162@item
1163Temporarily move the cursor to a reference line, i.e., the line that
1164was used to calculate the current indentation.
1165@item
11e52000
JB
1166Display in the message window the name of the variable that provided
1167the offset for the indentation.
00ce3714
GM
1168@end itemize
1169
1170The exact indentation of the current line is the same as the one for the
1171reference line, plus an offset given by the variable.
1172
00ce3714 1173@table @kbd
2e78ad14
RS
1174@item @key{TAB}
1175Indent the current line or the current region.
718fb8a1 1176@item C-M-\
11e52000 1177Indent lines in the current region.
2e78ad14 1178@item C-c @key{TAB}
11e52000 1179Indent the current line and display the name of the variable used for
00ce3714
GM
1180indentation.
1181@end table
1182
00ce3714
GM
1183@node Formatting Parameter Lists, Automatic Casing, Automatic Smart Indentation, Top
1184@chapter Formatting Parameter Lists
00ce3714
GM
1185
1186@table @kbd
2e78ad14 1187@item C-c C-f
de803500 1188@findex ada-format-paramlist
2e78ad14 1189Format the parameter list (@code{ada-format-paramlist}).
00ce3714
GM
1190@end table
1191
11e52000
JB
1192This aligns the declarations on the colon (@samp{:}) separating
1193argument names and argument types, and aligns the @code{in},
1194@code{out} and @code{in out} keywords.
1195
00ce3714
GM
1196@node Automatic Casing, Statement Templates, Formatting Parameter Lists, Top
1197@chapter Automatic Casing
00ce3714 1198
11e52000
JB
1199Casing of identifiers, attributes and keywords is automatically
1200performed while typing when the variable @code{ada-auto-case} is set.
1201Every time you press a word separator, the previous word is
00ce3714
GM
1202automatically cased.
1203
11e52000
JB
1204You can customize the automatic casing differently for keywords,
1205attributes and identifiers. The relevant variables are the following:
1206@code{ada-case-keyword}, @code{ada-case-attribute} and
00ce3714
GM
1207@code{ada-case-identifier}.
1208
1209All these variables can have one of the following values:
1210
2e78ad14 1211@table @code
00ce3714 1212@item downcase-word
11e52000
JB
1213The word will be lowercase. For instance @code{My_vARIable} is
1214converted to @code{my_variable}.
00ce3714
GM
1215
1216@item upcase-word
11e52000
JB
1217The word will be uppercase. For instance @code{My_vARIable} is
1218converted to @code{MY_VARIABLE}.
00ce3714
GM
1219
1220@item ada-capitalize-word
11e52000
JB
1221The first letter and each letter following an underscore (@samp{_})
1222are uppercase, others are lowercase. For instance @code{My_vARIable}
1223is converted to @code{My_Variable}.
00ce3714
GM
1224
1225@item ada-loose-case-word
11e52000
JB
1226Characters after an underscore @samp{_} character are uppercase,
1227others are not modified. For instance @code{My_vARIable} is converted
1228to @code{My_VARIable}.
00ce3714
GM
1229@end table
1230
11e52000
JB
1231Ada mode allows you to define exceptions to these rules, in a file
1232specified by the variable variable @code{ada-case-exception-file}
1233(default @file{~/.emacs_case_exceptions}). Each line in this file
1234specifies the casing of one word or word fragment. Comments may be
1235included, separated from the word by a space.
00ce3714 1236
11e52000
JB
1237If the word starts with an asterisk (@key{*}), it defines the casing
1238af a word fragemnt (or ``substring''); part of a word between two
1239underscores or word boundary.
00ce3714 1240
11e52000 1241For example:
00ce3714
GM
1242
1243@example
1244DOD Department of Defense
11e52000 1245*IO
00ce3714
GM
1246GNAT The GNAT compiler from Ada Core Technologies
1247@end example
1248
11e52000
JB
1249The word fragment @code{*IO} applies to any word containing ``_io'';
1250@code{Text_IO}, @code{Hardware_IO}, etc.
00ce3714 1251
de803500 1252@findex ada-create-case-exception
11e52000
JB
1253There are two ways to add new items to this file: you can simply edit
1254it as you would edit any text file. Or you can position point on the
1255word you want to add, and select menu @samp{Ada | Edit | Create Case
1256Exception}, or press @kbd{C-c C-y} (@code{ada-create-case-exception}).
1257The word will automatically be added to the current list of exceptions
1258and to the file.
1259
1260To define a word fragment case exception, select the word fragment,
1261then select menu @samp{Ada | Edit | Create Case Exception Substring}.
1262
1263It is sometimes useful to have multiple exception files around (for
1264instance, one could be the standard Ada acronyms, the second some
1265company specific exceptions, and the last one some project specific
1266exceptions). If you set up the variable @code{ada-case-exception-file}
1267as a list of files, each of them will be parsed and used in your emacs
1268session. However, when you save a new exception through the menu, as
1269described above, the new exception will be added to the first file in
1270the list.
2e78ad14 1271
00ce3714
GM
1272@table @kbd
1273@item C-c C-b
de803500
EZ
1274@findex ada-adjust-case-buffer
1275Adjust case in the whole buffer (@code{ada-adjust-case-buffer}).
00ce3714
GM
1276@item C-c C-y
1277Create a new entry in the exception dictionary, with the word under
de803500 1278the cursor (@code{ada-create-case-exception})
00ce3714 1279@item C-c C-t
de803500 1280@findex ada-case-read-exceptions
00ce3714 1281Rereads the exception dictionary from the file
de803500 1282@code{ada-case-exception-file} (@code{ada-case-read-exceptions}).
00ce3714
GM
1283@end table
1284
00ce3714
GM
1285@node Statement Templates, Comment Handling, Automatic Casing, Top
1286@chapter Statement Templates
00ce3714 1287
11e52000
JB
1288Templates are defined for most Ada statements, using the Emacs
1289``skeleton'' package. They can be inserted in the buffer using the
1290following commands:
00ce3714
GM
1291
1292@table @kbd
1293@item C-c t b
de803500
EZ
1294@findex ada-exception-block
1295exception Block (@code{ada-exception-block}).
00ce3714 1296@item C-c t c
de803500
EZ
1297@findex ada-case
1298case (@code{ada-case}).
00ce3714 1299@item C-c t d
de803500
EZ
1300@findex ada-declare-block
1301declare Block (@code{ada-declare-block}).
00ce3714 1302@item C-c t e
de803500
EZ
1303@findex ada-else
1304else (@code{ada-else}).
00ce3714 1305@item C-c t f
de803500
EZ
1306@findex ada-for-loop
1307for Loop (@code{ada-for-loop}).
00ce3714 1308@item C-c t h
de803500
EZ
1309@findex ada-header
1310Header (@code{ada-header}).
00ce3714 1311@item C-c t i
de803500
EZ
1312@findex ada-if
1313if (@code{ada-if}).
00ce3714 1314@item C-c t k
de803500
EZ
1315@findex ada-package-body
1316package Body (@code{ada-package-body}).
00ce3714 1317@item C-c t l
de803500
EZ
1318@findex ada-loop
1319loop (@code{ada-loop}).
1320@item C-c p
1321@findex ada-subprogram-body
1322subprogram body (@code{ada-subprogram-body}).
00ce3714 1323@item C-c t t
de803500
EZ
1324@findex ada-task-body
1325task Body (@code{ada-task-body}).
00ce3714 1326@item C-c t w
de803500
EZ
1327@findex ada-while
1328while Loop (@code{ada-while}).
00ce3714 1329@item C-c t u
de803500
EZ
1330@findex ada-use
1331use (@code{ada-use}).
00ce3714 1332@item C-c t x
de803500
EZ
1333@findex ada-exit
1334exit (@code{ada-exit}).
00ce3714 1335@item C-c t C-a
de803500
EZ
1336@findex ada-array
1337array (@code{ada-array}).
00ce3714 1338@item C-c t C-e
de803500
EZ
1339@findex ada-elsif
1340elsif (@code{ada-elsif}).
00ce3714 1341@item C-c t C-f
de803500
EZ
1342@findex ada-function-spec
1343function Spec (@code{ada-function-spec}).
00ce3714 1344@item C-c t C-k
de803500
EZ
1345@findex ada-package-spec
1346package Spec (@code{ada-package-spec}).
00ce3714 1347@item C-c t C-p
de803500
EZ
1348@findex ada-procedure-spec
1349procedure Spec (@code{ada-package-spec}.
00ce3714 1350@item C-c t C-r
de803500
EZ
1351@findex ada-record
1352record (@code{ada-record}).
00ce3714 1353@item C-c t C-s
de803500
EZ
1354@findex ada-subtype
1355subtype (@code{ada-subtype}).
00ce3714 1356@item C-c t C-t
de803500
EZ
1357@findex ada-task-spec
1358task Spec (@code{ada-task-spec}).
00ce3714 1359@item C-c t C-u
de803500
EZ
1360@findex ada-with
1361with (@code{ada-with}).
00ce3714 1362@item C-c t C-v
de803500
EZ
1363@findex ada-private
1364private (@code{ada-private}).
00ce3714 1365@item C-c t C-w
de803500
EZ
1366@findex ada-when
1367when (@code{ada-when}).
00ce3714 1368@item C-c t C-x
de803500
EZ
1369@findex ada-exception
1370exception (@code{ada-exception}).
00ce3714 1371@item C-c t C-y
de803500
EZ
1372@findex ada-type
1373type (@code{ada-type}).
00ce3714
GM
1374@end table
1375
11e52000 1376@node Comment Handling, Index, Statement Templates, Top
00ce3714 1377@chapter Comment Handling
00ce3714
GM
1378
1379By default, comment lines get indented like Ada code. There are a few
1380additional functions to handle comments:
1381
00ce3714
GM
1382@table @kbd
1383@item M-;
1384Start a comment in default column.
1385@item M-j
1386Continue comment on next line.
2e78ad14 1387@item C-c ;
00ce3714
GM
1388Comment the selected region (add -- at the beginning of lines).
1389@item C-c :
1390Uncomment the selected region
1391@item M-q
1392autofill the current comment.
1393@end table
1394
11e52000 1395@node Index, , Comment Handling, Top
de803500
EZ
1396@unnumbered Index
1397
1398@printindex fn
1399
00ce3714
GM
1400@contents
1401@bye
ab5796a9
MB
1402
1403@ignore
1404 arch-tag: 68cf0d8a-55cc-4190-a28d-4984fa56ed1e
1405@end ignore