5
<TITLE>SWI-Prolog 5.6.53 Reference Manual: Section 4.4</TITLE><LINK REL=home HREF="index.html">
5
<TITLE>SWI-Prolog 5.6.55 Reference Manual: Section 4.4</TITLE><LINK REL=home HREF="index.html">
6
6
<LINK REL=contents HREF="Contents.html">
7
7
<LINK REL=index HREF="DocIndex.html">
8
8
<LINK REL=previous HREF="consulting.html">
135
135
<P>SWI-Prolog offers an extensible interface which allows the user to
136
136
edit objects of the program: predicates, modules, files, etc. The editor
137
interface is implemented by <A NAME="idx:edit1:459"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
137
interface is implemented by <A NAME="idx:edit1:460"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
138
138
and consists of three parts:
139
139
<EM>locating</EM>, <EM>selecting</EM> and <EM>starting the editor</EM>.
141
141
<P>Any of these parts may be extended or redefined by adding clauses to
142
various multi-file (see <A NAME="idx:multifile1:460"></A><A class="pred" href="dynamic.html#multifile/1">multifile/1</A>)
142
various multi-file (see <A NAME="idx:multifile1:461"></A><A class="pred" href="dynamic.html#multifile/1">multifile/1</A>)
143
143
predicates defined in the module
144
144
<CODE>prolog_edit</CODE>.
146
<P>The built-in edit specifications for <A NAME="idx:edit1:461"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
146
<P>The built-in edit specifications for <A NAME="idx:edit1:462"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
147
147
(see prolog_edit:locate/3) are described below.
178
178
into a list of <EM>Locations</EM>. If there is more than one `hit', the
179
179
user is asked to select from the locations found. Finally,
180
180
prolog_edit:edit_source/1 is used to invoke the user's preferred editor.
181
Typically, <A NAME="idx:edit1:462"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
181
Typically, <A NAME="idx:edit1:463"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
182
182
can be handed the name of a predicate, module, basename of a file, XPCE
183
183
class, XPCE method, etc.</DD>
184
184
<DT class="pubdef"><A NAME="edit/0"><STRONG>edit</STRONG></A></DT>
185
185
<DD class="defbody">
186
Edit the `default' file using <A NAME="idx:edit1:463"></A><A class="pred" href="listing.html#edit/1">edit/1</A>.
186
Edit the `default' file using <A NAME="idx:edit1:464"></A><A class="pred" href="listing.html#edit/1">edit/1</A>.
187
187
The default file is the file loaded with the command-line option <STRONG>-s</STRONG>
188
188
or, in windows, the file loaded by double-clicking from the Windows
190
190
<DT class="pubdef"><A NAME="prolog_edit:locate/3"><STRONG>prolog_edit:locate</STRONG>(<VAR>+Spec,
191
191
-FullSpec, -Location</VAR>)</A></DT>
192
192
<DD class="defbody">
193
Where <VAR>Spec</VAR> is the specification provided through <A NAME="idx:edit1:464"></A><A class="pred" href="listing.html#edit/1">edit/1</A>.
193
Where <VAR>Spec</VAR> is the specification provided through <A NAME="idx:edit1:465"></A><A class="pred" href="listing.html#edit/1">edit/1</A>.
194
194
This multifile predicate is used to enumerate locations at with an
195
195
object satisfying the given <VAR>Spec</VAR> can be found. <VAR>FullSpec</VAR>
196
196
is unified with the complete specification for the object. This
211
211
<DD class="defbody">
212
212
Start editor on <VAR>Location</VAR>. See prolog_edit:locate/3 for the
213
213
format of a location term. This multi-file predicate is normally not
214
defined. If it succeeds, <A NAME="idx:edit1:465"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
214
defined. If it succeeds, <A NAME="idx:edit1:466"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
215
215
assumes the editor is started.
217
<P>If it fails, <A NAME="idx:edit1:466"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
217
<P>If it fails, <A NAME="idx:edit1:467"></A><A class="pred" href="listing.html#edit/1">edit/1</A>
218
218
uses its internal defaults, which are defined by the Prolog flag <A class="flag" href="flags.html#flag:editor">editor</A>
219
219
and/or the environment variable
220
220
<CODE>EDITOR</CODE>. The following rules apply. If the Prolog flag <A class="flag" href="flags.html#flag:editor">editor</A>
232
232
<DT class="pubdef"><A NAME="prolog_edit:edit_command/2"><STRONG>prolog_edit:edit_command</STRONG>(<VAR>+Editor,
233
233
-Command</VAR>)</A></DT>
234
234
<DD class="defbody">
235
Determines how <VAR>Editor</VAR> is to be invoked using <A NAME="idx:shell1:467"></A><A class="pred" href="system.html#shell/1">shell/1</A>.
236
<VAR>Editor</VAR> is the determined editor (see <A NAME="idx:editsource1:468"></A><SPAN class="pred-ext">edit_source/1</SPAN>),
235
Determines how <VAR>Editor</VAR> is to be invoked using <A NAME="idx:shell1:468"></A><A class="pred" href="system.html#shell/1">shell/1</A>.
236
<VAR>Editor</VAR> is the determined editor (see <A NAME="idx:editsource1:469"></A><SPAN class="pred-ext">edit_source/1</SPAN>),
237
237
without the full path specification, and without possible (exe)
239
239
<VAR>Command</VAR> is an atom describing the command. The pattern
268
268
List specified predicates (when an atom is given all predicates with
269
269
this name will be listed). The listing is produced on the basis of the
270
270
internal representation, thus losing user's layout and variable name
271
information. See also <A NAME="idx:portrayclause1:469"></A><A class="pred" href="listing.html#portray_clause/1">portray_clause/1</A>.
271
information. See also <A NAME="idx:portrayclause1:470"></A><A class="pred" href="listing.html#portray_clause/1">portray_clause/1</A>.
273
273
<DT class="pubdef"><A NAME="listing/0"><STRONG>listing</STRONG></A></DT>
274
274
<DD class="defbody">
275
List all predicates of the database using <A NAME="idx:listing1:470"></A><A class="pred" href="listing.html#listing/1">listing/1</A>.</DD>
275
List all predicates of the database using <A NAME="idx:listing1:471"></A><A class="pred" href="listing.html#listing/1">listing/1</A>.</DD>
276
276
<DT class="pubdef"><A NAME="portray_clause/1"><STRONG>portray_clause</STRONG>(<VAR>+Clause</VAR>)</A></DT>
277
277
<DD class="defbody">
278
278
Pretty print a clause. A clause should be specified as a term `<CODE><<VAR>Head</VAR>>
279
279
:- <<VAR>Body</VAR>></CODE>'. Facts are represented as `<CODE><<VAR>Head</VAR>>
280
280
:- true</CODE>' or simply <CODE><<VAR>Head</VAR>></CODE>.
281
281
Variables in the clause are written as <VAR>A</VAR>, <VAR>B</VAR>, ... .
282
Singleton variables are written as <CODE>_</CODE>. See also <A NAME="idx:portrayclause2:471"></A><A class="pred" href="listing.html#portray_clause/2">portray_clause/2</A>.</DD>
282
Singleton variables are written as <CODE>_</CODE>. See also <A NAME="idx:portrayclause2:472"></A><A class="pred" href="listing.html#portray_clause/2">portray_clause/2</A>.</DD>
283
283
<DT class="pubdef"><A NAME="portray_clause/2"><STRONG>portray_clause</STRONG>(<VAR>+Stream,
284
284
+Clause</VAR>)</A></DT>
285
285
<DD class="defbody">
286
Pretty print a clause to <VAR>Stream</VAR>. See <A NAME="idx:portrayclause1:472"></A><A class="pred" href="listing.html#portray_clause/1">portray_clause/1</A>
286
Pretty print a clause to <VAR>Stream</VAR>. See <A NAME="idx:portrayclause1:473"></A><A class="pred" href="listing.html#portray_clause/1">portray_clause/1</A>