Go to the first, previous, next, last section, table of contents.


5. Support for other Packages

Proof General makes some configuration for other Emacs packages which provide various useful facilities that can make your editing more effective.

Sometimes this configuration is purely at the proof assistant specific level (and so not necessarily available), and sometimes it is made using Proof General settings.

When adding support for a new proof assistant, we suggest that these other packages are supported, as a convention.

The packages currently supported are font-lock, x-symbol, func-menu, outline-mode, completion, and etags.

5.1 Syntax highlighting

Proof script buffers are decorated (or fontified) with colours, bold and italic fonts, etc, according to the syntax of the proof language and the settings for font-lock-keywords made by the proof assistant specific portion of Proof General. Moreover, Proof General usually decorates the output from the proof assistant, also using font-lock.

In XEmacs, fontification is automatically turned on. To automatically switch on fontification in GNU Emacs 20.4, you may need to engage M-x global-font-lock-mode. The old mechanism of adding hooks to the mode hooks (lego-mode-hooks, coq-mode-hooks, etc) is no longer recommended; it should not be needed in latest Emacs versions which have more flexible customization.

Fontification for output is controlled by a separate switch in Proof General. Set proof-output-fontify-enable to nil if you don't want the output from your proof assistant to be fontified according to the setting of font-lock-keywords in the proof assistant specific portion of Proof General. See section 7.4 User options.

By the way, the choice of colour, font, etc, for each kind of markup is fully customizable in Proof General. Each face (Emacs terminology) controlled by its own customization setting. You can display a list of all of them using the customize menu:

Proof General -> Customize -> Faces -> Proof Faces.

5.2 X-Symbol support

The X-Symbol package displays characters from a variety of fonts in Emacs buffers, automatically converting between codes for special characters and tokens which are character sequences stored in files.

Proof General uses X-Symbol to allow interaction between the user and the proof assistant to use tokens, yet appear to be using special characters. So proof scripts and proofs can be processed with real mathematical symbols, Greek letters, etc.

You will be able to enable X-Symbol support if you have installed the X-Symbol package and support has been provided in Proof General for a token language for your proof assistant. The X-Symbol package is available from http://x-symbol.sourceforge.net/. To enable X-Symbol, use the menu item:

  Proof-General -> Options -> X-Symbol

To enable it automatically every time you use Proof General, you need to customize the setting PA-x-symbol-enable.

Notice that for proper symbol support, the proof assistant needs to have a special token language, or a special character set, to use symbols. In this case, the proof assistant will output, and accept as input, tokens like \longrightarrow, which display as the corresponding symbols. However, for proof assistants which do not have such token support, we can use "fake" symbol support quite effectively, displaying ordinary character sequences such as --> with symbols. The only problem with this hack is that it can cause surprising results, when you really want character sequences instead of, for example, Greek letters!

5.3 Support for function menus

The Emacs package func-menu (formerly called fume-func) is a handy facility to make a menu from the names of entities declared in a buffer. Proof General configures func-menu so that you can quickly jump to particular proofs in a script buffer. (This is done with the configuration variables proof-goal-with-hole-regexp and proof-save-with-hole-regexp.)

If you want to use function menu, you can simply select "Function menu" from the Proof General menu, or type M-x function-menu.

Although the package is distributed with XEmacs, it is not enabled by default every time you visit a buffer. To enable it by default (i.e. avoid typing M-x function-menu), you should find the file `func-menu.el' and follow the instructions there.

GNU Emacs 20.4 does not have the function menu library built in, but you may be able to download it from the elisp archives. A similar mode which is supported is imenu, also in XEmacs. Proof General would be grateful if anyone can send patches for using imenu as an alternative to function menu.

5.4 Support for outline mode

Proof General configures Emacs variables (outline-regexp and outline-heading-end-regexp) so that outline minor mode can be used on proof script files. The headings taken for outlining are the "goal" statements at the start of goal-save sequences, see section 2.3.2 Goal-save sequences. If you want to use outline to hide parts of the proof script in the locked region, you need to disable proof-strict-read-only.

Use M-x outline-minor-mode to turn on outline minor mode. Functions for navigating, hiding, and revealing the proof script are available in menus.

See See Info file `(xemacs)', node `Outline Mode' for more information about outline mode.

5.5 Support for completion

You might find the completion facility of Emacs useful when you're using Proof General. The key C-RET is defined to invoke the complete command. Pressing C-RET cycles through completions displaying hints in the minibuffer.

Completions are filled in according to what has been recently typed, from a database of symbols. The database is automatically saved at the end of a session.

Proof General has the additional facility for setting a completion table for each supported proof assistant, which gets loaded into the completion database automatically. Ideally the completion table would be set from the running process according to the identifiers available are within the particular context of a script file. But until this is available, this table may be set to contain a number of standard identifiers available for your proof assistant.

The setting PA-completion-table holds the list of identifiers for a proof assistant. The function proof-add-completions adds these into the completion database.

Variable: PA-completion-table
List of identifiers to use for completion for this proof assistant.
Completion is activated with C-return.

If this table is empty or needs adjusting, please make changes using `customize-variable' and send suggestions to support@proofgeneral.org

The completion facility uses a library `completion.el' which usually ships with XEmacs and GNU Emacs, and supplies the complete function.

Command: complete
Fill out a completion of the word before point.
Point is left at end. Consecutive calls rotate through all possibilities. Prefix args:
C-u
leave point at the beginning of the completion, not the end.
a number
rotate through the possible completions by that amount
0
same as -1 (insert previous completion)

See the comments at the top of `completion.el' for more info.

5.6 Support for tags

An Emacs "tags table" is a description of how a multi-file system is broken up into files. It lists the names of the component files and the names and positions of the functions (or other named subunits) in each file. Grouping the related files makes it possible to search or replace through all the files with one command. Recording the function names and positions makes possible the M-. command which finds the definition of a function by looking up which of the files it is in.

Some instantiations of Proof General (currently LEGO and Coq) are supplied with external programs (`legotags' and `coqtags') for making tags tables. For example, invoking `coqtags *.v' produces a file `TAGS' for all files `*.v' in the current directory. Invoking `coqtags `find . -name \*.v`' produces a file `TAGS' for all files ending in `.v' in the current directory structure. Once a tag table has been made for your proof developments, you can use the Emacs tags mechanisms to find tags, and complete symbols from tags table.

One useful key-binding you might want to make is to set the usual tags completion key M-tab to run tag-complete-symbol to use completion from names in the tag table. To set this binding in Proof General script buffers, put this code in your `.emacs' file:

(add-hook 'proof-mode-hook
  (lambda () (local-set-key '(meta tab) 'tag-complete-symbol)))

Since this key-binding interferes with a default binding that users may already have customized (or may be taken by the window manager), Proof General doesn't do this automatically.

Apart from completion, there are several other operations on tags. One common one is replacing identifiers across all files using tags-query-replace. For more information on how to use tags, See Info file `(xemacs)', node `Tags'.

To use tags for completion at the same time as the completion mechanism mentioned already, you can use the command M-x add-completions-from-tags-table.

Command: add-completions-from-tags-table
Add completions from the current tags table.


Go to the first, previous, next, last section, table of contents.