Emacs with org-mode living knowledge WWU Mnster Christoph - - PowerPoint PPT Presentation

emacs with org mode
SMART_READER_LITE
LIVE PREVIEW

Emacs with org-mode living knowledge WWU Mnster Christoph - - PowerPoint PPT Presentation

W ESTFLISCHE W ILHELMS -U NIVERSITT M NSTER Emacs with org-mode living knowledge WWU Mnster Christoph Lehrenfeld November 4, 2015 (lehrenfeld@wwu.de) W ESTFLISCHE W ILHELMS -U NIVERSITT M NSTER Emacs with org-mode 2 /31


slide-1
SLIDE 1

Emacs with org-mode

Christoph Lehrenfeld (lehrenfeld@wwu.de) November 4, 2015

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

slide-2
SLIDE 2

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 2 /31

Outline

Emacs

  • rg-mode

Resources

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-3
SLIDE 3

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 3 /31

Outline

Emacs

  • rg-mode

Resources

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-4
SLIDE 4

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 4 /31

Emacs - (More than) another editor

◮ Main developer: Richard Stallman

history

◮ 1976-1979, Greenberg: Collection of Macros

(“Editor MACroS”) with Maclisp

◮ 1981, Gosling: erster Emacs (in C)

with rudimentary scripting language (Mocklisp)

◮ 1984, Stallman: GNU Emacs

(first GNU project) in Emacs Lisp (dialect to lisp)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-5
SLIDE 5

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 5 /31

Features (a few)

◮ terminal-based ◮ keystrokes - independence of mouse (faster/remote access) ◮ support for many programming languages ◮ lots of included features (games/calendar/shell/...) ◮ lots of extensions for special features ◮ highly customizable ◮ self-documenting (good manual-structure)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-6
SLIDE 6

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 6 /31

Getting started

◮ No how-to-use, rather motivation for emacs (or similar eds.) ◮ nice video tutorials: hack-emacs

help commands:

C-h t start a tutorial for emacs C-h b shows all active key bindings C-h k displays command of a key binding C-h f explains function M-x TAB 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 (lehrenfeld@wwu.de)

slide-7
SLIDE 7

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 7 /31

My mostly used features (1)

◮ standard editor features(fast): (search, mark, replace, ...) ◮ modes: add functionality and adapt to file-type (buffer-type) ◮ macros (sequence of commands: record and replay)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-8
SLIDE 8

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 7 /31

My mostly used features (1)

◮ standard editor features(fast): (search, mark, replace, ...) ◮ modes: add functionality and adapt to file-type (buffer-type) ◮ macros (sequence of commands: record and replay)

coding:

◮ autocompletion, tags (index of key words and ‘jump’ access to

definitions)

◮ sessions (set of “buffers” for a project) ◮ compilation-mode (error/warnings jump to line)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-9
SLIDE 9

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 8 /31

My mostly used features (2)

latex:

◮ flyspell-mode (spell checker) ◮ preview-latex, “compilation”, reftex-mode (list-access to

labels, bib-entries..)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-10
SLIDE 10

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 8 /31

My mostly used features (2)

latex:

◮ flyspell-mode (spell checker) ◮ preview-latex, “compilation”, reftex-mode (list-access to

labels, bib-entries..)

  • rg-mode

◮ taking notes / preparation of talks / documentation ◮ export to html/latex/beamer/pdf/markdown (/ source code)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-11
SLIDE 11

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 9 /31

Usage of features

How to use all these features?

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-12
SLIDE 12

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 10 /31

shortcuts/keystrokes for everything

https://xkcd.com/378/

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-13
SLIDE 13

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 11 /31

My emacs

It doesn’t matter what your editor is capable of!

◮ availability of features (fast/simple) ◮ good documentation ◮ features should help you

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-14
SLIDE 14

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 11 /31

My emacs

It doesn’t matter what your editor is capable of!

◮ availability of features (fast/simple) ◮ good documentation ◮ features should help you

How do I get my emacs to do what I want?

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-15
SLIDE 15

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 12 /31

customization

Set Preferences

user interface via “M-x customize-variable”

Extend basic settings with config-files

◮ Bind your keys to (sequences of) commands ◮ How do I do that ?

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-16
SLIDE 16

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 13 /31

emacs lisp

◮ scripting language (dialect to lisp) ◮ emacs is written in emacs lisp (and C) ◮ your configuration files are written in emacs lisp ◮ makes emacs highly customizable

key bindings

(global-set-key (kbd "M-r") ’recompile) (global-set-key (kbd "<f5>") ’revert-buffer)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-17
SLIDE 17

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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 (lehrenfeld@wwu.de)

slide-18
SLIDE 18

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 15 /31

high level of customization

https://xkcd.com/1172/

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-19
SLIDE 19

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 16 /31

some remarks on emacs

◮ There are other nice text editors out there (Sublime, vi(m), ..) ◮ cedet is an IDE for emacs (...) ◮ REPL (Read-eval-print loop) for script languages (python, lisp,

..) can nicely be done with emacs

◮ Not everybody loves emacs: “a great operating system, lacking

  • nly a decent editor”

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-20
SLIDE 20

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 17 /31

There are other good editors

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-21
SLIDE 21

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 18 /31

Outline

Emacs

  • rg-mode

Resources

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-22
SLIDE 22

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 19 /31

Origin and goals

◮ Original developer: Carsten Dominik ◮ Created 2003 to organize his life and work as a scientist ◮ slogan: “org-mode: Your life in plain text” ◮ aims:

◮ note taking ◮ project planning ◮ authoring (e.g. this talk!) ◮ documentation (source code, literate programming) Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-23
SLIDE 23

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 20 /31

Main features

◮ everything in plain text (version control)

(similar to Wiki-world but better!)

◮ outlining ◮ note-taking ◮ hyperlinks ◮ spreadsheet features ◮ TODO lists ◮ literate programming (org-babel)

◮ documentation contains source code which can be extracted

◮ an emacs-mode

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-24
SLIDE 24

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 21 /31

  • rg-mode as an emacs-mode

Emacs-mode

◮ highly customizable ◮ integrates into other modes (latex/c++/..) ◮ is bound to emacs :(

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-25
SLIDE 25

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 22 /31

  • rg-mode files as documents

Similar to Wikis

◮ lists ◮ tables ◮ formulas (full latex!) ◮ images ◮ hyperlinks ◮ ...

Exports to HTML/latex/beamer/pdf/markdown/ ...

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-26
SLIDE 26

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 23 /31

Note-taking example

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-27
SLIDE 27

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 24 /31

Literate programming

Write documentation around your source code.

◮ Extensive documentation of your source code ◮ 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 (lehrenfeld@wwu.de)

slide-28
SLIDE 28

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 25 /31

Working with source code (org-babel) (octave)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-29
SLIDE 29

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-30
SLIDE 30

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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.11446

0.32670

  • 0.99343

eigval = Diagonal Matrix

  • 0.036986

27.036986

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-31
SLIDE 31

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-32
SLIDE 32

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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 (lehrenfeld@wwu.de)

slide-33
SLIDE 33

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 28 /31

Working with source code (org-babel) (shell)

Shell code

uname -o -n -r emacs --version | head -n 1 grep "model name" /proc/cpuinfo | head -n 1

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-34
SLIDE 34

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 28 /31

Working with source code (org-babel) (shell)

Shell code

uname -o -n -r emacs --version | head -n 1 grep "model name" /proc/cpuinfo | head -n 1

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 (lehrenfeld@wwu.de)

slide-35
SLIDE 35

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 29 /31

Working with source code (remarks)

◮ result-regions are created in org-mode on

◮ demand (C-c C-c) ◮ export

◮ export of documentation into several files ◮ well-suited for tutorials or lectures

(source code is exactly the same as in the documentation!)

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-36
SLIDE 36

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 30 /31

Outline

Emacs

  • rg-mode

Resources

Christoph Lehrenfeld (lehrenfeld@wwu.de)

slide-37
SLIDE 37

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Emacs with org-mode 31 /31

links/references

◮ emacs

◮ https://www.gnu.org/software/emacs/

◮ org-mode

◮ http://orgmode.org/manual/

◮ both:

◮ hack-emacs (youtube tutorials for emacs/org-mode) Christoph Lehrenfeld (lehrenfeld@wwu.de)