aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorVincent Belaïche2015-12-30 12:37:54 +0100
committerVincent Belaïche2015-12-30 17:42:03 +0100
commit209e30bac2d73c2e6f1c46b0d7281b474527cfa4 (patch)
tree763e169916fb9b8835e6f7305561a4de8e6a85f9 /doc/misc
parente8702794d46ae032803bf54ffbd71ebde215179c (diff)
downloademacs-209e30bac2d73c2e6f1c46b0d7281b474527cfa4.tar.gz
emacs-209e30bac2d73c2e6f1c46b0d7281b474527cfa4.zip
Don't fake empty cells value by "" when printing with a lambda.
When using a lambda expression printer function the user should be free to format differently a really empty cell, ie. containing nil, from a cell containing an empty string "". * ses.el (ses-call-printer): Replace `(or value "")' by just `value' in the case of a lambda expression printer function. * ses.texi (Printer functions): Add example and description about lambda expression printer function handling all the possible values, including unexpected ones.
Diffstat (limited to 'doc/misc')
-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 2f92e3ea836..4cb4188f690 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -443,6 +443,36 @@ printer function. Then, if you call again
443@code{"%.3f"} all the cells using printer @samp{foo} will be reprinted 443@code{"%.3f"} all the cells using printer @samp{foo} will be reprinted
444accordingly. 444accordingly.
445 445
446When you define a printer function with a lambda expression taking one
447argument, please take care that the returned value is a string, or a
448list containing a string, even when the input argument has an
449unexpected value. Here is an example:
450
451@example
452(lambda (val)
453 (cond
454 ((null val) "")
455 ((and (numberp val) (>= val 0)) (format "%.1f" val))
456 (t (ses-center-span (format "%S" val) ?#))))
457@end example
458
459This example will:
460@itemize
461@item
462When the cell is empty (ie.@: when @code{val} is @code{nil}), print an
463empty string @code{""}
464@item
465When the cell value is a non negative number, format the the value in
466fixed-point notation with one decimal after point
467@item
468Otherwise, handle the value as erroneous by printing it as an
469s-expression (using @code{prin1}), centered and surrounded by @code{#}
470filling.
471@end itemize
472
473
474
475
446@node Clearing cells 476@node Clearing cells
447@section Clearing cells 477@section Clearing cells
448@cindex clearing commands 478@cindex clearing commands