emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>, Bastien <bzg@gnu.org>
Cc: Brandon Guttersohn <brandon@guttersohn.org>, emacs-orgmode@gnu.org
Subject: Re: Possible fix for :includes header argument in org-babel C source blocks
Date: Thu, 28 May 2020 02:30:02 +0000	[thread overview]
Message-ID: <87imggx045.fsf@kyleam.com> (raw)
In-Reply-To: <875zchyq7y.fsf@gmail.com>

Kévin Le Gouguec writes:

> Bastien <bzg@gnu.org> writes:
>
>> Brandon Guttersohn <brandon@guttersohn.org> writes:
>>
>>> Hey all, I think I may have a small fix for executing C source blocks
>>> in org-babel. Or, possibly just a bad case of user error.
>>>
>>> The issue (in emacs 27 with -q) is that it doesn't seem possible to
>>> specify non-system header files with the :includes header argument.
>>>
>>> [...]
>>>
>>> The attached patch will wrap filenames in quotes if they do not begin
>>> with "<", and works for me.
>>
>> Thanks for reporting this and for suggesting this patch, I think it is
>> good enough.  I have applied it to the master branch of Org:
>>
>> https://code.orgmode.org/bzg/org-mode/commit/44cb98fdb6

I think this discussion was on emacs-devel only, so here are some links
for others who might go looking for more context:

  https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg01880.html
  https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg03051.html

> I think this commit might have broken test ob-C/string-var: running
> "make test" on master (516c038e5) right now I get:
>
>> Test ob-C/string-var condition:
>>     (wrong-type-argument sequencep <iostream>)
>>    FAILED    8/834  ob-C/string-var (0.004651 sec)

Thanks.  I started seeing that as well but hadn't looked into it yet.

> The following patch fixes the test:
>
> diff --git a/lisp/ob-C.el b/lisp/ob-C.el
> index c3e72c680..ae7b2ed1c 100644
> --- a/lisp/ob-C.el
> +++ b/lisp/ob-C.el
> @@ -233,6 +233,7 @@ its header arguments."
>  		;; includes
>  		(mapconcat
>  		 (lambda (inc)
> +		   (when (symbolp inc) (setq inc (symbol-name inc)))
>  		   (if (string-prefix-p "<" inc)
>  		       (format "#include %s" inc)
>  		     (format "#include \"%s\"" inc)))
>
> I don't know if it's the best way forward; another way to make the test
> pass is double-quoting "<iostream>" and "<cstring>" in ob-C-test.org:

The above looks reasonable to me...

> diff --git a/testing/examples/ob-C-test.org b/testing/examples/ob-C-test.org
> index 0faf630b9..efae02a19 100644
> --- a/testing/examples/ob-C-test.org
> +++ b/testing/examples/ob-C-test.org
> @@ -38,7 +38,7 @@
>  #+end_src
>  
>  #+source: string_var
> -#+begin_src cpp :var q="word" :includes '(<iostream> <cstring>) :results silent
> +#+begin_src cpp :var q="word" :includes '("<iostream>" "<cstring>") :results silent
>    std::cout << q << ' ' << std::strlen(q);
>    return 0;
>  #+end_src

...given this test seems to be explicitly checking that case.

> I guess there might be some people out there who will expect things to
> keep working without double-quotes?  I have never used Babel, so I have
> no idea…

I don't know either, but the test does make me think so.  Hopefully
Brandon, Bastien, or someone else will chime in if that's not the case.

Could you send the first patch with a commit message tacked on?

Thanks again!


  reply	other threads:[~2020-05-28  2:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <21b0cd85-d678-2fe6-3c22-e41abc6cf242@guttersohn.org>
     [not found] ` <87wo51jo5w.fsf@gnu.org>
2020-05-27 22:20   ` Possible fix for :includes header argument in org-babel C source blocks Kévin Le Gouguec
2020-05-28  2:30     ` Kyle Meyer [this message]
2020-05-28  8:25       ` Kévin Le Gouguec
2020-05-28 10:09         ` Kévin Le Gouguec
2020-05-29  2:47           ` Kyle Meyer
2020-05-29 12:41             ` Failing tests (was: Possible fix for :includes header argument in org-babel C source blocks) Kévin Le Gouguec
2020-05-31  4:59               ` Kyle Meyer
2020-06-01 14:48                 ` Failing tests Kévin Le Gouguec
2020-06-01 14:56                   ` Kévin Le Gouguec
2020-06-03  4:20                   ` Kyle Meyer
2020-06-01 13:54               ` Bastien
2020-05-29  3:37           ` Possible fix for :includes header argument in org-babel C source blocks Brandon Guttersohn
2020-05-29  9:57             ` Kévin Le Gouguec
2020-05-30 17:29               ` Brandon Guttersohn
2020-06-01 13:55                 ` Bastien
2020-06-01 20:17                   ` Kévin Le Gouguec
2020-06-02  0:02                     ` Brandon Guttersohn
2020-05-29  2:45         ` Kyle Meyer

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=87imggx045.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=brandon@guttersohn.org \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=kevin.legouguec@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 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).