From: Ihor Radchenko <yantar92@posteo.net>
To: Visuwesh <visuweshm@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add support for tables in Calc src block :var
Date: Sat, 16 Mar 2024 09:52:48 +0000 [thread overview]
Message-ID: <87y1aiijv3.fsf@localhost> (raw)
In-Reply-To: <877ci2261h.fsf@gmail.com>
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?
> - (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 :)
> +++ 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
> +(ert-deftest ob-calc/simple-program-mult ()
> + "Test of simple multiplication."
> + (org-test-at-id "40e4cd26-fe15-45c0-938b-111e021a5a99"
> + (org-babel-next-src-block)
> + (should (equal "2" (org-babel-execute-src-block)))))
it is very difficult to understand what exactly the tests is checking.
`org-test-with-temp-text' would make things a lot more readable as we
would see the calc code being tested right inside the test code.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2024-03-16 9:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-16 3:45 [PATCH] Add support for tables in Calc src block :var Visuwesh
2024-03-16 9:52 ` Ihor Radchenko [this message]
2024-03-16 11:37 ` Visuwesh
2024-03-16 12:19 ` Ihor Radchenko
2024-03-16 12:34 ` Visuwesh
2024-03-18 12:48 ` Fraga, Eric
2024-03-18 15:29 ` Visuwesh
2024-03-18 15:45 ` Fraga, Eric
2024-03-30 13:04 ` Visuwesh
2024-04-03 12:43 ` Fraga, Eric
2024-12-13 7:31 ` Visuwesh
2024-12-13 9:02 ` Visuwesh
2024-12-13 10:53 ` Fraga, Eric
2024-12-13 11:06 ` Visuwesh
2024-12-13 11:48 ` Fraga, Eric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1aiijv3.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=visuweshm@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.