This document assumes you have installed emacs as explained here. All the screenshots in this demo are done under the Windows operating system but similar results should be obtained on any OS.
Launch emacs
Create a new file using the "white sheet of paper" left icon, right below the File
menu. Name it foo.org
in which ever directory you want.
You now have a blank org-mode file.
Type <b
and press the tab
key to expend it as the beginning of a shell block. You can then type whichever command you want (e.g., dir
under windows or ls
under linux or Mac). By typing C-c C-c
(this means typing twice Ctrl
c
), your shell command should be executed and the output should but put right below.
Whenever you feel emacs has entered a weird state and you want to exit from this mode, press C-g
(again, this reads as Ctrl
g
) several times.
Similarly to the abovementionned <b
shortcut, the shortcut <r
+ tab
will allow you to create a block for running R commands (e.g., summary(cars)
). Likewise, the code will be executed by typing C-c
C-c
(typing twice Ctrl
c
)
At this point, Emacs will prompt you to ask where R should be launched. Simply keep the current directory by hitting the Return
key. Again, the output is captured and inserted right below.
The <R
+ tab
shortcut will allow you to run R commands that generate graphics. The (org-babel-temp-file \"figure\" \".png\")
generates a temporary file name. It will thus be erased when closing emacs. If you want the image to be persistant, indicate a real file name instead.
If you do not like this behavior, you can edit the init.el
file and replace (org-babel-temp-file \"figure\" \".png\")
by \"D:/temp/figure.png\"
or whichever location/name you prefer (both for <R
and <PP
).
You may want to read the Python Source Code Blocks in Org Mode webpage for more examples
The <p
+ tab
will insert a Python block in a non-session mode. This means that a new Python shell will be started for this block and that variables will not be shared between blocks. Again, the code is executed with the C-c C-c
shortcut.
The <P
+ tab
will insert a Python block in session mode. This allows to keep variables alive from a block to an other. Internally, emacs will have a buffer with a Python session running. Again, the code is executed with the C-c C-c
shortcut.
The <PP
+ tab
will insert a Python block in session mode and ready to generate graphics.
If this fails, try to update the Python numpy
library, for exemple like this in a dos/shell command:
python -m pip install -U numpy
journal.org
file you have placed in the ~/org/
directory. You will find a few first "old" entries with the most useful emacs shortcuts, including the ones that have been presented above.The C-c c
(Ctrl c
then c
) will open a menu asking you whether you want to take notes in your todo list or in your journal.
Hit j
to take notes in your journal. Emacs then opens journal.org
to create an entry with the right date and presents you with a mini buffer in which you can start taking notes.
When you are done, simply hit C-c C-c
to save your modifications and close the mini-buffer.
Alt
+ \leftarrow
or Alt
+ \rightarrow
will allow you to shift items to the left or to the right. Likewise, entries can be moved up or down.journal.org
file we gave you and which contains many useful tips.