emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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/)]
@ 2014-08-26 16:24 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-04 19:47 ` 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/)] Thierry Banel
  0 siblings, 2 replies; 5+ messages in thread
From: Will Everett @ 2014-08-26 16:24 UTC (permalink / raw)
  To: emacs-orgmode

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

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------

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>

Then, of course printf and cout are undeclared. It looks like the include
is just throwing all the includes onto one line when they should be broken
up and each put on their own line.


Emacs  : GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.12.2)
 of 2014-06-06 on barber, modified by Debian
Package: Org-mode version 8.2.7 (8.2.7-4-g880362-elpa @
/home/will/.emacs.d/elpa/org-20140616/)

current state:
==============
(setq
 org-tab-first-hook '(org-hide-block-toggle-maybe
org-src-native-tab-command-maybe org-babel-hide-result-toggle-maybe
                      org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook
org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-html-format-drawer-function '(lambda (name contents) contents)
 org-log-done t
 org-latex-format-inlinetask-function 'ignore
 org-confirm-shell-link-function 'yes-or-no-p
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-latex-format-headline-function
'org-latex-format-headline-default-function
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-format-drawer-function '(lambda (name contents) contents)
 org-from-is-user-regexp "\\<William Everett\\>"
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(org-journal-update-auto-mode-alist
                 #[nil "\300\301\302\303\304$\207" [org-add-hook
change-major-mode-hook org-show-block-all append local] 5]
                 #[nil "\300\301\302\303\304$\207" [org-add-hook
change-major-mode-hook org-babel-show-result-all append local]
                   5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-ascii-format-drawer-function '(lambda (name contents width) contents)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point
org-babel-execute-safely-maybe)
 org-enforce-todo-dependencies t
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
org-cycle-hide-inline-tasks org-cycle-show-empty-lines
                  org-optimize-window-after-visibility-change)
 org-journal-dir "~/Journal/"
 org-archive-location "~/projects/Archived/%s_archive::"
 org-use-property-inheritance t
 org-deadline-warning-days 3
 org-babel-tangle-lang-exts '(("latex" . "tex") ("python" . "py") ("C++" .
"cpp") ("awk" . "awk") ("emacs-lisp" . "el"))
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-log-into-drawer t
 org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
 org-html-format-headline-function 'ignore
 org-babel-load-languages '((awk . t) (C . t) (sh . t) (python . t) (latex
. t) (makefile \.t))
 org-src-preserve-indentation t
 org-html-format-inlinetask-function 'ignore
 org-agenda-files '("/home/will/projects/local" "/home/will/projects")
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-confirm-babel-evaluate nil
 )

[-- Attachment #2: Type: text/html, Size: 5198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 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/)]
  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 ` Will Everett
  2014-09-03  6:35   ` Thierry Banel
  2014-09-04 19:47 ` 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/)] Thierry Banel
  1 sibling, 1 reply; 5+ messages in thread
From: Will Everett @ 2014-09-02 23:06 UTC (permalink / raw)
  To: emacs-orgmode

Will Everett <will <at> spings.net> writes:
> 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>
> 
> Then, of course printf and cout are undeclared. It looks like the include
is just throwing all the includes onto one line when they should be broken
up and each put on their own line.


Sorry to be a pest, but did anyone see this? Does no one else try to use
org-babel for LP with C/C++?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 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/)]
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Banel @ 2014-09-03  6:35 UTC (permalink / raw)
  To: emacs-orgmode

Yes Will, there is a bug.
I will look at it.
In the meantime, as a workaround, you may move includes from header to body:

#+BEGIN_SRC C++
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
  printf("Hello ");
  cout << "world";
}
#+END_SRC


Thanks for reporting
Thierry



Le 03/09/2014 01:06, Will Everett a écrit :
> Will Everett <will <at> spings.net> writes:
>> 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>
>>
>> Then, of course printf and cout are undeclared. It looks like the include
> is just throwing all the includes onto one line when they should be broken
> up and each put on their own line.
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 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/)]
  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-04 19:47 ` Thierry Banel
  2014-10-12 12:01   ` Bastien
  1 sibling, 1 reply; 5+ messages in thread
From: Thierry Banel @ 2014-09-04 19:47 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* 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/)]
  2014-09-04 19:47 ` 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/)] Thierry Banel
@ 2014-10-12 12:01   ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2014-10-12 12:01 UTC (permalink / raw)
  To: Thierry Banel; +Cc: emacs-orgmode

Hi Thierry,

Thierry Banel <tbanelwebmin@free.fr> writes:

> Here is a patch to fix the issue.

Applied, thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-12 12:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` 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/)] Thierry Banel
2014-10-12 12:01   ` Bastien

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).