Add a paragraph for non-ASCII examples at the head. Add
[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
8ba00a55
GM
5@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6@comment The following lines inserts the copyright notice
7@comment into the Info file.
8@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00ce3714 9
18f952d5 10@copying
b65d8176 11Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004,
b223e22d 122005, 2006 Free Software Foundation, Inc.
00ce3714 13
18f952d5 14@quotation
8ba00a55 15Permission is granted to copy, distribute and/or modify this document
678e7c71 16under the terms of the GNU Free Documentation License, Version 1.2 or
8ba00a55
GM
17any later version published by the Free Software Foundation; with the
18Invariant Sections being ``The GNU Manifesto'', ``Distribution'' and
19``GNU GENERAL PUBLIC LICENSE'', with the Front-Cover texts being ``A GNU
20Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
21license is included in the section entitled ``GNU Free Documentation
22License'' in the Emacs manual.
00ce3714 23
8ba00a55
GM
24(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
25this GNU Manual, like GNU software. Copies published by the Free
26Software Foundation raise funds for GNU development.''
00ce3714 27
8ba00a55
GM
28This document is part of a collection distributed under the GNU Free
29Documentation License. If you want to distribute this document
30separately from the collection, you can do so by adding a copy of the
31license to the document, as described in section 6 of the license.
18f952d5
KB
32@end quotation
33@end copying
8ba00a55 34
18f952d5
KB
35@dircategory Emacs
36@direntry
37* Ada mode: (ada-mode). Emacs mode for editing Ada code.
38@end direntry
00ce3714
GM
39
40@titlepage
41@sp 10
42@title{Ada Mode}
43@sp 2
44@subtitle An Emacs major mode for programming Ada 95 with GNAT
45@subtitle July 1998 for Ada Mode Version 3.0
46@sp 2
00ce3714
GM
47@page
48@vskip 0pt plus 1filll
18f952d5 49@insertcopying
00ce3714
GM
50@end titlepage
51
8ba00a55 52
00ce3714
GM
53@node Top, Overview, (dir), (dir)
54
55@menu
56* Overview::
2e78ad14
RS
57* Installation:: Installing Ada mode on your system
58* Customization:: Setting up Ada mode to your taste
00ce3714
GM
59* Project files:: Describing the organization of your project
60* Syntax highlighting:: Using specific colors and fonts to highlight
61 the structure of your files
62* Moving Through Ada Code:: Moving easily through Ada sources
63* Identifier completion:: Finishing words automatically
64* Index Menu of Subprograms:: A menu of all the types and subprograms
65 defined in your application
66* File Browser:: Easy access to your files
67* Automatic Smart Indentation:: Indenting your code automatically as you type
28665d46 68* Formatting Parameter Lists:: Formatting subprograms' parameter lists
00ce3714
GM
69 automatically
70* Automatic Casing:: Adjusting the case of words automatically
71* Statement Templates:: Inserting code templates
72* Comment Handling:: Reformatting comments easily
73* Compiling Executing:: Working with your application within Emacs
74* Debugging:: Debugging your application
75* Using non-standard file names:: Configuring Emacs for special file names
76* Working Remotely:: Working on a different machine
de803500 77* Index::
00ce3714
GM
78@end menu
79
80
81@c -----------------------------------------------------------------------
82@node Overview, Installation, Top, Top
83@chapter Overview
84@c -----------------------------------------------------------------------
85
86The Emacs mode for programming in Ada 95 with GNAT helps the user in
87understanding existing code and facilitates writing new code. It
88furthermore provides some utility functions for easier integration of
89standard Emacs features when programming in Ada.
90
91@section General features:
92
93@itemize @bullet
2e78ad14
RS
94@item
95full Integrated Development Environment:
00ce3714 96@itemize @bullet
2e78ad14
RS
97@item
98support of ``project files'' for the configuration (directories,
00ce3714 99compilation options,...)
2e78ad14
RS
100@item
101compiling and stepping through error messages.
102@item
103running and debugging your applications within Emacs.
00ce3714 104@end itemize
2e78ad14
RS
105@item
106easy to use for beginners by pull-down menus,
107@item
108user configurable by many user-option variables.
00ce3714
GM
109@end itemize
110
111@section Ada mode features that help understanding code:
112
113@itemize @bullet
2e78ad14
RS
114@item
115functions for easy and quick stepping through Ada code,
116@item
117getting cross reference information for identifiers (e.g. find the
00ce3714 118defining place by a keystroke),
2e78ad14
RS
119@item
120displaying an index menu of types and subprograms and move point to
00ce3714 121the chosen one,
2e78ad14
RS
122@item
123automatic color highlighting of the various entities in Ada code.
00ce3714
GM
124@end itemize
125
126@section Emacs support for writing Ada code:
127
128@itemize @bullet
2e78ad14
RS
129@item
130switching between spec and body files with eventually
00ce3714 131auto-generation of body files,
2e78ad14 132@item
28665d46 133automatic formatting of subprograms' parameter lists.
2e78ad14
RS
134@item
135automatic smart indentation according to Ada syntax,
136@item
137automatic completion of identifiers,
138@item
139automatic casing of identifiers, keywords, and attributes,
140@item
141insertion of statement templates,
142@item
143filling comment paragraphs like filling normal text,
00ce3714
GM
144@end itemize
145
146@c -----------------------------------------------------------------------
147@node Installation, Customization, Overview, Top
148@chapter Installation
149@c -----------------------------------------------------------------------
150
2e78ad14 151If you got Ada mode as a separate distribution, you should have a
00ce3714
GM
152look at the @file{README} file. It explains the basic steps necessary
153for a good installation of the emacs Ada mode.
154
155Installing the Ada mode is basically just a matter of copying a few
156files into the Emacs library directories. Every time you open a file
157with a file extension of @file{.ads} or @file{.adb}, Emacs will
2e78ad14 158automatically load and activate Ada mode.
00ce3714 159
744e59f6 160@xref{Using non-standard file names}, if your files do
00ce3714
GM
161not use these extensions and if you want Emacs to automatically start the
162Ada mode every time you edit an Ada file.
163
744e59f6 164Also, for general usage variables that you might want to set,
177c0ea7 165see
744e59f6
RC
166@iftex
167@cite{The GNU Emacs Manual}.
168@end iftex
169@ifhtml
170@cite{The GNU Emacs Manual}.
171@end ifhtml
172@ifinfo
173@ref{Top, , The GNU Emacs Manual, emacs, The GNU Emacs Manual}.
174@end ifinfo
00ce3714
GM
175
176@c ---------------------------------------------------------------------
177@section Required files
178@c ---------------------------------------------------------------------
179
180This Ada mode works best with Emacs 20.3 or higher (the easy editing
181features for the project files won't work with any older version), but
182most of the commands should work with older versions too. Please try to
183install the most recent version of Emacs on your system before
2e78ad14 184installing Ada mode.
00ce3714 185
2e78ad14 186Although part of Ada mode is compiler-independent, the most advanced
00ce3714
GM
187features are specific to the Gnat compiler @url{http://www.gnat.com}.
188
189The following files are provided with the Ada mode distribution:
190
191@itemize @bullet
192
2e78ad14
RS
193@item
194@file{ada-mode.el}: The main file for Ada mode.
00ce3714
GM
195This is the only file which does not require Gnat. It contains the
196functions for indentation, formatting of parameter lists, stepping
197through code, comment handling and automatic casing. Emacs versions
19820.2 and higher already contain Ada mode version 2.27, which is an older
199version of this file and should be replaced. Loading @file{ada-mode.el}
200from the current distribution supersedes the standard installation.
201
2e78ad14
RS
202@item
203@file{ada-stmt.el}: Contains the statement templates feature.
00ce3714 204
2e78ad14
RS
205@item
206@file{ada-xref.el}: This file provides the main support for Gnat.
00ce3714
GM
207This is where the functions for cross-references, completion of
208identifiers, support for project files and compilation of your
209application are defined.
210
2e78ad14
RS
211@item
212@file{ada-prj.el}: The functions to use for easy-edition of the
213project files. This file is the only one which really requires Emacs
214at least 20.2. It uses the new widget features from Emacs.
00ce3714
GM
215
216@end itemize
217
218@c --------------------------------------------------------------------
219@node Customization, Project files, Installation, Top
2e78ad14 220@chapter Customizing Ada mode
00ce3714
GM
221@c ---------------------------------------------------------------------
222
2e78ad14 223Ada mode is fully customizable. Everything, from the file names to
00ce3714
GM
224the automatic indentation and the automatic casing can be adapted to
225your own needs.
226
227There are two different kinds of variables that control this
228customization, both are easy to modify.
229
230The first set of variables are standard Emacs variables. Of course, some
2e78ad14 231are defined only for Ada mode, whereas others have a more general
00ce3714
GM
232meaning in Emacs. Please see the Emacs documentation for more
233information on the latest. In this documentation, we will detail all the
2e78ad14 234variables that are specific to Ada mode, and a few others. The names
00ce3714
GM
235will be given, as in @code{ada-case-identifier}.
236
237Emacs provides an easy way to modify them, through a special mode called
238customization. To access this mode, select the menu
2e78ad14 239@samp{Ada->Customize}. This will open a new buffer with some fields that
00ce3714
GM
240you can edit. For instance, you will get something like:
241@example
242Put below the compiler switches.
243comp_opt= _____________________________________
244@end example
245The first line gives a brief description of the variable. The second
246line is the name of the variable and the field where you can give a
247value for this variable. Simply type what you want in the field.
248
249When you are finished modifying the variables, you can simply click on
250the @b{Save for future sessions} button at the top of the buffer (click
251with the middle mouse button). This will save the values in your
252@file{.emacs} file, so that next time you start Emacs they will have the
253same values.
254
255To modify a specific variable, you can directly call the function
2e78ad14
RS
256@code{customize-variable} from Emacs (just type @kbd{M-x
257customize-variable @key{RET} @var{variable-name} @key{RET}}).
00ce3714
GM
258
259Some users might prefer to modify the variables directly in their
260configuration file, @file{.emacs}. This file is coded in Emacs lisp, and
261the syntax to set a variable is the following:
262@example
263(setq variable-name value)
264@end example
265
266The second set of variables for customization are set through the use of
267project files. These variables are specific to a given project, whereas
268the first set was more general. For more information, please
269@xref{Project files}.
270
271@c ---------------------------------------------------------------------
272@node Project files, Syntax highlighting, Customization, Top
273@chapter Project files
274@c ---------------------------------------------------------------------
275
276@c ---------------------------------------------------------------------
277@section General overview
278@c ---------------------------------------------------------------------
279
280Emacs provides a full Integrated Development Environment for GNAT and
281Ada programmers. That is to say, editing, compiling, executing and
282debugging can be performed within Emacs in a convenient and natural way.
283
284To take full advantage of this features, it is possible to create a file
2e78ad14 285in the main directory of your application, with a @samp{.adp} extension.
00ce3714
GM
286This file contain all needed information dealing with the way your
287application is organized between directories, the commands to compile,
288run and debug it etc. Creating this file is not mandatory and convenient
289defaults are automatically provided for simple setups. It only becomes
290necessary when those above mentioned defaults need customizing.
291
292A simple way to edit this file is provided for Emacs 20.2 or newer, with
293the following functions, that you can access also through the Ada
294menu. It is also possible to edit the project file as a regular text
295file.
296
297Once in the buffer for editing the project file, you can save your
2e78ad14 298modification using the @samp{[OK]} button at the bottom of the buffer, or
00ce3714 299simply use the usual @kbd{C-x C-s} binding. To cancel your
2e78ad14 300modifications, simply kill the buffer or click on the @samp{[CANCEL]} button
00ce3714
GM
301at the button.
302
303Each buffer using Ada mode will be associated with one project file when
304there is one available, so that Emacs can easily navigate through
305related source files for instance.
306
307The exact algorithm to determine which project file should be used is
308described in the next section, but you can force the project file you
309want to use by setting one or two variables in your @file{.emacs} file.
310
311@itemize @bullet
2e78ad14
RS
312@item
313To set up a default project file to use for any directory, anywhere
00ce3714
GM
314on your system, set the variable @code{ada-prj-default-project-file} to
315the name of that file.
2e78ad14 316
00ce3714 317@example
2e78ad14 318(set 'ada-prj-default-project-file "/dir1/dir2/file")
00ce3714
GM
319@end example
320
2e78ad14
RS
321@item
322For finer control, you can set a per-directory project file.
00ce3714 323This is done through the variable @code{ada-xref-default-prj-file}.
2e78ad14 324
00ce3714
GM
325@example
326 (set 'ada-xref-default-prj-file
327 '(("/dir1/dir2" . "/dir3/file1")
328 ("/dir4/dir5" . "/dir6/file2")))
329@end example
2e78ad14 330
00ce3714
GM
331Note: This has a higher priority than the first variable, so the first
332choice is to use this variable settings, and otherwise
333@code{ada-prj-default-project-file}.
334@end itemize
335
336
337@table @kbd
2e78ad14 338@item C-c u
de803500 339@findex ada-customize
2e78ad14 340Create or edit the project file for the current buffer (@code{ada-customize}).
177c0ea7 341@item C-c c
de803500 342@findex ada-change-prj
2e78ad14 343Change the project file associated with the current Ada buffer (@code{ada-change-prj}).
00ce3714 344@item C-c d
de803500
EZ
345@findex ada-change-default-project
346Change the default project file for the current directory
347(@code{ada-change-default-project}). Every new file opened from this
348directory will be associated with that file by default.
2e78ad14 349@item ada-set-default-project-file
de803500 350@findex ada-set-default-project-file
00ce3714
GM
351Set the default project file to use for *any* Ada file opened anywhere
352on your system. This sets this file only for the current Emacs session.
353@end table
354
355@c ---------------------------------------------------------------------
356@section Project file variables
357@c ---------------------------------------------------------------------
358
359The following variables can be defined in a project file. They all have
360a default value, so that small projects do not need to create a project
361file.
362
363Some variables below can be referenced in other variables, using a
364shell-like notation. For instance, if the variable @code{comp_cmd}
365contains a sequence like @code{$@{comp_opt@}}, the value of that variable
366will be substituted.
367
368Here is the list of variables:
369
2e78ad14
RS
370@table @asis
371@item @code{src_dir} [default: @code{"./"}]
372This is a list of directories where Ada mode will look for source
00ce3714
GM
373files. These directories are used mainly in two cases, both as a switch
374for the compiler and for the cross-references.
375
2e78ad14
RS
376@item @code{obj_dir} [default: @code{"./"}]
377This is a list of directories where to look for object and library
378files. The library files are the @samp{.ali} files generated by Gnat
379and that contain cross-reference informations.
00ce3714 380
2e78ad14 381@item @code{comp_opt} [default: @code{""}]
00ce3714
GM
382Creates a variable which can be referred to subsequently by using the
383@code{$@{comp_opt@}} notation. This is intended to store the default
2e78ad14 384switches given to @command{gnatmake} and @command{gcc}.
00ce3714 385
2e78ad14 386@item @code{bind_opt=@var{switches}} [default: @code{""}]
00ce3714
GM
387Creates a variable which can be referred to subsequently by using the
388@code{$@{bind_opt@}} notation. This is intended to store the default
2e78ad14 389switches given to @command{gnatbind}.
00ce3714 390
2e78ad14 391@item @code{link_opt=@var{switches}} [default: @code{""}]
00ce3714
GM
392Creates a variable which can be referred to subsequently by using the
393@code{$@{link_opt@}} notation. This is intended to store the default
2e78ad14 394switches given to @command{gnatlink}.
00ce3714 395
2e78ad14 396@item @code{main=@var{executable}} [default: @code{""}]
00ce3714
GM
397Specifies the name of the executable for the application. This variable
398can be referred to in the following lines by using the @code{$@{main@}}
399notation.
400
2e78ad14 401@item @code{cross_prefix=@var{prefix}} [default: @code{""}]
00ce3714
GM
402This variable should be set if you are working in a cross-compilation
403environment. This is the prefix used in front of the gnatmake commands.
404
2e78ad14
RS
405@item @code{remote_machine=@var{machine}} [default: @code{""}]
406This is the name of the machine to log into before issuing the
407compilation command. If this variable is empty, the command will be
408run on the local machine. This will not work on Windows NT machines,
409since Ada mode will simply precede the compilation command with a
410@command{rsh} command, unknown on Windows.
00ce3714 411
2e78ad14 412@item @code{comp_cmd=@var{command}} [default: @code{"$@{cross_prefix@}gcc -c -I$@{src_dir@} -g -gnatq"}]
00ce3714
GM
413Specifies the command used to compile a single file in the application.
414The name of the file will be added at the end of this command.
415
2e78ad14 416@item @code{make_cmd=@var{command}} [default: @code{"$@{cross_prefix@}gnatmake $@{main@} -aI$@{src_dir@} -aO$@{obj_dir@} -g -gnatq -cargs $@{comp_opt@} -bargs $@{bind_opt@} -largs $@{link_opt@}"]}'
00ce3714
GM
417Specifies the command used to recompile the whole application.
418
2e78ad14 419@item @code{run_cmd=@var{command}} [default: @code{"$@{main@}"}]
00ce3714
GM
420Specifies the command used to run the application.
421
2e78ad14 422@item @code{debug_cmd=@var{command}} [default: @code{"$@{cross_prefix@}gdb $@{main@}"}]
00ce3714
GM
423Specifies the command used to debug the application
424
425@end table
426
427@c ---------------------------------------------------------------------
428@section Detailed algorithm
429@c ---------------------------------------------------------------------
430
431This section gives more details on the project file setup and is only of
432interest for advanced users.
433
434Usually, an Ada file is part of a larger application, whose sources and
435objects can be spread over multiple directories. The first time emacs is
436asked to compile, run or debug an application, or when a cross reference
437function is used (goto declaration for instance), the following steps
438are taken:
439
440@itemize @bullet
2e78ad14
RS
441@item
442find the appropriate project file, open and parse it.
00ce3714
GM
443All the fields read in the project file are then stored by emacs
444locally. Finding the project file requires a few steps:
445
446@itemize @minus
2e78ad14
RS
447@item
448if a file from the same directory was already associated with
00ce3714
GM
449a project file, use the same one. This is the variable
450@code{ada-xref-default-prj-file} described above.
2e78ad14
RS
451@item
452if the variable @code{ada-prj-default-project-file} is set,
00ce3714 453use the project file specified in this variable.
2e78ad14
RS
454@item
455if there is a project file whose name is the same as the source file
456except for the suffix, use this one.
457@item
458if there's only one project file in the source directory, use
00ce3714 459that one.
2e78ad14
RS
460@item
461if there are more than one project file in the source directory,
00ce3714 462ask the user.
2e78ad14
RS
463@item
464if there are no project files in the source directory use standard
00ce3714
GM
465default values.
466@end itemize
467
468The first project file that is selected in a given directory becomes the
469default project file for this directory and is used implicitly for other
470sources unless specified otherwise by the user.
471
2e78ad14 472@item
1cd0f7e3 473look for the corresponding @samp{.ali} file in the @code{obj_dir} defined
00ce3714
GM
474in the project file. If this file can not be found, emacs proposes to
475compile the source using the @code{comp_cmd} defined in the project file
476in order to create the ali file.
477
2e78ad14 478@item
1cd0f7e3 479when cross referencing is requested, the @samp{.ali} file is parsed to
00ce3714 480determine the file and line of the identifier definition. It is
1cd0f7e3
EZ
481possible for the @samp{.ali} file to be older than the source file,
482in which case it will be recompiled if the variable
483@code{ada-xref-create-ali} is set, otherwise the reference is searched
484in the obsolete ali file with possible inaccurate results.
00ce3714 485
2e78ad14
RS
486@item
487look for the file containing the declaration using the source
00ce3714
GM
488path @code{src_dir} defined in the project file. Put the cursor at the
489correct position and display this new cursor.
490@end itemize
491
492@c -----------------------------------------------------------------------
493@node Syntax highlighting, Moving Through Ada Code, Project files, Top
494@chapter Syntax highlighting
495@c -----------------------------------------------------------------------
496
2e78ad14 497Ada mode is made to help you understand the structure of your source
00ce3714
GM
498files. Some people like having colors or different fonts depending on
499the context: commands should be displayed differently than keywords,
2e78ad14 500which should also be different from strings, @dots{}
00ce3714
GM
501
502Emacs is able to display in a different way the following syntactic
503entities:
504
505@itemize @bullet
506@item keywords
507@item commands
508@item strings
509@item gnatprep statements (preprocessor)
510@item types (under certain conditions)
511@item other words
512@end itemize
513
514This is not the default behavior for Emacs. You have to explicitly
515activate it. This requires that you add a new line in your @file{.emacs}
516file (if this file does not exist, just create it).
517
518@example
2e78ad14 519(global-font-lock-mode t)
00ce3714
GM
520@end example
521
522But the default colors might not be the ones you like. Fortunately,
523there is a very easy way to change them. Just select the menu
2e78ad14
RS
524@samp{Help->Customize->Specific Face...} and press @key{RET}. This
525will display a buffer will all the ``faces'' (the colors) that Emacs knows
00ce3714
GM
526about. You can change any of them.
527
528
529@c -----------------------------------------------------------------------
530@node Moving Through Ada Code, Identifier completion, Syntax highlighting, Top
531@chapter Moving Through Ada Code
532@c -----------------------------------------------------------------------
533
534There are several easy to use commands to stroll through Ada code. All
535these functions are available through the Ada menu, and you can also use
536the following key bindings or the command names:
537
538@table @kbd
718fb8a1 539@item C-M-e
de803500 540@findex ada-next-procedure
2e78ad14
RS
541Move to the next function/procedure/task, which ever comes next
542(@code{ada-next-procedure}).
718fb8a1 543@item C-M-a
de803500 544@findex ada-previous-procedure
2e78ad14
RS
545Move to previous function/procedure/task
546(@code{ada-previous-procedure}).
547@item M-x ada-next-package
de803500 548@findex ada-next-package
00ce3714 549Move to next package.
2e78ad14 550@item M-x ada-prev-package
de803500 551@findex ada-prev-package
00ce3714 552Move to previous package.
2e78ad14 553@item C-c C-a
de803500 554@findex ada-move-to-start
2e78ad14
RS
555Move to matching start of @code{end} (@code{ada-move-to-start}). If
556point is at the end of a subprogram, this command jumps to the
557corresponding @code{begin} if the user option
558@code{ada-move-to-declaration} is @code{nil} (default), it jumps to
559the subprogram declaration otherwise.
560@item C-c C-e
de803500 561@findex ada-move-to-end
2e78ad14
RS
562Move point to end of current block (@code{ada-move-to-end}).
563@item C-c o
564Switch between corresponding spec and body file
565(@code{ff-find-other-file}). If the cursor is on a subprogram, switch
566between declaration and body.
00ce3714 567@item C-c c-d
de803500 568@findex ada-goto-declaration
00ce3714
GM
569Move from any reference to its declaration and switch between
570declaration and body (for procedures, tasks, private and incomplete
571types).
2e78ad14 572@item C-c C-r
de803500 573@findex ada-find-references
2e78ad14
RS
574runs the @file{gnatfind} command to search for all references to the
575entity pointed by the cursor (@code{ada-find-references}). Use
576@kbd{C-x `} (@code{next-error}) to visit each reference (as for
577compilation errors).
00ce3714
GM
578@end table
579
580These functions use the information in the output of the Gnat Ada
581compiler. However, if your application was compiled with the
2e78ad14 582@samp{-gnatx} switch, these functions will not work, since no extra
00ce3714
GM
583information is generated by GNAT. See GNAT documentation for further
584information.
585
586Emacs will try to run Gnat for you whenever the cross-reference
587informations are older than your source file (provided the
2e78ad14 588@code{ada-xref-create-ali} variable is non-@code{nil}). Gnat then produces a
00ce3714 589file with the same name as the current Ada file but with the extension
2e78ad14 590changed to @file{.ali}. This files are normally used by the binder, but
00ce3714
GM
591they will also contain additional cross-referencing information.
592
593@c -----------------------------------------------------------------------
594@node Identifier completion, Index Menu of Subprograms, Moving Through Ada Code, Top
595@chapter Identifier completion
596@c -----------------------------------------------------------------------
597
598@c -----------------------------------------------------------------------
599@section Overview
600@c -----------------------------------------------------------------------
601
2e78ad14 602Emacs and Ada mode provide two general ways for the completion of
00ce3714
GM
603identifiers. This is an easy way to type faster: you just have to type
604the first few letters of an identifiers, and then loop through all the
605possible completions.
606
607The first method is general for Emacs. It will work both with Ada
2e78ad14 608buffers, but also in C buffers, Java buffers, @enddots{} The idea is to parse
00ce3714
GM
609all the opened buffers for possible completions.
610
2e78ad14
RS
611For instance, if the words @samp{my_identifier}, @samp{my_subprogram}
612are the only words starting with @samp{my} in any of the opened files,
613then you will have this scenario:
614
615@quotation
00ce3714 616You type: my@key{M-/}
2e78ad14
RS
617Emacs inserts: @samp{my_identifier}
618If you press @key{M-/} once again, Emacs replaces @samp{my_identifier} with
619@samp{my_subprogram}.
620Pressing @key{M-/} once more will bring you back to @samp{my_identifier}.
621@end quotation
00ce3714
GM
622
623This is a very fast way to do completion, and the casing of words will
624also be respected.
625
626The second method is specific to Ada buffer, and even to users of the
1cd0f7e3
EZ
627Gnat compiler. Emacs will search the cross-information found in the
628@samp{.ali} files generated by Gnat for possible completions.
00ce3714
GM
629
630The main advantage is that this completion is more accurate: only
631existing identifier will be suggested, you don't need to have a file
2e78ad14 632opened that already contains this identifiers, @enddots{}
00ce3714
GM
633
634On the other hand, this completion is a little bit slower and requires
635that you have compiled your file at least once since you created that
636identifier.
637
638@c -----------------------------------------------------------------------
639@section Summary of commands
640@c -----------------------------------------------------------------------
641
642@table @kbd
2e78ad14 643@item C-@key{TAB}
de803500 644@findex ada-complete-identifier
2e78ad14
RS
645Complete accurately current identifier using information in @samp{.ali} file
646(@code{ada-complete-identifier}).
00ce3714 647@item M-/
2e78ad14 648Complete identifier using buffer information (not Ada-specific).
00ce3714
GM
649@end table
650
651@c -----------------------------------------------------------------------
652@node Index Menu of Subprograms, File Browser, Identifier completion, Top
653@chapter Index Menu of Subprograms
654@c -----------------------------------------------------------------------
655
656You can display a choice menu with all procedure/function/task
657declarations in the file and choose an item by mouse click to get to its
2e78ad14
RS
658declaration. This function is accessible through the @samp{Ada} menu when
659editing a Ada file, or simply through the following key binding:
00ce3714
GM
660
661@table @kbd
6aa73dc4 662@item C-S-Mouse-3
00ce3714
GM
663display index menu
664@end table
665
666@c -----------------------------------------------------------------------
667@node File Browser, Automatic Smart Indentation, Index Menu of Subprograms, Top
668@chapter File Browser
669@c -----------------------------------------------------------------------
670
671Emacs provides a special mode, called @code{speedbar}. When this mode is
672activated, a new frame is displayed, with a file browser. The files from
673the current directory are displayed, and you can click on them as you
674would with any file browser. The following commands are then available.
675
676You can click on a directory name or file name to open it. The editor
677will automatically select the best possible mode for this file,
2e78ad14 678including of course Ada mode for files written in Ada.
00ce3714 679
2e78ad14 680If you click on the @samp{[+]} symbol near a file name, all the symbols (types,
00ce3714
GM
681variables and subprograms) defined in that file will be displayed, and
682you can directly click on them to open the right file at the right
683place.
684
685You can activate this mode by typing @key{M-x speedbar} in the editor.
28665d46 686This will open a new frame. A better way might be to associate the
00ce3714
GM
687following key binding
688
689@example
690(global-set-key [f7] 'speedbar-get-focus)
691@end example
692
2e78ad14 693Every time you press @key{F7}, the mouse will automatically move to the
00ce3714
GM
694speedbar frame (which will be created if it does not exist).
695
696@c -----------------------------------------------------------------------
697@node Automatic Smart Indentation, Formatting Parameter Lists, File Browser, Top
698@chapter Automatic Smart Indentation
699@c -----------------------------------------------------------------------
700
2e78ad14 701Ada mode comes with a full set of rules for automatic indentation.
00ce3714
GM
702You can of course configure the indentation as you want, by setting the
703value of a few variables.
704
705As always, the preferred way to modify variables is to use the
2e78ad14 706@samp{Ada->Customize} menu (don't forget to save your changes!). This
00ce3714
GM
707will also show you some example of code where this variable is used, and
708hopefully make things clearer.
709
710The relevant variables are the following:
711
2e78ad14
RS
712@table @asis
713@item @code{ada-broken-indent} (default value: 2)
714Number of columns to indent the continuation of a broken line.
00ce3714 715
2e78ad14
RS
716@item @code{ada-indent} (default value: 3)
717Width of the default indentation.
00ce3714 718
2e78ad14
RS
719@item @code{ada-indent-record-rel-type} (default value: 3)
720Indentation for @code{record} relative to @code{type} or @code{use}.
00ce3714 721
2e78ad14
RS
722@item @code{ada-indent-return} (default value: 0)
723Indentation for @code{return} relative to @code{function} (if
724@code{ada-indent-return} is greater than 0), or the open parenthesis
725(if @code{ada-indent-return} is negative or null). Note that in the second
726case, when there is no open parenthesis, the indentation is done
727relative to @code{function} with the value of @code{ada-broken-indent}.
00ce3714 728
2e78ad14
RS
729@item @code{ada-label-indent} (default value: -4)
730Number of columns to indent a label.
00ce3714 731
2e78ad14
RS
732@item @code{ada-stmt-end-indent} (default value: 0)
733Number of columns to indent a statement @code{end} keyword on a separate line.
00ce3714 734
2e78ad14
RS
735@item @code{ada-when-indent} (default value: 3)
736Indentation for @code{when} relative to @code{exception} or @code{case}.
00ce3714 737
2e78ad14
RS
738@item @code{ada-indent-is-separate} (default value: t)
739Non-@code{nil} means indent @code{is separate} or @code{is abstract} if on a single line.
00ce3714 740
2e78ad14
RS
741@item @code{ada-indent-to-open-paren} (default value: t)
742Non-@code{nil} means indent according to the innermost open parenthesis.
00ce3714 743
2e78ad14
RS
744@item @code{ada-indent-after-return} (default value: t)
745Non-@code{nil} means that the current line will also be re-indented before
746inserting a newline, when you press @key{RET}.
00ce3714
GM
747@end table
748
749Most of the time, the indentation will be automatic, i.e when you will
2e78ad14 750press @key{RET}, the cursor will move to the correct column on the
00ce3714
GM
751next line.
752
753However, you might want or need sometimes to re-indent the current line
754or a set of lines. For this, you can simply go to that line, or select
2e78ad14 755the lines, and then press @key{TAB}. This will automatically re-indent
00ce3714
GM
756the lines.
757
2e78ad14
RS
758Another mode of indentation exists that helps you to set up your
759indentation scheme. If you press @kbd{C-c @key{TAB}}, Ada mode will do
760the following:
761
00ce3714 762@itemize @bullet
2e78ad14
RS
763@item
764Reindent the current line, as @key{TAB} would do.
765@item
766Temporarily move the cursor to a reference line, i.e., the line that
767was used to calculate the current indentation.
768@item
769Display at the bottom of the window the name of the variable that
770provided the offset for the indentation.
00ce3714
GM
771@end itemize
772
773The exact indentation of the current line is the same as the one for the
774reference line, plus an offset given by the variable.
775
2e78ad14
RS
776Once you know the name of the variable, you can either modify it
777through the usual @samp{Ada->Customize} menu, or by typing @kbd{M-x
778customize-variable @key{RET}} in the Emacs window, and then give the
779name of the variable.
00ce3714
GM
780
781@table @kbd
2e78ad14
RS
782@item @key{TAB}
783Indent the current line or the current region.
718fb8a1 784@item C-M-\
2e78ad14
RS
785Indent lines in the current selected block.
786@item C-c @key{TAB}
787Indent the current line and prints the name of the variable used for
00ce3714
GM
788indentation.
789@end table
790
791
792
793@c -----------------------------------------------------------------------
794@node Formatting Parameter Lists, Automatic Casing, Automatic Smart Indentation, Top
795@chapter Formatting Parameter Lists
796@c -----------------------------------------------------------------------
797
2e78ad14
RS
798To help you correctly align fields in a subprogram parameter list,
799Emacs provides one function that will do most of the work for you.
800This function will align the declarations on the colon (@samp{:})
801separating argument names and argument types, plus align the
802@code{in}, @code{out} and @code{in out} keywords if required.
00ce3714
GM
803
804@table @kbd
2e78ad14 805@item C-c C-f
de803500 806@findex ada-format-paramlist
2e78ad14 807Format the parameter list (@code{ada-format-paramlist}).
00ce3714
GM
808@end table
809
810@c -----------------------------------------------------------------------
811@node Automatic Casing, Statement Templates, Formatting Parameter Lists, Top
812@chapter Automatic Casing
813@c -----------------------------------------------------------------------
814
815Casing of identifiers, attributes and keywords is automatically
816performed while typing when the variable @code{ada-auto-case} is set.
817Every time you press a word separator, the previous word is
818automatically cased.
819
820You can customize the automatic casing differently for keywords,
821attributes and identifiers. The relevant variables are the following:
822@code{ada-case-keyword}, @code{ada-case-attribute} and
823@code{ada-case-identifier}.
824
825All these variables can have one of the following values:
826
2e78ad14 827@table @code
00ce3714
GM
828@item downcase-word
829The previous word will simply be in all lower cases. For instance
830@code{My_vARIable} is converted to @code{my_variable}.
831
832@item upcase-word
833The previous word will be fully converted to upper cases. For instance
834@code{My_vARIable} is converted to @code{MY_VARIABLE}.
835
836@item ada-capitalize-word
837All letters, except the first one of the word and every letter after the
2e78ad14 838@samp{_} character are lower cased. Other letters are upper cased. For
00ce3714
GM
839instance @code{My_vARIable} is converted to @code{My_Variable}.
840
841@item ada-loose-case-word
842No letters is modified in the previous word, except the ones after the
2e78ad14 843@samp{_} character that are upper cased. For instance @code{My_vARIable} is
00ce3714
GM
844converted to @code{My_VARIable}.
845@end table
846
847These functions, although they will work in most cases, will not be
848accurate sometimes. The Ada mode allows you to define some exceptions,
849that will always be cased the same way.
850
851The idea is to create a dictionary of exceptions, and store it in a
852file. This file should contain one identifier per line, with the casing
853you want to force. The default name for this file is
854@file{~/.emacs_case_exceptions}. You can of course change this name,
855through the variable @code{ada-case-exception-file}.
856
857Note that each line in this file must start with the key word whose
858casing you want to specify. The rest of the line can be used for
859comments (explaining for instance what an abbreviation means, as
2e78ad14 860recommended in the Ada 95 Quality and Style, paragraph 3.1.4). Thus, a
00ce3714
GM
861good example for this file could be:
862
863@example
864DOD Department of Defense
865Text_IO
866GNAT The GNAT compiler from Ada Core Technologies
867@end example
868
869When working on project involving multiple programmers, we recommend
870that every member of the team sets this variable to the same value,
871which should point to a system-wide file that each of them can
872write. That way, you will ensure that the casing is consistent
873throughout your application(s).
874
de803500 875@findex ada-create-case-exception
00ce3714
GM
876There are two ways to add new items to this file: you can simply edit it
877as you would edit any text file, and add or suppress entries in this
878file. Remember that you should put one entity per line. The other,
879easier way, is to position the cursor over the word you want to add, in
880an Ada buffer. This word should have the casing you want. Then simply
2e78ad14 881select the menu @samp{Ada->Edit->Create Case Exception}, or the key
de803500
EZ
882@kbd{C-c C-y} (@code{ada-create-case-exception}). The word will
883automatically be added to the current list of exceptions and to the file.
00ce3714
GM
884
885It is sometimes useful to have multiple exception files around (for
886instance, one could be the standard Ada acronyms, the second some
887company specific exceptions, and the last one some project specific
888exceptions). If you set up the variable @code{ada-case-exception-file}
889as a list of files, each of them will be parsed and used in your emacs
890session.
891
892However, when you save a new exception through the menu, as described
893above, the new exception will be added to the first file in the list
894only. You can not automatically add an exception to one of the other
895files, although you can of course edit the files by hand at any time.
896
897Automatic casing can be performed on port or whole buffer using:
2e78ad14 898
00ce3714
GM
899@table @kbd
900@item C-c C-b
de803500
EZ
901@findex ada-adjust-case-buffer
902Adjust case in the whole buffer (@code{ada-adjust-case-buffer}).
00ce3714
GM
903@item C-c C-y
904Create a new entry in the exception dictionary, with the word under
de803500 905the cursor (@code{ada-create-case-exception})
00ce3714 906@item C-c C-t
de803500 907@findex ada-case-read-exceptions
00ce3714 908Rereads the exception dictionary from the file
de803500 909@code{ada-case-exception-file} (@code{ada-case-read-exceptions}).
00ce3714
GM
910@end table
911
912@c -----------------------------------------------------------------------
913@node Statement Templates, Comment Handling, Automatic Casing, Top
914@chapter Statement Templates
915@c -----------------------------------------------------------------------
916
917NOTE: This features are not available on VMS for Emacs 19.28. The
918functions used here do not exist on Emacs 19.28.
919
920Templates exist for most Ada statements. They can be inserted in the
921buffer using the following commands:
922
923@table @kbd
924@item C-c t b
de803500
EZ
925@findex ada-exception-block
926exception Block (@code{ada-exception-block}).
00ce3714 927@item C-c t c
de803500
EZ
928@findex ada-case
929case (@code{ada-case}).
00ce3714 930@item C-c t d
de803500
EZ
931@findex ada-declare-block
932declare Block (@code{ada-declare-block}).
00ce3714 933@item C-c t e
de803500
EZ
934@findex ada-else
935else (@code{ada-else}).
00ce3714 936@item C-c t f
de803500
EZ
937@findex ada-for-loop
938for Loop (@code{ada-for-loop}).
00ce3714 939@item C-c t h
de803500
EZ
940@findex ada-header
941Header (@code{ada-header}).
00ce3714 942@item C-c t i
de803500
EZ
943@findex ada-if
944if (@code{ada-if}).
00ce3714 945@item C-c t k
de803500
EZ
946@findex ada-package-body
947package Body (@code{ada-package-body}).
00ce3714 948@item C-c t l
de803500
EZ
949@findex ada-loop
950loop (@code{ada-loop}).
951@item C-c p
952@findex ada-subprogram-body
953subprogram body (@code{ada-subprogram-body}).
00ce3714 954@item C-c t t
de803500
EZ
955@findex ada-task-body
956task Body (@code{ada-task-body}).
00ce3714 957@item C-c t w
de803500
EZ
958@findex ada-while
959while Loop (@code{ada-while}).
00ce3714 960@item C-c t u
de803500
EZ
961@findex ada-use
962use (@code{ada-use}).
00ce3714 963@item C-c t x
de803500
EZ
964@findex ada-exit
965exit (@code{ada-exit}).
00ce3714 966@item C-c t C-a
de803500
EZ
967@findex ada-array
968array (@code{ada-array}).
00ce3714 969@item C-c t C-e
de803500
EZ
970@findex ada-elsif
971elsif (@code{ada-elsif}).
00ce3714 972@item C-c t C-f
de803500
EZ
973@findex ada-function-spec
974function Spec (@code{ada-function-spec}).
00ce3714 975@item C-c t C-k
de803500
EZ
976@findex ada-package-spec
977package Spec (@code{ada-package-spec}).
00ce3714 978@item C-c t C-p
de803500
EZ
979@findex ada-procedure-spec
980procedure Spec (@code{ada-package-spec}.
00ce3714 981@item C-c t C-r
de803500
EZ
982@findex ada-record
983record (@code{ada-record}).
00ce3714 984@item C-c t C-s
de803500
EZ
985@findex ada-subtype
986subtype (@code{ada-subtype}).
00ce3714 987@item C-c t C-t
de803500
EZ
988@findex ada-task-spec
989task Spec (@code{ada-task-spec}).
00ce3714 990@item C-c t C-u
de803500
EZ
991@findex ada-with
992with (@code{ada-with}).
00ce3714 993@item C-c t C-v
de803500
EZ
994@findex ada-private
995private (@code{ada-private}).
00ce3714 996@item C-c t C-w
de803500
EZ
997@findex ada-when
998when (@code{ada-when}).
00ce3714 999@item C-c t C-x
de803500
EZ
1000@findex ada-exception
1001exception (@code{ada-exception}).
00ce3714 1002@item C-c t C-y
de803500
EZ
1003@findex ada-type
1004type (@code{ada-type}).
00ce3714
GM
1005@end table
1006
1007@c -----------------------------------------------------------------------
1008@node Comment Handling, Compiling Executing, Statement Templates, Top
1009@chapter Comment Handling
1010@c -----------------------------------------------------------------------
1011
1012By default, comment lines get indented like Ada code. There are a few
1013additional functions to handle comments:
1014
1015
1016@table @kbd
1017@item M-;
1018Start a comment in default column.
1019@item M-j
1020Continue comment on next line.
2e78ad14 1021@item C-c ;
00ce3714
GM
1022Comment the selected region (add -- at the beginning of lines).
1023@item C-c :
1024Uncomment the selected region
1025@item M-q
1026autofill the current comment.
1027@end table
1028
1029@c -----------------------------------------------------------------------
1030@node Compiling Executing, Debugging, Comment Handling, Top
1031@chapter Compiling Executing
1032@c -----------------------------------------------------------------------
1033
1034Ada mode provides a much complete environment for compiling, debugging
1035and running an application within Emacs.
1036
1037All the commands used by Emacs to manipulate your application can be
1038customized in the project file. Some default values are provided, but
1039these will likely not be good enough for a big or even medium-sized
1040project. See the section on the project file for an explanation on how
1041to set up the commands to use.
1042
1043One of the variables you can set in your project file,
1044@code{cross_prefix}, indicates whether you are using a cross-compilation
1045environment, and if yes for which target. The default command used for
1046compilation will add this @code{cross_prefix} in front of the name:
1047@code{gcc} will become @code{cross_prefix}-@code{gcc}, @code{gnatmake}
1cd0f7e3 1048will become @code{cross_prefix}-@code{gnatmake}, @enddots{}
00ce3714
GM
1049
1050This will also modify the way your application is run and debugged,
1051although this is not implemented at the moment.
1052
1053Here are the commands for building and using an Ada application
1054
1055@itemize @bullet
1056
1057@item Compiling the current source
1058This command is issued when issuing the @code{compile} command from the
1059Ada menu. It compiles unconditionally the current source using the
1060@code{comp_cmd} variable of the project file. Compilation options can be
1061customized with the variable @code{comp_opt} of the project file.
1062
1063Emacs will display a new buffer that contains the result of the
1064compilation. Each line associated with an error will become active: you
1065can simply click on it with the middle button of the mouse, or move the
2e78ad14 1066cursor on it and press @key{RET}. Emacs will then display the
00ce3714
GM
1067relevant source file and put the cursor on the line and column the error
1068was found at.
1069
1070You can also simply press the @kbd{C-x `} key and Emacs will jump to the
1071first error. If you press that key again, it will move you to the second
1072error, and so on.
1073
1074Some error messages might also include references to some files. These
1075references are also clickable in the same way.
1076
1077
1078@item (Re)building the whole application
1079This command is issued when you select the @code{build} command from the
1080Ada menu. It compiles all obsolete units of the current application
1081using the @code{make_cmd} variable of the project file. Compilation
1082options can be customized with the variable @code{comp_opt} of the
1083project file, binder options with @code{bind_opt} and linker options
1084with @code{link_opt}. The main unit of the application may be specified
1085with @code{main}.
1086
1087The compilation buffer is also active in the same way it was for the above
1088command.
1089
1090@item Running the application
1091This command is issued when you select the @code{run} command from the
1092Ada menu. It executes the current application in an emacs
1093buffer. Arguments can be passed through before executing. The execution
1094buffer allows for interactive input/output.
1095
1096This command is not yet available in a cross-compilation
1097toolchain. Emacs would first need to log on the target before running
1098the application. This will be implemented in a future release of Gnat.
1099
1100@end itemize
1101
1102@c ---------------------------------------------------------------------
1103@node Debugging, Using non-standard file names, Compiling Executing, Top
1104@chapter Debugging your application
1105@c ---------------------------------------------------------------------
1106
1107You can set up in the project file a command to use to debug your
1108application. Emacs is compatible with a lot of debuggers, and provide an
1109easy interface to them.
1110
1111This selection will focus on the gdb debugger, and two of the graphical
1112interfaces that exist for it.
1113
1114In all cases, the main window in Emacs will be split in two: in the
1115upper buffer, the source code will appear, whereas the debugger
1116input/output window is displayed at the bottom. You can enter the
1117debugger commands as usual in the command window. Every time a new
1118source file is selected by the debugger (for instance as a result of a
1119@code{frame} command), the appropriate source file is displayed in the
1120upper buffer.
1121
1122The source window is interactive: you can click on an identifier with the
1123right mouse button, and print its value in the debugger window. You can
1124also set a breakpoint simply by right-clicking on a line.
1125
1126You can easily use Emacs as the source window when you are using a
1127graphical interface for the debugger. The interesting thing is that,
1128whereas you still have the graphical nifties, you can also you the
2e78ad14
RS
1129cross-references features that Ada mode provides to look at the
1130definition for the identifiers, @enddots{}
00ce3714
GM
1131
1132Here is how you can set up gdbtk and ddd for use with Emacs (These are
1133the commands you should setup in the project file):
1134
1135@itemize @bullet
1136@item gdbtk
2e78ad14 1137should be used with the switch @samp{--emacs_gdbtk}. It provides a nice
00ce3714
GM
1138backtrace window, as well as a tasks window. You can click interactively
1139on both of them, and Emacs will display the source file on the correct
1140line.
1141
1142@item ddd (Data Display Debugger)
2e78ad14
RS
1143should be used with the switches @samp{--tty} and
1144@samp{--fullname}. Whenever you print a variable from Emacs, it will
1145be displayed graphically in the data window.
00ce3714
GM
1146
1147@end itemize
1148
1149
1150@c ---------------------------------------------------------------------
1151@node Using non-standard file names, Working Remotely, Debugging, Top
1152@chapter Using non-standard file names
1153@c ---------------------------------------------------------------------
1154
1155By default, Emacs is configured to use the GNAT style file names, where
1156file names are the package names, and the extension for spec and bodies
2e78ad14 1157are respectively @samp{.ads} and @samp{.adb}.
00ce3714
GM
1158
1159If you want to use other types of file names, you will need to modify
2e78ad14 1160your @file{.emacs} file.
00ce3714 1161
2e78ad14 1162Adding new possible extensions is easy. Since Ada mode needs to know
00ce3714 1163how to go from the body to the spec (and back), you always have to
2e78ad14 1164specify both. A function is provided with Ada mode to add new
00ce3714
GM
1165extensions.
1166
2e78ad14
RS
1167For instance, if your spec and bodies files are called
1168@file{@var{unit}_s.ada} and @file{@var{unit}_b.ada}, respectively, you
1169need to add the following to your @file{.emacs} file:
00ce3714
GM
1170
1171@example
1172(ada-add-extensions "_s.ada" "_b.ada")
1173@end example
1174
1175Note that it is possible to redefine the extension, even if they already
1176exist, as in:
1177
1178@example
1179(ada-add-extensions ".ads" "_b.ada")
1180(ada-add-extensions ".ads" ".body")
1181@end example
1182
1183This simply means that whenever the ada-mode will look for the body for
1184a file whose extension is @file{.ads}, it will take the first available
1185file that ends with either @file{.adb} (standard), @file{_b.ada} or
1186@file{.body}.
1187
2e78ad14
RS
1188If the filename is not the unit name, then things are a little more
1189complicated. You then need to rewrite the function
1190@code{ada-make-filename-from-adaname} (see the file @file{ada-mode.el}
1191for an example).
00ce3714
GM
1192
1193@c ---------------------------------------------------------------------
de803500 1194@node Working Remotely, Index, Using non-standard file names, Top
00ce3714
GM
1195@chapter Working Remotely
1196@c ---------------------------------------------------------------------
1197
1198When you work on project that involve a lot of programmers, it is
1199generally the case that you will edit the files on your own machine, but
1200you want to compile, run and debug your application in another buffer.
1201
1202Fortunately, here too Emacs provides a very convenient way to do this.
1203
1204@c ---------------------------------------------------------------------
1205@section Remote editing
1206@c ---------------------------------------------------------------------
1207
1208First of all, the files do not need to be on your machine. Emacs can
1209edit any remote file, by doing transparent FTP sessions between your
1210machine and the remote machine that stores your files. This is a special
1211Emacs mode, called @code{ange-ftp}. To use it, you just have to use a
1212slightly different syntax when you open a file.
1213
2e78ad14 1214For instance, if you want to open the file @file{/work/foo.adb} on the machine
00ce3714
GM
1215aleph.gnu.org, where you log in as qwe, you would simply do this:
1216
2e78ad14
RS
1217@example
1218C-x C-f /qwe@@aleph.gnu.org:/work/foo.adb @key{RET}
00ce3714
GM
1219@end example
1220
2e78ad14
RS
1221@noindent
1222i.e., use your name, the name of the machine and the name of the file.
1223
00ce3714
GM
1224The first time, Emacs will ask you for a password that it will remember
1225until you close the current Emacs. Even if the ftp session times out,
1226you won't need to reenter your password.
1227
1228Every time you save the file, Emacs will upload it to the remote machine
1229transparently. No file is modified on the local machine.
1230
1231@c ---------------------------------------------------------------------
1232@section Remote compiling
1233@c ---------------------------------------------------------------------
1234
1235If the machine you want to compile on is not the one your Emacs is
1236running on, you can set the variable @code{remote_machine} in the
1237project file for your application.
1238
2e78ad14 1239This will force Emacs to issue a @command{rsh} command for the compilation,
00ce3714
GM
1240instead of running it on the local machine. Unfortunately, this won't
1241work on Windows workstations, since this protocol is not supported.
1242
1243@example
1244If your @code{remote_machine} is aleph.gnu.org and the standard
1245compilation command is @code{cd /work/ && gnatmake foo}, then Emacs will
1246actually issue the command @code{rsh aleph.gnu.org 'cd /work/ &&
1247gnatmake foo'}.
1248@end example
1249
1250The advantage of using the @code{remote_machine} variable is that it is
1251easier to change that machine without having to modify the compilation
1252command.
1253
1254Note that if you need to set up some environment variables before the
1255compilation, you need to insert a call to the appropriate initialization
1256script in the compilation command, for instance:
1257
1258@example
2e78ad14 1259build_cmd= initialization_script; cd /work/ && gnatmake foo
00ce3714
GM
1260@end example
1261
1262@c ---------------------------------------------------------------------
1263@section Remote running and debugging
1264@c ---------------------------------------------------------------------
1265
1266This feature is not completely implemented yet.
1267
1268However, most of the time, you will be able to run your application
2e78ad14
RS
1269remotely simply by replacing it with a @command{rsh} call.
1270For instance, if your command was @code{$@{main@}}, you could replace it with
1271@code{rsh aleph.gnu.org $@{main@}}.
00ce3714 1272
2e78ad14
RS
1273However, this would not work on vxworks, for instance, where
1274@command{rsh} is not supported.
00ce3714 1275
de803500
EZ
1276@node Index, , Working Remotely, Top
1277@unnumbered Index
1278
1279@printindex fn
1280
00ce3714
GM
1281@contents
1282@bye
ab5796a9
MB
1283
1284@ignore
1285 arch-tag: 68cf0d8a-55cc-4190-a28d-4984fa56ed1e
1286@end ignore