Emacs with org-mode - Universität Münster

Transcription

Emacs with org-mode - Universität Münster
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
living knowledge
WWU Münster
Christoph Lehrenfeld
([email protected])
November 4, 2015
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
2 /31
Outline
org-mode
Resources
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Emacs
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
3 /31
Outline
org-mode
Resources
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Emacs
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
4 /31
Emacs - (More than) another editor
I
Main developer: Richard Stallman
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])
living knowledge
WWU Münster
history
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
5 /31
I
terminal-based
I
keystrokes - independence of mouse (faster/remote access)
I
support for many programming languages
I
lots of included features (games/calendar/shell/. . . )
I
lots of extensions for special features
I
highly customizable
I
self-documenting (good manual-structure)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Features (a few)
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
6 /31
Getting started
I
I
No how-to-use, rather motivation for emacs (or similar eds.)
nice video tutorials: hack-emacs
C-h
C-h
C-h
C-h
M-x
t
b
k
f
TAB
start a tutorial for emacs
shows all active key bindings
displays command of a key binding
explains function
search/browse available functions (e.g. kill-emacs)
C-h t means pressing Control(C) and the t-key followed by (only) the
t-key.
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
help commands:
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
7 /31
My mostly used features (1)
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)
living knowledge
WWU Münster
I
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M Ü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)
I
autocompletion, tags (index of key words and ‘jump’ access to
definitions)
I
sessions (set of “buffers” for a project)
I
compilation-mode (error/warnings jump to line)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
coding:
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
8 /31
My mostly used features (2)
latex:
flyspell-mode (spell checker)
I
preview-latex, “compilation”, reftex-mode (list-access to
labels, bib-entries..)
living knowledge
WWU Münster
I
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
8 /31
My mostly used features (2)
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 / documentation
I
export to html/latex/beamer/pdf/markdown (/ source code)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
latex:
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
9 /31
Usage of features
living knowledge
WWU Münster
How to use all these features?
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
10 /31
https://xkcd.com/378/
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
shortcuts/keystrokes for everything
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
11 /31
My emacs
I
availability of features (fast/simple)
I
good documentation
I
features should help you
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
It doesn’t matter what your editor is capable of!
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
11 /31
My emacs
I
availability of features (fast/simple)
I
good documentation
I
features should help you
How do I get my emacs to do what I want?
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
It doesn’t matter what your editor is capable of!
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
12 /31
customization
Set Preferences
Extend basic settings with config-files
I
Bind your keys to (sequences of) commands
I
How do I do that ?
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
user interface via “M-x customize-variable”
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
13 /31
I
scripting language (dialect to lisp)
I
emacs is written in emacs lisp (and C)
I
your configuration files are written in emacs lisp
I
makes emacs highly customizable
key bindings
(global-set-key (kbd "M-r") ’recompile)
(global-set-key (kbd "<f5>") ’revert-buffer)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
emacs lisp
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
14 /31
emacs lisp (more advanced)
(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])
living knowledge
WWU Münster
(sort of) new functionality
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
15 /31
https://xkcd.com/1172/
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
high level of customization
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
16 /31
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 emacs
I
Not everybody loves emacs: “a great operating system, lacking
only a decent editor”
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
some remarks on emacs
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
17 /31
living knowledge
WWU Münster
There are other good editors
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
18 /31
Outline
org-mode
Resources
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Emacs
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
19 /31
I
I
I
I
Original developer: Carsten Dominik
Created 2003 to organize his life and work as a scientist
slogan: “org-mode: Your life in plain text”
aims:
I
I
I
I
note taking
project planning
authoring (e.g. this talk!)
documentation (source code, literate programming)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Origin and goals
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
20 /31
I
everything in plain text (version control)
(similar to Wiki-world but better!)
I
outlining
I
note-taking
I
hyperlinks
I
spreadsheet features
I
TODO lists
literate programming (org-babel)
I
I
I
documentation contains source code which can be extracted
an emacs-mode
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Main features
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
21 /31
org-mode as an emacs-mode
I
highly customizable
I
integrates into other modes (latex/c++/..)
I
is bound to emacs :(
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Emacs-mode
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
22 /31
org-mode files as documents
I
lists
I
tables
I
formulas (full latex!)
I
images
I
hyperlinks
I
...
Exports to HTML/latex/beamer/pdf/markdown/ . . .
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Similar to Wikis
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
23 /31
living knowledge
WWU Münster
Note-taking example
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
24 /31
Literate programming
1
2
3
4
I
Extensive documentation of your source code
I
Extract source code from the same file as the documentation!
double myf(double x)
{
return sqrt(x)+sqrt(1-x)+1-2.0*x;
}
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Write documentation around your source code.
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
25 /31
living knowledge
WWU Münster
Working with source code (org-babel) (octave)
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
26 /31
Working with source code (org-babel) (octave)
A = [1,3;9,26];
[eigvec,eigval]=eig(A)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Octave code
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
26 /31
Working with source code (org-babel) (octave)
The output
eigvec =
-0.94513
0.32670
-0.11446
-0.99343
A = [1,3;9,26];
eigval =
[eigvec,eigval]=eig(A)
Diagonal Matrix
-0.036986
0
Christoph Lehrenfeld ([email protected])
0
27.036986
living knowledge
WWU Münster
Octave code
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
27 /31
Working with source code (org-babel) (python)
Python code
living knowledge
WWU Münster
a = ["apfel","gurken","elefanten"]
b = ["baum","truppe","parkschein"]
c = [ c+d for [c,d] in zip(a,b)]
print(c)
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
27 /31
Working with source code (org-babel) (python)
Python code
The output
[’apfelbaum’, ’gurkentruppe’, ’elefantenparkschein’]
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
a = ["apfel","gurken","elefanten"]
b = ["baum","truppe","parkschein"]
c = [ c+d for [c,d] in zip(a,b)]
print(c)
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
28 /31
Working with source code (org-babel) (shell)
Shell code
living knowledge
WWU Münster
uname -o -n -r
emacs --version | head -n 1
grep "model name" /proc/cpuinfo | head -n 1
Christoph Lehrenfeld ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
28 /31
Working with source code (org-babel) (shell)
Shell code
The output
schrustux 4.1.4-1-ARCH GNU/Linux
GNU Emacs 24.5.1
model name
: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
uname -o -n -r
emacs --version | head -n 1
grep "model name" /proc/cpuinfo | head -n 1
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
29 /31
Working with source code (remarks)
result-regions are created in org-mode on
I
I
demand (C-c C-c)
export
I
export of documentation into several files
I
well-suited for tutorials or lectures
(source code is exactly the same as in the documentation!)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
I
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
30 /31
Outline
org-mode
Resources
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
Emacs
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
Emacs with org-mode
31 /31
links/references
emacs
I
I
org-mode
I
I
https://www.gnu.org/software/emacs/
http://orgmode.org/manual/
both:
I
hack-emacs (youtube tutorials for emacs/org-mode)
Christoph Lehrenfeld ([email protected])
living knowledge
WWU Münster
I

Similar documents