emacs with org-mode - universität münster · emacs with org-mode christoph lehrenfeld...
TRANSCRIPT
Emacs with org-mode
Christoph Lehrenfeld([email protected])
November 4, 2015living knowledgeWWU Münster
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 2 /31
Outline
Emacs
org-mode
Resources
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 3 /31
Outline
Emacs
org-mode
Resources
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 4 /31
Emacs - (More than) another editor
I Main developer: Richard Stallman
history
I 1976-1979, Greenberg: Collection of Macros(“Editor MACroS”) with Maclisp
I 1981, Gosling: erster Emacs (in C)with rudimentary scripting language (Mocklisp)
I 1984, Stallman: GNU Emacs(first GNU project) in Emacs Lisp (dialect to lisp)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 5 /31
Features (a few)
I terminal-basedI keystrokes - independence of mouse (faster/remote access)I support for many programming languagesI lots of included features (games/calendar/shell/. . . )I lots of extensions for special featuresI highly customizableI self-documenting (good manual-structure)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 6 /31
Getting started
I No how-to-use, rather motivation for emacs (or similar eds.)I nice video tutorials: hack-emacs
help commands:
C-h t start a tutorial for emacsC-h b shows all active key bindingsC-h k displays command of a key bindingC-h f explains functionM-x TAB search/browse available functions (e.g. kill-emacs)
C-h t means pressing Control(C) and the t-key followed by (only) thet-key.
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 7 /31
My mostly used features (1)
I standard editor features(fast): (search, mark, replace, . . . )I modes: add functionality and adapt to file-type (buffer-type)I macros (sequence of commands: record and replay)
coding:
I autocompletion, tags (index of key words and ‘jump’ access todefinitions)
I sessions (set of “buffers” for a project)I compilation-mode (error/warnings jump to line)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 7 /31
My mostly used features (1)
I standard editor features(fast): (search, mark, replace, . . . )I modes: add functionality and adapt to file-type (buffer-type)I macros (sequence of commands: record and replay)
coding:
I autocompletion, tags (index of key words and ‘jump’ access todefinitions)
I sessions (set of “buffers” for a project)I compilation-mode (error/warnings jump to line)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 8 /31
My mostly used features (2)
latex:
I flyspell-mode (spell checker)I preview-latex, “compilation”, reftex-mode (list-access to
labels, bib-entries..)
org-mode
I taking notes / preparation of talks / documentationI export to html/latex/beamer/pdf/markdown (/ source code)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 8 /31
My mostly used features (2)
latex:
I flyspell-mode (spell checker)I preview-latex, “compilation”, reftex-mode (list-access to
labels, bib-entries..)
org-mode
I taking notes / preparation of talks / documentationI export to html/latex/beamer/pdf/markdown (/ source code)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 9 /31
Usage of features
How to use all these features?
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 10 /31
shortcuts/keystrokes for everything
https://xkcd.com/378/
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 11 /31
My emacs
It doesn’t matter what your editor is capable of!
I availability of features (fast/simple)I good documentationI features should help you
How do I get my emacs to do what I want?
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 11 /31
My emacs
It doesn’t matter what your editor is capable of!
I availability of features (fast/simple)I good documentationI features should help you
How do I get my emacs to do what I want?
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 12 /31
customization
Set Preferences
user interface via “M-x customize-variable”
Extend basic settings with config-files
I Bind your keys to (sequences of) commandsI How do I do that ?
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 13 /31
emacs lisp
I scripting language (dialect to lisp)I emacs is written in emacs lisp (and C)I your configuration files are written in emacs lispI makes emacs highly customizable
key bindings
(global-set-key (kbd "M-r") ’recompile)(global-set-key (kbd "<f5>") ’revert-buffer)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 14 /31
emacs lisp (more advanced)
(sort of) new functionality
(defun prelude-google ()"Googles a query or region if any."(interactive)(browse-url(concat"http://www.google.com/search?ie=utf-8&oe=utf-8&q="(if mark-active
(buffer-substring (region-beginning) (region-end))(read-string "Google: ")))))
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 15 /31
high level of customization
https://xkcd.com/1172/
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 16 /31
some remarks on emacs
I There are other nice text editors out there (Sublime, vi(m), ..)I cedet is an IDE for emacs (. . . )I REPL (Read-eval-print loop) for script languages (python, lisp,
..) can nicely be done with emacsI Not everybody loves emacs: “a great operating system, lacking
only a decent editor”
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 17 /31
There are other good editors
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 18 /31
Outline
Emacs
org-mode
Resources
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 19 /31
Origin and goals
I Original developer: Carsten DominikI Created 2003 to organize his life and work as a scientistI slogan: “org-mode: Your life in plain text”I aims:
I note takingI project planningI authoring (e.g. this talk!)I documentation (source code, literate programming)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 20 /31
Main features
I everything in plain text (version control)(similar to Wiki-world but better!)
I outliningI note-takingI hyperlinksI spreadsheet featuresI TODO listsI literate programming (org-babel)
I documentation contains source code which can be extracted
I an emacs-mode
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 21 /31
org-mode as an emacs-mode
Emacs-mode
I highly customizableI integrates into other modes (latex/c++/..)I is bound to emacs :(
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 22 /31
org-mode files as documents
Similar to Wikis
I listsI tablesI formulas (full latex!)I imagesI hyperlinksI . . .
Exports to HTML/latex/beamer/pdf/markdown/ . . .
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 23 /31
Note-taking example
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 24 /31
Literate programming
Write documentation around your source code.
I Extensive documentation of your source codeI Extract source code from the same file as the documentation!
1 double myf(double x)2 {3 return sqrt(x)+sqrt(1-x)+1-2.0*x;4 }
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 25 /31
Working with source code (org-babel) (octave)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 26 /31
Working with source code (org-babel) (octave)
Octave code
A = [1,3;9,26];
[eigvec,eigval]=eig(A)
The output
eigvec =
-0.94513 -0.114460.32670 -0.99343
eigval =
Diagonal Matrix
-0.036986 00 27.036986
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 26 /31
Working with source code (org-babel) (octave)
Octave code
A = [1,3;9,26];
[eigvec,eigval]=eig(A)
The output
eigvec =
-0.94513 -0.114460.32670 -0.99343
eigval =
Diagonal Matrix
-0.036986 00 27.036986
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 27 /31
Working with source code (org-babel) (python)
Python code
a = ["apfel","gurken","elefanten"]b = ["baum","truppe","parkschein"]c = [ c+d for [c,d] in zip(a,b)]print(c)
The output
[’apfelbaum’, ’gurkentruppe’, ’elefantenparkschein’]
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 27 /31
Working with source code (org-babel) (python)
Python code
a = ["apfel","gurken","elefanten"]b = ["baum","truppe","parkschein"]c = [ c+d for [c,d] in zip(a,b)]print(c)
The output
[’apfelbaum’, ’gurkentruppe’, ’elefantenparkschein’]
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 28 /31
Working with source code (org-babel) (shell)
Shell code
uname -o -n -remacs --version | head -n 1grep "model name" /proc/cpuinfo | head -n 1
The output
schrustux 4.1.4-1-ARCH GNU/LinuxGNU Emacs 24.5.1model name : Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 28 /31
Working with source code (org-babel) (shell)
Shell code
uname -o -n -remacs --version | head -n 1grep "model name" /proc/cpuinfo | head -n 1
The output
schrustux 4.1.4-1-ARCH GNU/LinuxGNU Emacs 24.5.1model name : Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 29 /31
Working with source code (remarks)
I result-regions are created in org-mode onI demand (C-c C-c)I export
I export of documentation into several filesI well-suited for tutorials or lectures
(source code is exactly the same as in the documentation!)
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 30 /31
Outline
Emacs
org-mode
Resources
Christoph Lehrenfeld ([email protected])
livin
gkn
owle
dge
WW
UM
ünst
er
WESTFÄLISCHEWILHELMS-UNIVERSITÄTMÜNSTER Emacs with org-mode 31 /31
links/references
I emacsI https://www.gnu.org/software/emacs/
I org-modeI http://orgmode.org/manual/
I both:I hack-emacs (youtube tutorials for emacs/org-mode)
Christoph Lehrenfeld ([email protected])