[Top][All Lists]

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

RE: a ses question

From: Vincent Belaïche
Subject: RE: a ses question
Date: Sun, 29 Oct 2023 21:25:15 +0000

Just to complete my answer, if you do not want to rely on SES to do formatting output (with cell printers), then you can retrieve the computation result and format it explicitly with some code like this (not tested) : 

(let ((range (with-current-buffer the-ses-buffer (ses-range A1 C3 ; adapt to your case
                                              *2 '>v ; use 'v> to read columnwsise
  (dolist (row (cdr range))
    (dolist (cell (cdr row))
      (insert (format "%f" cell) ; assuming all cells are floating point numbers
            "&" ;; if & is the column separator
    (insert "\\\\\n"; if \\ is the row separator

De : Vincent Belaïche <vincent.b.1@hotmail.fr>
Envoyé : dimanche 29 octobre 2023 17:43
À : Andrés Ramírez <rrandresf@hotmail.com>
Cc : emacs-devel <emacs-devel@gnu.org>
Objet : RE: a ses question
Please wite to me directly also, because I am not actively following the list.

I think that the issue is that you collect the result of the computation by reading the text in the print area. The print area is refreshed in a deferred way, and this is why it is not up-to-date when you read it with a buffer-substring call.
You need to call ses-write-cells before doing that. I have not tested it.


PS : you can set the cell value by just doing something like (setq A1 "value of A1" A2 "value of A2"), that will work for setting the input of the the computation, but the undoing won't work, and you will need an explicit ses-recalculate-… to trigger the computation. Also this is probably not futureproof because I intend to change the way how the ses cell value are stored. Maybe I should create a ses-setq form to do that. If you set the input as you are doing, I don't think that the ses-recalculate-… is needed, but if you collect the result from buffer-substringing the print-area you will need it.

De : Andrés Ramírez <rrandresf@hotmail.com>
Envoyé : lundi 21 août 2023 12:38
À : Vincent Belaïche <vincent.b.1@hotmail.fr>
Objet : a ses question

Hi Vincent.

In case You are not following the emacs-help mailing list. I am sending You the link to the mail message.

–8<----------–—cut here----------–—start--------–—>8— https://lists.gnu.org/archive/cgi-bin/namazu.cgi?query=%2Bmessage-id%3ASJ1PR12MB6363267DB30BCE80E678BCFDA61EA%40SJ1PR12MB6363.namprd12.prod.outlook.com&submit=Search%21&idxname=help-gnu-emacs –8<----------–—cut here----------–—end----------–—>8—

Best Regards

reply via email to

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