This package provides a major mode for GNU Emacs, or XEmacs, to edit files written in the Ada programming language.
It provides:
* Support for project-files
* Auto-casing and auto-indentation
* Support for cross-referencing source code including
cross-references to operators.
Download :
Similar packages:
When the Gnu Ada compiler GNAT is used, the cross-reference information output by the compiler is used to provide powerful code navigation (jump to definition, find all uses, etc).
When you open a file with a file extension of .ads or .adb, Emacs will automatically load and activate Ada mode.
Ada mode works without any customization, if you are using the GNAT compiler (https://libre2.adacore.com/) and the GNAT default naming convention.
You must customize a few things if you are using a different compiler or file naming convention; See Other compiler, See Non-standard file names.
In addition, you may want to customize the indentation, capitalization, and other things; See Other customization.
Finally, for large Ada projects, you will want to set up an Emacs Ada mode project file for each project; See Project files. Note that these are different from the GNAT project files used by gnatmake and other GNAT commands.
See the Emacs info manual, section 'Running Debuggers Under Emacs', for general information on debugging.
Installation.
Ada mode is part of the standard Emacs distribution; if you use that, no files need to be installed.
Ada mode is also available as a separate distribution, from the Emacs Ada mode website http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html. The separate distribution may be more recent.
For installing the separate distribution, see the README file in the distribution.
To see what version of Ada mode you have installed, do M-x ada-mode-version.
The following files are provided with the Ada mode distribution:
Here we assume you are familiar with setting variables in Emacs, either thru 'customize' or in elisp (in your .emacs file). For a basic introduction to customize, elisp, and Emacs in general, see the tutorial in The GNU Emacs Manual.
These global Emacs settings are strongly recommended (put them in your .emacs):
‘(transient-mark-mode t)’ highlights selected text.
See the Emacs help for each of these variables for more information.
Non-standard file names.
By default, Ada mode is configured to use the GNAT file naming convention, where file names are a simple modification of the Ada names, and the extension for specs and bodies are ‘.ads’ and ‘.adb’, respectively.
Ada mode uses the file extentions to allow moving from a package body to the corresponding spec and back.
Ada mode supports a list of alternative file extensions for specs and bodies.
For instance, if your spec and bodies files are called unit_s.ada and unit_b.ada, respectively, you can add the following to your .emacs file:
Simililarly, if Ada mode is looking for a spec, it will look for .ads or _s.ada.
If the filename is not derived from the Ada name following the GNAT convention, things are a little more complicated. You then need to rewrite the function
Other compiler.
By default, Ada mode is configured to use the Gnu Ada compiler GNAT.
To use a different Ada compiler, you must specify the command lines used to run that compiler, either in lisp variables or in Emacs Ada mode project files. See Project file variables for the list of project variables, and the corresponding lisp variables.
Other customization.
All user-settable Ada mode variables can be set via the menu ‘Ada | Customize’. Click on the ‘Help’ button there for help on using customize.
To modify a specific variable, you can directly call the function variable-name ).
Alternately, you can specify variable settings in the Emacs configuration file, .emacs. This file is coded in Emacs lisp, and the syntax to set a variable is the following:
Ada projects can be compiled, linked, and executed using commands on the Ada menu. All of these commands can be customized via a project file (see Project files), but the defaults are sufficient for using the GNAT compiler for simple projects (single files, or several files in a single directory).
Even when no project file is used, the GUI project editor (menu ‘Ada | Project | Edit’) shows the settings of the various project file variables referenced here.
Compile commands.
Here are the commands for building and using an Ada project, as listed in the Ada menu.
In multi-file projects, there must be one file that is the main program. That is given by the
Build runs 'gnatmake' on the main unit. During a typical edit/compile session, this is the only command you need to invoke, which is why it is bound to C-c C-c. It will compile all files needed by the main unit, and display compilation errors in any of them.
Note that Build can be invoked from any Ada buffer; typically you will be fixing errors in files other than the main, but you don't have to switch back to the main to invoke the compiler again.
Novices and students typically work on single-file Ada projects. In this case, C-c C-m will normally be the only command needed; it will build the current file, rather than the last-built main.
There are three ways to change
If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:
It provides:
* Support for project-files
* Auto-casing and auto-indentation
* Support for cross-referencing source code including
cross-references to operators.
Download :
Similar packages:
- python-mode
- nxml-mode
- gnu-smalltalk-el
- ocaml-mode
- css-mode
- erlang-mode
- haskell-mode
- gnuplot-mode
- prolog-el
- tuareg-mode
- records-common
When the Gnu Ada compiler GNAT is used, the cross-reference information output by the compiler is used to provide powerful code navigation (jump to definition, find all uses, etc).
When you open a file with a file extension of .ads or .adb, Emacs will automatically load and activate Ada mode.
Ada mode works without any customization, if you are using the GNAT compiler (https://libre2.adacore.com/) and the GNAT default naming convention.
You must customize a few things if you are using a different compiler or file naming convention; See Other compiler, See Non-standard file names.
In addition, you may want to customize the indentation, capitalization, and other things; See Other customization.
Finally, for large Ada projects, you will want to set up an Emacs Ada mode project file for each project; See Project files. Note that these are different from the GNAT project files used by gnatmake and other GNAT commands.
See the Emacs info manual, section 'Running Debuggers Under Emacs', for general information on debugging.
Installation.
Ada mode is part of the standard Emacs distribution; if you use that, no files need to be installed.
Ada mode is also available as a separate distribution, from the Emacs Ada mode website http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html. The separate distribution may be more recent.
For installing the separate distribution, see the README file in the distribution.
To see what version of Ada mode you have installed, do M-x ada-mode-version.
The following files are provided with the Ada mode distribution:
- ada-mode.el: The main file for Ada mode, providing indentation, formatting of parameter lists, moving through code, comment handling and automatic casing.
- ada-prj.el: GUI editing of Ada mode project files, using Emacs widgets.
- ada-stmt.el: Ada statement templates.
- ada-xref.el: GNAT cross-references, completion of identifiers, and compilation. Also provides project files (which are not GNAT-specific).
Here we assume you are familiar with setting variables in Emacs, either thru 'customize' or in elisp (in your .emacs file). For a basic introduction to customize, elisp, and Emacs in general, see the tutorial in The GNU Emacs Manual.
These global Emacs settings are strongly recommended (put them in your .emacs):
(global-font-lock-mode t) (transient-mark-mode t)‘(global-font-lock-mode t)’ turns on syntax highlighting for all buffers (it is off by default because it may be too slow for some machines).
‘(transient-mark-mode t)’ highlights selected text.
See the Emacs help for each of these variables for more information.
Non-standard file names.
By default, Ada mode is configured to use the GNAT file naming convention, where file names are a simple modification of the Ada names, and the extension for specs and bodies are ‘.ads’ and ‘.adb’, respectively.
Ada mode uses the file extentions to allow moving from a package body to the corresponding spec and back.
Ada mode supports a list of alternative file extensions for specs and bodies.
For instance, if your spec and bodies files are called unit_s.ada and unit_b.ada, respectively, you can add the following to your .emacs file:
(ada-add-extensions "_s.ada" "_b.ada")<br />You can define additional extensions:
(ada-add-extensions ".ads" "_b.ada")<br /> (ada-add-extensions ".ads" ".body")<br />This means that whenever Ada mode looks for the body for a file whose extension is .ads, it will take the first available file that ends with either .adb, _b.ada or .body.
Simililarly, if Ada mode is looking for a spec, it will look for .ads or _s.ada.
If the filename is not derived from the Ada name following the GNAT convention, things are a little more complicated. You then need to rewrite the function
ada-make-filename-from-adaname
. Doing that is beyond the scope of this manual; see the current definitions in ada-mode.el and ada-xref.el for examples.Other compiler.
By default, Ada mode is configured to use the Gnu Ada compiler GNAT.
To use a different Ada compiler, you must specify the command lines used to run that compiler, either in lisp variables or in Emacs Ada mode project files. See Project file variables for the list of project variables, and the corresponding lisp variables.
Other customization.
All user-settable Ada mode variables can be set via the menu ‘Ada | Customize’. Click on the ‘Help’ button there for help on using customize.
To modify a specific variable, you can directly call the function
customize-variable
; just type M-x customize-variable Alternately, you can specify variable settings in the Emacs configuration file, .emacs. This file is coded in Emacs lisp, and the syntax to set a variable is the following:
(setq variable-name value)<br /><br /><b><br /></b>Compiling Executing.
Ada projects can be compiled, linked, and executed using commands on the Ada menu. All of these commands can be customized via a project file (see Project files), but the defaults are sufficient for using the GNAT compiler for simple projects (single files, or several files in a single directory).
Even when no project file is used, the GUI project editor (menu ‘Ada | Project | Edit’) shows the settings of the various project file variables referenced here.
Compile commands.
Here are the commands for building and using an Ada project, as listed in the Ada menu.
In multi-file projects, there must be one file that is the main program. That is given by the
main
project file variable; it defaults to the current file if not yet set, but is also set by the “set main and build” command. Check file
- Compiles the current file in syntax check mode, by running
check_cmd
defined in the current project file. This typically runs faster than full compile mode, speeding up finding and fixing compilation errors.
This setsmain
only if it has not been set yet. Compile file
- Compiles the current file, by running
comp_cmd
from the current project file.
This does not setmain
. Set main and Build
- Sets
main
to the current file, then executes the Build command. Show main
- Display
main
in the message buffer. Build
- Compiles all obsolete units of the current
main
, and linksmain
, by runningmake_cmd
from the current project.
This setsmain
only if it has not been set yet. Run
- Executes the main program in a shell, displayed in a separate Emacs buffer. This runs
run_cmd
from the current project. The execution buffer allows for interactive input/output.
To modify the run command, in particular to provide or change the command line arguments, type C-u before invoking the command.
This command is not available for a cross-compilation toolchain.
main
is used and changed. Build runs 'gnatmake' on the main unit. During a typical edit/compile session, this is the only command you need to invoke, which is why it is bound to C-c C-c. It will compile all files needed by the main unit, and display compilation errors in any of them.
Note that Build can be invoked from any Ada buffer; typically you will be fixing errors in files other than the main, but you don't have to switch back to the main to invoke the compiler again.
Novices and students typically work on single-file Ada projects. In this case, C-c C-m will normally be the only command needed; it will build the current file, rather than the last-built main.
There are three ways to change
main
: - Invoke ‘Ada | Set main and Build’, which sets
main
to the current file. - Invoke ‘Ada | Project | Edit’, edit
main
andmain
, and click ‘[save]’ - Invoke ‘Ada | Project | Load’, and load a project file that specifies
main
- ada-mode-4.01.tar.gz
- My latest version.
- ada-mode-examples-4.01.tar.gz
- Ada examples from the current Ada mode manual.
- ada-mode.html
- The current Ada mode manual. The distribution contains this and an Emacs info version.
- ada-mode-patches.el
- My current patches to Ada mode; open for discussion about including in Emacs distribution.
- ada-mode-keys.el
- My bindings, settings, and hooks for using Ada mode; provided as an example.
- gnat-fix-error.el
- Utilities for automatically fixing errors reported by the gnat compiler; proposed addition to Ada mode.
If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:
Related Post
| |
Linux Links
|
0 comments:
Post a Comment