[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master bfeacfc 2/3: Handle nil cell value in compiled prin
From: |
Vincent Belaïche |
Subject: |
[Emacs-diffs] master bfeacfc 2/3: Handle nil cell value in compiled printer functions. |
Date: |
Wed, 10 Aug 2016 08:14:45 +0000 (UTC) |
branch: master
commit bfeacfcdc9f584c798ef22528433dde5d78bcba7
Author: Vincent Belaïche <address@hidden>
Commit: Vincent Belaïche <address@hidden>
Handle nil cell value in compiled printer functions.
* doc/misc/ses.texi (Quick Tutorial): Minor clarification about the
ses-range `!' modifier.
(More on cell printing): Fix this that the fallback printer is
`ses-prin1', not "%S". That makes a difference for any cell value for
which "%S" would insert a backslash characters.
* lisp/ses.el (ses-local-printer-compile): Handle the nil cell value
--- contrary to emacs-25 branches ses-call-printer does not handle
prior to calling a function printer. Not doing this would still work
because the compiled function would throw and error and SES would in
the end resort to the ses-prin1 fallback, however this way would not
be in line with the raison d'être of compiling printer which is speed.
---
doc/misc/ses.texi | 7 ++++---
lisp/ses.el | 9 ++++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi
index c43ddf4..1f951de 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -188,8 +188,8 @@ the end-points, e.g.:
@emph{list} of values. This allows for more complex possibilities.)
Alternatively you can use the @code{!} modifier of @code{ses-range} to
-remove blank cells which allows to use @code{+} instead of
address@hidden:
+remove blank cells from the returned list, which allows to use
address@hidden instead of @code{ses+}:
@lisp
(apply '+ (ses-range A2 A5 !))
@@ -1020,7 +1020,8 @@ this to undo the effect of @kbd{t}.
@end table
When a printer function signals an error, the fallback printer
address@hidden"%S"} is substituted. This is useful when your column printer
address@hidden ses-prin1
address@hidden is substituted. This is useful when your column printer
is numeric-only and you use a string as a cell value. Note that the
standard default printer is @samp{"%.7g"} which is numeric-only, so cells
that are empty of contain strings will use the fallback printer.
diff --git a/lisp/ses.el b/lisp/ses.el
index 9abbd6d..c80415e 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -565,11 +565,14 @@ definition."
(cond
((functionp printer) printer)
((stringp printer)
- `(lambda (x) (format ,printer x)))
+ `(lambda (x)
+ (if (null x) ""
+ (format ,printer x))))
((stringp (car-safe printer))
`(lambda (x)
- (setq ses-call-printer-return t)
- (format ,(car printer) x)))
+ (if (null x) ""
+ (setq ses-call-printer-return t)
+ (format ,(car printer) x))))
(t (error "Invalid printer %S" printer))))
(defun ses--local-printer (name def)