M-x org-mode

simon

Jan. 24, 2019

Created: 2019-02-12 Tue 09:48

From where I talk ?

Who I am ?

  • Mainly a geek guy
  • Research Engineer at Univ. Paris 7 Diderot
    • Post-Doc Católica (Chile)
    • Post-Doc Univ. Liège (hi Berty!)
    • PhD at ONERA Toulouse

simon.tournier@univ-paris-diderot.fr

https://github.com/zimoun

My life

  • 2006-2010: Vim user… and happy!
  • 2011 New Year Resolutions: Switch to Emacs (video)
  • 2016: New Job with heavy context switch

Not able to Getting Things Done.

\(\Rightarrow\) Switch to Org-mode

I am only an enthusiast user, not a guru

My typical use-cases

  • Organize my tasks and log them
  • Write docs for myself
  • Produce computational notebooks
(defun ask-at-point (&optional i-know)
  "Feel free to ask everything."
  (interactive "P")
  (if i-know (message "Quick Answer.")
   (browse-url
    (concat "https://www.ddg.gg/?q=org-mode+"
            (thing-at-point 'symbol)))))

What Org-mode is?

  1. A major mode of Emacs
  2. Markup language, help for:
    • keeping notes
    • maintenaing TODO lists
    • planning projects
    • authoring documents
    • table editor
  3. Killer feature of Emacs ;-)

What Emacs is ?

The Power to the people :-)

220px-Unico_Anello.png

Explanations in previous info-math

https://zimoun.github.io/infomath-emacs/pres.html

(ok let quick recap in 3 slides)

Definition

Emacs is a User Interface (UI) to manipulate text

Theorem / Corollary / Example

All what X is able, Emacs does it too.

l58yl5wh6fk11.png

Advice: give a try to the tutorial of Emacs: C-h t

Alternative Reality

How to configure

The Org-mode configuration is driven by

$HOME/.emacs.d/init.el

Configure what?

Nothing to do!

Org-mode is included in all recent Emacs

(since GNU Emacs 22 released in 2006)

But…

Specific features are in contrib

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
             ;; `use-package' is not in ELPA, as many more ;-)
             '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives
               ;; Add org-plus-contrib
               '("org" . "http://orgmode.org/elpa/"))
(package-initialize)

M-x package-list-packages

Let's talk about Unicorn

jpgOOYZDKoq6T.jpg

org-mode is…

"Awesome!" – John Kitchin (video)

Org is vast…

start small!

"Don't try to set up the 'final' task managing system from the start. Because you have no idea yet what your system should look like. […] Start by creating and managing a small TODO list and then develop your own system as the needs arises." – Carsten Dominik (creator of org)

Where/How to start

2014-01-07-Map-for-learning-Org-Mode-for-Emacs-640x480.png

https://orgmode.org/orgcard.pdf

My experience

  • Learn a couple of its capabilities
  • Integrate them into your workflow
  • You’ll find yourself thinking, "Hum?, it would be nice if I could X"
  • Then browse the manual (C-h i m org)

… and, in fact, Org can do X

Show me the Unicorn!!

jpgOOYZDKoq6T.jpg

Markup languages

Basics

  • underline
  • bold
  • italic
  • verbatim
  • code
  • strike
  • list
  • section, link, etc.

Raw

* Level 1
** Level 2
*** Level 3
**** Level 4

   + _underline_
   + *bold*
   + /italic/

*** Other 3

   1) =verbatim=
   2) ~code~
   3) +strike+

** More 2

   - list
   - section, [[https://orgmode.org/][link]], etc.

Facilities to write

  • M-Enter creates new item
  • M-Left/Right changes the level
  • M-Up/Dow moves the item up/down
  • C-c C-n move next header (C-p previous)
  • C-c C-u move upper header (level 2->level 1)
  • S-Left/Right change list item kind (C-c -)
  • S-TAB cycles the visibility

Emacs power! ;-)

Equation (raw)

Let only consider $\pi^2$ or $\Pi_\infty$, considering
$$\cos(x) = \textrm{real}~ \sum_n \frac{ix}{n!}$$

\begin{array}{ccl}
u^{\prime\prime} + k^2 u &=& 0 \\
& \textrm{with} &
u(0) = 1 \\
& \textrm{and} &
u^\prime(1)=iku(1)
\end{array}

\(\LaTeX\) support

The equations exported

Let only consider \(\pi^2\) or \(\Pi_\infty\), considering \[\cos(x) = \textrm{real}~ \sum_n \frac{ix}{n!}\]

\begin{array}{ccl} u^{\prime\prime} + k^2 u &=& 0 \\ & \textrm{with} & u(0) = 1 \\ & \textrm{and} & u^\prime(1)=iku(1) \end{array}

Exported?

Yes!

from .org to HTML or PDF (or .tex) or … Reveal.js etc.

C-c C-e opens the menu of exporters

More list: checkbox

* Stuff [2/4]

- [X] Read the Dautray-Lions
- [-] Write summary [75%]
  + [X] Tome 1
  + [X] Tome 2
  + [X] Tome 3
  + [ ] Les autres
- [ ] Present Chapter 2 in Seminar
- [X] Drink coffee
  • Validate: C-c C-c on the item
  • Automatic update

Wait!

Is not also a planner?

34909043-4ebd-4043-a6d5-c31b2f6cbbf4_1.8e2dea8a0fc20d8775352b09caca44ff.jpeg

Plan: TODO DONE (NEXT WAIT CANCELED) etc.

* TODO Presentation [1/4]
** TODO Collect ressources [50%]
*** DONE Read the manual
    CLOSED: [2019-01-22 Tue 17:12]
*** TODO Browse the web
** DONE Preparation
   DEADLINE: <2019-01-23 Wed>
   CLOSED: [2019-01-22 Tue 22:22]
** Free header
** TODO Lunch Bertrand
   SCHEDULED: <2019-01-24 Thu>
** TODO Fix bugs with Reveal.js
   DEADLINE: <2019-01-25 Fri>
  • C-c C-t cycles nothing->TODO->DONE->nothing
  • Automatic set date and hour when closing (see init.el)
  • S-Left/Right also works
  • C-c C-s schedules
  • C-c C-d assigns a deadline

Manipulation of dates

  • Cursor inside the brackets then S-Up/Down
  • C-c C-c updates the day
  • Use Emacs calendar M-x calendar

(C-h i g (emacs)Calendar Diary)

Agenda View

:bind ("\C-ca"  . org-agenda)

;; where to look for the agenda files
(setq org-agenda-files (directory-files-recursively "~/org/" "\.org$"))

demo

(C-c a a or M-x org-agenda)

  • Navigate: menu Agenda etc.
  • Search: C-a a s and e.g. web

@simon: v l to setup log on.

Tags / Priorities

** TODO Bertrand's idea
*** DONE Discuss                                                      :@meet:
    CLOSED: [2019-01-16 Wed 18:37]
*** TODO Proof-of-Concept with Julia                                   :code:
**** TODO [#B] Clean the geo file
**** TODO [#A] Read the mesh
**** TODO [#C] Update Petsc
**** TODO [#B] Implement decent Krylov
*** TODO Refresh the idea                                       :@meet:write:
    SCHEDULED: <2019-01-31 Thu 18:00>
*** TODO Sent the paper to Wave                                       :write:
    DEADLINE: <2019-02-01 Fri>
** DONE Calderon preconditioner                             :read:write:code:
   CLOSED: [2019-01-15 Tue 15:51]

demo

  • C-c a t shows the tasks sorted by priorities
  • C-c a m code shows the tasks corresponding to the tag code

Possible+Imposible = Possimpible?

Legen-wait-for-it-dary-stinson-quotes.jpg

or how to easily manage the table

M-x org-table-create

| Student | Algebra | Analysis |
|---------+---------+----------|
| Alice   |    12.5 |      15. |
| Bob     |     11. |      14. |
| John    |     10. |      10. |
  • C-c | creates with the convention line x col
  • M-S-Right creates new col (Left deletes)
  • M-a/e moves beginning/end cell
  • C-c - or C-c Enter inserts horizontal line
  • M-S-Up removes the current line
  • C-c ^ sorts the col

table and \(\LaTeX\)

  • Write table with Org-mode (easy!)
  • Export to .tex with C-c C-e C-b l l (body only)
  • Use \input{}

(or epxort to buffer C-c C-e C-b l L and copy/paste)

DEMO!

makefile

all: doc.tex table1.tex table2.tex
    pdflatex doc.tex

%.tex: %.org
     emacs -batch -q $< --eval="(org-latex-export-to-latex nil nil t t)"

clean:
    -rm table?.tex
    -rm doc.{aux,log}

The spreadsheet

| N | N^4 | ~Sqrt(N)~ | 1/N | Mean |
|---+-----+-----------+-----+------|
| 4 |     |           |     |      |
| 3 |     |           |     |      |
| 2 |     |           |     |      |
| 1 |     |           |     |      |
|   |     |           |     |      |
#+TBLFM: $2=$1^4::$3=sqrt($1)::$4=1/$1::$5=vmean($2..$4)::@6$1=vmean(@2$1..@4$1)

I do not use myself

  • C-c ? to get information the current cell
  • C-c } to enter in debbuging mode

Entry point: the tutorial :-)

Computational Document

Toward Reproducible workflow

"Buzzword – What'chu talkin' 'bout, Willis?" – Arnold

Org-babel

babelfish.png

The Babel Fish is small, yellow, and simultaneously translates from one spoken language to another.

The Hitchhiker's Guide to the Galaxy – Douglas Adams

Blocks

#+begin_src python
  def f(x):
    return x + x
#+end_src

#+begin_src r
  f <- function(x) {
  x + x
  }
#+end_src

#+begin_src julia
  function f(x)
      x + x
  end
#+end_src
  • Options with :tangle or :noweb or :export etc.
  • C-c C-, opens the menu of different blocks
  • Org 9.2 <s or <q … does not work anymore. Use Org Tempo.

Eval blocks

demo

  • C-c C-v t tangles i.e. writes to files the exposed blocks
  • C-c C-v e evals all the blocks

Remember!

Org-mode is:

  • Markdown on steroids
  • Jupyter notebook usable outside class (troll inside :-)

9f2ce89a8d9e7db42a03041717f5e276.jpg

Start now!

galactic_explorer.en.png

Key of Success

  • Master a tool needs large amount of work

    think all the maths you learn before complete non-trivial proofs

  • Master a tool is not easy; otherwise it is a lie

    think nunchaku practise to be as efficient as Bruce Lee

Why computing tools should be different ?

Be good at something is long

My personal conclusion

Why flamewar tools ? :-)

  • Our daily life is interacting with computers
  • We are all differently wired
  • Cognition is not straightforward

Tools should be freedom, not constraint and pain.

Happy end?

Be productive in procrastination :-)

phd010408s.gif