]> code.delx.au - gnu-emacs/blob - man/ses.texi
Document SMTPSERVER environment variable.
[gnu-emacs] / man / ses.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename ../info/ses
4 @settitle SES: Simple Emacs Spreadsheet
5 @setchapternewpage off
6 @c %**end of header
7
8 @copying
9 This file documents SES: the Simple Emacs Spreadsheet.
10
11 Copyright @copyright{} 2002 Free Software Foundation, Inc.
12
13 @quotation
14 Permission is granted to copy, distribute and/or modify this document
15 under the terms of the GNU Free Documentation License, Version 1.1 or
16 any later version published by the Free Software Foundation; with no
17 Invariant Sections, with the Front-Cover texts being ``A GNU
18 Manual,'' and with the Back-Cover Texts as in (a) below. A copy of the
19 license is included in the section entitled ``GNU Free Documentation
20 License'' in the Emacs manual.
21
22 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
23 this GNU Manual, like GNU software. Copies published by the Free
24 Software Foundation raise funds for GNU development.''
25
26 This document is part of a collection distributed under the GNU Free
27 Documentation License. If you want to distribute this document
28 separately from the collection, you can do so by adding a copy of the
29 license to the document, as described in section 6 of the license.
30 @end quotation
31 @end copying
32
33 @dircategory Emacs
34 @direntry
35 * SES: (ses). Simple Emacs Spreadsheet
36 @end direntry
37
38 @finalout
39
40 @titlepage
41 @title SES
42 @subtitle Simple Emacs Spreadsheet
43 @author Jonathan A. Yavner
44 @author @email{jyavner@@engineer.com}
45
46 @page
47 @vskip 0pt plus 1filll
48 @insertcopying
49 @end titlepage
50
51 @contents
52
53 @c ===================================================================
54
55 @ifnottex
56 @node Top, Sales Pitch, (dir), (dir)
57 @comment node-name, next, previous, up
58 @top SES: Simple Emacs Spreadsheet
59
60 @display
61 SES is a major mode for GNU Emacs to edit spreadsheet files, which
62 contain a rectangular grid of cells. The cells' values are specified
63 by formulas that can refer to the values of other cells.
64 @end display
65 @end ifnottex
66
67 This (such as @pxref{Top,calc,,calc}) is good.
68
69 To report bugs, send email to @email{jyavner@@engineer.com}.
70
71 @menu
72 * Sales Pitch:: Why use SES?
73 * The Basics:: Basic spreadsheet commands
74 * Advanced Features:: Want to know more?
75 * For Gurus:: Want to know @emph{even more}?
76 * Acknowledgements:: Acknowledgements
77 @end menu
78
79 @c ===================================================================
80
81 @node Sales Pitch, The Basics, Top, Top
82 @comment node-name, next, previous, up
83 @chapter Sales Pitch
84
85 @itemize @bullet
86 @item Create and edit simple spreadsheets with a minimum of fuss.
87 @item Full undo/redo/autosave.
88 @item Immune to viruses in spreadsheet files.
89 @item Cell formulas are straight Emacs Lisp.
90 @item Printer functions for control of cell appearance.
91 @item Intuitive keystroke commands: C-o = insert row, M-o = insert column, etc.
92 @item ``Spillover'' of lengthy cell values into following blank cells.
93 @item Header line shows column letters or a selected row.
94 @item Completing-read for entering symbols as cell values.
95 @item Cut, copy, and paste can transfer formulas and printer functions.
96 @item Import and export of tab-separated values or tab-separated formulas.
97 @item Plaintext, easily-hacked file format.
98 @end itemize
99
100 @c ===================================================================
101
102 @node The Basics, Advanced Features, Sales Pitch, Top
103 @comment node-name, next, previous, up
104 @chapter The Basics
105
106 A @dfn{cell identifier} is a symbol with a column letter and a row
107 number. Cell B7 is the 2nd column of the 7th row. For very wide
108 spreadsheets, there are two column letters: cell AB7 is the 28th
109 column of the 7th row.
110
111 @table @kbd
112 @item j
113 Moves point to cell, specified by identifier (@code{ses-jump}).
114 @end table
115
116 Point is always at the left edge of a cell, or at the empty endline.
117 When mark is inactive, the current cell is underlined. When mark is
118 active, the range is the highlighted rectangle of cells (SES always
119 uses transient mark mode). Drag the mouse from A1 to A3 to create the
120 range A1-A2. Many SES commands operate only on single cells, not
121 ranges.
122
123 @table @kbd
124 @item C-SPC
125 @itemx C-@@
126 Set mark at point (@code{set-mark-command}).
127
128 @item C-g
129 Turn off the mark (@code{keyboard-quit}).
130
131 @item M-h
132 Highlight current row (@code{ses-mark-row}).
133
134 @item S-M-h
135 Highlight current column (@code{ses-mark-column}).
136
137 @item C-x h
138 Highlight all cells (@code{mark-whole-buffer}).
139 @end table
140
141 @menu
142 * Formulas::
143 * Resizing::
144 * Printer functions::
145 * Clearing cells::
146 * Copy/cut/paste::
147 * Customizing SES::
148 @end menu
149
150 @node Formulas, Resizing, The Basics, The Basics
151 @section Cell formulas
152
153 To enter a number into the current cell, just start typing:
154
155 @table @kbd
156 @item 0..9
157 Self-insert a digit (@code{ses-read-cell}).
158
159 @item -
160 Self-insert a negative number (@code{ses-read-cell}).
161
162 @item .
163 Self-insert a fractional number (@code{ses-read-cell}).
164
165 @item "
166 Self-insert a quoted string. The ending double-quote
167 is inserted for you (@code{ses-read-cell}).
168
169 @item (
170 Self-insert an expression. The right-parenthesis is inserted for you
171 (@code{ses-read-cell}). To access another cell's value, just use its
172 identifier in your expression. Whenever the other cell is changed,
173 this cell's formula will be reevaluated. While typing in the
174 expression, you can use @kbd{M-TAB} to complete symbol names.
175
176 @item ' @r{(apostrophe)}
177 Enter a symbol (ses-read-symbol). SES remembers all symbols that have
178 been used as formulas, so you can type just the beginning of a symbol
179 and use @kbd{SPC}, @kbd{TAB}, and @kbd{?} to complete it.
180 @end table
181
182 To enter something else (e.g., a vector), begin with a digit, then
183 erase the digit and type whatever you want.
184
185 @table @kbd
186 @item RET
187 Edit the existing formula in the current cell (@code{ses-edit-cell}).
188
189 @item C-c C-c
190 Force recalculation of the current cell or range (@code{ses-recalculate-cell}).
191
192 @item C-c C-l
193 Recalculate the entire spreadsheet (@code{ses-recalculate-all}).
194 @end table
195
196 @node Resizing, Printer functions, Formulas, The Basics
197 @section Resizing the spreadsheet
198
199 Basic commands:
200
201 @table @kbd
202 @item C-o
203 (@code{ses-insert-row})
204
205 @item M-o
206 (@code{ses-insert-column})
207
208 @item C-k
209 (@code{ses-delete-row})
210
211 @item M-k
212 (@code{ses-delete-column})
213
214 @item w
215 (@code{ses-set-column-width})
216
217 @item TAB
218 Moves point to the next rightward cell, or inserts a new column if
219 already at last cell on line, or inserts a new row if at endline
220 (@code{ses-forward-or-insert}).
221
222 @item C-j
223 Linefeed inserts below the current row and moves to column A
224 (@code{ses-append-row-jump-first-column}).
225 @end table
226
227 Resizing the spreadsheet (unless you're just changing a column width)
228 relocates all the cell-references in formulas so they still refer to
229 the same cells. If a formula mentioned B1 and you insert a new first
230 row, the formula will now mention B2.
231
232 If you delete a cell that a formula refers to, the cell-symbol is
233 deleted from the formula, so @code{(+ A1 B1 C1)} after deleting the third
234 column becomes @code{(+ A1 B1)}. In case this is not what you wanted:
235
236 @table @kbd
237 @item C-_
238 @itemx C-x u
239 Undo previous action (@code{(undo)}).
240 @end table
241
242
243 @node Printer functions, Clearing cells, Resizing, The Basics
244 @section Printer functions
245
246 Printer functions convert binary cell values into the print forms that
247 Emacs will display on the screen.
248
249 A printer can be a format string, like @samp{"$%.2f"}. The result
250 string is right-aligned within the print cell. To get left-alignment,
251 use parentheses: @samp{("$%.2f")}. A printer can also be a
252 one-argument function (a symbol or a lambda), whose result is a string
253 (right-aligned) or list of one string (left-aligned). While typing in
254 a lambda, you can use @kbd{M-TAB} to complete the names of symbols.
255
256 Each cell has a printer. If nil, the column-printer for the cell's
257 column is used. If that is also nil, the default-printer for the
258 spreadsheet is used.
259
260 @table @kbd
261 @item p
262 Enter a printer for current cell or range (@code{ses-read-cell-printer}).
263
264 @item M-p
265 Enter a printer for the current column (@code{ses-read-column-printer}).
266
267 @item C-c C-p
268 Enter the default printer for the spreadsheet
269 (@code{ses-read-default-printer}).
270 @end table
271
272 The @code{ses-read-@r{XXX}-printer} commands have their own minibuffer
273 history, which is preloaded with the set of all printers used in this
274 spreadsheet, plus the standard printers.
275
276 The standard printers are suitable only for cells, not columns or
277 default, because they format the value using the column-printer (or
278 default-printer if nil) and then center the result:
279
280 @table @code
281 @item ses-center
282 Just centering.
283
284 @item ses-center-span
285 Centering with spill-over to following blank cells.
286
287 @item ses-dashfill
288 Centering using dashes (-) instead of spaces.
289
290 @item ses-dashfill-span
291 Centering with dashes and spill-over.
292
293 @item ses-tildefill-span
294 Centering with tildes (~) and spill-over.
295 @end table
296
297
298 @node Clearing cells, Copy/cut/paste, Printer functions, The Basics
299 @section Clearing cells
300
301 These commands set both formula and printer to nil:
302
303 @table @kbd
304 @item DEL
305 Clear cell and move left (@code{ses-clear-cell-backward}).
306
307 @item C-d
308 Clear cell and move right (@code{ses-clear-cell-forward}).
309 @end table
310
311
312 @node Copy/cut/paste, Customizing SES, Clearing cells, The Basics
313 @section Copy, cut, and paste
314
315 The copy functions work on rectangular regions of cells. You can paste the
316 copies into non-SES buffers to export the print text.
317
318 @table @kbd
319 @item M-w
320 @itemx [copy]
321 @itemx [C-insert]
322 Copy the highlighted cells to kill ring and primary clipboard
323 (@code{kill-ring-save}).
324
325 @item [drag-mouse-1]
326 Mark a region and copy it to kill ring and primary clipboard
327 (@code{mouse-set-region}).
328
329 @item [M-drag-mouse-1]
330 Mark a region and copy it to kill ring and secondary clipboard
331 (@code{mouse-set-secondary}).
332
333 @item C-w
334 @itemx [cut]
335 @itemx [S-delete]
336 The cut functions do not actually delete rows or columns - they copy
337 and then clear (@code{ses-kill-override}).
338
339 @item C-y
340 @itemx [S-insert]
341 Paste from kill ring (@code{yank}). The paste functions behave
342 differently depending on the format of the text being inserted:
343 @itemize @bullet
344 @item
345 When pasting cells that were cut from a SES buffer, the print text is
346 ignored and only the attached formula and printer are inserted; cell
347 references in the formula are relocated unless you use @kbd{C-u}.
348 @item
349 The pasted text overwrites a rectangle of cells whose top left corner
350 is the current cell. If part of the rectangle is beyond the edges of
351 the spreadsheet, you must confirm the increase in spreadsheet size.
352 @item
353 Non-SES text is usually inserted as a replacement formula for the
354 current cell. If the formula would be a symbol, it's treated as a
355 string unless you use @kbd{C-u}. Pasted formulas with syntax errors
356 are always treated as strings.
357 @end itemize
358
359 @item [paste]
360 Paste from primary clipboard or kill ring (@code{clipboard-yank}).
361
362 @item [mouse-2]
363 Set point and paste from primary clipboard (@code{mouse-yank-at-click}).
364
365 @item [M-mouse-2]
366 Set point and paste from secondary clipboard (@code{mouse-yank-secondary}).
367
368 @item M-y
369 Immediately after a paste, you can replace the text with a preceding
370 element from the kill ring (@code{ses-yank-pop}). Unlike the standard
371 Emacs yank-pop, the SES version uses @code{undo} to delete the old
372 yank. This doesn't make any difference?
373 @end table
374
375 @node Customizing SES, , Copy/cut/paste, The Basics
376 @section Customizing SES
377
378 By default, a newly-created spreadsheet has 1 row and 1 column. The
379 column width is 7 and the default printer is @samp{"%.7g"}. Each of these
380 can be customized. Look in group ``ses''.
381
382 After entering a cell value, point normally moves right to the next
383 cell. You can customize @code{ses-after-entry-functions} to move left or
384 up or down. For diagonal movement, select two functions from the
385 list.
386
387 @code{ses-mode-hook} is a normal mode hook (list of functions to
388 execute when starting SES mode for a buffer).
389
390 The variable @code{safe-functions} is a a list of possibly-unsafe
391 functions to be treated as safe when analysing formulas and printers.
392 @xref{Virus protection}. Before customizing @code{safe-functions},
393 think about how much you trust the person who's suggesting this
394 change. The value t turns off all anti-virus protection. A
395 list-of-functions value might enable a ``gee whiz'' spreadsheet, but it
396 also creates trapdoors in your anti-virus armor. In order for virus
397 protection to work, you must always press @kbd{n} when presented with
398 a virus warning, unless you understand what the questionable code is
399 trying to do. Do not listen to those who tell you to customize
400 @code{enable-local-eval}---this variable is for people who don't wear
401 safety belts!
402
403
404 @c ===================================================================
405
406 @node Advanced Features, For Gurus, The Basics, Top
407 @chapter Advanced Features
408
409 @table @kbd
410 @item C-c M-C-h
411 (@code{ses-read-header-row}). The header line at the top of the SES
412 window normally shows the column letter for each column. You can set
413 it to show a copy of some row, such as a row of column titles, so that
414 row will always be visible. Set the header line to row 0 to show
415 column letters again.
416 @end table
417
418 @menu
419 * The print area::
420 * Ranges in formulas::
421 * Sorting by column::
422 * Standard formula functions::
423 * More on cell printing::
424 * Import and export::
425 * Virus protection::
426 * Spreadsheets with details and summary::
427 @end menu
428
429 @node The print area, Ranges in formulas, Advanced Features, Advanced Features
430 @section The print area
431
432 A SES file consists of a print area and a data area. Normally the
433 buffer is narrowed to show only the print area. The print area is
434 read-only except for special SES commands; it contains cell values
435 formatted by printer functions. The data area records the formula and
436 printer functions, etc.
437
438 @table @kbd
439 @item C-x n w
440 Show print and data areas (@code{widen}).
441
442 @item C-c C-n
443 Show only print area (@code{ses-renarrow-buffer}).
444
445 @item S-C-l
446 @itemx M-C-l
447 Recreate print area by reevaluating printer functions for all cells
448 (@code{ses-reprint-all}).
449 @end table
450
451 @node Ranges in formulas, Sorting by column, The print area, Advanced Features
452 @section Ranges in formulas
453
454 A formula like
455 @lisp
456 (+ A1 A2 A3)
457 @end lisp
458 is the sum of three specific cells. If you insert a new second row,
459 the formula becomes
460 @lisp
461 (+ A1 A3 A4)
462 @end lisp
463 and the new row is not included in the sum.
464
465 The macro @code{(ses-range @var{from} @var{to})} evalutes to a list of
466 the values in a rectangle of cells. If your formula is
467 @lisp
468 (apply '+ (ses-range A1 A3))
469 @end lisp
470 and you insert a new second row, it becomes
471 @lisp
472 (apply '+ (ses-range A1 A4))
473 @end lisp
474 and the new row is included in the sum.
475
476 While entering or editing a formula in the minibuffer, you can select
477 a range in the spreadsheet (using mouse or keyboard), then paste a
478 representation of that range into your formula. Suppose you select
479 A1-C1:
480
481 @table @kbd
482 @item [S-mouse-3]
483 Inserts "A1 B1 C1" @code{(ses-insert-range-click})
484
485 @item C-c C-r
486 Keyboard version (@code{ses-insert-range}).
487
488 @item [C-S-mouse-3]
489 Inserts "(ses-range A1 C1)" (@code{ses-insert-ses-range-click}).
490
491 @item C-c C-s
492 Keyboard version (@code{ses-insert-ses-range}).
493 @end table
494
495 If you delete the @var{from} or @var{to} cell for a range, the nearest
496 still-existing cell is used instead. If you delete the entire range,
497 the formula relocator will delete the ses-range from the formula.
498
499 If you insert a new row just beyond the end of a one-column range, or
500 a new column just beyond a one-row range, the new cell is included in
501 the range. New cells inserted just before a range are not included.
502
503
504 @node Sorting by column, Standard formula functions, Ranges in formulas, Advanced Features
505 @section Sorting by column
506
507 @table @kbd
508 @item C-c M-C-s
509 Sort the cells of a range using one of the columns
510 (@code{ses-sort-column}). The rows (or partial rows if the range
511 doesn't include all columns) are rearranged so the chosen column will
512 be in order.
513
514 @item [header-line mouse-2]
515 The easiest way to sort is to click mouse-2 on the chosen column's header row
516 (@code{ses-sort-column-click}).
517 @end table
518
519 The sort comparison uses @code{string<}, which works well for
520 right-justified numbers and left-justified strings.
521
522 With prefix arg, sort is in descending order.
523
524 Rows are moved one at a time, with relocation of formulas. This works
525 well if formulas refer to other cells in their row, not so well for
526 formulas that refer to other rows in the range or to cells outside the
527 range.
528
529
530 @node Standard formula functions, More on cell printing, Sorting by column, Advanced Features
531 @section Standard formula functions
532
533 Oftentimes you want a calculation to exclude the blank cells. Here
534 are some useful functions to call from your formulas:
535
536 @table @code
537 @item (ses-delete-blanks &rest @var{args})
538 Returns a list from which all blank cells (value is either nil or
539 '*skip*) have been deleted.
540
541 @item (ses+ &rest @var{args})
542 Sum of non-blank arguments.
543
544 @item (ses-average @var{list})
545 Average of non-blank elements in @var{list}. Here the list is passed
546 as a single argument, since you'll probably use it with @code{ses-range}.
547 @end table
548
549 @node More on cell printing, Import and export, Standard formula functions, Advanced Features
550 @section More on cell printing
551
552 Special cell values:
553 @itemize
554 @item nil prints the same as "", but allows previous cell to spill over.
555 @item '*skip* replaces nil when the previous cell actually does spill over;
556 nothing is printed for it.
557 @item '*error* indicates that the formula signalled an error instead of
558 producing a value: the print cell is filled with hash marks (#).
559 @end itemize
560
561 If the result from the printer function is too wide for the cell and
562 the following cell is nil, the result will spill over into the
563 following cell. Very wide results can spill over several cells. If
564 the result is too wide for the available space (up to the end of the
565 row or the next non-nil cell), the result is truncated if the cell's
566 value is a string, or replaced with hash marks otherwise.
567
568 SES could get confused by printer results that contain newlines or
569 tabs, so these are replaced with question marks.
570
571 @table @kbd
572 @item C-c C-t
573 Confine a cell to its own column (@code{ses-truncate-cell}). This
574 alows you to move point to a rightward cell that would otherwise be
575 covered by a spill-over. If you don't change the rightward cell, the
576 confined cell will spill over again the next time it is reprinted.
577
578 @item C-c C-c
579 When applied to a single cell, this command displays in the echo area any
580 formula error or printer error that occurred during
581 recalculation/reprinting (@code{ses-recalculate-cell}).
582 @end table
583
584 When a printer function signals an error, the default printer
585 @samp{"%s"} is substituted. This is useful when your column printer
586 is numeric-only and you use a string as a cell value.
587
588
589 @node Import and export, Virus protection, More on cell printing, Advanced Features
590 @section Import and export
591
592 @table @kbd
593 @item x t
594 Export a range of cells as tab-separated values (@code{ses-export-tsv}).
595 @item x T
596 Export a range of cells as tab-separated formulas (@code{ses-export-tsf}).
597 @end table
598
599 The exported text goes to the kill ring --- you can paste it into
600 another buffer. Columns are separated by tabs, rows by newlines.
601
602 To import text, use any of the yank commands where the text to paste
603 contains tabs and/or newlines. Imported formulas are not relocated.
604
605 @node Virus protection, Spreadsheets with details and summary, Import and export, Advanced Features
606 @section Virus protection
607
608 Whenever a formula or printer is read from a file or is pasted into
609 the spreadsheet, it receives a ``needs safety check'' marking. Later,
610 when the formula or printer is evaluated for the first time, it is
611 checked for safety using the @code{unsafep} predicate; if found to be
612 ``possibly unsafe'', the questionable formula or printer is displayed
613 and you must press Y to approve it or N to use a substitute. The
614 substitute always signals an error.
615
616 Formulas or printers that you type in are checked immediately for
617 safety. If found to be possibly unsafe and you press N to disapprove,
618 the action is cancelled and the old formula or printer will remain.
619
620 Besides viruses (which try to copy themselves to other files),
621 @code{unsafep} can also detect all other kinds of Trojan horses, such as
622 spreadsheets that delete files, send email, flood Web sites, alter
623 your Emacs settings, etc.
624
625 Generally, spreadsheet formulas and printers are simple things that
626 don't need to do any fancy computing, so all potentially-dangerous
627 parts of the Emacs Lisp environment can be excluded without cramping
628 your style as a formula-writer. See the documentation in @file{unsafep.el}
629 for more info on how Lisp forms are classified as safe or unsafe.
630
631 @node Spreadsheets with details and summary, , Virus protection, Advanced Features
632 @section Spreadsheets with details and summary
633
634 A common organization for spreadsheets is to have a bunch of ``detail''
635 rows, each perhaps describing a transaction, and then a set of
636 ``summary'' rows that each show reduced data for some subset of the
637 details. SES supports this organization via the @code{ses-select}
638 function.
639
640 @table @code
641 @item (ses-select @var{fromrange} @var{test} @var{torange})
642 Returns a subset of @var{torange}. For each member in @var{fromrange}
643 that is equal to @var{test}, the corresponding member of @var{torange}
644 is included in the result.
645 @end table
646
647 Example of use:
648 @lisp
649 (ses-average (ses-select (ses-range A1 A5) 'Smith (ses-range B1 B5)))
650 @end lisp
651 This computes the average of the B column values for those rows whose
652 A column value is the symbol 'Smith.
653
654 Arguably one could specify only @var{fromrange} plus
655 @var{to-row-offset} and @var{to-column-offset}. The @var{torange} is
656 stated explicitly to ensure that the formula will be recalculated if
657 any cell in either range is changed.
658
659 File @file{etc/ses-example.el} in the Emacs distribution is an example of a
660 details-and-summary spreadsheet.
661
662
663 @c ===================================================================
664
665 @node For Gurus, Acknowledgements, Advanced Features, Top
666 @chapter For Gurus
667
668 @menu
669 * Deferred updates::
670 * Nonrelocatable references::
671 * The data area::
672 * Buffer-local variables in spreadsheets::
673 * Uses of defadvice in SES::
674 @end menu
675
676 @node Deferred updates, Nonrelocatable references, For Gurus, For Gurus
677 @section Deferred updates
678
679 To save time by avoiding redundant computations, cells that need
680 recalculation due to changes in other cells are added to a set. At
681 the end of the command, each cell in the set is recalculated once.
682 This can create a new set of cells that need recalculation. The
683 process is repeated until either the set is empty or it stops changing
684 (due to circular references among the cells). In extreme cases, you
685 might see progress messages of the form ``Recalculating... (@var{nnn}
686 cells left)''. If you interrupt the calculation using @kbd{C-g}, the
687 spreadsheet will be left in an inconsistent state, so use @kbd{C-_} or
688 @kbd{C-c C-l} to fix it.
689
690 To save even more time by avoiding redundant writes, cells that have
691 changes are added to a set instead of being written immediately to the
692 data area. Each cell in the set is written once, at the end of the
693 command. If you change vast quantities of cells, you might see a
694 progress message of the form ``Writing... (@var{nnn} cells left)''.
695 These deferred cell-writes cannot be interrupted by @kbd{C-g}, so
696 you'll just have to wait.
697
698 SES uses @code{run-with-idle-timer} to move the cell underline when
699 Emacs will be scrolling the buffer after the end of a command, and
700 also to narrow and underline after @kbd{C-x C-v}. This is visible as
701 a momentary glitch after C-x C-v and certain scrolling commands. You
702 can type ahead without worrying about the glitch.
703
704
705 @node Nonrelocatable references, The data area, Deferred updates, For Gurus
706 @section Nonrelocatable references
707
708 @kbd{C-y} relocates all cell-references in a pasted formula, while
709 @kbd{C-u C-y} relocates none of the cell-references. What about mixed
710 cases?
711
712 You can use
713 @lisp
714 (symbol-value 'B3)
715 @end lisp
716 to make an @dfn{absolute reference}. The formula relocator skips over
717 quoted things, so this will not be relocated when pasted or when
718 rows/columns are inserted/deleted. However, B3 will not be recorded
719 as a dependency of this cell, so this cell will not be updated
720 automatically when B3 is changed.
721
722 The variables @code{row} and @code{col} are dynamically bound while a
723 cell formula is being evaluated. You can use
724 @lisp
725 (ses-cell-value row 0)
726 @end lisp
727 to get the value from the leftmost column in the current row. This
728 kind of dependency is also not recorded.
729
730
731 @node The data area, Buffer-local variables in spreadsheets, Nonrelocatable references, For Gurus
732 @section The data area
733
734 Begins with an 014 character, followed by sets of cell-definition
735 macros for each row, followed by column-widths, column-printers,
736 default-printer, and header-row. Then there's the global parameters
737 (file-format ID, numrows, numcols) and the local variables (specifying
738 SES mode for the buffer, etc.)
739
740 When a SES file is loaded, first the numrows and numcols values are
741 loaded, then the entire data area is @code{eval}ed, and finally the local
742 variables are processed.
743
744 You can edit the data area, but don't insert or delete any newlines
745 except in the local-variables part, since SES locates things by
746 counting newlines. Use @kbd{C-x C-e} at the end of a line to install
747 your edits into the spreadsheet data structures (this does not update
748 the print area, use e.g. @kbd{C-c C-l} for that).
749
750 The data area is maintained as an image of spreadsheet data
751 structures that area stored in buffer-local variables. If the data
752 area gets messed up, you can try reconstructing the data area from the
753 data structures:
754
755 @table @kbd
756 @item C-c M-C-l
757 (@code{ses-reconstruct-all}).
758 @end table
759
760
761 @node Buffer-local variables in spreadsheets, Uses of defadvice in SES, The data area, For Gurus
762 @section Buffer-local variables in spreadsheets
763
764 You can add additional local variables to the list at the bottom of
765 the data area, such as hidden constants you want to refer to in your
766 formulas.
767
768 You can override the variable @code{symbolic-formulas} to be a list of
769 symbols (as parenthesized strings) to show as completions for the '
770 command. This initial completions list is used instead of the actual
771 set of symbols-as-formulas in the spreadsheet.
772
773 For examples of these, see file @file{etc/ses-example.ses}.
774
775 If (for some reason) you want your formulas or printers to save data
776 into variables, you must declare these variables as buffer-locals in
777 order to avoid a virus warning.
778
779 You can define functions by making them values for the fake local
780 variable @code{eval}. Such functions can then be used in your
781 formulas and printers, but usually each @code{eval} is presented to
782 the user during file loading as a potential virus --- this can get
783 annoying.
784
785 You can define functions in your @file{.emacs} file. Other people can
786 still read the print area of your spreadsheet, but they won't be able
787 to recalculate or reprint anything that depends on your functions. To
788 avoid virus warnings, each function used in a formula needs
789 @lisp
790 (put 'your-function-name 'safe-function t)
791 @end lisp
792
793 @node Uses of defadvice in SES, , Buffer-local variables in spreadsheets, For Gurus
794 @section Uses of defadvice in SES
795
796 @table @code
797 @item undo-more
798 Defines a new undo element format (@var{fun} . @var{args}), which
799 means ``undo by applying @var{fun} to @var{args}''. For spreadsheet
800 buffers, it allows undos in the data area even though that's outside
801 the narrowing.
802
803 @item copy-region-as-kill
804 When copying from the print area of a spreadsheet, treat the region as
805 a rectangle and attach each cell's formula and printer as 'ses
806 properties.
807
808 @item yank
809 When yanking into the print area of a spreadsheet, first try to yank
810 as cells (if the yank text has 'ses properties), then as tab-separated
811 formulas, then (if all else fails) as a single formula for the current
812 cell.
813 @end table
814
815
816 @c ===================================================================
817
818 @node Acknowledgements, , For Gurus, Top
819 @chapter Acknowledgements
820
821 @quotation
822 Christoph Conrad @email{christoph.conrad@@gmx.de}@*
823 CyberBob @email{cyberbob@@redneck.gacracker.org}@*
824 Syver Enstad @email{syver-en@@online.no}@*
825 Ami Fischman @email{fischman@@zion.bpnetworks.com}@*
826 Thomas Gehrlein @email{Thomas.Gehrlein@@t-online.de}@*
827 Chris F.A. Johnson @email{c.f.a.johnson@@rogers.com}@*
828 Yusong Li @email{lyusong@@hotmail.com}@*
829 Yuri Linkov @email{link0ff@@yahoo.com}@*
830 Harald Maier @email{maierh@@myself.com}@*
831 Alan Nash @email{anash@@san.rr.com}@*
832 François Pinard @email{pinard@@iro.umontreal.ca}@*
833 Pedro Pinto @email{ppinto@@cs.cmu.edu}@*
834 Stefan Reichör @email{xsteve@@riic.at}@*
835 Oliver Scholz @email{epameinondas@@gmx.de}@*
836 Richard M. Stallman @email{rms@@gnu.org}@*
837 J. Otto Tennant @email{jotto@@pobox.com}@*
838 Jean-Philippe Theberge @email{jphil@@acs.pagesjaunes.fr}
839 @end quotation
840
841 @c ===================================================================
842
843 @bye