Prolog Emacs, PceEmacs


3.4 The exhaust of
the PceEmacs built-in editor

3.4.1 Activating

At the delivery edit/1
uses the editor specified in the EDITOR atmosphere
variable. There are two ways to drive it to make exhaust of the built-in editor. One
is to verbalize the Prolog flag editor
pce_emacs and the opposite is by beginning the editor
explicitly the exhaust of the emacs/[0,1] predicates.

3.4.2 Bluffing
via PceEmacs

PceEmacs carefully mimics Richard Stallman’s GNU-Emacs instructions, in conjunction with
aspects from contemporary window-based mostly editors to make it more acceptable for
novices.41First rate merging with
MS-Windows regulate-key conventions is sophisticated as many war with
GNU-Emacs. Particularly the decrease/reproduction/paste instructions war with
crucial GNU-Emacs instructions.

At the root, PceEmacs maps keyboard sequences to solutions defined on
the prolonged editor object. Some frequently faded instructions are,
with their key-binding, supplied in the menu bar above every editor
window. A complete overview of the bindings for the contemporary mode
is supplied via Abet/Showcase key bindings (Administration-h
). Edit

Modes are the heart of (Pce)Emacs. Modes present an explanation for dedicated enhancing
give a expend to for a explicit more or much less (source) text. For our function we desire
Prolog mode. There are an excessive amount of ways to make PceEmacs exhaust Prolog
mode for a file.

  • The exhaust of the factual extension

    If the file ends in .pl or the chosen different (e.g. .official)
    extension, Prolog mode is chosen.

  • The exhaust of #!/direction/to/.../swipl

    If the file is a Prolog Script file, beginning with the line
    #!/direction/to/swipl alternate choices, Prolog mode is
    chosen no matter the extension.

  • The exhaust of -*- Prolog -*-

    If the above sequence seems in the first line of the file (inner a
    Prolog comment) Prolog mode is chosen.

  • Narrate choice

    In the end, the exhaust of File/Mode/Prolog that you should switch to
    Prolog mode explicitly. Many times
faded editor instructions

Under we listing a pair of crucial instructions and easy solutions to spark off them.

  • Slice/Copy/Paste

    These instructions observe Unix/X11 traditions. You have to seemingly well seemingly also very effectively be most fitted with a
    three-button mouse. After deciding on the exhaust of the left-mouse (double-click on
    uses notice-mode and triple line-mode), the chosen text is
    robotically copied to the clipboard (X11 most critical choice on
    Unix). Slice is completed the exhaust of the DEL key or by
    typing one thing else at the positioning. Paste is completed the exhaust of
    the heart-mouse (or wheel) button. While you don’t prefer a heart-mouse
    button, pressing the left- and appropriate-button at the identical time is
    interpreted as a heart-button click on. If nothing helps, there could be the Edit/Paste
    menu entry. Text is pasted at the caret situation.

  • Undo

    Undo is certain to the GNU-Emacs Administration-_ in addition to to the
    Administration-Z sequence.

  • Abort

    Multi-key sequences could seemingly well also furthermore be aborted at any stage the exhaust of Administration-G.

  • Find

    Find (Search) is began the exhaust of Administration-S (forward) or
    Administration-R (backward). PceEmacs implements incremental
    . Here’s sophisticated to make exhaust of for beginners, but very grand
    when you receive the clue. After one among the above delivery keys, the system
    indicates search mode in the gap line. As you should seemingly well also very effectively be typing the search
    string, the system searches for it, extending the search with every
    personality you form. It illustrates the contemporary match the exhaust of a inexperienced

    If the target can now not be chanced on, PceEmacs warns you and now now not
    extends the search string.42GNU-Emacs
    retains extending the string, but why? Adding more text is now not going to make it
    Trusty via search, some characters have special which device.
    Typing anything else but these characters commits the search, re-beginning
    recurring edit mode. Particular instructions are:

    Search forwards for next.
    Search backwards for next.
    Delay search to next notice boundary.
    Slay search, return to the place it began.
    Commit search, leaving caret at chanced on situation.
    Lift a personality from the search string.
  • Dynamic Abbreviation

    Continually frequently known as dabbrev, dynamic abbreviation is a truly crucial
    feature of Emacs clones to present a expend to programming. After typing the first
    few letters of an identifier, you should seemingly well also just press Alt-/, causing
    PceEmacs to appear backwards for identifiers that delivery the identical and exhaust
    it to cease the text you typed. A 2d Alt-/ searches
    further backwards. If there need to now not any hits before the caret, it begins
    looking forwards. With some observe, this vogue permits for entering
    code very fleet with fantastic and readable identifiers (or other sophisticated
    long words).

  • Initiate (a file)

    Continuously known as File/Find file (Administration-x Administration-f).
    By default the file is loaded into the contemporary window. You potentially need to need to
    withhold this window, press Alt-s or click on the tiny icon at
    the bottom left to make the window sticky.

  • Split survey

    Assuredly you will want to need to gape at two locations in the identical file. To make this,
    exhaust Administration-x 2 to create a brand contemporary window pointing to the identical
    file. Attain now not be troubled, that you should edit in addition to to transfer around in each.
    Administration-x 1 kills all other windows running on the identical

These are basically the most recurrently faded instructions. In
section 3.4.3 we
focus on specific give a expend to for going via Prolog source code.

3.4.3 Prolog

In the previous section (section
) we explained the basics of PceEmacs. Here we continue with
Prolog-specific efficiency. Maybe basically the most attention-grabbing is Syntax
. Unlike most editors the place right here’s in conserving with straightforward
patterns, PceEmacs syntax highlighting is completed by Prolog itself
in actuality reading and interpreting the source as you form it. There are
three moments at which PceEmacs tests (segment of) the syntax.

  • After typing a .

    After typing a . that is now not preceded by a image
    personality, the system assumes you completed a clause, tries to search out the
    delivery of this clause and verifies the syntax. If this process succeeds
    it colours the parts of the clause per the foundations given
    below. Colouring is done the exhaust of files from the last beefy take a look at on
    this file. If it fails, the syntax error is displayed in the gap line
    and the clause is now not colored.

  • After the divulge Administration-c Administration-s

    Acronym for Check Syntax, it performs the identical tests as
    above for the clause surrounding the caret. On a syntax error, nonetheless,
    the caret is moved to the anticipated situation of the error.43In
    most cases the positioning the place the parser can now not proceed is further down
    the file than the exact error situation.

  • After pausing for two seconds

    After a short cease (2 seconds), PceEmacs opens the edit buffer and
    reads it as a complete, rising an index of defined, known as, dynamic,
    imported and exported predicates. After finishing up this, it re-reads the
    file and colours all clauses and calls with official syntax.

  • After typing Administration-l Administration-l

    The Administration-l divulge re-facilities the window (scrolls the
    window to make the caret the heart of the window). Typing this divulge
    twice begins the identical process as above.

The colour schema itself is defined in
library(emacs/prolog_colour). The colouring could seemingly well also furthermore be prolonged
and modified the exhaust of multifile predicates. Please take a look at this source file
for info. In classic, underlined objects have a popup (appropriate-mouse
button) linked with classic instructions similar to viewing the
documentation or source. Heroic text is faded to point the
definition of objects (usually predicates when the exhaust of easy Prolog).
Somewhat a pair of colours observe intuitive conventions. Admire table

Blue valorous Head of an exported predicate
Red valorous Head of a predicate that is now not known as
Black valorous Head of last predicates
Calls in the clause body
Blue Name to built-in or imported
Red Name to undefined predicate
Crimson Name to dynamic predicate
Somewhat a pair of entities
Dim inexperienced Comment
Dim blue Quoted atom or string
Brown Variable

Desk 3 : Shade conventions

Layout give a expend to

Layout is now not‘honest fantastic’, it is some distance critical for writing
readable code. There is a lot debate on the factual structure of Prolog.
PceEmacs, being a rather minute project, helps totally one explicit
model for structure.44Outlined in
Prolog in the file library(emacs/prolog_mode), you should seemingly well also just wish
to lengthen this. Please make a contribution your extensions!
are examples of long-established constructs.

head(arg1, arg2).

head(arg1, arg2) :- !.

head(Arg1, arg2) :- !,

head(Arg1, arg2) :-
        (   if(Arg1)
        ->  then
        ;   else

head(Arg1) :-
        (   a
        ;   b

head :-
          and([ a,
              | tail

PceEmacs uses the identical conventions as GNU-Emacs. The TAB
key indents the contemporary line per the syntax rules. Alt-q
indents all traces of the contemporary clause. It gives give a expend to for head,
calls (indented 1 tab), if-then-else, disjunction and argument lists
broken across multiple traces as illustrated above. Finding
your device around

The divulge Alt-. extracts title and arity from the caret
situation and jumps (after conformation or edit) to the definition of the
predicate. It does so in conserving with the source-situation database of loaded
predicates also faded by edit/1.
This makes discovering predicates official if all sources are loaded and
up-to-date (stumble on make/0).

To boot to, references to files in use_module/[1,2], consult/1,
etc. are crimson if the file can now not be chanced on and underlined blue if the file
could seemingly well also furthermore be loaded. A popup permits for opening the referenced file.

Read More

Leave A Reply

Your email address will not be published.