emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] ob-lua


From: Thibault Marin
Subject: Re: [O] ob-lua
Date: Sat, 20 Aug 2016 23:47:16 -0500
User-agent: mu4e 0.9.16; emacs 24.5.1

>> There may be a better way to do it, but it seems to work.
>
> In this case, `org-babel-get-header' should be replaced with
> `org-babel--get-vars', per ORG-NEWS.

Thanks, it is much better.

>> So my question is: could this be considered for a merge?  The code does
>> not seem to support sessions, I am not sure if that should be
>> a blocker.
>
> It isn't a blocker, indeed. Could you send an updated patch? A set of
> tests would be nice, too.

I have updated the patch to use `org-babel--get-vars' as suggested.  I
also have replaced `org-babel-trim' by `org-trim' (as advised in
ORG-NEWS) and replaced the `case' statement by a `pcase' (I used
ob-python.el for reference).  Please let me know if these changes are
acceptable and if other changes are required.

About the test, I am attaching my first attempt at this, please let me
know if you have some advice on how to improve it or if you had
something else in mind.  This is the first time I use ert or org-test,
but these seem to pass and test the basic features.

By the way, when trying to run the tests from emacs, I had an error
message when doing a (require 'org-test): "let: Required feature `ert-x'
was not provided".  Am I doing something wrong?  I worked around it by
(1) installing the `ertx' package and (2) replacing (require 'ert-x) by
(require 'ertx) in org-test.el (that's probably the wrong thing to do,
but it allowed me to run my tests).

Thanks for your help.

thibault

Attachment: test-ob-lua.el
Description: application/emacs-lisp

132c132
<    (mapcar #'cdr (org-babel-get-header params :var))))
---
>    (org-babel--get-vars params)))
292,312c292,312
<          (case result-type
<            (output (org-babel-eval org-babel-lua-command
<                                    (concat (if preamble (concat preamble 
"\n"))
<                                            body)))
<            (value (let ((tmp-file (org-babel-temp-file "lua-")))
<                     (org-babel-eval
<                      org-babel-lua-command
<                      (concat
<                       (if preamble (concat preamble "\n") "")
<                       (format
<                        (if (member "pp" result-params)
<                            org-babel-lua-pp-wrapper-method
<                          org-babel-lua-wrapper-method)
<                        (mapconcat
<                         (lambda (line) (format "\t%s" line))
<                         (split-string
<                          (org-remove-indentation
<                           (org-babel-trim body))
<                          "[\r\n]") "\n")
<                        (org-babel-process-file-name tmp-file 'noquote))))
<                     (org-babel-eval-read-file tmp-file))))))
---
>          (pcase result-type
>            (`output (org-babel-eval org-babel-lua-command
>                                   (concat (if preamble (concat preamble "\n"))
>                                           body)))
>            (`value (let ((tmp-file (org-babel-temp-file "lua-")))
>                    (org-babel-eval
>                     org-babel-lua-command
>                     (concat
>                      (if preamble (concat preamble "\n") "")
>                      (format
>                       (if (member "pp" result-params)
>                           org-babel-lua-pp-wrapper-method
>                         org-babel-lua-wrapper-method)
>                       (mapconcat
>                        (lambda (line) (format "\t%s" line))
>                        (split-string
>                         (org-remove-indentation
>                          (org-trim body))
>                         "[\r\n]") "\n")
>                       (org-babel-process-file-name tmp-file 'noquote))))
>                    (org-babel-eval-read-file tmp-file))))))
315c315
<       (org-babel-lua-table-or-string (org-babel-trim raw)))))
---
>       (org-babel-lua-table-or-string (org-trim raw)))))
369c369
<               #'org-babel-trim
---
>               #'org-trim

reply via email to

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