Lacking Natural Simplicity

Random musings on books, code, and tabletop games.

Using the old version of Ada Mode for Emacs

Last edited: 2022-12-06 14:33:55 EST

There are a lot of things to like about the Ada programming language; it seems to have a solid core of users, enough to support multiple commercial implementations and a free/libre software implementation that is part of the GNU Compiler Collection. I occasionally use it myself.

However: I'm sure that the current version of Ada Mode for Emacs (available as an ELPA package, and thus not included in Emacs itself), which provides smart editing for the Ada programming language, and uses an external parser for the indentation, fontification[1], and navigation engine, is wonderful if you can get it working, but I have never been able to get it to work. My most recent try was today on Fedora 36 using GNAT 12.1.1 20220507 (Red Hat 12.1.1-1).

Here's what happened when I tried to build the Ada code for the parser, which is supplied as part of the ada-mode:

$ ./build.sh
ada_mode_wisi_parse.gpr:44:26: warning: object directory "obj" not found
Setup
   [mkdir]        object directory for project Ada_Mode_Wisi_Parse
Compile
   [Ada]          ada_mode_wisi_lalr_parse.ads
   [Ada]          ada_mode_wisi_lr1_parse.ads
   [Ada]          run_ada_lalr_parse.ads
   [Ada]          run_ada_lr1_parse.ads
   [Ada]          gpr_mode_wisi_parse.ads
   [Ada]          run_gpr_parse.ads
   [Ada]          gpr_query.adb
   [C]            wisitoken_grammar_re2c.c
   [C]            ada_re2c.c
   [C]            gpr_re2c.c
   [Ada]          ada_process_actions.adb
   [Ada]          ada_process_lr1_main.adb
   [Ada]          gen_run_wisi_lr_text_rep_parse.adb
   [Ada]          run_wisi_common_parse.adb
   [Ada]          wisi.adb
gnatcoll-sql.adb:742:07: error: ambiguous expression (cannot resolve "Append")
gnatcoll-sql.adb:742:07: error: possible interpretation at a-coinve.ads:280, instance at gnatcoll-sql.ads:1109
gnatcoll-sql.adb:742:07: error: possible interpretation at a-coinve.ads:270, instance at gnatcoll-sql.ads:1109

   compilation of gpr_query.adb failed

gprbuild: *** compilation phase failed

Sigh. Without the external parser the current Ada Mode is completely unworkable: it doesn't even do indentation correctly, much less do fontification.

However, when I did some Ada work a number of years ago, I was ok with the version that used to be in Emacs itself. So I dug it out of the Emacs git repository at savannah.gnu.org. Basically, I cloned the git repository and then figured out what commit it was deleted in by doing:

$ git rev-list HEAD -n 1 -- lisp/progmodes/ada-mode.el
a13c64204c8ead966789abf8efe176e4f2d4f599

Then I checked out the files involved:

$ git checkout a13c64204c8ead966789abf8efe176e4f2d4f599^ lisp/progmodes/ada-mode.el lisp/progmodes/ada-prj.el lisp/progmodes/ada-stmt.el lisp/progmodes/ada-xref.el doc/misc/ada-mode.texi

The ^ at the end of the commit hash says to get the previous commit.

You'll also need doc/docstyle.texi and doc/doclicense.texi if you want to build documentation from ada-mode.texi.

And I've put the files in a zip file for anybody who is in the same situation as I was, along with the generated documentation files .info, .html, and .pdf.

Just put them somewhere on your load-path and add (autoload 'ada-mode "ada-mode") to your emacs config file.

I'm sure the current Ada Mode has a lot more useful features, and I'd love to use it, but this at least lets me edit with automatic indentation, formatting, and fontification.

Print Friendly and PDF

Comments

Comments powered by Disqus