File: prolog.el.html

This package provides a major mode for editing Prolog code, with all the bells and whistles one would expect, including syntax highlighting and auto indentation. It can also send regions to an inferior Prolog process.

Some settings you may wish to use:

(setq prolog-system 'swi) ; optional, the system you are using;
                           ; see prolog-system below for possible values
(setq auto-mode-alist (append '(("\\\\.pl\\\\'" . prolog-mode)
                                ("\\\\.m\\\\'" . mercury-mode))
                               auto-mode-alist))

The last expression above makes sure that files ending with .pl are assumed to be Prolog files and not Perl, which is the default Emacs setting. If this is not wanted, remove this line. It is then necessary to either

 o insert in your Prolog files the following comment as the first line:

      % -*- Mode: Prolog -*-

    and then the file will be open in Prolog mode no matter its
    extension, or

 o manually switch to prolog mode after opening a Prolog file, by typing
    M-x prolog-mode.

If the command to start the prolog process ('sicstus', 'pl' or
'swipl' for SWI prolog, etc.) is not available in the default path,
then it is necessary to set the value of the environment variable EPROLOG to a shell command to invoke the prolog process. You can also customize the variable prolog-program-name(var)/prolog-program-name(fun) (in the group prolog-inferior) and provide a full path for your Prolog system (swi, scitus, etc.).

Changelog:

Version 1.22:
 o Allowed both 'swipl' and 'pl' as names for the SWI Prolog
    interpreter.
 o Atoms that start a line are not blindly colored as
    predicates. Instead we check that they are followed by ( or
    :- first. Patch suggested by Guy Wiener.
Version 1.21:
 o Cleaned up the code that defines faces. The missing face
    warnings on some Emacsen should disappear.
Version 1.20:
 o Improved the handling of clause start detection and multi-line
    comments: prolog-clause-start no longer finds non-predicate
    (e.g., capitalized strings) beginning of clauses.
    prolog-tokenize recognizes when the end point is within a
    multi-line comment.
Version 1.19:
 o Minimal changes for Aquamacs inclusion and in general for
    better coping with finding the Prolog executable. Patch
    provided by David Reitter
Version 1.18:
 o Fixed syntax highlighting for clause heads that do not begin at
    the beginning of the line.
 o Fixed compilation warnings under Emacs.
 o Updated the email address of the current maintainer.
Version 1.17:
 o Minor indentation fix (patch by Markus Triska)
 o prolog-underscore-wordchar-flag defaults now to nil (more
    consistent to other Emacs modes)
Version 1.16:
 o Eliminated a possible compilation warning.
Version 1.15:
 o Introduced three new customizable variables: electric colon
    (prolog-electric-colon-flag, default nil), electric dash
    (prolog-electric-dash-flag, default nil), and a possibility
    to prevent the predicate template insertion from adding commas
    (prolog-electric-dot-full-predicate-template, defaults to t
    since it seems quicker to me to just type those commas). A
    trivial adaptation of a patch by Markus Triska.
 o Improved the behavior of electric if-then-else to only skip
    forward if the parenthesis/semicolon is preceded by
    whitespace. Once more a trivial adaptation of a patch by
    Markus Triska.
Version 1.14:
 o Cleaned up align code. prolog-align-flag is eliminated (since
    on a second thought it does not do anything useful). Added key
    binding (C-c C-a) and menu entry for alignment.
 o Condensed regular expressions for lower and upper case
    characters (GNU Emacs seems to go over the regexp length limit
    with the original form). My code on the matter was improved
    considerably by Markus Triska.
 o Fixed prolog-insert-spaces-after-paren (which used an
    uninitialized variable).
 o Minor changes to clean up the code and avoid some implicit
    package requirements.
Version 1.13:
 o Removed the use of map-char-table in prolog-build-case-strings
    which appears to cause problems in (at least) Emacs 23.0.0.1.
 o Added if-then-else indentation + corresponding electric
    characters. New customization: prolog-electric-if-then-else-flag
 o Align support (requires align). New customization:
    prolog-align-flag.
 o Temporary consult files have now the same name throughout the
    session. This prevents issues with reconsulting a buffer
    (this event is no longer passed to Prolog as a request to
    consult a new file).
 o Adaptive fill mode is now turned on. Comment indentation is
    still worse than it could be though, I am working on it.
 o Improved filling and auto-filling capabilities. Now block
    comments should be [auto-]filled correctly most of the time;
    the following pattern in particular is worth noting as being
    filled correctly:
        <some code here> % some comment here that goes beyond the
                         % rightmost column, possibly combined with
                         % subsequent comment lines
 o prolog-char-quote-workaround now defaults to nil.
 o Note: Many of the above improvements have been suggested by
    Markus Triska, who also provided useful patches on the matter
    when he realized that I was slow in responding. Many thanks.
Version 1.11 / 1.12
 o GNU Emacs compatibility fix for paragraph filling (fixed
    incorrectly in 1.11, fix fixed in 1.12).
Version 1.10
 o Added paragraph filling in comment blocks and also correct auto
    filling for comments.
 o Fixed the possible "Regular expression too big" error in
    prolog-electric-dot.
Version 1.9
 o Parenthesis expressions are now indented by default so that
    components go one underneath the other, just as for compound
    terms. You can use the old style (the second and subsequent
    lines being indented to the right in a parenthesis expression)
    by setting the customizable variable prolog-paren-indent-p
    (group "Prolog Indentation") to t.
 o (Somehow awkward) handling of the 0' character escape
    sequence. I am looking into a better way of doing it but
    prospects look bleak. If this breaks things for you please let
    me know and also set the prolog-char-quote-workaround (group
    "Prolog Other") to nil.
Version 1.8
 o Key binding fix.
Version 1.7
 o Fixed a number of issues with the syntax of single quotes,
    including Debian bug #324520.
Version 1.6
 o Fixed mercury mode menu initialization (Debian bug #226121).
 o Fixed (i.e., eliminated) Delete remapping (Debian bug #229636).
 o Corrected indentation for clauses defining quoted atoms.
Version 1.5:
 o Keywords fontifying should work in console mode so this is
    enabled everywhere.
Version 1.4:
 o Now supports GNU Prolog--minor adaptation of a patch by Stefan
    Moeding.
Version 1.3:
 o Info-follow-nearest-node now called correctly under Emacs too
    (thanks to Nicolas Pelletier). Should be implemented more
    elegantly (i.e., without compilation warnings) in the future.
Version 1.2:
 o Another prompt fix, still in SWI mode (people seem to have
    changed the prompt of SWI Prolog).
Version 1.1:
 o Fixed dots in the end of line comments causing indentation
    problems. The following code is now correctly indented (note
    the dot terminating the comment):
       a(X) :- b(X),
           c(X). % comment here.
       a(X).
    and so is this (and variants):
       a(X) :- b(X),
           c(X). /* comment here. */
       a(X).
Version 1.0:
 o Revamped the menu system.
 o Yet another prompt recognition fix (SWI mode).
 o This is more of a renumbering than a new edition. I promoted
    the mode to version 1.0 to emphasize the fact that it is now
    mature and stable enough to be considered production (in my
    opinion anyway).
Version 0.1.41:
 o GNU Emacs compatibility fixes.
Version 0.1.40:
 o prolog-get-predspec is now suitable to be called as
    imenu-extract-index-name-function. The predicate index works.
 o Since imenu works now as advertised, prolog-imenu-flag is t
    by default.
 o Eliminated prolog-create-predicate-index since the imenu
    utilities now work well. Actually, this function is also
    buggy, and I see no reason to fix it since we do not need it
    anyway.
 o Fixed prolog-pred-start, prolog-clause-start, prolog-clause-info.
 o Fix for prolog-build-case-strings; now prolog-upper-case-string
    and prolog-lower-case-string are correctly initialized,
 o Various font-lock changes; most importantly, block comments (/*
    ... */) are now correctly fontified in XEmacs even when they
    extend on multiple lines.
Version 0.1.36:
 o The debug prompt of SWI Prolog is now correctly recognized.
Version 0.1.35:
 o Minor font-lock bug fixes.

Defined variables (69)

mercury-mode-abbrev-tableAbbrev table for ‘mercury-mode’.
mercury-mode-hookHook run after entering ‘mercury-mode’.
mercury-mode-mapKeymap for ‘mercury-mode’.
mercury-mode-syntax-tableSyntax table for ‘mercury-mode’.
prolog-atom-char-regexpRegexp specifying characters which constitute atoms without quoting.
prolog-compilation-bufferName of the output buffer for Prolog compilation/consulting.
prolog-compile-stringAlist of strings and lists defining predicate for recompilation.
prolog-consult-compile-fileThe file to compile/consult (can be a temporary file).
prolog-consult-compile-first-lineThe number of the first line of the file to consult/compile.
prolog-consult-compile-outputHold the unprocessed output from the current prolog task.
prolog-consult-compile-real-fileThe file name of the buffer to compile/consult.
prolog-consult-stringAlist of strings defining predicate for reconsulting.
prolog-debug-off-stringPredicate for disabling debug mode.
prolog-debug-on-stringPredicate for enabling debug mode.
prolog-determinism-specificatorsAlist of Prolog determinism specificators used by font locking.
prolog-directivesAlist of Prolog source code directives used by font locking.
prolog-edit-menu-insert-moveCommands for Prolog code manipulation.
prolog-edit-menu-runtimeRuntime Prolog commands available from the editing buffer.
prolog-electric-colon-flagNon-nil means make ‘:’ electric (inserts ‘:-’ on a new line).
prolog-electric-dash-flagNon-nil means make ‘-’ electric (inserts a ‘-->’ on a new line).
prolog-electric-dot-flagNon-nil means make dot key electric.
prolog-electric-dot-full-predicate-templateIf nil, electric dot inserts only the current predicate’s name and ‘(’
prolog-electric-if-then-else-flagNon-nil makes ‘(’, ‘>’ and ‘;’ electric
prolog-electric-underscore-flagNon-nil means make underscore key electric.
prolog-eof-stringString or alist of strings that represent end of file for prolog.
prolog-head-delimiterA regexp for matching on the end delimiter of a head (e.g. ":-").
prolog-help-functionAlist for the name of the function for finding help on a predicate.
prolog-imenu-flagNon-nil means add a clause index menu for all prolog files.
prolog-imenu-max-linesThe maximum number of lines of the file for imenu to be enabled.
prolog-indent-widthThe indentation width used by the editing buffer.
prolog-inferior-menu-allMenu for the inferior Prolog buffer.
prolog-inferior-mode-abbrev-tableAbbrev table for ‘prolog-inferior-mode’.
prolog-inferior-mode-hookList of functions to call after the inferior prolog mode has initialized.
prolog-inferior-mode-mapKeymap for ‘prolog-inferior-mode’.
prolog-inferior-mode-syntax-tableSyntax table for ‘prolog-inferior-mode’.
prolog-info-alistAlist with all builtin predicates.
prolog-info-predicate-indexThe info node for the SICStus predicate index.
prolog-keywordsAlist of Prolog keywords which is used for font locking of directives.
prolog-left-indent-regexpRegexp for ‘prolog-electric-if-then-else-flag’.
prolog-left-parenThe characters used as left parentheses for the indentation code.
prolog-menu-helpHelp menu for the Prolog mode.
prolog-mode-abbrev-tableAbbrev table for ‘prolog-mode’.
prolog-mode-hookList of functions to call after the prolog mode has initialized.
prolog-mode-mapKeymap for ‘prolog-mode’.
prolog-mode-specificatorsAlist of Prolog mode specificators used by font locking.
prolog-mode-syntax-tableSyntax table for ‘prolog-mode’.
prolog-mode-versionProlog mode version number.
prolog-old-sicstus-keys-flagNon-nil means old SICStus Prolog mode keybindings are used.
prolog-paren-indentThe indentation increase for parenthesis expressions.
prolog-paren-indent-pIf non-nil, increase indentation for parenthesis expressions.
prolog-parse-modeThe parse mode used (decides from which point parsing is done).
prolog-process-flagNon-nil means that a prolog task (i.e. a consultation or compilation job)
prolog-program-nameAlist of program names for invoking an inferior Prolog with ‘run-prolog’.
prolog-program-switchesAlist of switches given to inferior Prolog run with ‘run-prolog’.
prolog-prompt-regexpAlist of prompts of the prolog system command line.
prolog-quoted-atom-regexpRegexp matching a quoted atom.
prolog-right-parenThe characters used as right parentheses for the indentation code.
prolog-smie-grammarPrecedence levels of infix operators.
prolog-string-regexpRegexp matching a string.
prolog-systemProlog interpreter/compiler used.
prolog-system-versionAlist of Prolog system versions.
prolog-trace-off-stringPredicate for disabling tracing.
prolog-trace-on-stringPredicate for enabling tracing.
prolog-typesAlist of Prolog types used by font locking.
prolog-underscore-wordchar-flagNon-nil means underscore (_) is a word-constituent character.
prolog-use-sicstus-sdIf non-nil, use the source level debugger of SICStus 3#7 and later.
prolog-use-standard-consult-compile-method-flagNon-nil means use the standard compilation method.
prolog-zip-off-stringPredicate for disabling zip mode for SICStus.
prolog-zip-on-stringPredicate for enabling zip mode for SICStus.

Defined functions (102)

mercury-mode()
prolog-atleast-version(VERSION)
prolog-atom-under-point()
prolog-beginning-of-clause()
prolog-beginning-of-predicate()
prolog-bsts(STRING)
prolog-buffer-module()
prolog-build-info-alist(&optional VERBOSE)
prolog-build-prolog-command(COMPILEP FILE BUFFERNAME &optional FIRST-LINE)
prolog-clause-end(&optional NOT-ALLOW-METHODS)
prolog-clause-info()
prolog-clause-start(&optional NOT-ALLOW-METHODS)
prolog-comment-limits()
prolog-compile-buffer()
prolog-compile-file()
prolog-compile-predicate()
prolog-compile-region(BEG END)
prolog-consult-buffer()
prolog-consult-compile(COMPILEP FILE &optional FIRST-LINE)
prolog-consult-compile-buffer(COMPILEP)
prolog-consult-compile-file(COMPILEP)
prolog-consult-compile-filter(PROCESS OUTPUT)
prolog-consult-compile-predicate(COMPILEP)
prolog-consult-compile-region(COMPILEP BEG END)
prolog-consult-file()
prolog-consult-predicate()
prolog-consult-region(BEG END)
prolog-debug-off()
prolog-debug-on(&optional ARG)
prolog-disable-sicstus-sd()
prolog-do-auto-fill()
prolog-edit-menu-insert-move(ARG1)
prolog-edit-menu-runtime(ARG1)
prolog-electric--colon()
prolog-electric--dash()
prolog-electric--dot()
prolog-electric--if-then-else()
prolog-electric--underscore()
prolog-enable-sicstus-sd()
prolog-end-of-clause()
prolog-end-of-predicate()
prolog-ensure-process(&optional WAIT)
prolog-face-name-p(FACE)
prolog-fill-paragraph()
prolog-find-documentation()
prolog-find-term(FUNCTOR ARITY &optional PREFIX)
prolog-find-unmatched-paren()
prolog-find-value-by-system(ALIST)
prolog-font-lock-keywords()
prolog-font-lock-object-matcher(BOUND)
prolog-goto-predicate-info(PREDICATE)
prolog-goto-prolog-process-buffer()
prolog-help-apropos(STRING)
prolog-help-info(PREDICATE)
prolog-help-on-predicate()
prolog-help-online(PREDICATE)
prolog-in-object()
prolog-indent-buffer()
prolog-indent-predicate()
prolog-inferior-buffer(&optional DONT-RUN)
prolog-inferior-guess-flavor(&optional IGNORED)
prolog-inferior-menu()
prolog-inferior-menu-all(ARG1)
prolog-inferior-mode()
prolog-inferior-self-insert-command()
prolog-input-filter(STR)
prolog-insert-module-modeline()
prolog-insert-next-clause()
prolog-insert-predicate-template()
prolog-insert-predspec()
prolog-mark-clause()
prolog-mark-predicate()
prolog-menu()
prolog-menu-help(ARG1)
prolog-mode()
prolog-mode-keybindings-common(MAP)
prolog-mode-keybindings-edit(MAP)
prolog-mode-keybindings-inferior(MAP)
prolog-mode-variables()
prolog-mode-version()
prolog-old-process-buffer(COMPILEP)
prolog-old-process-file(COMPILEP)
prolog-old-process-predicate(COMPILEP)
prolog-old-process-region(COMPILEP START END)
prolog-paren-balance()
prolog-pred-end()
prolog-pred-start()
prolog-process-insert-string(PROCESS STRING)
prolog-read-predicate()
prolog-replace-in-string(STR REGEXP NEWTEXT &optional LITERAL)
prolog-smie-rules(KIND TOKEN)
prolog-temporary-file()
prolog-toggle-sicstus-sd()
prolog-trace-off()
prolog-trace-on(&optional ARG)
prolog-uncomment-region(BEG END &optional ARG)
prolog-variables-to-anonymous(BEG END)
prolog-view-predspec()
prolog-zip-off()
prolog-zip-on(&optional ARG)
run-prolog(ARG)
switch-to-prolog(ARG)

Defined faces (0)