Ask Your Question
1

attempt at ob-sage.el for org-mode (emacs)

asked 2013-03-19 23:51:31 +0100

sabbatini.luca gravatar image

updated 2015-01-13 22:19:33 +0100

FrédéricC gravatar image

I am a big fan of Sage and of emacs' org-mode. I use org-mode to outline lectures for my students and often need to include evaluatable code inside my org-mode's BEGIN_SRC/END_SRC environment blocks. No problem, I already do this with some languages, such as python and sh, but I'd really like to do it with Sage. Unfortunately, there is no support yet for Sage, i.e. there's no ob-sage.el file.

So I tried making my own ob-sage.el file with some success. I did this by copying the ob-python.el file that came with my emacs installation, renaming it ob-sage.el, and then just doing a query-replace inside, converting every instance of "python" or "py" or "python-mode" into an instance of "sage" or "sage-mode". This works to an extent, but I am not able to get persistent sessions to work. Has anybody attempted this yet? Would anyone like to share their progress?

I would like to upload the ob-sage.el file I have, but I think it is generally regarded as bad netiquette to upload 300 lines of code to a post on a forum like this. What would be the appropriate/best way to share my ob-sage.el file here on asksage?

edit retag flag offensive close merge delete

Comments

Put it on pastebin. And make sure before submitting on pastebin, the paste expiration is set to "never", so that if someone looks up this question a year later they can still access the code. If you create an account on pastebin, then you can later edit and update the code also later. The other option is to open a github/bitbucket/googlecode account and put your file in github/bitbucket/googlecode. That way every time you update the code, it will be available and also the changes that are effected will be visible to everyone. By the way, I hope you are aware of [sage-mode](http://wiki.sagemath.org/sage-mode). I don't use emacs so I can not say if it is relevant to what you are doing.

ppurka gravatar imageppurka ( 2013-03-20 01:08:31 +0100 )edit

A third option is to get a Sage Trac account (see instructions at http://trac.sagemath.org/sage_trac/) and open a ticket there and put the code in a file attached there. I've emailed the maintainer of sage-mode to see if he has any comments.

kcrisman gravatar imagekcrisman ( 2013-03-20 09:59:43 +0100 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2013-03-20 11:49:53 +0100

Ivan Andrus gravatar image

updated 2013-03-20 11:50:50 +0100

I don't know of any attempts to add an ob-sage.el. I maintain sage-mode and use org, but I use LaTeX to write papers so I haven't had a need (yet) for ob-sage. Coincidentally, there is a currently thread on the org list that talks about people having problems with persistent sessions with ob-python. There are three different python modes so it's not surprising that it doesn't work with all of them. You may wish to follow that thread and see if any fixes there resolve your problem.

I already have code in sage-mode to allow sage to work when exporting via latex, so I wouldn't mind adding ob-sage.el. I would suggest opening a ticket on bitbucket. Also, you can fork and open a pull request. If possible I would prefer to "hook into" ob-python rather than copy/paste/modify it, but such a thing may not be possible (or even desirable), I haven't looked. That way it will hopefully take advantage of improvements to ob-python. I think all that should need to change is the executable.

Or maybe a patch to ob-python to allow it to dynamically switch to Sage would be best. I don't know if such a change would be welcome in org, though I suspect it would. I have papers on file with the FSF so I can make such a change if desired.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-03-19 23:51:31 +0100

Seen: 929 times

Last updated: Mar 20 '13