~ubuntu-branches/ubuntu/edgy/ess/edgy

« back to all changes in this revision

Viewing changes to doc/html/ess_7.html

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-11-11 00:51:43 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20041111005143-wv1cih1h04xyrxrb
Tags: 5.2.3-3
* repair broken replace-regexp-in-string -> ess-replace-regexp-in-string
  patch
* expand autoload functionality in emacsen-startup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<HTML>
2
 
<HEAD>
3
 
<!-- Created by texi2html 1.56k from ess.texi on 6 August 2002 -->
4
 
 
5
 
<TITLE>ESS -- Emacs Speaks Statistics - Editing S functions</TITLE>
6
 
</HEAD>
7
 
<BODY>
8
 
Go to the <A HREF="ess_1.html">first</A>, <A HREF="ess_6.html">previous</A>, <A HREF="ess_8.html">next</A>, <A HREF="ess_16.html">last</A> section, <A HREF="ess_toc.html">table of contents</A>.
9
 
<P><HR><P>
10
 
 
11
 
 
12
 
<H1><A NAME="SEC49" HREF="ess_toc.html#TOC49">Editing <B>S</B> functions</A></H1>
13
 
 
14
 
<P>
15
 
<A NAME="IDX134"></A>
16
 
ESS provides facilities for editing <B>S</B> objects within your Emacs
17
 
session.  Most editing is performed on <B>S</B> functions, although in
18
 
theory you may edit datasets as well.  Edit buffers are always
19
 
associated with files, although you may choose to make these files
20
 
temporary if you wish.  Alternatively, you may make use of a simple yet
21
 
powerful mechanism for maintaining backups of text representations of
22
 
<B>S</B> functions.  Error-checking is performed when <B>S</B> code is loaded
23
 
into the <B>ESS</B> process.
24
 
 
25
 
 
26
 
 
27
 
<UL>
28
 
<LI><A HREF="ess_7.html#SEC50">Edit buffer</A>: Edit objects in a specialized buffer
29
 
<LI><A HREF="ess_7.html#SEC51">Loading</A>: Loading source files into the <B>ESS</B> process
30
 
<LI><A HREF="ess_7.html#SEC52">Error Checking</A>: Detecting errors in source files
31
 
<LI><A HREF="ess_7.html#SEC53">Evaluating code</A>: Sending code to the <B>ESS</B> process
32
 
<LI><A HREF="ess_7.html#SEC54">Indenting</A>: Indenting and formatting <B>S</B> code
33
 
<LI><A HREF="ess_7.html#SEC55">Other edit buffer commands</A>: Commands for motion, completion and more
34
 
<LI><A HREF="ess_7.html#SEC56">Source Files</A>: Maintaining <B>S</B> source files
35
 
<LI><A HREF="ess_7.html#SEC57">Source Directories</A>: Names and locations of dump files
36
 
</UL>
37
 
 
38
 
 
39
 
 
40
 
<H2><A NAME="SEC50" HREF="ess_toc.html#TOC50">Creating or modifying <B>S</B> objects</A></H2>
41
 
<P>
42
 
<A NAME="IDX135"></A>
43
 
 
44
 
 
45
 
<P>
46
 
To edit an <B>S</B> object, type
47
 
 
48
 
 
49
 
 
50
 
<UL>
51
 
<LI>
52
 
 
53
 
<KBD>C-c C-d</KBD> (<CODE>ess-dump-object-into-edit-buffer</CODE>) <BR>
54
 
<A NAME="IDX136"></A>
55
 
Edit an <B>S</B> object in its own edit buffer.
56
 
</UL>
57
 
 
58
 
<P>
59
 
from within the <B>ESS</B> process buffer (<CODE>*S*</CODE>).  You will then be
60
 
prompted for an object to edit: you may either type in the name of an
61
 
existing object (for which completion is available using the <KBD>TAB</KBD>
62
 
key),
63
 
<A NAME="IDX137"></A>
64
 
or you may enter the name of a new object.
65
 
<A NAME="IDX138"></A>
66
 
<A NAME="IDX139"></A>
67
 
A buffer will be created containing the text representation of the
68
 
requested object or, if you entered the name of a non-existent object at
69
 
the prompt and the variable <CODE>ess-insert-function-templates</CODE>
70
 
<A NAME="IDX140"></A>
71
 
is non-<CODE>nil</CODE>, you will be presented with a template defined by
72
 
<CODE>ess-function-template</CODE>
73
 
<A NAME="IDX141"></A>
74
 
which defaults to a skeleton function construct.
75
 
 
76
 
 
77
 
<P>
78
 
You may then edit the function as required.  The edit buffer generated
79
 
by <CODE>ess-dump-object-into-edit-buffer</CODE> is placed in the <CODE>ESS</CODE>
80
 
major mode which provides a number of commands to facilitate editing
81
 
<B>S</B> source code.  Commands are provided to intelligently indent <B>S</B>
82
 
code, evaluate portions of <B>S</B> code and to move around <B>S</B> code
83
 
constructs.
84
 
 
85
 
 
86
 
<P>
87
 
<A NAME="IDX142"></A>
88
 
<A NAME="IDX143"></A>
89
 
<STRONG>Note:</STRONG> when you dump a file with <KBD>C-c C-d</KBD>, ESS first checks
90
 
to see whether there already exists an edit buffer containing that
91
 
object and, if so, pops you directly to that buffer.  If not, ESS next
92
 
checks whether there is a file in the appropriate place with the
93
 
appropriate name (see section <A HREF="ess_7.html#SEC56">Maintaining <B>S</B> source files</A>) and if so, reads in that file.
94
 
You can use this facility to return to an object you were editing in a
95
 
previous session (and which possibly was never loaded to the <B>S</B>
96
 
session).  Finally, if both these tests fail, the <B>ESS</B> process is
97
 
consulted and a <CODE>dump()</CODE> command issued.
98
 
<A NAME="IDX144"></A>
99
 
If you want to force ESS to ask the <B>ESS</B> process for the object's
100
 
definition (say, to reformat an unmodified buffer or to revert back to
101
 
S's idea of the object's definition) pass a prefix argument to
102
 
<CODE>ess-dump-object-into-edit-buffer</CODE> by typing <KBD>C-u C-c C-d</KBD>.
103
 
 
104
 
 
105
 
 
106
 
 
107
 
<H2><A NAME="SEC51" HREF="ess_toc.html#TOC51">Loading source files into the <B>ESS</B> process</A></H2>
108
 
 
109
 
<P>
110
 
The best way to get information -- particularly function definitions
111
 
--- into <B>S</B> is to load them in as source file, using S's
112
 
<CODE>source</CODE> function.  You have already seen how to create source
113
 
files using <KBD>C-c C-d</KBD>; ESS provides a complementary command for
114
 
loading source files (even files not created with ESS!) into the <B>ESS</B>
115
 
process:
116
 
 
117
 
 
118
 
 
119
 
<UL>
120
 
<LI>
121
 
 
122
 
<KBD>C-c C-l</KBD> (<CODE>ess-load-file</CODE>) <BR>
123
 
<A NAME="IDX145"></A>
124
 
Loads a file into the <B>ESS</B> process using <CODE>source()</CODE>.
125
 
<A NAME="IDX146"></A>
126
 
</UL>
127
 
 
128
 
<P>
129
 
After typing <KBD>C-c C-l</KBD> you will prompted for the name of the file to
130
 
load into S; usually this is the current buffer's file which is the
131
 
default value (selected by simply pressing <KBD>RET</KBD> at the prompt).
132
 
You will be asked to save the buffer first if it has been modified (this
133
 
happens automatically if the buffer was generated with <KBD>C-c C-d</KBD>).
134
 
The file will then be loaded, and if it loads successfully you will be
135
 
returned to the <B>ESS</B> process.
136
 
 
137
 
 
138
 
 
139
 
 
140
 
<H2><A NAME="SEC52" HREF="ess_toc.html#TOC52">Detecting errors in source files</A></H2>
141
 
<P>
142
 
<A NAME="IDX147"></A>
143
 
<A NAME="IDX148"></A>
144
 
If any errors occur when loading a file with <CODE>C-c C-l</CODE>, ESS will
145
 
inform you of this fact.  In this case, you can jump directly to the
146
 
line in the source file which caused the error by typing <KBD>C-x `</KBD>
147
 
(<CODE>ess-parse-errors</CODE>).
148
 
<A NAME="IDX149"></A>
149
 
You will be returned to the offending file (loading it into a buffer if
150
 
necessary) with point at the line <B>S</B> reported as containing the
151
 
error.  You may then correct the error, and reload the file.  Note that
152
 
none of the commands in an <B>S</B> source file will take effect if any
153
 
part of the file contains errors.
154
 
 
155
 
 
156
 
<P>
157
 
Sometimes the error is not caused by a syntax error (loading a
158
 
non-existent file for example). In this case typing <KBD>C-x `</KBD> will
159
 
simply display a buffer containing S's error message.  You can force
160
 
this behavior (and avoid jumping to the file when there <EM>is</EM> a
161
 
syntax error) by passing a prefix argument to <CODE>ess-parse-errors</CODE>
162
 
with <KBD>C-u C-x `</KBD>.
163
 
 
164
 
 
165
 
 
166
 
 
167
 
<H2><A NAME="SEC53" HREF="ess_toc.html#TOC53">Sending code to the <B>ESS</B> process</A></H2>
168
 
 
169
 
<P>
170
 
Other commands are also available for evaluating portions of code in the
171
 
S process.  These commands cause the selected code to be evaluated
172
 
directly by the <B>ESS</B> process as if you had typed them in at the
173
 
command line; the <CODE>source()</CODE> function is not used.  You may choose
174
 
whether both the commands and their output appear in the process buffer
175
 
(as if you had typed in the commands yourself) or if the output alone is
176
 
echoed.  The behavior is controlled by the variable
177
 
<CODE>ess-eval-visibly-p</CODE> whose default is <CODE>nil</CODE>
178
 
<A NAME="IDX150"></A>
179
 
(display output only).  Passing a prefix argument (<KBD>C-u</KBD>) to any of
180
 
the following commands, however, reverses the meaning of
181
 
<CODE>ess-eval-visibly-p</CODE> for that command only -- for example <KBD>C-u
182
 
C-c C-j</KBD> echoes the current line of S (or other) code in the <B>ESS</B>
183
 
process buffer, followed by its output.  This method of evaluation is an
184
 
alternative to S's <CODE>source()</CODE> function
185
 
<A NAME="IDX151"></A>
186
 
<A NAME="IDX152"></A>
187
 
<A NAME="IDX153"></A>
188
 
when you want the input as well as the output to be displayed.  (You can
189
 
sort of do this with <CODE>source()</CODE> when the option <CODE>echo=T</CODE> is
190
 
set, except that prompts do not get displayed.  ESS puts prompts in the
191
 
right places.) The commands for evaluating code are:
192
 
 
193
 
 
194
 
 
195
 
<UL>
196
 
<LI>
197
 
 
198
 
<A NAME="IDX154"></A>
199
 
 
200
 
<KBD>C-c C-j</KBD> (<CODE>ess-eval-line</CODE>) <BR>
201
 
<A NAME="IDX155"></A>
202
 
Send the line containing point to the <B>ESS</B> process.
203
 
 
204
 
<LI>
205
 
 
206
 
<KBD>C-c M-j</KBD> (<CODE>ess-eval-line-and-go</CODE>) <BR>
207
 
<A NAME="IDX156"></A>
208
 
As above, but returns you to the <B>ESS</B> process buffer as well.
209
 
 
210
 
<LI>
211
 
 
212
 
<KBD>C-c C-f</KBD> or <KBD>ESC C-x</KBD> (<CODE>ess-eval-function</CODE>) <BR>
213
 
<A NAME="IDX157"></A>
214
 
Send the <B>S</B> function containing point to the <B>ESS</B> process.
215
 
 
216
 
<LI>
217
 
 
218
 
<KBD>C-c M-f</KBD> (<CODE>ess-eval-function-and-go</CODE>) <BR>
219
 
<A NAME="IDX158"></A>
220
 
As above, but returns you to the <B>ESS</B> process buffer as well.
221
 
 
222
 
<LI>
223
 
 
224
 
<KBD>C-c C-r</KBD> (<CODE>ess-eval-region</CODE>) <BR>
225
 
<A NAME="IDX159"></A>
226
 
Send the text between point and mark to the <B>ESS</B> process.
227
 
 
228
 
<LI>
229
 
 
230
 
<KBD>C-c M-r</KBD> (<CODE>ess-eval-region-and-go</CODE>) <BR>
231
 
<A NAME="IDX160"></A>
232
 
As above, but returns you to the <B>ESS</B> process buffer as well.
233
 
 
234
 
<LI>
235
 
 
236
 
<KBD>C-c C-b</KBD> (<CODE>ess-eval-buffer</CODE>) <BR>
237
 
<A NAME="IDX161"></A>
238
 
Send the contents of the edit buffer to the <B>ESS</B> process.
239
 
 
240
 
<LI>
241
 
 
242
 
<KBD>C-c M-b</KBD> (<CODE>ess-eval-buffer-and-go</CODE>) <BR>
243
 
<A NAME="IDX162"></A>
244
 
As above, but returns you to the <B>ESS</B> process buffer as well.
245
 
 
246
 
<LI>
247
 
 
248
 
<KBD>C-c C-n</KBD> (<CODE>ess-eval-line-and-next-line</CODE>) <BR>
249
 
<A NAME="IDX163"></A>
250
 
<A NAME="IDX164"></A>
251
 
<A NAME="IDX165"></A>
252
 
Sends the current line to the <B>ESS</B> process, echoing it in the process
253
 
buffer, and moves point to the next line.  Useful when debugging for
254
 
stepping through your code.
255
 
</UL>
256
 
 
257
 
<P>
258
 
It should be stressed once again that these <CODE>ess-eval-</CODE> commands
259
 
should only be used for evaluating small portions of code for debugging
260
 
purposes, or for generating transcripts from source files.  When editing
261
 
S functions, <KBD>C-c C-l</KBD> is the command to use to update the
262
 
function's value.  In particular, <CODE>ess-eval-buffer</CODE> is now largely
263
 
obsolete.
264
 
 
265
 
 
266
 
<P>
267
 
One final command is provided for spot-evaluations of <B>S</B> code:
268
 
 
269
 
 
270
 
 
271
 
<UL>
272
 
<KBD>C-c C-e</KBD> (<CODE>ess-execute-in-tb</CODE>) <BR>
273
 
Prompt for an <B>S</B> expression and evaluate it.  Displays result in a
274
 
temporary buffer.
275
 
</UL>
276
 
 
277
 
<P>
278
 
This is useful for quick calculations, etc.
279
 
 
280
 
 
281
 
<P>
282
 
All the above commands are useful for evaluating small amounts of code
283
 
and observing the results in the process buffer.  A useful way to work
284
 
is to divide the frame into two windows; one containing the source code
285
 
and the other containing the process buffer.  If you wish to make the
286
 
process buffer scroll automatically when the output reaches the bottom
287
 
of the window, you will need to set the variable
288
 
<CODE>comint-scroll-to-bottom-on-output</CODE> to <CODE>others</CODE> or <CODE>t</CODE>.
289
 
 
290
 
 
291
 
<P>
292
 
*** Maybe a link to customization section here ***
293
 
 
294
 
 
295
 
 
296
 
 
297
 
<H2><A NAME="SEC54" HREF="ess_toc.html#TOC54">Indenting and formatting <B>S</B> code</A></H2>
298
 
 
299
 
<P>
300
 
ESS now provides a sophisticated mechanism for indenting <B>S</B> source
301
 
code (thanks to Ken'ichi Shibayama).  Compound statements (delimited by
302
 
<SAMP>`{'</SAMP> and <SAMP>`}'</SAMP>) are indented relative to their enclosing block.
303
 
In addition, the braces have been electrified to automatically indent to
304
 
the correct position when inserted, and optionally insert a newline at
305
 
the appropriate place as well.  Lines which continue an incomplete
306
 
expression are indented relative to the first line of the expression.
307
 
Function definitions, <CODE>if</CODE> statements, calls to <CODE>expression()</CODE>
308
 
and loop constructs are all recognized and indented appropriately.  User
309
 
variables are provided to control the amount if indentation in each
310
 
case, and there are also a number of predefined indentation styles to
311
 
choose from.  See section <A HREF="ess_12.html#SEC76">Variables controlling indentation</A>.
312
 
 
313
 
 
314
 
<P>
315
 
<A NAME="IDX167"></A>
316
 
Comments are also handled specially by ESS, using an idea borrowed from
317
 
the Emacs-Lisp indentation style.  By default,
318
 
comments beginning with <SAMP>`###'</SAMP>
319
 
are aligned to the beginning of the line.  Comments beginning with
320
 
<SAMP>`##'</SAMP> are aligned to the current level of indentation for the block
321
 
containing the comment.  Finally, comments beginning with <SAMP>`#'</SAMP> are
322
 
aligned to a column on the right (the 40th column by default, but this
323
 
value is controlled by the variable <CODE>comment-column</CODE>,)
324
 
<A NAME="IDX168"></A>
325
 
or just after the expression on the line containing the comment if it
326
 
extends beyond the indentation column.  You turn off the default
327
 
behavior by adding the line
328
 
<CODE>(setq ess-fancy-comments nil)</CODE> to your <TT>`.emacs'</TT> file.
329
 
<A NAME="IDX169"></A>
330
 
(GNU emacs uses the filename <TT>`~/.emacs'</TT> and
331
 
Xemacs uses the filename <TT>`~/.xemacs/init.el'</TT>
332
 
for the initialization file.)
333
 
 
334
 
 
335
 
<P>
336
 
The indentation commands provided by ESS are:
337
 
<A NAME="IDX170"></A>
338
 
<A NAME="IDX171"></A>
339
 
 
340
 
 
341
 
 
342
 
<UL>
343
 
<LI>
344
 
 
345
 
<A NAME="IDX166"></A>
346
 
 
347
 
<KBD>TAB</KBD> (<CODE>ess-indent-command</CODE>) <BR>
348
 
Indents the current line as <B>S</B> code.  If a prefix argument is given,
349
 
all following lines which are part of the same (compound) expression are
350
 
indented by the same amount (but relative indents are preserved).
351
 
 
352
 
<LI>
353
 
 
354
 
<KBD>LFD</KBD> (<CODE>newline-and-indent</CODE>) <BR>
355
 
Insert a newline, and indent the next line.  (Note: if your keyboard
356
 
does not have a <KBD>LINEFEED</KBD> key, you can use <KBD>C-j</KBD> instead.)
357
 
Some people prefer to bind <KBD>RET</KBD> to this command.
358
 
 
359
 
<LI>
360
 
 
361
 
<KBD>ESC C-q</KBD> (<CODE>ess-indent-exp</CODE>) <BR>
362
 
Indents each line in the <B>S</B> (compound) expression which follows point.
363
 
Very useful for beautifying your <B>S</B> code.
364
 
 
365
 
<LI>
366
 
 
367
 
<KBD>{</KBD> and <KBD>}</KBD> (<CODE>ess-electric-brace</CODE>) <BR>
368
 
The braces automatically indent to the correct position when typed.
369
 
 
370
 
<LI>
371
 
 
372
 
<KBD>M-;</KBD> (<CODE>indent-for-comment</CODE>) <BR>
373
 
Indents a comment line appropriately, or inserts an empty
374
 
(single-<SAMP>`#'</SAMP>) comment.
375
 
 
376
 
<LI>
377
 
 
378
 
<KBD>M-x ess-set-style</KBD> <BR>
379
 
Set the formatting style in this buffer to be one of the predefined
380
 
styles: <CODE>GNU</CODE>, <CODE>BSD</CODE>, <CODE>K&#38;R</CODE>, <CODE>CLB</CODE>, and <CODE>C++</CODE>.
381
 
The <CODE>DEFAULT</CODE> style uses the default values for the indenting
382
 
variables (unless they have been modified in your <TT>`.emacs'</TT> file.)
383
 
<A NAME="IDX172"></A>
384
 
This command causes all of the formatting variables
385
 
see section <A HREF="ess_12.html#SEC76">Variables controlling indentation</A> to be buffer-local.
386
 
</UL>
387
 
 
388
 
 
389
 
 
390
 
<H2><A NAME="SEC55" HREF="ess_toc.html#TOC55">Commands for motion, completion and more</A></H2>
391
 
 
392
 
<P>
393
 
A number of commands are provided to move across function definitions
394
 
in the edit buffer:
395
 
 
396
 
<UL>
397
 
<LI>
398
 
 
399
 
<KBD>ESC C-e</KBD> (<CODE>ess-beginning-of-function</CODE>) <BR>
400
 
<A NAME="IDX173"></A>
401
 
Moves point to the beginning of the function containing point.
402
 
 
403
 
<LI>
404
 
 
405
 
<KBD>ESC C-a</KBD> (<CODE>ess-end-of-function</CODE>) <BR>
406
 
<A NAME="IDX174"></A>
407
 
Moves point to the end of the function containing point.
408
 
 
409
 
<LI>
410
 
 
411
 
<KBD>ESC C-h</KBD> (<CODE>ess-mark-function</CODE>) <BR>
412
 
Places point at the beginning of the <B>S</B> function containing point, and
413
 
mark at the end.
414
 
</UL>
415
 
 
416
 
<P>
417
 
Don't forget the usual Emacs commands for moving over balanced
418
 
expressions and parentheses: See section `Lists and Sexps' in <CITE>The GNU Emacs Reference Manual</CITE>.
419
 
 
420
 
 
421
 
<P>
422
 
<A NAME="IDX175"></A>
423
 
Completion is provided in the edit buffer in a similar fashion to the
424
 
process buffer: <KBD>M-TAB</KBD> completes file names and <KBD>M-?</KBD> lists
425
 
file completions.  Since <KBD>TAB</KBD> is used for indentation in the edit
426
 
buffer, object completion is now performed with <KBD>C-c TAB</KBD>.  Note
427
 
however that completion is only provided over globally known S objects
428
 
(such as system functions) -- it will <EM>not</EM> work for arguments to
429
 
functions or other variables local to the function you are editing.
430
 
 
431
 
 
432
 
<P>
433
 
Finally, two commands are provided for returning to the <B>ESS</B> process buffer:
434
 
 
435
 
 
436
 
 
437
 
<UL>
438
 
<LI>
439
 
 
440
 
<KBD>C-c C-z</KBD> (<CODE>ess-switch-to-end-of-ESS</CODE>) <BR>
441
 
<A NAME="IDX176"></A>
442
 
Returns you to the <B>ESS</B> process buffer, placing point at the end of the
443
 
buffer.
444
 
 
445
 
<LI>
446
 
 
447
 
<KBD>C-c C-y</KBD> (<CODE>ess-switch-to-ESS</CODE>) <BR>
448
 
<A NAME="IDX177"></A>
449
 
Also returns to to the <B>ESS</B> process buffer, but leaves point where it is.
450
 
</UL>
451
 
 
452
 
<P>
453
 
In addition some commands available in the process buffer are also
454
 
available in the edit buffer.  You can still read help files with
455
 
<KBD>C-c C-v</KBD>, edit another function with <KBD>C-c C-d</KBD> and of course
456
 
<KBD>C-c C-l</KBD> can be used to load a source file into S.  See section <A HREF="ess_6.html#SEC48">Other commands provided by inferior-ESS</A>,
457
 
for more details on these commands.
458
 
 
459
 
 
460
 
 
461
 
 
462
 
<H2><A NAME="SEC56" HREF="ess_toc.html#TOC56">Maintaining <B>S</B> source files</A></H2>
463
 
 
464
 
<P>
465
 
Every edit buffer in ESS is associated with a <EM>dump file</EM> on disk.
466
 
Dump files are created whenever you type <KBD>C-c C-d</KBD>
467
 
(<CODE>ess-dump-object-into-edit-buffer</CODE>), and may either be deleted
468
 
after use, or kept as a backup file or as a means of keeping several
469
 
versions of an <B>S</B> function.
470
 
<A NAME="IDX178"></A>
471
 
 
472
 
 
473
 
<P>
474
 
<DL>
475
 
<DT><U>User Option:</U> <B>ess-delete-dump-files</B>
476
 
<DD><A NAME="IDX179"></A>
477
 
If non-<CODE>nil</CODE>, dump files created with C-c C-d are deleted
478
 
immediately after they are created by the ess-process.
479
 
</DL>
480
 
 
481
 
 
482
 
<P>
483
 
Since immediately after <B>S</B> dumps an object's definition to a disk
484
 
file the source code on disk corresponds exactly to S's idea of the
485
 
object's definition, the disk file isn't really needed; deleting it now
486
 
has the advantage that if you <EM>don't</EM> modify the file (say, because
487
 
you just wanted to look at the definition of one of the standard S
488
 
functions) the source dump file won't be left around when you kill the
489
 
buffer.  Note that this variable only applies to files generated with
490
 
S's <CODE>dump</CODE> function; it doesn't apply to source files which already
491
 
exist.  The default value is <CODE>t</CODE>.
492
 
 
493
 
 
494
 
<P>
495
 
<DL>
496
 
<DT><U>User Option:</U> <B>ess-keep-dump-files</B>
497
 
<DD><A NAME="IDX180"></A>
498
 
Option controlling what to do with the dump file after an object has
499
 
been successfully loaded into S.  Valid values are <CODE>nil</CODE> (always
500
 
delete), <CODE>ask</CODE> (always ask whether to delete), <CODE>check</CODE> (delete
501
 
files generated with <KBD>C-c C-d</KBD> in this Emacs session, otherwise ask
502
 
--- this is the default) and <CODE>t</CODE> (never delete).  This variable is
503
 
buffer-local.
504
 
</DL>
505
 
 
506
 
 
507
 
<P>
508
 
After an object has been successfully (i.e. without error) been loaded
509
 
back into <B>S</B> with <KBD>C-c C-l</KBD>, the disk file again corresponds
510
 
exactly (well, almost -- see below) to S's record of the object's
511
 
definition, and so some people prefer to delete the disk file rather
512
 
than unnecessarily use up space.  This option allows you to do just
513
 
that.
514
 
 
515
 
 
516
 
<P>
517
 
<A NAME="IDX181"></A>
518
 
<A NAME="IDX182"></A>
519
 
<A NAME="IDX183"></A>
520
 
If the value of <CODE>ess-keep-dump-files</CODE> is <CODE>t</CODE>, dump files are
521
 
never deleted after they are loaded.  Thus you can maintain a complete
522
 
text record of the functions you have edited within ESS.  Backup files
523
 
kept as usual, and so by using the Emacs numbered backup facility ---
524
 
see section `Single or Numbered Backups' in <CITE>The Gnu Emacs Reference Manual</CITE>, you can keep a historic
525
 
record of function definitions.  Another possibility is to maintain the
526
 
files with a version-control system such as RCS See section `Version Control' in <CITE>The Gnu Emacs Reference Manual</CITE>.  As long as a dump file exists in the appropriate place for a
527
 
particular object, editing that object with <KBD>C-c C-d</KBD> finds that
528
 
file for editing (unless a prefix argument is given) -- the <B>ESS</B>
529
 
process is not consulted.  Thus you can keep comments <EM>outside</EM> the
530
 
function definition as a means of documentation that does not clutter
531
 
the <B>S</B> object itself.  Another useful feature is that you may format
532
 
the code in any fashion you please without <B>S</B> re-indenting the code
533
 
every time you edit it.  These features are particularly useful for
534
 
project-based work.
535
 
 
536
 
 
537
 
<P>
538
 
If the value of <CODE>ess-keep-dump-files</CODE> is nil, the dump file is always
539
 
silently deleted after a successful load with <KBD>C-c C-l</KBD>.  While this
540
 
is useful for files that were created with <KBD>C-c C-d</KBD> it also applies
541
 
to any other file you load (say, a source file of function
542
 
definitions), and so can be dangerous to use unless you are careful.
543
 
Note that since <CODE>ess-keep-dump-files</CODE> is buffer-local, you can make
544
 
sure particular files are not deleted by setting it to <CODE>t</CODE> in the
545
 
Local Variables section of the file See section `Local Variables in Files' in <CITE>The Gnu Emacs Reference Manual</CITE>.
546
 
 
547
 
 
548
 
<P>
549
 
A safer option is to set <CODE>ess-keep-dump-files</CODE> to <CODE>ask</CODE>; this
550
 
means that ESS will always ask for confirmation before deleting the
551
 
file.  Since this can get annoying if you always want to delete dump
552
 
files created with <CODE>C-c C-d</CODE>, but not any other files, setting
553
 
<CODE>ess-keep-dump-files</CODE> to <CODE>check</CODE> (the default value) will
554
 
silently delete dump files created with <KBD>C-c C-d</KBD> in the current
555
 
Emacs session, but query for any other file.  Note that in any case you
556
 
will only be asked for confirmation once per file, and your answer is
557
 
remembered for the rest of the Emacs session.
558
 
 
559
 
 
560
 
<P>
561
 
Note that in all cases, if an error (such as a syntax error) is detected
562
 
while loading the file with <KBD>C-c C-l</KBD>, the dump file is <EM>never</EM>
563
 
deleted.  This is so that you can edit the file in a new Emacs session
564
 
if you happen to quit Emacs before correcting the error.
565
 
 
566
 
 
567
 
<P>
568
 
<A NAME="IDX184"></A>
569
 
Dump buffers are always autosaved, regardless of the value of
570
 
<CODE>ess-keep-dump-files</CODE>.
571
 
 
572
 
 
573
 
 
574
 
 
575
 
<H2><A NAME="SEC57" HREF="ess_toc.html#TOC57">Names and locations of dump files</A></H2>
576
 
 
577
 
<P>
578
 
<A NAME="IDX185"></A>
579
 
Every dump file should be given a unique file name, usually the dumped
580
 
object name with some additions.
581
 
 
582
 
 
583
 
<P>
584
 
<DL>
585
 
<DT><U>User Option:</U> <B>ess-dump-filename-template</B>
586
 
<DD><A NAME="IDX186"></A>
587
 
Template for filenames of dumped objects.  <CODE>%s</CODE> is replaced by the
588
 
object name.
589
 
</DL>
590
 
 
591
 
 
592
 
<P>
593
 
By default, dump file names are the user name, followed by <SAMP>`.'</SAMP> and
594
 
the object and ending with <SAMP>`.S'</SAMP>.  Thus if user <CODE>joe</CODE> dumps the
595
 
object <CODE>myfun</CODE> the dump file will have name <TT>`joe.myfun.S'</TT>.
596
 
The username part is included to avoid clashes when dumping into a
597
 
publicly-writable directory, such as <TT>`/tmp'</TT>; you may wish to remove
598
 
this part if you are dumping into a directory owned by you.
599
 
 
600
 
 
601
 
<P>
602
 
<A NAME="IDX187"></A>
603
 
You may also specify the directory in which dump files are written:
604
 
 
605
 
 
606
 
<P>
607
 
<DL>
608
 
<DT><U>User Option:</U> <B>ess-source-directory</B>
609
 
<DD><A NAME="IDX188"></A>
610
 
Directory name (ending in a slash) where <B>S</B> dump files are to be written.
611
 
</DL>
612
 
 
613
 
 
614
 
<P>
615
 
By default, dump files are always written to <TT>`/tmp'</TT>, which is fine
616
 
when <CODE>ess-keep-dump-files</CODE> is <CODE>nil</CODE>.  If you are keeping dump
617
 
files, then you will probably want to keep them somewhere in your home
618
 
directory, say <TT>`~/S-source'</TT>.  This could be achieved by including
619
 
the following line in your <TT>`.emacs'</TT> file:
620
 
<A NAME="IDX189"></A>
621
 
 
622
 
<PRE>
623
 
(setq ess-source-directory (expand-file-name "~/S-source/"))
624
 
</PRE>
625
 
 
626
 
<P>
627
 
If you would prefer to keep your dump files in separate directories
628
 
depending on the value of some variable, ESS provides a facility for
629
 
this also.  By setting <CODE>ess-source-directory</CODE> to a lambda
630
 
expression which evaluates to a directory name, you have a great deal of
631
 
flexibility in selecting the directory for a particular source file to
632
 
appear in.  The lambda expression is evaluated with the process buffer
633
 
as the current buffer and so you can use the variables local to that
634
 
buffer to make your choice.  For example, the following expression
635
 
causes source files to be saved in the subdirectory <TT>`Src'</TT> of the
636
 
directory the <B>ESS</B> process was run in.
637
 
 
638
 
 
639
 
 
640
 
<PRE>
641
 
(setq ess-source-directory
642
 
      (lambda ()
643
 
         (concat ess-directory "Src/")))
644
 
</PRE>
645
 
 
646
 
<P>
647
 
<A NAME="IDX190"></A>
648
 
(<CODE>ess-directory</CODE> is a buffer-local variable in process buffers
649
 
which records the directory the <B>ESS</B> process was run from.)  This is
650
 
useful if you keep your dump files and you often edit objects with the
651
 
same name in different <B>ESS</B> processes.  Alternatively, if you often
652
 
change your <B>S</B> working directory during an <B>S</B> session, you may
653
 
like to keep dump files in some subdirectory of the directory pointed to
654
 
by the first element of the current search list.  This way you can edit
655
 
objects of the same name in different directories during the one S
656
 
session:
657
 
<A NAME="IDX191"></A>
658
 
<A NAME="IDX192"></A>
659
 
 
660
 
<PRE>
661
 
(setq ess-source-directory
662
 
   (lambda ()
663
 
       (file-name-as-directory
664
 
        (expand-file-name (concat
665
 
                           (car ess-search-list)
666
 
                           "/.Src")))))
667
 
</PRE>
668
 
 
669
 
<P>
670
 
<A NAME="IDX193"></A>
671
 
 
672
 
 
673
 
<P>
674
 
If the directory generated by the lambda function does not exist but can
675
 
be created, you will be asked whether you wish to create the directory.
676
 
If you choose not to, or the directory cannot be created, you will not
677
 
be able to edit functions.
678
 
 
679
 
 
680
 
<P><HR><P>
681
 
Go to the <A HREF="ess_1.html">first</A>, <A HREF="ess_6.html">previous</A>, <A HREF="ess_8.html">next</A>, <A HREF="ess_16.html">last</A> section, <A HREF="ess_toc.html">table of contents</A>.
682
 
</BODY>
683
 
</HTML>