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!
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.
A very convenient way to customize file-specific variables is to use the File Variables (See Info file `xemacs', node `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
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 -emacs -full -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.
Extending the previous example, if the makefile for `foo.v' is located in directory `.../dir/', you can add the right compile command:
(* Local Variables: coq-prog-name: "coqtop -emacs -full -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 Info file `xemacs', node `File Variables'.
A very useful package of Emacs supports automatic expansions of abbreviations as you type, See Info file `(xemacs)', node `Abbrevs'.
Proof General has no special support for abbreviations, we just mention it here to encourage its use. For example, the proof assistant Coq has many command strings that are long, such as "Reflexivity," "Inductive," "Definition" and "Discriminate." Here is the Coq Proof General author's suggested abbreviations for Coq:
"assn" 0 "Assumption" "ax" 0 "Axiom" "coern" 0 "Coercion" "cofixpt" 0 "CoFixpt" "coindv" 0 "CoInductive" "constr" 0 "Constructor" "contradn" 0 "Contradiction" "defn" 0 "Definition" "discr" 0 "Discriminate" "extrn" 0 "Extraction" "fixpt" 0 "Fixpoint" "genz" 0 "Generalize" "hypo" 0 "Hypothesis" "immed" 0 "Immediate" "indn" 0 "Induction" "indv" 0 "Inductive" "injn" 0 "Injection" "intn" 0 "Intuition" "invn" 0 "Inversion" "pmtr" 0 "Parameter" "refly" 0 "Reflexivity" "rmk" 0 "Remark" "specz" 0 "Specialize" "symy" 0 "Symmetry" "thm" 0 "Theorem" "transpt" 0 "Transparent" "transy" 0 "Transitivity" "trivial" 0 "Trivial" "varl" 0 "Variable"
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.
Go to the first, previous, next, last section, table of contents.