From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Jay Kamat <jaygkamat@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Support for 'using namespace *' in ob-C.el
Date: Sun, 23 Jul 2017 16:44:08 +0200 [thread overview]
Message-ID: <874lu3mcw7.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CACe_Yv_hoDqrM9VMGQihCPgJBO4qw2Kmr=RZ0AkJerSwWD1Ouw@mail.gmail.com> (Jay Kamat's message of "Sun, 16 Jul 2017 22:31:01 -0700")
Hello,
Jay Kamat <jaygkamat@gmail.com> writes:
> However, it would be nice to add a "using namespace std" to this
> source code block, so it can become:
>
> #+BEGIN_SRC C++ :includes <iostream> :namespaces std
> cout << "Hello world\n";
> #+END_SRC
>
>
> Which makes it cleaner and easier to read, especially for very short
> code snippets, using a bunch of std tools.
Good idea.
> One concern that I have is that "using namespace *;" is only available
> in C++ and not C, but there isn't an easy way I could find to limit
> it's usage to only C++ blocks without a bunch of restructuring, so
> this will fail if you attempt to set a namespace on a plain C block.
I suggest to add the following to "ob-C.el" so that `org-lint' can issue
a warning whenever :namespaces is used in a C block.
(defconst org-babel-header-args:C '((includes . :any))
"C-specific header arguments.")
(defconst org-babel-header-args:C++
`(,(append '((namespaces . :any))
org-babel-header-args:C))
"C++-specific header arguments.")
> Also, this contribution puts me very close to the 15 line limit before
> I need to get FSF papers signed. I intend to sign papers soon, but I'm
> a little busy right now, and I'll get around to submitting the request
> later on.
Thank you. FYI, in many cases, the whole process is very quick and not
time-consuming.
> 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.
Some comments follow.
> + (namespaces (org-babel-read
> + (or (cdr (assq :namespaces params))
> + (org-entry-get nil "namespaces" t))
> + nil)))
Using `org-entry-get' is no longer supported. You can replace the `or'
with
(cdr (assq :namespaces params))
> + ;; namespaces
> + (mapconcat
> + (lambda (inc) (format "using namespace %s;" inc))
> + namespaces "\n")
Nitpick: I would put the "\n" on another line.
Could you also provide an ORG-NEWS entry for the feature?
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2017-07-23 20:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 5:31 [PATCH] Support for 'using namespace *' in ob-C.el Jay Kamat
2017-07-23 14:44 ` Nicolas Goaziou [this message]
2017-07-31 8:03 ` Jay Kamat
2017-07-31 15:34 ` Charles C. Berry
2017-08-01 5:54 ` Jay Kamat
2017-08-01 16:48 ` Nicolas Goaziou
2017-08-01 16:48 ` Nicolas Goaziou
2017-08-02 1:40 ` Jay Kamat
2017-08-02 6:49 ` Nicolas Goaziou
2017-08-01 8:22 ` Nicolas Goaziou
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874lu3mcw7.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=jaygkamat@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.