ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 20 Mar 2013 05:49:53 -0500attempt at ob-sage.el for org-mode (emacs)http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/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](http://ask.sagemath.org)?Tue, 19 Mar 2013 17:51:31 -0500http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/Comment by ppurka for <p>I am a big fan of <code>Sage</code> and of <code>emacs</code>' <code>org-mode</code>. I use <code>org-mode</code> to outline lectures for my students and often need to include evaluatable code inside my <code>org-mode</code>'s <code>BEGIN_SRC</code>/<code>END_SRC</code> environment blocks. No problem, I already do this with some languages, such as <code>python</code> and <code>sh</code>, but I'd really like to do it with <code>Sage</code>. Unfortunately, there is no support yet for <code>Sage</code>, i.e. there's no <code>ob-sage.el</code> file.</p>
<p>So I tried making my own <code>ob-sage.el</code> file with some success. I did this by copying the <code>ob-python.el</code> file that came with my emacs installation, renaming it <code>ob-sage.el</code>, and then just doing a <code>query-replace</code> 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?</p>
<p>I would like to upload the <code>ob-sage.el</code> 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 <code>ob-sage.el</code> file here on <a href="http://ask.sagemath.org">asksage</a>?</p>
http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/?comment=18045#post-id-18045Put 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.Tue, 19 Mar 2013 19:08:31 -0500http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/?comment=18045#post-id-18045Comment by kcrisman for <p>I am a big fan of <code>Sage</code> and of <code>emacs</code>' <code>org-mode</code>. I use <code>org-mode</code> to outline lectures for my students and often need to include evaluatable code inside my <code>org-mode</code>'s <code>BEGIN_SRC</code>/<code>END_SRC</code> environment blocks. No problem, I already do this with some languages, such as <code>python</code> and <code>sh</code>, but I'd really like to do it with <code>Sage</code>. Unfortunately, there is no support yet for <code>Sage</code>, i.e. there's no <code>ob-sage.el</code> file.</p>
<p>So I tried making my own <code>ob-sage.el</code> file with some success. I did this by copying the <code>ob-python.el</code> file that came with my emacs installation, renaming it <code>ob-sage.el</code>, and then just doing a <code>query-replace</code> 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?</p>
<p>I would like to upload the <code>ob-sage.el</code> 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 <code>ob-sage.el</code> file here on <a href="http://ask.sagemath.org">asksage</a>?</p>
http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/?comment=18042#post-id-18042A 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.Wed, 20 Mar 2013 03:59:43 -0500http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/?comment=18042#post-id-18042Answer by Ivan Andrus for <p>I am a big fan of <code>Sage</code> and of <code>emacs</code>' <code>org-mode</code>. I use <code>org-mode</code> to outline lectures for my students and often need to include evaluatable code inside my <code>org-mode</code>'s <code>BEGIN_SRC</code>/<code>END_SRC</code> environment blocks. No problem, I already do this with some languages, such as <code>python</code> and <code>sh</code>, but I'd really like to do it with <code>Sage</code>. Unfortunately, there is no support yet for <code>Sage</code>, i.e. there's no <code>ob-sage.el</code> file.</p>
<p>So I tried making my own <code>ob-sage.el</code> file with some success. I did this by copying the <code>ob-python.el</code> file that came with my emacs installation, renaming it <code>ob-sage.el</code>, and then just doing a <code>query-replace</code> 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?</p>
<p>I would like to upload the <code>ob-sage.el</code> 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 <code>ob-sage.el</code> file here on <a href="http://ask.sagemath.org">asksage</a>?</p>
http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/?answer=14669#post-id-14669I 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](http://thread.gmane.org/gmane.emacs.orgmode/68748) 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](https://bitbucket.org/gvol/sage-mode/issues). 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.Wed, 20 Mar 2013 05:49:53 -0500http://ask.sagemath.org/question/9927/attempt-at-ob-sageel-for-org-mode-emacs/?answer=14669#post-id-14669