From 61d321944b5699ba9c1ae473271eb3aa214ca23a Mon Sep 17 00:00:00 2001 From: Arnaud Legrand Date: Tue, 24 Jul 2018 18:36:44 +0200 Subject: [PATCH] Use python3 by default and fix babel chunks --- module2/ressources/rr_org/init.el | 6 ++++-- module2/ressources/rr_org/init.org | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/module2/ressources/rr_org/init.el b/module2/ressources/rr_org/init.el index de9ecce..3147926 100644 --- a/module2/ressources/rr_org/init.el +++ b/module2/ressources/rr_org/init.el @@ -155,6 +155,8 @@ Entered on %U )) (setq org-src-preserve-indentation t) +(setq org-babel-python-command "python3") + (add-to-list 'org-structure-template-alist '("s" "#+begin_src ?\n\n#+end_src" "\n\n")) @@ -174,10 +176,10 @@ Entered on %U '("p" "#+begin_src python :results output :exports both\n\n#+end_src" "\n\n")) (add-to-list 'org-structure-template-alist - '("P" "#+begin_src python :results output :session *python* :exports both\n\n#+end_src" "\n\n")) + '("P" "#+begin_src python :results output :session :exports both\n\n#+end_src" "\n\n")) (add-to-list 'org-structure-template-alist - '("PP" "#+begin_src python :results file :var matplot_lib_filename=(org-babel-temp-file \"figure\" \".png\") :exports both \nimport matplotlib.pyplot as plt\n\nimport numpy\nx=numpy.linspace(-15,15)\nplt.figure(figsize=(10,5))\nplt.plot(x,numpy.cos(x)/x)\nplt.tight_layout()\n\nplt.savefig(matplot_lib_filename)\nreturn(matplot_lib_filename)\n#+end_src" "\n\n")) + '("PP" "#+begin_src python :results output file :session :var matplot_lib_filename=(org-babel-temp-file \"figure\" \".png\") :exports both\nimport matplotlib.pyplot as plt\n\nimport numpy\nx=numpy.linspace(-15,15)\nplt.figure(figsize=(10,5))\nplt.plot(x,numpy.cos(x)/x)\nplt.tight_layout()\n\nplt.savefig(matplot_lib_filename)\nprint(matplot_lib_filename)\n#+end_src" "\n\n")) (add-to-list 'org-structure-template-alist '("b" "#+begin_src shell :results output :exports both\n\n#+end_src" "\n\n")) diff --git a/module2/ressources/rr_org/init.org b/module2/ressources/rr_org/init.org index e1877be..a872554 100644 --- a/module2/ressources/rr_org/init.org +++ b/module2/ressources/rr_org/init.org @@ -281,6 +281,11 @@ Additional shortcuts for navigating through org-mode documents: (setq org-src-preserve-indentation t) #+end_src +** Python +*** We use python3 +#+begin_src emacs-lisp :tangle init.el +(setq org-babel-python-command "python3") +#+end_src ** Adding source code blocks: :LUKA: *** With capital letters: To use this type \n\n")) + '("P" "#+begin_src python :results output :session :exports both\n\n#+end_src" "\n\n")) #+end_src #+begin_src emacs-lisp :tangle init.el (add-to-list 'org-structure-template-alist - '("PP" "#+begin_src python :results file :var matplot_lib_filename=(org-babel-temp-file \"figure\" \".png\") :exports both \nimport matplotlib.pyplot as plt\n\nimport numpy\nx=numpy.linspace(-15,15)\nplt.figure(figsize=(10,5))\nplt.plot(x,numpy.cos(x)/x)\nplt.tight_layout()\n\nplt.savefig(matplot_lib_filename)\nreturn(matplot_lib_filename)\n#+end_src" "\n\n")) + '("PP" "#+begin_src python :results output file :session :var matplot_lib_filename=(org-babel-temp-file \"figure\" \".png\") :exports both\nimport matplotlib.pyplot as plt\n\nimport numpy\nx=numpy.linspace(-15,15)\nplt.figure(figsize=(10,5))\nplt.plot(x,numpy.cos(x)/x)\nplt.tight_layout()\n\nplt.savefig(matplot_lib_filename)\nprint(matplot_lib_filename)\n#+end_src" "\n\n")) #+end_src *** Bash "sh" code: To use this type