PceEmacs closely mimics Richard Stallman's GNU-Emacs commands, adding features from modern window-based editors to make it more acceptable for beginners.37Decent merging with MS-Windows control-key conventions is difficult as many conflict with GNU-Emacs. Especially the cut/copy/paste commands conflict with important GNU-Emacs commands.
At the basis, PceEmacs maps keyboard sequences to methods defined on
the extended editor object. Some frequently used commands are,
with their key-binding, presented in the menu bar above each editor
window. A complete overview of the bindings for the current mode
is provided through Help/Show key bindings (
Modes are the heart of (Pce)Emacs. Modes define dedicated editing support for a particular kind of (source) text. For our purpose we want Prolog mode. There are various ways to make PceEmacs use Prolog mode for a file.
- Using the proper extension
If the file ends in
.plor the selected alternative (e.g.
.pro) extension, Prolog mode is selected.
If the file is a Prolog Script file, starting with the line
#!/path/to/swiploptions, Prolog mode is selected regardless of the extension.
-*- Prolog -*-
If the above sequence appears in the first line of the file (inside a Prolog comment) Prolog mode is selected.
- Explicit selection
Finally, using File/Mode/Prolog you can switch to Prolog mode explicitly.
Below we list a few important commands and how to activate them.
These commands follow Unix/X11 traditions. You're best suited with a three-button mouse. After selecting using the left-mouse (double-click uses word-mode and triple line-mode), the selected text is automatically copied to the clipboard (X11 primary selection on Unix). Cut is achieved using the
DELkey or by typing something else at the location. Paste is achieved using the middle-mouse (or wheel) button. If you don't have a middle-mouse button, pressing the left- and right-button at the same time is interpreted as a middle-button click. If nothing helps, there is the Edit/Paste menu entry. Text is pasted at the caret location.
Undo is bound to the GNU-Emacs
Control-_as well as the MS-Windows
Multi-key sequences can be aborted at any stage using
Find (Search) is started using
Control-R(backward). PceEmacs implements incremental search. This is difficult to use for novices, but very powerful once you get the clue. After one of the above start keys, the system indicates search mode in the status line. As you are typing the search string, the system searches for it, extending the search with every character you type. It illustrates the current match using a green background.
If the target cannot be found, PceEmacs warns you and no longer extends the search string.38GNU-Emacs keeps extending the string, but why? Adding more text will not make it match. During search, some characters have special meaning. Typing anything but these characters commits the search, re-starting normal edit mode. Special commands are:
- Search forwards for next.
- Search backwards for next.
- Extend search to next word boundary.
- Cancel search, go back to where it started.
- Commit search, leaving caret at found location.
- Remove a character from the search string.
- Dynamic Abbreviation
Also called dabbrev, dynamic abbreviation is an important feature of Emacs clones to support programming. After typing the first few letters of an identifier, you may press
Alt-/, causing PceEmacs to search backwards for identifiers that start the same and use it to complete the text you typed. A second
Alt-/searches further backwards. If there are no hits before the caret, it starts searching forwards. With some practice, this system allows for entering code very fast with nice and readable identifiers (or other difficult long words).
- Open (a file)
Is called File/Find file (
Control-x Control-f). By default the file is loaded into the current window. If you want to keep this window, press
Alt-sor click the little icon at the bottom left to make the window sticky.
- Split view
Sometimes you want to look at two places in the same file. To do this, use
Control-x 2to create a new window pointing to the same file. Do not worry, you can edit as well as move around in both.
Control-x 1kills all other windows running on the same file.
These are the most commonly used commands. In section 3.4.3 we discuss specific support for dealing with Prolog source code.