From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: 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 00:20:49 +0200 [thread overview]
Message-ID: <875zchyq7y.fsf@gmail.com> (raw)
In-Reply-To: <87wo51jo5w.fsf@gnu.org> (Bastien's message of "Sun, 24 May 2020 18:25:15 +0200")
[-- Attachment #1: Type: text/plain, Size: 993 bytes --]
Hi,
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
>
> Best,
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)
The following patch fixes the test:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-C.patch --]
[-- Type: text/x-patch, Size: 373 bytes --]
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)))
[-- Attachment #3: Type: text/plain, Size: 144 bytes --]
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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: ob-C-test.patch --]
[-- Type: text/x-patch, Size: 472 bytes --]
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
[-- Attachment #5: Type: text/plain, Size: 224 bytes --]
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 hope this has not already been brought up; apologies if so.
next parent reply other threads:[~2020-05-27 22:21 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 ` Kévin Le Gouguec [this message]
2020-05-28 2:30 ` Possible fix for :includes header argument in org-babel C source blocks Kyle Meyer
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=875zchyq7y.fsf@gmail.com \
--to=kevin.legouguec@gmail.com \
--cc=brandon@guttersohn.org \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/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).