emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sacha Chua <sacha@sachachua.com>
To: emacs-orgmode@gnu.org
Subject: Re: [babel] Setting python interpreter version on per-block or per-subtree basis
Date: Thu, 24 Apr 2014 21:59:18 -0400	[thread overview]
Message-ID: <86k3ae6ufd.fsf@sachachua.com> (raw)
In-Reply-To: CAKchnZOham41L2jzWbynFk3oQyrWcw6vUGduya2c3x3ZHVJQDw@mail.gmail.com

William Henney <whenney@gmail.com> writes:

Hello, Will!

> Is there an easy way to specify the python version to use for a particular
> block or sub-tree?

Is it something you can define an inherited property or a tag for, and
then add some advice around org-babel-execute:python to check that
property and use let to bind org-babel-python-comand?

Maybe something like this, for example:

#+begin_src emacs-lisp
(defadvice org-babel-execute:python (around will activate)
  (if (member "python2" (org-get-tags-at))
    (let ((org-babel-python-command "/path/to/python2"))
      ad-do-it)
    ad-do-it))
#+end_src
	
* Test :python2:
#+begin_src python
return 1 + 3
#+end_src

Sacha

  reply	other threads:[~2014-04-25  1:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 17:04 [babel] Setting python interpreter version on per-block or per-subtree basis William Henney
2014-04-25  1:59 ` Sacha Chua [this message]
2014-04-25  9:00 ` Ian Barton
2014-04-25 15:27 ` Eric Schulte
2014-04-25 16:29   ` William Henney
2014-04-25 18:04     ` Eric Schulte

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=86k3ae6ufd.fsf@sachachua.com \
    --to=sacha@sachachua.com \
    --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).