From 1e5fff1741dc853214962b7ea90b0832b4ae3e69 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Sun, 16 Jul 2017 21:55:24 -0700 Subject: [PATCH] ob-C.el: Add support for specifying namespaces in C/C++ * lisp/ob-C.el (org-babel-C-expand-C): Add a :namespaces export option to C++ org babel blocks. Namespaces specified here will be added to the file in the format 'using namespace %s;'. Multiple namespaces can be specified, separated by spaces. TINYCHANGE --- lisp/ob-C.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index 2bdda68d5..ba10833d0 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -202,9 +202,15 @@ its header arguments." (defines (org-babel-read (or (cdr (assq :defines params)) (org-entry-get nil "defines" t)) - nil))) + nil)) + (namespaces (org-babel-read + (or (cdr (assq :namespaces params)) + (org-entry-get nil "namespaces" t)) + nil))) (when (stringp includes) (setq includes (split-string includes))) + (when (stringp namespaces) + (setq namespaces (split-string namespaces))) (when (stringp defines) (let ((y nil) (result (list t))) @@ -224,6 +230,10 @@ its header arguments." (mapconcat (lambda (inc) (format "#define %s" inc)) (if (listp defines) defines (list defines)) "\n") + ;; namespaces + (mapconcat + (lambda (inc) (format "using namespace %s;" inc)) + namespaces "\n") ;; variables (mapconcat 'org-babel-C-var-to-C vars "\n") ;; table sizes -- 2.11.0