[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 7. Hints and Tips

Apart from the packages officially supported in Proof General, many other features of Emacs are useful when using Proof General, even though they need no specific configuration for Proof General. It is worth taking a bit of time to explore the Emacs manual to find out about them.

Here we provide some hints and tips for a couple of Emacs features which users have found valuable with Proof General. Further contributions to this chapter are welcomed!

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 7.1 Adding your own keybindings

Proof General follows Emacs convention for file modes in using <C-c> prefix key-bindings for its own functions, which is why some of the default keyboard short-cuts are quite lengthy.

Some users may prefer to add additional key-bindings for shorter sequences. This can be done interactively with the command `M-x local-set-key`, or for longevity, by adding code like this to your ‘`.emacs`’ (or ‘`.xemacs/init.el`’) file:

    (eval-after-load "proof-script" '(progn
     (define-key proof-mode-map [(control n)]
                                'proof-assert-next-command-interactive)
     (define-key proof-mode-map [(control b)]
                                'proof-undo-last-successful-command)
     ))

This lisp fragment adds bindings for every buffer in proof script mode (the Emacs keymap is called `proof-mode-map`). To just affect one prover, use a keymap name like `isar-mode-map` and evaluate after the library `isar` has been loaded.

To find the names of the functions you may want to bind, look in this manual, or query current bindings interactively with `C-h k`. This command (`describe-key`) works for menu operations as well; also use it to discover the current key-bindings which you're losing by declarations such as those above. By default, `C-n` is `next-line` and `C-b` is `backward-char-command`; neither are really needed if you have working cursor keys.

If you're using XEmacs and your keyboard has a super modifier (on my PC keyboard it has a Windows symbol and is next to the control key), you can freely bind keys on that modifier globally (since none are used by default). Use lisp like this:

    (global-set-key [(super l)] 'x-symbol-INSERT-lambda)
    (global-set-key [(super n)] 'x-symbol-INSERT-notsign)
    (global-set-key [(super a)] 'x-symbol-INSERT-logicaland)
    (global-set-key [(super o)] 'x-symbol-INSERT-logicalor)
    (global-set-key [(super f)] 'x-symbol-INSERT-universal1)
    (global-set-key [(super t)] 'x-symbol-INSERT-existential1)
    (global-set-key [(super A)] 'x-symbol-INSERT-biglogicaland)
    (global-set-key [(super e)] 'x-symbol-INSERT-equivalence)
    (global-set-key [(super u)] 'x-symbol-INSERT-notequal)
    (global-set-key [(super m)] 'x-symbol-INSERT-arrowdblright)
    (global-set-key [(super i)] 'x-symbol-INSERT-longarrowright)

This defines a bunch of short-cuts for insert X-Symbol logical symbols which are often used in Isabelle.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 7.2 Using file variables

A very convenient way to customize file-specific variables is to use the File Variables (See (xemacs)File Variables). This feature of Emacs allows to specify the values to use for certain Emacs variables when a file is loaded. Those values are written as a list at the end of the file.

For example, in projects involving multiple directories, it is often useful to set the variables `proof-prog-name`, `proof-prog-args` and `compile-command` for each file. Here is an example for Coq users: for the file ‘`.../dir/bar/foo.v`’, if you want Coq to be started with the path `.../dir/theories/` added in the libraries path (`"-I"` option), you can put at the end of ‘`foo.v`’:

    (*
    *** Local Variables: ***
    *** coq-prog-name: "coqtop" ***
    *** coq-prog-args: ("-emacs" "-I" "../theories") ***
    *** End: ***
    *)

That way the good command is called when the scripting starts in ‘`foo.v`’. Notice that the command argument `"-I" "../theories"` is specific to the file ‘`foo.v`’, and thus if you set it via the configuration tool, you will need to do it each time you load this file. On the contrary with this method, Emacs will do this operation automatically when loading this file. Please notice that all the strings above should never contain spaces see documentation of variables `proof-prog-name` and `proof-prog-args`.

Extending the previous example, if the makefile for ‘`foo.v`’ is located in directory ‘`.../dir/`’, you can add the right compile command. And if you want a non standard coq executable to be used, here is what you should put in variables:

    (*
     Local Variables:
     coq-prog-name: "../../coqsrc/bin/coqtop"
     coq-prog-args: "-emacs" "-I" "../theories"
     compile-command: "make -C .. -k bar/foo.vo"
     End:
    *)

And then the right call to make will be done if you use the `M-x compile` command. Notice that the lines are commented in order to be ignored by the proof assistant. It is possible to use this mechanism for any other buffer local variable. See (xemacs)File Variables.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 7.3 Using abbreviations

A very useful package of Emacs supports automatic expansions of abbreviations as you type, See ((xemacs))Abbrevs.

For example, the proof assistant Coq has many command strings that are long, such as “reflexivity,” “Inductive,” “Definition” and “Discriminate.” Here is a part of the Coq Proof General abbreviations:

    "abs" "absurd "
    "ap" "apply "
    "as" "assumption"

The above list was taken from the file that Emacs saves between sessions. The easiest way to configure abbreviations is as you write, by using the key presses `C-x a g` (`add-global-abbrev`) or `C-x a i g` (`inverse-add-global-abbrev`). To enable automatic expansion of abbreviations (which can be annoying), the `Abbrev` minor mode, type `M-x abbrev-mode RET`. When you are not in Abbrev mode you can expand an abbreviation by pressing `C-x '` (`expand-abbrev`). See the Emacs manual for more details.

Coq Proof General has a special experimental feature called "Holes" which makes use of the abbreviation mechanism and includes a large list of command abbreviations. See section Holes feature, for details. With other provers, you may use the standard Emacs commands above to set up your own abbreviation tables.

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by David Aspinall on July, 24 2008 using texi2html 1.78.