Emacs with Org-Mode
Total Page:16
File Type:pdf, Size:1020Kb
WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode living knowledge WWU Münster Christoph Lehrenfeld November 4, 2015 ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 2/31 Outline Emacs org-mode Resources knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 3/31 Outline Emacs org-mode Resources knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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) knowledge with rudimentary scripting language (Mocklisp) Münster I 1984, Stallman: GNU Emacs (first GNU project) in Emacs Lisp (dialect to lisp) WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 5/31 Features (a few) 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) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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 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) knowledge Münster C-h t means pressing Control(C) and the t-key followed by (only) the t-key. WWU living Christoph Lehrenfeld ([email protected]) coding: 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) WESTFÄLISCHE WILHELMS-UNIVERSITÄ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) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄ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) coding: I autocompletion, tags (index of key words and ‘jump’ access to definitions) I sessions (set of “buffers” for a project) knowledge Münster I compilation-mode (error/warnings jump to line) WWU living Christoph Lehrenfeld ([email protected]) org-mode I taking notes / preparation of talks / documentation I export to html/latex/beamer/pdf/markdown (/ source code) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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..) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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 / documentation knowledge I export to html/latex/beamer/pdf/markdown (/ source code) Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 9/31 Usage of features How to use all these features? knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 10/31 shortcuts/keystrokes for everything knowledge Münster https://xkcd.com/378/ WWU living Christoph Lehrenfeld ([email protected]) How do I get my emacs to do what I want? 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! I availability of features (fast/simple) I good documentation I features should help you knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) 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! 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? knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) 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 I Bind your keys to (sequences of) commands I How do I do that ? knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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 lisp I makes emacs highly customizable key bindings (global-set-key (kbd "M-r") ’recompile) (global-set-key (kbd "<f5>") ’revert-buffer) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) 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: "))))) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 15/31 high level of customization knowledge Münster https://xkcd.com/1172/ WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜ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 emacs I Not everybody loves emacs: “a great operating system, lacking only a decent editor” knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 17/31 There are other good editors knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 18/31 Outline Emacs org-mode Resources knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 19/31 Origin and goals I Original developer: Carsten Dominik I Created 2003 to organize his life and work as a scientist I slogan: “org-mode: Your life in plain text” I aims: I note taking knowledge I project planning Münster I authoring (e.g. this talk!) I documentation (source code, literate programming) WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 20/31 Main features 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 I literate programming (org-babel) I documentation contains source code which can be extracted knowledge Münster I an emacs-mode WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 21/31 org-mode as an emacs-mode Emacs-mode I highly customizable I integrates into other modes (latex/c++/..) I is bound to emacs :( knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 22/31 org-mode files as documents Similar to Wikis I lists I tables I formulas (full latex!) I images I hyperlinks I ... knowledge Münster Exports to HTML/latex/beamer/pdf/markdown/ . WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 23/31 Note-taking example knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 24/31 Literate programming Write documentation around your source code. I Extensive documentation of your source code I 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 } knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 25/31 Working with source code (org-babel) (octave) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) The output eigvec = -0.94513 -0.11446 0.32670 -0.99343 eigval = Diagonal Matrix -0.036986 0 0 27.036986 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) knowledge Münster WWU living Christoph Lehrenfeld ([email protected]) WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER Emacs with org-mode 26/31 Working with source code (org-babel) (octave) The output eigvec = Octave code -0.94513 -0.11446 0.32670 -0.99343 A = [1,3;9,26]; eigval