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