PowerAda Using XEmacs with Powerada

From OC Systems Wiki!
Jump to: navigation, search

XEmacs is a powerful, extensible text editor that is included with the PowerAda distribution. In addition to the variety of text-editing code that is included with XEmacs, PowerAda supplies XEmacs extensions (including source code) to support a number of useful functions.

Some Emacs Basics

XEmacs should be fairly intuitive to use at a basic level. Files can be opened and closed with the buttonbar or File menu (though MB2 is the button that selects files in XEmacs' file selection dialog), and the cursor keys or mouse and scrollbars can be used to move around a file.

Unlike many other editors, XEmacs is designed to run with any number of files open at once. Files are viewed in buffers. Use the Buffer menu to switch between buffers. You can also view multiple buffers by splitting a window (with Split Window in the File menu) or creating a number of windows (with New Frame in the File menu -- XEmacs calls top-level windows "frames").

The minibuffer -- the line at the bottom of each XEmacs window -- displays status information and is also where "command" input takes place. The modeline -- directly above the minibuffer -- displays the current filename, editing mode, and other information.

Rather than using XEmacs' menus, advanced users generally find it more efficient to use keyboard shortcuts (all of which are redefinable). Here are a few notable ones. In this list, C-x means Control-x, and M-x means Meta-x. To enter a Meta sequence, either press Alt at the same time as the key (Alt-x), or press and release Escape, then press the key itself (Escape, X).

  • Open file: C-x C-f
  • Save buffer: C-x C-s
  • Split window: C-x 2
  • Unsplit window, keeping the current buffer visible: C-x 1
  • Create a new frame: C-x 5 2
  • Search: C-s
  • Search backward: C-r
  • Undo: C-x u
  • Set mark (to define a region): C-space
  • Kill (cut) region: C-w
  • Copy region: M-w
  • Insert killed (cut) text: C-y
  • Abort current command: C-g (useful if you manage to get XEmacs into a strange state)

Getting Help with XEmacs

There is a great deal of documentation included with XEmacs. Its Help menu includes entries for the XEmacs tutorial, the XEmacs FAQ, and for Info, XEmacs' documentation browser.

For more help with XEmacs basics, see the OCS Getting Started With XEmacs tutorial.

Customizing XEmacs

XEmacs is extremely customizable. A number of basic options can be set using XEmacs' Options menu. You can save these settings with the Save Options button in the Options menu.

XEmacs is really a lisp engine (a lisp variant called "elisp", or Emacs lisp); nearly every keystroke translates into a number of elisp calls. This makes it easy to do very sophisticated customizations. These customizations go in $HOME/.emacs. See the XEmacs documentation for more details; the sample .emacs available under the Help menu is a good start.

XEmacs' Ada Support

XEmacs includes a major mode for writing Ada code, called ada-mode. This mode does automatic casing and indentation of code, and navigating through code. OC Systems provides a number of Ada-related extensions as well. These allow compilation from XEmacs, interactive error editing and syntax checking, and code reformatting. The OCS Getting Started With XEmacs tutorial demonstrates most of these extensions.

Compiling Ada Files from XEmacs

The ocs-compile package provides support for compiling Ada files from XEmacs. This package can be loaded by adding this line to a .emacs file:

(require 'ocs-compile)

The Compile button in the Ada menu will invoke the PowerAda compiler on the current buffer. If there are compilation errors in the file, they can be edited interactively.

Using XEmacs to Fix Compilation Errors

In conjunction with XEmacs, powerada allows for true interactive editing of compilation errors. If XEmacs is set as the editor, compilation errors are opened in XEmacs, along with a window containing the list of errors in the file. Middle-clicking on an error will jump the source window to that error and highlight it. After fixing it, the next error can be highlighted by pressing C-x ', or by middle-clicking on the next error in the list of errors.

Syntax Checking from within XEmacs

The Syntax Check Buffer button in the Ada menu will perform a syntax check on the current buffer. If there are any syntax errors in the file, the cursor is moved to the first one.

Browsing Source Code from XEmacs

XEmacs can act as a source browsing view. This line must be added to your .emacs file:

(require 'ocs-paclient)

The Definition Of button in the mouse button 3 popup menu can then be used to do source browsing, just as in the source browser. Note that the buffer must be unmodified; that is, it much exactly match the compiled unit.