|Did you know ...||Search Documentation:|
In the previous section (section 3.4.2) we explained the basics of PceEmacs. Here we continue with Prolog-specific functionality. Possibly the most interesting is Syntax highlighting. Unlike most editors where this is based on simple patterns, PceEmacs syntax highlighting is achieved by Prolog itself actually reading and interpreting the source as you type it. There are three moments at which PceEmacs checks (part of) the syntax.
that is not preceded by a symbol character, the system assumes you completed a clause, tries to find the start of this clause and verifies the syntax. If this process succeeds it colours the elements of the clause according to the rules given below. Colouring is done using information from the last full check on this file. If it fails, the syntax error is displayed in the status line and the clause is not coloured.
Control-lcommand re-centers the window (scrolls the window to make the caret the center of the window). Typing this command twice starts the same process as above.
The colour schema itself is defined in
library(emacs/prolog_colour). The colouring can be extended
and modified using multifile predicates. Please check this source file
for details. In general, underlined objects have a popup (right-mouse
button) associated with common commands such as viewing the
documentation or source. Bold text is used to indicate the
definition of objects (typically predicates when using plain Prolog).
Other colours follow intuitive conventions. See table
|Blue bold||Head of an exported predicate|
|Red bold||Head of a predicate that is not called|
|Black bold||Head of remaining predicates|
|Calls in the clause body|
|Blue||Call to built-in or imported predicate|
|Red||Call to undefined predicate|
|Purple||Call to dynamic predicate|
|Dark blue||Quoted atom or string|
Layout is not `just nice', it is essential for writing
readable code. There is much debate on the proper layout of Prolog.
PceEmacs, being a rather small project, supports only one particular
style for layout.41Defined in
Prolog in the file
library(emacs/prolog_mode), you may wish
to extend this. Please contribute your extensions! Below
are examples of typical constructs.
head(arg1, arg2). head(arg1, arg2) :- !. head(Arg1, arg2) :- !, call1(Arg1). head(Arg1, arg2) :- ( if(Arg1) -> then ; else ). head(Arg1) :- ( a ; b ). head :- a(many, long, arguments(with, many, more), and([ a, long, list, with, a, | tail ])).
PceEmacs uses the same conventions as GNU-Emacs. The
key indents the current line according to the syntax rules.
indents all lines of the current clause. It provides support for head,
calls (indented 1 tab), if-then-else, disjunction and argument lists
broken across multiple lines as illustrated above.
Alt-. extracts name and arity from the caret
location and jumps (after conformation or edit) to the definition of the
predicate. It does so based on the source-location database of loaded
predicates also used by edit/1.
This makes locating predicates reliable if all sources are loaded and
up-to-date (see make/0).
In addition, references to files in use_module/[1,2], consult/1, etc. are red if the file cannot be found and underlined blue if the file can be loaded. A popup allows for opening the referenced file.