emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ista Zahn <istazahn@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: interesting dilemma with ob-ipython
Date: Tue, 28 Jun 2016 22:25:02 -0400	[thread overview]
Message-ID: <CA+vqiLGqQCGTehEbK0OBBda-OS24YWn638uXH=_vZtQWRJBKiQ@mail.gmail.com> (raw)
In-Reply-To: <m2h9d1qg6o.fsf@Johns-MacBook-Air.local>

On Fri, Jun 10, 2016 at 10:19 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Thanks for this tip. It was a great start! I turned it into this:
>
> #+BEGIN_SRC emacs-lisp
> ;; make src blocks open in the right mode
> (add-to-list 'org-src-lang-modes '("jupyter-hy" . hy))
> (add-to-list 'org-latex-minted-langs '(jupyter-hy  "hylang"))
>
> ;; set default headers for convenience
> (setq org-babel-default-header-args:jupyter-hy
>       '((:results . "output replace")
>         (:session . "hy")
>         (:kernel . "hy")
>         (:exports . "code")
>         (:cache .   "no")
>         (:noweb . "no")
>         (:hlines . "no")
>         (:tangle . "no")))
>
> (defalias 'org-babel-execute:jupyter-hy 'org-babel-execute:ipython)
>
> (add-to-list 'org-structure-template-alist
>              '("hy" "#+BEGIN_SRC jupyter-hy\n?\n#+END_SRC"
>                "<src lang=\"hy\">\n?\n</src>"))
> #+END_SRC
>
> Which solves all the problems!
> 1. src-blocks open in hy-mode and export as hylang in minted.
> 2. <hy expands nicely to the jupyter block with default settings.
> 3. C-c C-c runs the block using the hy jupyter kernel.

I worked up some code to do this for all installed jupyter kernels.
It's kind of rough (my elisp is not so good) by I submitted it as a
pull request at https://github.com/gregsexton/ob-ipython/pull/74. I
would appreciate any feedback or suggestions for improvement.

--Ista

>
> Fantastic. Thanks!
>
>
> Anthony Cowley writes:
>
>> John Kitchin writes:
>>
>>> I was looking into ob-ipython as a replacement for regular
>>> org-babel-python because it seems to be better at sessions. Also, you
>>> can use other kernels with it!
>>>
>>> For example:
>>>
>>> #+BEGIN_SRC ipython :session hy :results output :kernel hy
>>> (print "hello world")
>>> (import time)
>>> (print (time.asctime))
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : hello world
>>> : Thu Jun  9 17:26:56 2016
>>>
>>> Here is the dilemma:
>>> If I special edit this, it is in python-mode, not hy-mode. And similarly
>>> on export, it is highlighted as ipython, not hy-lang.
>>>
>>> Any thoughts on how to address these?
>>
>> I've had success using something like this,
>>
>> (add-to-list 'org-src-lang-modes '("ipython" . haskell))
>>
>> in a :noexport: setup section.
>>
>> Anthony
>
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>

      reply	other threads:[~2016-06-29  2:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 21:33 interesting dilemma with ob-ipython John Kitchin
2016-06-09 21:42 ` Ken Mankoff
2016-06-09 21:47 ` Anthony Cowley
2016-06-10 14:19   ` John Kitchin
2016-06-29  2:25     ` Ista Zahn [this message]

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='CA+vqiLGqQCGTehEbK0OBBda-OS24YWn638uXH=_vZtQWRJBKiQ@mail.gmail.com' \
    --to=istazahn@gmail.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).