* Sagemath with org-babel? @ 2012-08-06 19:31 Johan Ekh 2012-08-06 21:33 ` Thomas S. Dye 0 siblings, 1 reply; 7+ messages in thread From: Johan Ekh @ 2012-08-06 19:31 UTC (permalink / raw) To: emacs-orgmode Hi all, sage is not listed under languages that can be used with org-babel. But it is based on Python, is it possible to use it with org-babel? /Johan Sent from my iPad ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sagemath with org-babel? 2012-08-06 19:31 Sagemath with org-babel? Johan Ekh @ 2012-08-06 21:33 ` Thomas S. Dye 2012-08-06 21:47 ` Darlan Cavalcante Moreira 0 siblings, 1 reply; 7+ messages in thread From: Thomas S. Dye @ 2012-08-06 21:33 UTC (permalink / raw) To: Johan Ekh; +Cc: emacs-orgmode Aloha Johan, Babel can be configured to support new languages, see http://orgmode.org/worg/org-contrib/babel/languages.html#develop Someone will need to write language specific functions to support code block evaluation in sage. There is a template for this. The functions written for other languages provide good examples of what the sage-specific functions might look like. hth, Tom Johan Ekh <ekh.johan@gmail.com> writes: > Hi all, > sage is not listed under languages that can be used with > org-babel. But it is based on > Python, is it possible to use it with org-babel? > > /Johan > > Sent from my iPad > -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sagemath with org-babel? 2012-08-06 21:33 ` Thomas S. Dye @ 2012-08-06 21:47 ` Darlan Cavalcante Moreira 2014-11-04 22:26 ` Brady Trainor 0 siblings, 1 reply; 7+ messages in thread From: Darlan Cavalcante Moreira @ 2012-08-06 21:47 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode I have done this in the past, I don't have the files anymore. However, as Tom says it is very easy to modify the templates to make org work with sage. I remember I only needed some search and replace to make it work. Also, you may want to have a look at sage-mode first if you haven't already. http://wiki.sagemath.org/sage-mode With sage mode installed its is a simple matter to make "C-c '" edit the source code in sage-mode. -- Darlan At Mon, 06 Aug 2012 11:33:47 -1000, tsd@tsdye.com (Thomas S. Dye) wrote: > > Aloha Johan, > > Babel can be configured to support new languages, see > http://orgmode.org/worg/org-contrib/babel/languages.html#develop > > Someone will need to write language specific functions to support code > block evaluation in sage. There is a template for this. The functions > written for other languages provide good examples of what the > sage-specific functions might look like. > > hth, > Tom > > > > Johan Ekh <ekh.johan@gmail.com> writes: > > > Hi all, > > sage is not listed under languages that can be used with > > org-babel. But it is based on > > Python, is it possible to use it with org-babel? > > > > /Johan > > > > Sent from my iPad > > > > -- > Thomas S. Dye > http://www.tsdye.com > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sagemath with org-babel? 2012-08-06 21:47 ` Darlan Cavalcante Moreira @ 2014-11-04 22:26 ` Brady Trainor 2014-11-05 0:36 ` John Hendy 0 siblings, 1 reply; 7+ messages in thread From: Brady Trainor @ 2014-11-04 22:26 UTC (permalink / raw) To: emacs-orgmode Darlan Cavalcante Moreira <darcamo@gmail.com> writes: > I have done this in the past, I don't have the files anymore. However, as > Tom says it is very easy to modify the templates to make org work with > sage. I remember I only needed some search and replace to make it work. > > Also, you may want to have a look at sage-mode first if you haven't > already. > http://wiki.sagemath.org/sage-mode > > With sage mode installed its is a simple matter to make "C-c '" edit the > source code in sage-mode. > I have tried "C-c '", but it did not work. My attempt: As suggested at https://bitbucket.org/gvol/sage-mode/src, I try #+BEGIN_SRC sh sudo sage -f sage_mode #+END_SRC After running this, the end of message includes the suggestion to add #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "/usr/lib/sagemath/local/share/emacs/site-lisp/sage-mode") (require 'sage "sage") (setq sage-command "/usr/lib/sagemath/sage") #+END_SRC But if I try =C-c '= in a block like #+BEGIN_SRC sage f(x) = x^2 integrate(f(x), 1, 3).n() #+END_SRC I get ,---- | org-edit-src-code: No such language mode: sage-mode `---- Also, I cannot publish to html in this way. _I tried copying ob-python.el to a file ob-sage.el and replacing all instances of "python" and "py" with "sage"._ I also tried #+BEGIN_SRC emacs-lisp (add-to-list 'org-src-lang-modes '("sage" . sage)) (org-babel-do-load-languages 'org-babel-load-languages '((sage . t) (emacs-lisp . t) (latex . t) (sh . t))) #+END_SRC But it still tells me "No such language mode: sage-mode". Thoughts? -- Brady > > -- > Darlan > > At Mon, 06 Aug 2012 11:33:47 -1000, > tsd@tsdye.com (Thomas S. Dye) wrote: >> >> Aloha Johan, >> >> Babel can be configured to support new languages, see >> http://orgmode.org/worg/org-contrib/babel/languages.html#develop >> >> Someone will need to write language specific functions to support code >> block evaluation in sage. There is a template for this. The functions >> written for other languages provide good examples of what the >> sage-specific functions might look like. >> >> hth, >> Tom >> >> >> >> Johan Ekh <ekh.johan@gmail.com> writes: >> >> > Hi all, >> > sage is not listed under languages that can be used with >> > org-babel. But it is based on >> > Python, is it possible to use it with org-babel? >> > >> > /Johan >> > >> > Sent from my iPad >> > >> >> -- >> Thomas S. Dye >> http://www.tsdye.com >> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sagemath with org-babel? 2014-11-04 22:26 ` Brady Trainor @ 2014-11-05 0:36 ` John Hendy 2014-11-05 3:05 ` Brady Trainor 0 siblings, 1 reply; 7+ messages in thread From: John Hendy @ 2014-11-05 0:36 UTC (permalink / raw) To: Brady Trainor; +Cc: emacs-orgmode On Tue, Nov 4, 2014 at 4:26 PM, Brady Trainor <algebrat@uw.edu> wrote: > Darlan Cavalcante Moreira <darcamo@gmail.com> writes: > >> I have done this in the past, I don't have the files anymore. However, as >> Tom says it is very easy to modify the templates to make org work with >> sage. I remember I only needed some search and replace to make it work. >> >> Also, you may want to have a look at sage-mode first if you haven't >> already. >> http://wiki.sagemath.org/sage-mode >> >> With sage mode installed its is a simple matter to make "C-c '" edit the >> source code in sage-mode. >> > > I have tried "C-c '", but it did not work. I took a stab at fiddling with this and think sage "works," but not in the true babel sense like you might be expecting. My process: - install sage - $ sudo sage -f sage_mode - added the following to a minimal config: #+begin_src min-config (add-to-list 'load-path "~/.elisp/org.git/lisp/") (add-to-list 'load-path "/opt/sage/local/share/emacs/site-lisp/sage-mode/") (require 'sage "sage") (require 'sage-mode) (setq sage-command "/opt/sage/sage") #+end_src Having never played with sage/sage-mode, I found the "wiki" pretty unsatisfactory. It seemed to just cover installation, but nothing about how to actually use it once installed! On a complete whim, I added =(require 'sage-mode)=, which finally let me do what I was expecting, which was =M-x sage-mode=. With that, I'm able to use this simple file and *sort of* get it to work: #+begin_src test.sage print "Hello World"<point> print 2^3 #+end_src Just using the various M-x sage-* auto completes, I saw =sage-run=, so I used that. It hangs for a bit and then pops up a *Sage-main* buffer but with no results. After going back to the test.sage buffer, I can C-c C-c at <point> and it spits out the results in *Sage-main*. Next, I created a test.org file with the following: #+begin_src test.org * header #+begin_src sage print "Hello World"<point> print 2^3 #+end_src #+end_src =C-c '= on the block gets me to a typical Org babel buffer, and I can =C-c C-c= in it and get results output to *Sage-main*. > My attempt: > > As suggested at https://bitbucket.org/gvol/sage-mode/src, I try > > #+BEGIN_SRC sh > sudo sage -f sage_mode > #+END_SRC > > After running this, the end of message includes the suggestion to add > > #+BEGIN_SRC emacs-lisp > (add-to-list 'load-path "/usr/lib/sagemath/local/share/emacs/site-lisp/sage-mode") > (require 'sage "sage") > (setq sage-command "/usr/lib/sagemath/sage") > #+END_SRC > > But if I try =C-c '= in a block like > > #+BEGIN_SRC sage > f(x) = x^2 > integrate(f(x), 1, 3).n() > #+END_SRC > > I get > > ,---- > | org-edit-src-code: No such language mode: sage-mode > `---- I think the issue is needing =(require 'sage-mode)= in .emacs. I seriously have *no idea* why the docs didn't say anything about this. Perhaps someone else can chime in regarding what one can do with =(require 'sage "sage")= but without loading sage-mode itself? The only additional function I could get was =M-x sage-update-autoloads=. Hope that helps! John > Also, I cannot publish to html in this way. > > _I tried copying ob-python.el to a file ob-sage.el and replacing all instances of "python" and "py" with "sage"._ > > I also tried > > #+BEGIN_SRC emacs-lisp > (add-to-list 'org-src-lang-modes '("sage" . sage)) > (org-babel-do-load-languages 'org-babel-load-languages > '((sage . t) > (emacs-lisp . t) > (latex . t) > (sh . t))) > #+END_SRC > > But it still tells me "No such language mode: sage-mode". > > Thoughts? > > -- > Brady > > >> >> -- >> Darlan >> >> At Mon, 06 Aug 2012 11:33:47 -1000, >> tsd@tsdye.com (Thomas S. Dye) wrote: >>> >>> Aloha Johan, >>> >>> Babel can be configured to support new languages, see >>> http://orgmode.org/worg/org-contrib/babel/languages.html#develop >>> >>> Someone will need to write language specific functions to support code >>> block evaluation in sage. There is a template for this. The functions >>> written for other languages provide good examples of what the >>> sage-specific functions might look like. >>> >>> hth, >>> Tom >>> >>> >>> >>> Johan Ekh <ekh.johan@gmail.com> writes: >>> >>> > Hi all, >>> > sage is not listed under languages that can be used with >>> > org-babel. But it is based on >>> > Python, is it possible to use it with org-babel? >>> > >>> > /Johan >>> > >>> > Sent from my iPad >>> > >>> >>> -- >>> Thomas S. Dye >>> http://www.tsdye.com >>> > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sagemath with org-babel? 2014-11-05 0:36 ` John Hendy @ 2014-11-05 3:05 ` Brady Trainor 2014-11-05 4:58 ` John Hendy 0 siblings, 1 reply; 7+ messages in thread From: Brady Trainor @ 2014-11-05 3:05 UTC (permalink / raw) To: emacs-orgmode John Hendy <jw.hendy@gmail.com> writes: > (require 'sage-mode) Thank you, this enabled me to at least have sage code blocks to mix into files for blog publishing. > #+begin_src test.org > > * header > > #+begin_src sage > print "Hello World"<point> > print 2^3 > #+end_src > > #+end_src > > =C-c '= on the block gets me to a typical Org babel buffer, and I can > =C-c C-c= in it and get results output to *Sage-main*. > I had to modify org-babel-load-languages to get C-c C-c to do something. But I'm not really sure what it did, or how to get it to work. But maybe this could wait till more people are showing interest here. >> (org-babel-do-load-languages 'org-babel-load-languages >> '((sage . t) >> (emacs-lisp . t) >> (latex . t) >> (sh . t))) -- Brady ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sagemath with org-babel? 2014-11-05 3:05 ` Brady Trainor @ 2014-11-05 4:58 ` John Hendy 0 siblings, 0 replies; 7+ messages in thread From: John Hendy @ 2014-11-05 4:58 UTC (permalink / raw) To: Brady Trainor; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1281 bytes --] On Nov 4, 2014 9:06 PM, "Brady Trainor" <algebrat@uw.edu> wrote: > > John Hendy <jw.hendy@gmail.com> writes: > > > (require 'sage-mode) > > Thank you, this enabled me to at least have sage code blocks to mix into files for blog publishing. > > > #+begin_src test.org > > > > * header > > > > #+begin_src sage > > print "Hello World"<point> > > print 2^3 > > #+end_src > > > > #+end_src > > > > =C-c '= on the block gets me to a typical Org babel buffer, and I can > > =C-c C-c= in it and get results output to *Sage-main*. > > > > I had to modify org-babel-load-languages to get C-c C-c to do something. But I'm not really sure what it did, or how to get it to work. But maybe this could wait till more people are showing interest here. > Oops. Re-reading, that came out ambiguously. I meant from the interactive code editing buffer after C-c ', from *there* I could do C-c C-c. From the org file itself, my result was the same as yours with no babel definition for sage. Sorry about the confusion! John > >> (org-babel-do-load-languages 'org-babel-load-languages > >> '((sage . t) > >> (emacs-lisp . t) > >> (latex . t) > >> (sh . t))) > > -- > Brady > > [-- Attachment #2: Type: text/html, Size: 1945 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-11-05 4:58 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-08-06 19:31 Sagemath with org-babel? Johan Ekh 2012-08-06 21:33 ` Thomas S. Dye 2012-08-06 21:47 ` Darlan Cavalcante Moreira 2014-11-04 22:26 ` Brady Trainor 2014-11-05 0:36 ` John Hendy 2014-11-05 3:05 ` Brady Trainor 2014-11-05 4:58 ` John Hendy
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).