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