CM Modula-3 comes with a mode for editing Modula-3 programs under gnuemacs. The work on the mode is in progress, here we present some documentation on the current snapshot. Here is a list of the key things this mode provides:
of formatting code, one ``batch'' and one ``interactive.'' The batch method invokes the program m3pp, which takes a program unit such as a procedure and formats it completely. The gnuemacs commands that invoke m3pp are M-x m3::pp-buffer which pretty prints the current buffer, M-x m3::pp-region which pretty-prints the code between mark and point, and M-x m3::pp-unit which pretty-prints the ``unit'' containing the cursor. (A unit is a top-level construct such as CONST, TYPE, VAR, or PROCEDURE.) m3::pp-buffer, m3::pp-region and m3::pp-unit are bound to the keys C-c b, C-c r and C-c u, respectively.
The other method of formatting text is a more traditional one for gnuemacs, in which there the language mode provides a key that indents the current line appropriately. In keeping with the convention used in modes for other languages such as Lisp and C, the key used is TAB. Typing TAB on a line indents the current line in a way that is (we hope) appropriate given the lines that precede it.
The two formatting methods are not mutually exclusive; perhaps you like the way m3pp lines up columns in declarations, but you also like to keep things indented while you type. You can use the electric mode to get things close, then invoke m3pp when you're done.
Modula-3 mode offers some aid if you don't like typing a lot of uppercase keywords. The TAB actually serves double duty; it not only indents the current line, but when invoked at the end of a word, it attempts to complete the current word as a keyword. For example b TAB expands the b to BEGIN, provided the b appears in a context where BEGIN may be a valid keyword. There are some fairly extensive rules governing the contexts in which a given keyword is a valid completion; the net result is that it is seldom necessary to type more than one letter to get the correct completion. If you specify a non-unique prefix of a set of keywords, it chooses the first in an ordering intended to capture frequency of use; it also presents the other choices, and typing TAB repeatedly cycles through these choices.
A pair of related features are ``END-completion'' and ``END-matching.'' If the elisp variable m3::electric-end is set to 'all, completing the keyword END has the additional effect of finding the construct that the END completes. If that construct is a an interface, module, or procedure, it fills in the name of the completed construct after the END; otherwise, it inserts a comment containing the keyword of the completed construct. If m3::electric-end is 'proc-mod, it only fills in real names, never keyword comments. Independently, a non-nil value of the elisp variable m3::blink-end-matchers causes completion of END to blink the cursor briefly at the beginning of the completed construct.
The key C-c i is bound to m3::show-interface, which expects the point to be in an interface name, and attempts to find that interface and display it in another window. It uses a built-in list of directories. You may consider changing the default value of this list.
The key C-c m is bound to m3::show-implementation. This attempts to find the module that implements the interface in the current buffer. As distributed, this function relies on Modula-3 coding conventions. It may not work for you, in which case it may need to be re-implemented or abandoned.
To have the Modula-3 mode automatically invoked when visiting a Modula-3 source file, you should put in your .emacs:
(autoload 'modula-3-mode "modula3") (setq auto-mode-alist (append '(("\\.ig$" . modula-3-mode) ("\\.mg$" . modula-3-mode) ("\\.i3$" . modula-3-mode) ("\\.m3$" . modula-3-mode)) auto-mode-alist))
It is also convenient to have the lines:
(setq completion-ignored-extensions (append '(".mo" ".mx" ".mc" ".io" ".ix") completion-ignored-extensions))
so that you don't get the files with those extensions offered as possible completions.
Your system administrator may have inserted these lines in the default macro files for your system.
There is also a program to build tags file for Modula-3 programs: m3tags; see the manpage for the details. When the system is installed, a tag file for the public interfaces is built. To access it, you need in your .emacs (or in the system initialization file) the line:
(visit-tags-table "LIB_USE/FTAGS")
where LIB_USE is the place where the Modula-3 libraries have been installed.