Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr-ressources
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
9b01737421a268a54ae68902c9bdbf26
mooc-rr-ressources
Commits
1635efcd
Commit
1635efcd
authored
Apr 08, 2019
by
Konrad Hinsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init.el pleinement compatible avec orgmode 9.2
parent
cff12ba6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
66 deletions
+94
-66
init.el
module2/ressources/rr_org/init.el
+46
-33
init.org
module2/ressources/rr_org/init.org
+48
-33
No files found.
module2/ressources/rr_org/init.el
View file @
1635efcd
...
...
@@ -227,51 +227,64 @@ Entered on %U
))
(
setq
org-src-preserve-indentation
t
)
(
require
'org-tempo
nil
t
)
(
setq
rrmooc/new-org-templates
(
version<=
"9.2"
(
org-version
)))
(
when
rrmooc/new-org-templates
(
require
'org-tempo
))
(
add-to-list
'org-structure-template-alist
'
(
"s"
"#+begin_src ?\n\n#+end_src"
"<src lang=\"?\">\n\n</src>"
))
(
require
'subr-x
)
(
defun
rrmooc/add-org-template
(
old-style-template
)
(
add-to-list
'org-structure-template-alist
(
if
rrmooc/new-org-templates
(
cons
(
first
old-style-template
)
(
string-trim-right
(
substring
(
second
old-style-template
)
8
-9
)))
old-style-template
)))
(
unless
rrmooc/new-org-templates
;; this template is predefined in the new templating system
(
rrmooc/add-org-template
'
(
"s"
"#+begin_src ?\n\n#+end_src"
"<src lang=\"?\">\n\n</src>"
)))
(
add-to-list
'org-structure-template-alist
'
(
"m"
"#+begin_src emacs-lisp :tangle init.el
\n\n#+end_src"
"<src lang=\"emacs-lisp\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"m"
"#+begin_src emacs-lisp
\n\n#+end_src"
"<src lang=\"emacs-lisp\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"r"
"#+begin_src R :results output :session *R* :exports both\n\n#+end_src"
"<src lang=\"R\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"r"
"#+begin_src R :results output :session *R* :exports both\n\n#+end_src"
"<src lang=\"R\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"R"
"#+begin_src R :results output graphics :file (org-babel-temp-file \"figure\" \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src"
"<src lang=\"R\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"R"
"#+begin_src R :results output graphics :file (org-babel-temp-file \"figure\" \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src"
"<src lang=\"R\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"RR"
"#+begin_src R :results output graphics :file (org-babel-temp-file (concat (file-name-directory (or load-file-name buffer-file-name)) \"figure-\") \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src"
"<src lang=\"R\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"RR"
"#+begin_src R :results output graphics :file (org-babel-temp-file (concat (file-name-directory (or load-file-name buffer-file-name)) \"figure-\") \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src"
"<src lang=\"R\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"p"
"#+begin_src python :results output :exports both\n\n#+end_src"
"<src lang=\"python\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"p"
"#+begin_src python :results output :exports both\n\n#+end_src"
"<src lang=\"python\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"P"
"#+begin_src python :results output :session :exports both\n\n#+end_src"
"<src lang=\"python\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"P"
"#+begin_src python :results output :session :exports both\n\n#+end_src"
"<src lang=\"python\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"PP"
"#+begin_src python :results 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)\nmatplot_lib_filename\n#+end_src"
"<src lang=\"python\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"PP"
"#+begin_src python :results 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)\nmatplot_lib_filename\n#+end_src"
"<src lang=\"python\">\n\n</src>"
))
(
if
(
memq
system-type
'
(
windows-nt
ms-dos
))
;; Non-session shell execution does not seem to work under Windows, so we use
;; a named session just like for B.
(
add-to-list
'org-structure-template-alist
'
(
"b"
"#+begin_src shell :session session :results output :exports both\n\n#+end_src"
"<src lang=\"sh\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"b"
"#+begin_src shell :results output :exports both\n\n#+end_src"
"<src lang=\"sh\">\n\n</src>"
)))
(
add-to-list
'org-structure-template-alist
'
(
"B"
"#+begin_src shell :session *shell* :results output :exports both \n\n#+end_src"
"<src lang=\"sh\">\n\n</src>"
))
(
add-to-list
'org-structure-template-alist
'
(
"g"
"#+begin_src dot :results output graphics :file \"/tmp/graph.pdf\" :exports both
digraph G {
node [color=black,fillcolor=white,shape=rectangle,style=filled,fontname=\"Helvetica\"];
A[label=\"A\"]
B[label=\"B\"]
A->B
}\n#+end_src"
"<src lang=\"dot\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"b"
"#+begin_src shell :session session :results output :exports both\n\n#+end_src"
"<src lang=\"sh\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"b"
"#+begin_src shell :results output :exports both\n\n#+end_src"
"<src lang=\"sh\">\n\n</src>"
)))
(
rrmooc/add-org-template
'
(
"B"
"#+begin_src shell :session *shell* :results output :exports both \n\n#+end_src"
"<src lang=\"sh\">\n\n</src>"
))
(
rrmooc/add-org-template
'
(
"g"
"#+begin_src dot :results output graphics :file \"/tmp/graph.pdf\" :exports both
digraph G {
node [color=black,fillcolor=white,shape=rectangle,style=filled,fontname=\"Helvetica\"];
A[label=\"A\"]
B[label=\"B\"]
A->B
}\n#+end_src"
"<src lang=\"dot\">\n\n</src>"
))
(
global-set-key
(
kbd
"C-c S-t"
)
'org-babel-execute-subtree
)
...
...
module2/ressources/rr_org/init.org
View file @
1635efcd
...
...
@@ -83,7 +83,7 @@ document, simply =M-x org-babel-tangle=.
("melpa-stable" . 10)))
#+END_SRC
* Install missing packages
#+begin_src emacs-lisp
#+begin_src emacs-lisp
:tangle init.el
(dolist (pkg '(ess
auctex
htmlize
...
...
@@ -92,7 +92,7 @@ document, simply =M-x org-babel-tangle=.
(package-install pkg)))
#+end_src
* Import environment variables
#+begin_src emacs-lisp
#+begin_src emacs-lisp
:tangle init.el
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-env "PYTHONPATH")
#+end_src
...
...
@@ -366,57 +366,72 @@ Additional shortcuts for navigating through org-mode documents:
** Adding source code blocks: :LUKA:
*** Enable the old template system with Orgmode 9.2 and later
#+begin_src emacs-lisp :tangle init.el
(require 'org-tempo nil t)
(setq rrmooc/new-org-templates (version<= "9.2" (org-version)))
(when rrmooc/new-org-templates
(require 'org-tempo))
#+end_src
*** Template definitions that work with the old and new templating systems
#+begin_src emacs-lisp :tangle init.el
(require 'subr-x)
(defun rrmooc/add-org-template (old-style-template)
(add-to-list 'org-structure-template-alist
(if rrmooc/new-org-templates
(cons
(first old-style-template)
(string-trim-right (substring (second old-style-template) 8 -9)))
old-style-template)))
#+end_src
*** With capital letters:
To use this type <s and then TAB
#+begin_src emacs-lisp :tangle init.el
(add-to-list 'org-structure-template-alist
'("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>"))
(unless rrmooc/new-org-templates
;; this template is predefined in the new templating system
(rrmooc/add-org-template
'("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")))
#+end_src
*** Emacs-elisp code:
To use this type <m and then TAB
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("m" "#+begin_src emacs-lisp :tangle init.el
\n\n#+end_src" "<src lang=\"emacs-lisp\">\n\n</src>"))
(
rrmooc/add-org-template
'("m" "#+begin_src emacs-lisp
\n\n#+end_src" "<src lang=\"emacs-lisp\">\n\n</src>"))
#+end_src
*** R code:
To use this type <r and then TAB. This creates an R block for textual output.
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("r" "#+begin_src R :results output :session *R* :exports both\n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
(
rrmooc/add-org-template
'("r" "#+begin_src R :results output :session *R* :exports both\n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
#+end_src
To use this type <R and then TAB. This creates an R block for graphics
that are stored in the =/tmp/=.
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("R" "#+begin_src R :results output graphics :file (org-babel-temp-file \"figure\" \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
(
rrmooc/add-org-template
'("R" "#+begin_src R :results output graphics :file (org-babel-temp-file \"figure\" \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
#+end_src
To use this type <RR and then TAB. This creates an R block for
graphics that are stored in the directory of the current file.
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("RR" "#+begin_src R :results output graphics :file (org-babel-temp-file (concat (file-name-directory (or load-file-name buffer-file-name)) \"figure-\") \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
(
rrmooc/add-org-template
'("RR" "#+begin_src R :results output graphics :file (org-babel-temp-file (concat (file-name-directory (or load-file-name buffer-file-name)) \"figure-\") \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
#+end_src
*** Python code
To use this type <p and then TAB
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("p" "#+begin_src python :results output :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
(
rrmooc/add-org-template
'("p" "#+begin_src python :results output :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
#+end_src
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("P" "#+begin_src python :results output :session :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
(
rrmooc/add-org-template
'("P" "#+begin_src python :results output :session :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
#+end_src
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("PP" "#+begin_src python :results 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)\nmatplot_lib_filename\n#+end_src" "<src lang=\"python\">\n\n</src>"))
(
rrmooc/add-org-template
'("PP" "#+begin_src python :results 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)\nmatplot_lib_filename\n#+end_src" "<src lang=\"python\">\n\n</src>"))
#+end_src
*** Bash "sh" code:
To use this type <b and then TAB
...
...
@@ -424,28 +439,28 @@ To use this type <b and then TAB
(if (memq system-type '(windows-nt ms-dos))
;; Non-session shell execution does not seem to work under Windows, so we use
;; a named session just like for B.
(
add-to-list 'org-structure-template-alist
'("b" "#+begin_src shell :session session :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
(
add-to-list 'org-structure-template-alist
'("b" "#+begin_src shell :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>")))
(
rrmooc/add-org-template
'("b" "#+begin_src shell :session session :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
(
rrmooc/add-org-template
'("b" "#+begin_src shell :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>")))
#+end_src
To use this type <B and then TAB. This comes with a session argument
(e.g., in case you want to keep ssh connexions open).
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("B" "#+begin_src shell :session *shell* :results output :exports both \n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
(
rrmooc/add-org-template
'("B" "#+begin_src shell :session *shell* :results output :exports both \n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
#+end_src
*** Graphviz
#+begin_src emacs-lisp :tangle init.el
(
add-to-list 'org-structure-template-alist
'("g" "#+begin_src dot :results output graphics :file \"/tmp/graph.pdf\" :exports both
digraph G {
node [color=black,fillcolor=white,shape=rectangle,style=filled,fontname=\"Helvetica\"];
A[label=\"A\"]
B[label=\"B\"]
A->B
}\n#+end_src" "<src lang=\"dot\">\n\n</src>"))
(
rrmooc/add-org-template
'("g" "#+begin_src dot :results output graphics :file \"/tmp/graph.pdf\" :exports both
digraph G {
node [color=black,fillcolor=white,shape=rectangle,style=filled,fontname=\"Helvetica\"];
A[label=\"A\"]
B[label=\"B\"]
A->B
}\n#+end_src" "<src lang=\"dot\">\n\n</src>"))
#+end_src
** Evaluating whole subtree: :LUKA:
#+begin_src emacs-lisp :tangle init.el
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment