diff options
| author | Vincent Belaïche | 2016-08-10 10:13:27 +0200 |
|---|---|---|
| committer | Vincent Belaïche | 2016-08-10 10:13:27 +0200 |
| commit | bfeacfcdc9f584c798ef22528433dde5d78bcba7 (patch) | |
| tree | eaf82a7287cfb73312318fc28c74c376e2b653ca | |
| parent | 731d225cf3a8f95d3bad0baf60c792afc7d58b78 (diff) | |
| download | emacs-bfeacfcdc9f584c798ef22528433dde5d78bcba7.tar.gz emacs-bfeacfcdc9f584c798ef22528433dde5d78bcba7.zip | |
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.
| -rw-r--r-- | doc/misc/ses.texi | 7 | ||||
| -rw-r--r-- | lisp/ses.el | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi index c43ddf472a4..1f951de239f 100644 --- a/doc/misc/ses.texi +++ b/doc/misc/ses.texi | |||
| @@ -188,8 +188,8 @@ the end-points, e.g.: | |||
| 188 | @emph{list} of values. This allows for more complex possibilities.) | 188 | @emph{list} of values. This allows for more complex possibilities.) |
| 189 | 189 | ||
| 190 | Alternatively you can use the @code{!} modifier of @code{ses-range} to | 190 | Alternatively you can use the @code{!} modifier of @code{ses-range} to |
| 191 | remove blank cells which allows to use @code{+} instead of | 191 | remove blank cells from the returned list, which allows to use |
| 192 | @code{ses+}: | 192 | @code{+} instead of @code{ses+}: |
| 193 | 193 | ||
| 194 | @lisp | 194 | @lisp |
| 195 | (apply '+ (ses-range A2 A5 !)) | 195 | (apply '+ (ses-range A2 A5 !)) |
| @@ -1020,7 +1020,8 @@ this to undo the effect of @kbd{t}. | |||
| 1020 | @end table | 1020 | @end table |
| 1021 | 1021 | ||
| 1022 | When a printer function signals an error, the fallback printer | 1022 | When a printer function signals an error, the fallback printer |
| 1023 | @samp{"%S"} is substituted. This is useful when your column printer | 1023 | @findex ses-prin1 |
| 1024 | @code{ses-prin1} is substituted. This is useful when your column printer | ||
| 1024 | is numeric-only and you use a string as a cell value. Note that the | 1025 | is numeric-only and you use a string as a cell value. Note that the |
| 1025 | standard default printer is @samp{"%.7g"} which is numeric-only, so cells | 1026 | standard default printer is @samp{"%.7g"} which is numeric-only, so cells |
| 1026 | that are empty of contain strings will use the fallback printer. | 1027 | that are empty of contain strings will use the fallback printer. |
diff --git a/lisp/ses.el b/lisp/ses.el index 9abbd6dd2ca..c80415e1e15 100644 --- a/lisp/ses.el +++ b/lisp/ses.el | |||
| @@ -565,11 +565,14 @@ definition." | |||
| 565 | (cond | 565 | (cond |
| 566 | ((functionp printer) printer) | 566 | ((functionp printer) printer) |
| 567 | ((stringp printer) | 567 | ((stringp printer) |
| 568 | `(lambda (x) (format ,printer x))) | 568 | `(lambda (x) |
| 569 | (if (null x) "" | ||
| 570 | (format ,printer x)))) | ||
| 569 | ((stringp (car-safe printer)) | 571 | ((stringp (car-safe printer)) |
| 570 | `(lambda (x) | 572 | `(lambda (x) |
| 571 | (setq ses-call-printer-return t) | 573 | (if (null x) "" |
| 572 | (format ,(car printer) x))) | 574 | (setq ses-call-printer-return t) |
| 575 | (format ,(car printer) x)))) | ||
| 573 | (t (error "Invalid printer %S" printer)))) | 576 | (t (error "Invalid printer %S" printer)))) |
| 574 | 577 | ||
| 575 | (defun ses--local-printer (name def) | 578 | (defun ses--local-printer (name def) |