summaryrefslogtreecommitdiff
path: root/doc/misc/ses.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/misc/ses.texi')
-rw-r--r--doc/misc/ses.texi30
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi
index 58f9ba8ccf3..8b0bb82f174 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -444,6 +444,36 @@ printer function. Then, if you call again
@code{"%.3f"}, all the cells using printer @samp{foo} will be
reprinted accordingly.
+When you define a printer function with a lambda expression taking one
+argument, please take care that the returned value is a string, or a
+list containing a string, even when the input argument has an
+unexpected value. Here is an example:
+
+@example
+(lambda (val)
+ (cond
+ ((null val) "")
+ ((and (numberp val) (>= val 0)) (format "%.1f" val))
+ (t (ses-center-span (format "%S" val) ?#))))
+@end example
+
+This example will:
+@itemize
+@item
+When the cell is empty (ie.@: when @code{val} is @code{nil}), print an
+empty string @code{""}
+@item
+When the cell value is a non negative number, format the the value in
+fixed-point notation with one decimal after point
+@item
+Otherwise, handle the value as erroneous by printing it as an
+s-expression (using @code{prin1}), centered and surrounded by @code{#}
+filling.
+@end itemize
+
+
+
+
@node Clearing cells
@section Clearing cells
@cindex clearing commands