emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 209e30b 2/2: Don't fake empty cells value by "" whe


From: Vincent Belaïche
Subject: [Emacs-diffs] master 209e30b 2/2: Don't fake empty cells value by "" when printing with a lambda.
Date: Wed, 30 Dec 2015 16:43:02 +0000

branch: master
commit 209e30bac2d73c2e6f1c46b0d7281b474527cfa4
Author: Vincent Belaïche <address@hidden>
Commit: Vincent Belaïche <address@hidden>

    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.
---
 doc/misc/ses.texi |   30 ++++++++++++++++++++++++++++++
 lisp/ses.el       |    2 +-
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi
index 2f92e3e..4cb4188 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -443,6 +443,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:
+
address@hidden
+(lambda (val)
+   (cond
+      ((null val) "")
+      ((and (numberp val) (>= val 0)) (format "%.1f" val))
+      (t (ses-center-span (format "%S" val) ?#))))
address@hidden example
+
+This example will:
address@hidden
address@hidden
+When the cell is empty (ie.@: when @code{val} is @code{nil}), print an
+empty string @code{""}
address@hidden
+When the cell value is a non negative number, format the the value in
+fixed-point notation with one decimal after point
address@hidden
+Otherwise, handle the value as erroneous by printing it as an
+s-expression (using @code{prin1}), centered and surrounded by @code{#}
+filling.
address@hidden itemize
+
+
+
+
 @node Clearing cells
 @section Clearing cells
 @cindex clearing commands
diff --git a/lisp/ses.el b/lisp/ses.el
index 7347eb8..8cbc2e8 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -1289,7 +1289,7 @@ printer signaled one (and \"%s\" is used as the default 
printer), else nil."
                           (and locprn
                                (ses--locprn-compiled locprn))))
                    printer)
-               (or value "")))
+               value))
        (if (stringp value)
            value
          (or (stringp (car-safe value))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]