unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26169: 25.1; ses.el string cell recalculate message
@ 2017-03-19  5:02 Kevin Ryde
  2020-08-20 16:22 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Ryde @ 2017-03-19  5:02 UTC (permalink / raw)
  To: 26169

In debian packaged emacs 25.1.1, starting "emacs -Q /tmp/foo.ses"

   " Ret            # create a cell with a string
   hello Ret        # the string content
   C-p              # move point to that cell
   c                # ses-recalculate-cell
   =>
   Format specifier doesn't match argument type: A1

I expected recalc on a string cell to leave it unchanged.
The message looks like a caught error, but I don't know if it's
something bad or merely unsightly.  The same happens in emacs 24.

Occasionally I've had c on a string cell clear it to nil.  I'll see if I
can make something reproducable for that, if it could be related.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26169: 25.1; ses.el string cell recalculate message
  2017-03-19  5:02 bug#26169: 25.1; ses.el string cell recalculate message Kevin Ryde
@ 2020-08-20 16:22 ` Lars Ingebrigtsen
  2020-08-24 14:20   ` Vincent Belaïche
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-20 16:22 UTC (permalink / raw)
  To: Kevin Ryde; +Cc: Vincent Belaïche, 26169

Kevin Ryde <user42_kevin@yahoo.com.au> writes:

> In debian packaged emacs 25.1.1, starting "emacs -Q /tmp/foo.ses"
>
>    " Ret            # create a cell with a string
>    hello Ret        # the string content
>    C-p              # move point to that cell
>    c                # ses-recalculate-cell
>    =>
>    Format specifier doesn't match argument type: A1
>
> I expected recalc on a string cell to leave it unchanged.
> The message looks like a caught error, but I don't know if it's
> something bad or merely unsightly.  The same happens in emacs 24.
>
> Occasionally I've had c on a string cell clear it to nil.  I'll see if I
> can make something reproducable for that, if it could be related.

I had a peek at ses.el (a package I don't use regularly), and something
like the following fixes the problem, but is probably totally the wrong
solution.

I've Cc'd the maintainer on this -- Vincent?

diff --git a/lisp/ses.el b/lisp/ses.el
index 96b219fc60..e396cc72ac 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -1231,7 +1231,9 @@ ses-print-cell
                     (ses--col col))
                 (ses-call-printer (or printer
                                       (ses-col-printer col)
-                                      ses--default-printer)
+                                      (if (stringp value)
+                                          "%7s"
+                                        ses--default-printer))
                                   value)))
 	(if (consp ses-call-printer-return)
 	    ;; Printer returned an error.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#26169: 25.1; ses.el string cell recalculate message
  2020-08-20 16:22 ` Lars Ingebrigtsen
@ 2020-08-24 14:20   ` Vincent Belaïche
  2020-08-24 14:50     ` Vincent Belaïche
  0 siblings, 1 reply; 7+ messages in thread
From: Vincent Belaïche @ 2020-08-24 14:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Vincent Belaïche, Kevin Ryde, 26169

Hello Lars,

The root cause is that the default printer is "%.7g". This printer
being a string it is equivalent for (lambda (x) (format xxxx x)),
where xxxx is the concerned string, ie "%.7g".

That default printer comes from the const ses-initial-file-contents,
which hard wires the default printer to "%.7g".

So you can just change your spreadsheet not to get the error by
setting "%s" as a printer to cell A1 (just press p, then "%s", and
then RET). You can also change the default column printer with M-p, or
the default spreadsheet printer with C-c C-p.

A better fix would certainly to accept a new printer format that
instead of a string would be some sort of expression structure that
would map a format string to some predicate, where the predicates
could only be one of stringp , numberp. It could be something

'(printers (stringp . "%s") (numberp . "%.7g"))

So the code would check it for being safe (not to allow viruses on
load) this way

(mapc (lambda (x) (or (and (memq (car x) '(stringp numberp)) (stringp
(cdr x)) (errror "Unsafe printer %S" x))
   yyyy)

where yyyy would be the desired value '(printers (stringp . "%s")
(numberp . "%.7g")).

Well, probably what sort of structure we want to accommodate needs
some more thinking.

  Vincent.

PS : I cannot make the fix straight away, my personal PC ethernet card
has been broken by the latest storm overvoltage, and the other PC
having my credentials is also under repair after overheating damaged
the connectors (well, nothing surprising as this was a MACbook pro, a
notable unreliable sort of machine wrt to thermal extreme conditions).

Le jeu. 20 août 2020 à 18:22, Lars Ingebrigtsen <larsi@gnus.org> a écrit :
>
> Kevin Ryde <user42_kevin@yahoo.com.au> writes:
>
> > In debian packaged emacs 25.1.1, starting "emacs -Q /tmp/foo.ses"
> >
> >    " Ret            # create a cell with a string
> >    hello Ret        # the string content
> >    C-p              # move point to that cell
> >    c                # ses-recalculate-cell
> >    =>
> >    Format specifier doesn't match argument type: A1
> >
> > I expected recalc on a string cell to leave it unchanged.
> > The message looks like a caught error, but I don't know if it's
> > something bad or merely unsightly.  The same happens in emacs 24.
> >
> > Occasionally I've had c on a string cell clear it to nil.  I'll see if I
> > can make something reproducable for that, if it could be related.
>
> I had a peek at ses.el (a package I don't use regularly), and something
> like the following fixes the problem, but is probably totally the wrong
> solution.
>
> I've Cc'd the maintainer on this -- Vincent?
>
> diff --git a/lisp/ses.el b/lisp/ses.el
> index 96b219fc60..e396cc72ac 100644
> --- a/lisp/ses.el
> +++ b/lisp/ses.el
> @@ -1231,7 +1231,9 @@ ses-print-cell
>                      (ses--col col))
>                  (ses-call-printer (or printer
>                                        (ses-col-printer col)
> -                                      ses--default-printer)
> +                                      (if (stringp value)
> +                                          "%7s"
> +                                        ses--default-printer))
>                                    value)))
>         (if (consp ses-call-printer-return)
>             ;; Printer returned an error.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26169: 25.1; ses.el string cell recalculate message
  2020-08-24 14:20   ` Vincent Belaïche
@ 2020-08-24 14:50     ` Vincent Belaïche
  2020-08-25 20:27       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Vincent Belaïche @ 2020-08-24 14:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Vincent Belaïche, Kevin Ryde, 26169

Or we could have some extended format string, like this:

"%?n{%.7g%}%?s{%s%}%?*{%S%}"

where whatever is between %?xxxx{ and %} is conditioned by some
predicate xxxx that can be n for numberp, s for stringp, and * for
"none of those at the same level", and some parser would compile this
format string into

(cond
   ((numberp x) (format "%.7g" x))
   ((stringp x) (format "%s" x))
   (t (format "%S" x))

Le lun. 24 août 2020 à 16:20, Vincent Belaïche
<vincent.belaiche@gmail.com> a écrit :
>
> Hello Lars,
>
> The root cause is that the default printer is "%.7g". This printer
> being a string it is equivalent for (lambda (x) (format xxxx x)),
> where xxxx is the concerned string, ie "%.7g".
>
> That default printer comes from the const ses-initial-file-contents,
> which hard wires the default printer to "%.7g".
>
> So you can just change your spreadsheet not to get the error by
> setting "%s" as a printer to cell A1 (just press p, then "%s", and
> then RET). You can also change the default column printer with M-p, or
> the default spreadsheet printer with C-c C-p.
>
> A better fix would certainly to accept a new printer format that
> instead of a string would be some sort of expression structure that
> would map a format string to some predicate, where the predicates
> could only be one of stringp , numberp. It could be something
>
> '(printers (stringp . "%s") (numberp . "%.7g"))
>
> So the code would check it for being safe (not to allow viruses on
> load) this way
>
> (mapc (lambda (x) (or (and (memq (car x) '(stringp numberp)) (stringp
> (cdr x)) (errror "Unsafe printer %S" x))
>    yyyy)
>
> where yyyy would be the desired value '(printers (stringp . "%s")
> (numberp . "%.7g")).
>
> Well, probably what sort of structure we want to accommodate needs
> some more thinking.
>
>   Vincent.
>
> PS : I cannot make the fix straight away, my personal PC ethernet card
> has been broken by the latest storm overvoltage, and the other PC
> having my credentials is also under repair after overheating damaged
> the connectors (well, nothing surprising as this was a MACbook pro, a
> notable unreliable sort of machine wrt to thermal extreme conditions).
>
> Le jeu. 20 août 2020 à 18:22, Lars Ingebrigtsen <larsi@gnus.org> a écrit :
> >
> > Kevin Ryde <user42_kevin@yahoo.com.au> writes:
> >
> > > In debian packaged emacs 25.1.1, starting "emacs -Q /tmp/foo.ses"
> > >
> > >    " Ret            # create a cell with a string
> > >    hello Ret        # the string content
> > >    C-p              # move point to that cell
> > >    c                # ses-recalculate-cell
> > >    =>
> > >    Format specifier doesn't match argument type: A1
> > >
> > > I expected recalc on a string cell to leave it unchanged.
> > > The message looks like a caught error, but I don't know if it's
> > > something bad or merely unsightly.  The same happens in emacs 24.
> > >
> > > Occasionally I've had c on a string cell clear it to nil.  I'll see if I
> > > can make something reproducable for that, if it could be related.
> >
> > I had a peek at ses.el (a package I don't use regularly), and something
> > like the following fixes the problem, but is probably totally the wrong
> > solution.
> >
> > I've Cc'd the maintainer on this -- Vincent?
> >
> > diff --git a/lisp/ses.el b/lisp/ses.el
> > index 96b219fc60..e396cc72ac 100644
> > --- a/lisp/ses.el
> > +++ b/lisp/ses.el
> > @@ -1231,7 +1231,9 @@ ses-print-cell
> >                      (ses--col col))
> >                  (ses-call-printer (or printer
> >                                        (ses-col-printer col)
> > -                                      ses--default-printer)
> > +                                      (if (stringp value)
> > +                                          "%7s"
> > +                                        ses--default-printer))
> >                                    value)))
> >         (if (consp ses-call-printer-return)
> >             ;; Printer returned an error.
> >
> > --
> > (domestic pets only, the antidote for overdose, milk.)
> >    bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26169: 25.1; ses.el string cell recalculate message
  2020-08-24 14:50     ` Vincent Belaïche
@ 2020-08-25 20:27       ` Lars Ingebrigtsen
  2020-08-26 11:54         ` Vincent Belaïche
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-25 20:27 UTC (permalink / raw)
  To: Vincent Belaïche; +Cc: Vincent Belaïche, Kevin Ryde, 26169

Vincent Belaïche <vincent.belaiche@gmail.com> writes:

> Or we could have some extended format string, like this:
>
> "%?n{%.7g%}%?s{%s%}%?*{%S%}"
>
> where whatever is between %?xxxx{ and %} is conditioned by some
> predicate xxxx that can be n for numberp, s for stringp, and * for
> "none of those at the same level", and some parser would compile this
> format string into
>
> (cond
>    ((numberp x) (format "%.7g" x))
>    ((stringp x) (format "%s" x))
>    (t (format "%S" x))

Hm...  or it could just be an alist like

((numberp "%.7g")
 (stringp "%s")
 (t "%S"))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26169: 25.1; ses.el string cell recalculate message
  2020-08-25 20:27       ` Lars Ingebrigtsen
@ 2020-08-26 11:54         ` Vincent Belaïche
  2020-08-27 13:33           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Vincent Belaïche @ 2020-08-26 11:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Vincent Belaïche, Kevin Ryde, 26169

After some thought the extended format string seems better to me, it
could be some separate package as that sort of need is not SES
specific, and SES would check if the package is installed or not and
use extended format strings if the package is installed.
That would be a parameter in the sheet whether is uses extended format
strings. So when you share a sheet using extended format with somebody
else that do not have a extended formats, they would receive some
warning that they need to install the package.
  V.

Le mar. 25 août 2020 à 22:27, Lars Ingebrigtsen <larsi@gnus.org> a écrit :
>
> Vincent Belaïche <vincent.belaiche@gmail.com> writes:
>
> > Or we could have some extended format string, like this:
> >
> > "%?n{%.7g%}%?s{%s%}%?*{%S%}"
> >
> > where whatever is between %?xxxx{ and %} is conditioned by some
> > predicate xxxx that can be n for numberp, s for stringp, and * for
> > "none of those at the same level", and some parser would compile this
> > format string into
> >
> > (cond
> >    ((numberp x) (format "%.7g" x))
> >    ((stringp x) (format "%s" x))
> >    (t (format "%S" x))
>
> Hm...  or it could just be an alist like
>
> ((numberp "%.7g")
>  (stringp "%s")
>  (t "%S"))
>
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26169: 25.1; ses.el string cell recalculate message
  2020-08-26 11:54         ` Vincent Belaïche
@ 2020-08-27 13:33           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-27 13:33 UTC (permalink / raw)
  To: Vincent Belaïche; +Cc: Vincent Belaïche, Kevin Ryde, 26169

Vincent Belaïche <vincent.belaiche@gmail.com> writes:

> After some thought the extended format string seems better to me, it
> could be some separate package as that sort of need is not SES
> specific, and SES would check if the package is installed or not and
> use extended format strings if the package is installed.
> That would be a parameter in the sheet whether is uses extended format
> strings. So when you share a sheet using extended format with somebody
> else that do not have a extended formats, they would receive some
> warning that they need to install the package.

I'm not sure I see the logic here -- it's surely a plain and simple bug
stat ses signals an error when you're "recalculating" an ascii value.
Is your concern that fixing this bug will lead to people creating more
spreadsheets with ascii values, and then other people (using older
versions of Emacs) won't be able to use those spreadsheets?

If so, I think that sounds like an unlikely occurrence.  And if it does
happen, then there's nothing new about spreadsheets changing the formats
in non-backwards-compatible manner -- the recipient will just have to
update their spreadsheet software, too.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-27 13:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-19  5:02 bug#26169: 25.1; ses.el string cell recalculate message Kevin Ryde
2020-08-20 16:22 ` Lars Ingebrigtsen
2020-08-24 14:20   ` Vincent Belaïche
2020-08-24 14:50     ` Vincent Belaïche
2020-08-25 20:27       ` Lars Ingebrigtsen
2020-08-26 11:54         ` Vincent Belaïche
2020-08-27 13:33           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).