emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thibault Marin <thibault.marin@gmx.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: ob-lua
Date: Sat, 20 Aug 2016 23:47:16 -0500	[thread overview]
Message-ID: <87eg5ik9t7.fsf@dell-desktop.WORKGROUP> (raw)
In-Reply-To: <87h9af1la2.fsf@saiph.selenimh>

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]


>> 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 #2: test-ob-lua.el --]
[-- Type: application/emacs-lisp, Size: 3042 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: ob-lua.el.patch --]
[-- Type: text/x-diff, Size: 2185 bytes --]

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	other threads:[~2016-08-21  4:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-20  5:18 ob-lua Thibault Marin
2016-08-20 16:02 ` ob-lua Nicolas Goaziou
2016-08-21  4:47   ` Thibault Marin [this message]
2016-08-21  9:30     ` ob-lua Nicolas Goaziou
2016-08-22  2:38       ` ob-lua Thibault Marin
2016-08-22  9:28         ` ob-lua Nicolas Goaziou
2016-08-22 12:56           ` ob-lua Thibault Marin
2016-08-24  2:39             ` ob-lua Thibault Marin
2016-08-29  7:10               ` ob-lua Nicolas Goaziou
2016-08-31  3:36                 ` ob-lua Thibault Marin
2016-09-01 16:40                   ` ob-lua Nicolas Goaziou
2016-09-08  4:37                     ` ob-lua Thibault Marin

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eg5ik9t7.fsf@dell-desktop.WORKGROUP \
    --to=thibault.marin@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).