From: Thierry Banel <tbanelwebmin@free.fr>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: Cannot set header-args :includes with multiple includes [8.2.7 (8.2.7-4-g880362-elpa @ /home/will/.emacs.d/elpa/org-20140616/)]
Date: Thu, 04 Sep 2014 21:47:47 +0200 [thread overview]
Message-ID: <5408C1E3.2090102@free.fr> (raw)
In-Reply-To: <CAMy09DefWdvTdV7pv=icE5TgMDdajAzV4AkJLjmiZ01rk8DzuA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]
Le 26/08/2014 18:24, Will Everett a écrit :
>
>
> I believe the :includes header argument is incorrectly parsing lists
> of includes for c++. This snippet:
>
> #+BEGIN_SRC C++ :includes <cstdio> <iostream>
> using namespace std;
> printf("Hello ");
> cout << "world";
> #+END_SRC
>
> produces a compiler error:
>
> warning: extra tokens at end of #include directive
> #include <cstdio> <iostream>
>
>
Here is a patch to fix the issue.
The :includes, :defines, :imports headers have been extended to accept
multiple items without parenthesis. All the following forms are now allowed:
:includes <stdio.h>
:includes <stdio.h> "strings.h" <assert>
:includes '(<stdio.h> <strings.h> <assert>)
:includes (mapcar (lambda (x) (concat "<std/" x ".h>")) '("abc" "def"
"ghi"))
(same for :imports)
:defines AA 22 BB 33
:defines "AA 22 BB 33"
:defines '("abc 123" "def 456")
:defines (mapcar (lambda (x) (concat x " " x "_def")) '("A" "BB" "CCC"))
This works either in the header as here:
#+BEGIN_SRC C++ :includes <stdio.h> "strings.h" <assert>
#+END_SRC
or in a property drawer, like that:
:PROPERTIES:
:includes: <stdio.h> "strings.h" <assert>
:END:
Have fun
Thierry
[-- Attachment #2: 0001-Enable-multiple-files-in-includes-header.patch --]
[-- Type: text/x-diff, Size: 2266 bytes --]
From 63ab1d364f0e425d8d02ce946021611a1a3b7ce6 Mon Sep 17 00:00:00 2001
From: Thierry Banel <tbanelwebmin@free.fr>
Date: Thu, 4 Sep 2014 19:30:54 +0200
Subject: [PATCH] Enable multiple files in :includes header
* ob-C.el
(org-babel-C-expand-C)
(org-babel-C-expand-D):
:includes, :defines, :imports now accept
several items separated by blanks without
enclosing them in parenthesis.
Thanks to Will Everett for reporting this.
---
lisp/ob-C.el | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/lisp/ob-C.el b/lisp/ob-C.el
index 076276e..c42ccea 100644
--- a/lisp/ob-C.el
+++ b/lisp/ob-C.el
@@ -186,13 +186,26 @@ it's header arguments."
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
(colnames (cdar (org-babel-get-header params :colname-names)))
(main-p (not (string= (cdr (assoc :main params)) "no")))
- (includes (or (cdr (assoc :includes params))
- (org-babel-read (org-entry-get nil "includes" t))))
+ (includes (org-babel-read
+ (or (cdr (assoc :includes params))
+ (org-entry-get nil "includes" t))
+ nil))
(defines (org-babel-read
(or (cdr (assoc :defines params))
- (org-babel-read (org-entry-get nil "defines" t))))))
- (unless (listp includes) (setq includes (list includes)))
+ (org-entry-get nil "defines" t))
+ nil)))
+ (when (stringp includes)
+ (setq includes (split-string includes)))
(setq includes (append includes '("<string.h>" "<stdio.h>" "<stdlib.h>")))
+ (when (stringp defines)
+ (let ((y nil)
+ (result (list t)))
+ (dolist (x (split-string defines))
+ (if (null y)
+ (setq y x)
+ (nconc result (list (concat y " " x)))
+ (setq y nil)))
+ (setq defines (cdr result))))
(mapconcat 'identity
(list
;; includes
@@ -225,7 +238,8 @@ it's header arguments."
(main-p (not (string= (cdr (assoc :main params)) "no")))
(imports (or (cdr (assoc :imports params))
(org-babel-read (org-entry-get nil "imports" t)))))
- (unless (listp imports) (setq imports (list imports)))
+ (when (stringp imports)
+ (setq imports (split-string imports)))
(setq imports (append imports '("std.stdio" "std.conv")))
(mapconcat 'identity
(list
--
1.9.1
next prev parent reply other threads:[~2014-09-04 19:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 16:24 Bug: Cannot set header-args :includes with multiple includes [8.2.7 (8.2.7-4-g880362-elpa @ /home/will/.emacs.d/elpa/org-20140616/)] Will Everett
2014-09-02 23:06 ` Bug: Cannot set header-args :includes with multiple includes [8.2.7 (8.2.7-4-g880362-elpa <at> /home/will/.emacs.d/elpa/org-20140616/)] Will Everett
2014-09-03 6:35 ` Thierry Banel
2014-09-04 19:47 ` Thierry Banel [this message]
2014-10-12 12:01 ` Bug: Cannot set header-args :includes with multiple includes [8.2.7 (8.2.7-4-g880362-elpa @ /home/will/.emacs.d/elpa/org-20140616/)] Bastien
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=5408C1E3.2090102@free.fr \
--to=tbanelwebmin@free.fr \
--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).