emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] Add support for tables in Calc src block :var


From: Visuwesh
Subject: Re: [PATCH] Add support for tables in Calc src block :var
Date: Sat, 16 Mar 2024 17:07:39 +0530
User-agent: Gnus/5.13 (Gnus v5.13)

[சனி மார்ச் 16, 2024] Ihor Radchenko wrote:

> Visuwesh <visuweshm@gmail.com> writes:
>
>> Attached patch adds support for passing tables as matrices (or vector)
>> to a Calc source block through the :var parameter.  There might be a
>> better way to do it than manually construct the data structure expected
>> by Calc for a matrix but given that it rarely sees changes in this area,
>> it shouldn't be a bother.
>> I also added tests for this feature, and other simple tests to ensure
>> everything works.  I checked that all the tests passed on my side.
>
> Thanks!
> Since you are adding a new feature, may you also add an entry to etc/ORG-NEWS?

Now done.

>> -       (calc-push-list (list (cdr pair)))
>> +       (let ((val (cdr pair)))
>> +         (calc-push-list
>> +          (list (if (listp val)
>> +                    (cons 'vec
>> +                          (if (null (cdr val))
>> +                              (car val)
>> +                            (mapcar (lambda (x) (if (listp x) (cons 'vec x) 
>> x))
>> +                                    val)))
>> +                  val))))
>
> It would be nice to add code comments explaining the Calc's internal
> format. Ideally, with references to Calc's manual or source code.
> Otherwise, this code looks like black magic :)

I hope the comment I added in the attached patch is clear enough.

>> +++ b/testing/examples/ob-calc-test.org
>> @@ -0,0 +1,57 @@
>> +#+TITLE: Tests for ob-calc
>> +#+OPTIONS: ^:nil
>
> Thanks a lot for adding many tests!
> Would you mind using `org-test-with-temp-text' instead of
> `org-test-at-id' as much as possible? Otherwise, looking at tests like

OK, I wasn't sure what test style to use since the README in testing/
does not talk about writing new tests.  Now I have adapted the tests to
use org-test-with-temp-text.

Attachment: 0001-ob-calc.el-Add-support-for-tables-in-Calc-source-blo.patch
Description: Text Data


reply via email to

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