This file is indexed.

/usr/share/doc/swi-prolog-doc/Manual/pceemacs.html is in swi-prolog-doc 5.6.59-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<HTML>
<HEAD>
<TITLE>SWI-Prolog 5.6.59 Reference Manual: Section 3.4</TITLE><LINK REL=home HREF="index.html">
<LINK REL=contents HREF="Contents.html">
<LINK REL=index HREF="DocIndex.html">
<LINK REL=previous HREF="editreload.html">
<LINK REL=next HREF="guitracer.html">
<STYLE type="text/css">
/* Style sheet for SWI-Prolog latex2html
*/

dd.defbody
{ margin-bottom: 1em;
}

dt.pubdef
{ background-color: #c5e1ff;
}

pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}

div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}

div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}

div.author
{ text-align: center;
font-style: italic;
}

div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}

div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}

div.toc-h1
{ font-size: 200%;
font-weight: bold;
}

div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}

div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}

div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}

span.sec-nr
{ 
}

span.sec-title
{ 
}

span.pred-ext
{ font-weight: bold;
}

span.pred-tag
{ float: right;
font-size: 80%;
font-style: italic;
color: #202020;
}

/* Footnotes */

sup.fn { color: blue; text-decoration: underline; }
span.fn-text { display: none; }
sup.fn span {display: none;}
sup:hover span 
{ display: block !important;
position: absolute; top: auto; left: auto; width: 80%;
color: #000; background: white;
border: 2px solid;
padding: 5px; margin: 10px; z-index: 100;
font-size: smaller;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="white">
<DIV class="navigate"><A class="nav" href="index.html"><IMG SRC="home.gif" BORDER=0 ALT="Home"></A>
<A class="nav" href="Contents.html"><IMG SRC="index.gif" BORDER=0 ALT="Contents"></A>
<A class="nav" href="DocIndex.html"><IMG SRC="yellow_pages.gif" BORDER=0 ALT="Index"></A>
<A class="nav" href="editreload.html"><IMG SRC="prev.gif" BORDER=0 ALT="Previous"></A>
<A class="nav" href="guitracer.html"><IMG SRC="next.gif" BORDER=0 ALT="Next"></A>
</DIV>

<H2><A NAME="sec:3.4"><SPAN class="sec-nr">3.4</SPAN> <SPAN class="sec-title">Using 
the PceEmacs built-in editor</SPAN></A></H2>

<A NAME="sec:pceemacs"></A>

<H3><A NAME="sec:3.4.1"><SPAN class="sec-nr">3.4.1</SPAN> <SPAN class="sec-title">Activating 
PceEmacs</SPAN></A></H3>

<P>Initially <A NAME="idx:edit1:286"></A><A class="pred" href="listing.html#edit/1">edit/1</A> 
uses the editor specified in the <CODE>EDITOR</CODE> environment 
variable. There are two ways to force it to use the built-in editor. One 
is to set the Prolog flag <A class="flag" href="flags.html#flag:editor">editor</A> 
to
<CODE>pce_emacs</CODE> and the other is by starting the editor 
explicitly using the <A NAME="idx:emacs01:287"></A><SPAN class="pred-ext">emacs/[0,1]</SPAN> 
predicates.

<H3><A NAME="sec:3.4.2"><SPAN class="sec-nr">3.4.2</SPAN> <SPAN class="sec-title">Bluffing 
through PceEmacs</SPAN></A></H3>

<A NAME="sec:emacsbluff"></A>

<P>PceEmacs closely mimics Richard Stallman's GNU-Emacs commands, adding 
features from modern window-based editors to make it more acceptable for 
beginners.<SUP class="fn">16<SPAN class="fn-text">Decent 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.</SPAN></SUP>

<P>At the basis, PceEmacs maps keyboard sequences to methods defined on 
the extended <B>editor</B> 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 <EM>mode</EM> 
is provided through <STRONG>Help/Show key bindings</STRONG> (<CODE>Control-h 
Control-b</CODE>).

<H4><A NAME="sec:3.4.2.1"><SPAN class="sec-nr">3.4.2.1</SPAN> <SPAN class="sec-title">Edit 
modes</SPAN></A></H4>

<P>Modes are the heart of (Pce)Emacs. Modes define dedicated editing 
support for a particular kind of (source-)text. For our purpose we want
<EM>Prolog mode</EM>. Their are various ways to make PceEmacs use Prolog 
mode for a file.

<P>
<UL>
<LI><I>Using the proper extension</I><BR>
If the file ends in <CODE>.pl</CODE> or the selected alternative (e.g. <CODE>.pro</CODE>) 
extension, Prolog mode is selected.

<P>
<LI><I>Using <CODE>#!/path/to/pl</CODE></I><BR>
If the file is a <EM>Prolog Script</EM> file, starting with the line
<CODE>#!/path/to/pl options -s</CODE>, Prolog mode is selected 
regardless of the extension

<P>
<LI><I>Using <CODE>-*- Prolog -*-</CODE></I><BR>
If the above sequence appears in the first line of the file (inside a 
Prolog comment) Prolog mode is selected.

<P>
<LI><I>Explicit selection</I><BR>
Finally, using <STRONG>File/Mode/Prolog</STRONG> (<CODE>File/Mode/Prolog</CODE>)ou 
can switch to Prolog mode explicitly.
</UL>

<H4><A NAME="sec:3.4.2.2"><SPAN class="sec-nr">3.4.2.2</SPAN> <SPAN class="sec-title">Frequently 
used editor commands</SPAN></A></H4>

<P>Below we list a few important commands and how to activate them.

<P>
<UL>
<LI><I>Cut/Copy/Paste</I><BR>
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
<EM>automatically</EM> copied to the clipboard (X11 primary selection on 
Unix). <EM>Cut</EM> is achieved using the <CODE>DEL</CODE> key or by 
typing something else at the location. <EM>Paste</EM> 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 <STRONG>Edit/Paste</STRONG> 
menu-entry. Text is pasted at the caret-location.

<P>
<LI><I>Undo</I><BR>
Undo is bound to the GNU-Emacs <CODE>Control-_</CODE> as well as the 
MS-Windows
<CODE>Control-Z</CODE> sequence.

<P>
<LI><I>Abort</I><BR>
Multi-key sequences can be aborted at any stage using <CODE>Control-G</CODE>.

<P>
<LI><I>Find</I><BR>
Find (Search) is started using <CODE>Control-S</CODE> (forward) or
<CODE>Control-R</CODE> (backward). PceEmacs implements <EM>incremental 
search</EM>. 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.

<P>If the target cannot be found, PceEmacs warns you and no longer 
extends the search-string.<SUP class="fn">17<SPAN class="fn-text">GNU-Emacs 
keeps extending the string, but why? Adding more text will not make it 
match.</SPAN></SUP> During search some characters have special meaning. 
Typing anything but these characters commits the search, re-starting 
normal edit mode. Special commands are:

<DL>
<DT><B><CODE>Control-S</CODE></B></DT>
<DD class="defbody">
Search for next forwards.
</DD>
<DT><B><CODE>Control-R</CODE></B></DT>
<DD class="defbody">
Search for next backwards.
</DD>
<DT><B><CODE>Control-W</CODE></B></DT>
<DD class="defbody">
Extend search to next word-boundary.
</DD>
<DT><B><CODE>Control-G</CODE></B></DT>
<DD class="defbody">
Cancel search, go back to where it started.
</DD>
<DT><B><CODE>ESC</CODE></B></DT>
<DD class="defbody">
Commit search, leaving caret at found location.
</DD>
<DT><B><CODE>Backspace</CODE></B></DT>
<DD class="defbody">
Remove a character from the search string.
</DD>
</DL>

<P>
<LI><I>Dynamic Abbreviation</I><BR>
Also called <EM>dabbrev</EM> is an important feature of Emacs clones to 
support programming. After typing the first few letters of an identifier 
you may hit <CODE>Alt-/</CODE>, causing PceEmacs to search backwards for 
identifiers that start the same and using it to complete the text you 
typed. A second <CODE>Alt-/</CODE> searches further backwards. If there 
are no hits before the caret it starts searching forwards. With some 
practice, this system allows for very fast entering code with nice and 
readable identifiers (or other difficult long words).

<P>
<LI><I>Open (a file)</I><BR>
Is called <STRONG>File/Find file</STRONG> (<CODE>Control-x Control-f</CODE>). 
By default the file is loaded into the current window. If you want to 
keep this window, Hit <CODE>Alt-s</CODE> or click the little icon at the 
bottom-left to make the window <EM>sticky</EM>.

<P>
<LI><I>Split view</I><BR>
Sometimes you want to look at two places of the same file. To do this, 
use <CODE>Control-x 2</CODE> to create a new window pointing to the same 
file. Do not worry, you can edit as well as move around in both.
<CODE>Control-x 1</CODE> kills all other windows running on the same 
file.
</UL>

<P>These were the most commonly used commands. In section
<A class="sec" href="pceemacs.html">section 3.4.3</A> we discuss 
specific support for dealing with Prolog source code.

<H3><A NAME="sec:3.4.3"><SPAN class="sec-nr">3.4.3</SPAN> <SPAN class="sec-title">Prolog 
Mode</SPAN></A></H3>

<A NAME="sec:emacsprologmode"></A>

<P>In the previous section (<A class="sec" href="pceemacs.html">section 
3.4.2</A>) we explained the basics of PceEmacs. Here we continue with 
Prolog specific functionality. Possibly the most interesting is <EM>Syntax 
highlighting</EM>. 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.

<P>
<UL>
<LI><I>After typing a <CODE><CODE>.</CODE></CODE></I><BR>
After typing a <CODE><CODE>.</CODE></CODE> that is not preceded by a <EM>symbol</EM> 
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.

<P>
<LI><I>After the command <CODE>Control-c Control-s</CODE></I><BR>
Acronym for <B>C</B>check <B>S</B>yntax it performs the same checks as 
above for the clause surrounding the caret. On a syntax error however, 
the caret is moved to the expected location of the error.<SUP class="fn">18<SPAN class="fn-text">In 
most cases the location where the parser cannot proceed is further down 
the file than the actual error-location.</SPAN></SUP>

<P>
<LI><I>After pausing for two seconds</I><BR>
After a short pause (2 seconds), PceEmacs opens the edit-buffer and 
reads it as a whole, creating an index of defined, called, dynamic, 
imported and exported predicates. After completing this, it re-reads the 
file and colours all clauses and calls with valid syntax.

<P>
<LI><I>After typing <CODE>Control-l Control-l</CODE></I><BR>
The <CODE>Control-l</CODE> commands re-centers the window (scrolls the 
window to make the caret the center of the window). Hitting this command 
twice starts the same process as above.
</UL>

<P><B>The colour schema</B> itself is defined in
<CODE>library(emacs/prolog_colour)</CODE>. 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 for common commands such as viewing the documentation 
or source. <B>Bold</B> text is used to indicate the definition of 
objects (typically predicates when using plain Prolog). Other colours 
follow intuitive conventions. See <A class="tab" href="pceemacs.html#tab:plcolour">table 
3</A>.

<P>
<CENTER>
<TABLE BORDER=2 FRAME=box RULES=groups>
<TR VALIGN=top><TD COLSPAN=2 ALIGN=center>Clauses</TR>
<TBODY>
<TR VALIGN=top><TD>Blue bold</TD><TD>Head of an exported predicate </TD></TR>
<TR VALIGN=top><TD>Red bold</TD><TD>Head of a predicate that is not 
called </TD></TR>
<TR VALIGN=top><TD>Black Bold</TD><TD>Head of remaining predicates </TD></TR>
<TBODY>
<TR VALIGN=top><TD COLSPAN=2 ALIGN=center>Calls in the clause-body</TR>
<TBODY>
<TR VALIGN=top><TD>Blue</TD><TD>Call to built-in or imported predicate </TD></TR>
<TR VALIGN=top><TD>Red</TD><TD>Call to not-defined predicate </TD></TR>
<TR VALIGN=top><TD>Purple</TD><TD>Call to dynamic predicate </TD></TR>
<TBODY>
<TR VALIGN=top><TD COLSPAN=2 ALIGN=center>Other entities</TR>
<TBODY>
<TR VALIGN=top><TD>Dark green</TD><TD>Comment </TD></TR>
<TR VALIGN=top><TD>Dark blue</TD><TD>Quoted atom or string </TD></TR>
<TR VALIGN=top><TD>Brown</TD><TD>Variable </TD></TR>
</TABLE>

</CENTER>
<A NAME="tab:plcolour"></A>
<TABLE ALIGN=center WIDTH="75%"><TR><TD>
<B>Table 3 : </B>Colour conventions</TABLE>

<P><B>Layout support</B> 

<P>Layout is not `just nice', it is <EM>essential</EM> 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.<SUP class="fn">19<SPAN class="fn-text">Defined in 
Prolog in the file <CODE>library(emacs/prolog_mode)</CODE>, you may wish 
to extend this. Please contribute your extensions!</SPAN></SUP> Below 
are examples of typical constructs.

<PRE class="code">
head(arg1, arg2).

head(arg1, arg2) :- !.

head(Arg1, arg2) :- !,
        call1(Arg1).

head(Arg1, arg2) :-
        (   if(Arg1)
        -&gt;  then
        ;   else
        ).

head(Arg1) :-
        (   a
        ;   b
        ).

head :-
        a(many,
          long,
          arguments(with,
                    many,
                    more),
          and([ a,
                long,
                list,
                with,
                a,
              | tail
              ])).
</PRE>

<P>PceEmacs uses the same conventions as GNU-Emacs. The <CODE>TAB</CODE> 
key indents the current line according to the syntax rules. <CODE>Alt-q</CODE> 
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.

<H4><A NAME="sec:3.4.3.1"><SPAN class="sec-nr">3.4.3.1</SPAN> <SPAN class="sec-title">Finding 
your way around</SPAN></A></H4>

<P>The command <CODE>Alt-.</CODE> 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 <A NAME="idx:edit1:288"></A><A class="pred" href="listing.html#edit/1">edit/1</A>. 
This makes locating predicates reliable if all sources are loaded and 
up-to-date (see <A NAME="idx:make0:289"></A><A class="pred" href="consulting.html#make/0">make/0</A>).

<P>In addition, references to files in <A NAME="idx:usemodule12:290"></A><A class="pred" href="import.html#use_module/1">use_module/[1,2]</A>, <A NAME="idx:consult1:291"></A><A class="pred" href="consulting.html#consult/1">consult/1</A>, 
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.

<P></BODY></HTML>