Emacs Workshop

Simon Erfurth

Created: 2018-12-12 Wed 14:57

A Quick Overview of Emacs History

  • Artificial Intelligence Laboratory at MIT:
    • 1974: Stallmann adds macros to TECO
    • 1976: Editor MACroS <- Collection of such macros
    • 1976: Eine written in Lisp
  • 1981: Gosling Emacs
    • Sells to Unipress: $395 commercial product.

GNU Emacs

  • 1985-04-20: GNU Emacs 13.0
    • Unipress: "hobbyists and academics could never produce an Emacs that could compete"
  • 1985-12-20: GNU Emacs 17.36
  • Multiple derivatives: https://www.jwz.org/doc/emacs-timeline.html
  • 2018-05-28: GNU Emacs 26.1
    • Limited form of concurrency
    • Support for display of line numbers

0.3 editions/year

workflow.png

Keybindings

Prefix Meaning
C-h Control + h
M-x Alt + x
C-S-c or C-C Ctrl + Shfift + c
H-g Hyper + g

Why not A- instead of M-?

m-alt.jpg

Figure 2: Symbolics's Lisp Machine keyboard PN 365407.

Examples

C-s

C-x C-f

C-c C-e R R

Using Emacs

Remember: C-g (like escape) emacs-user.jpg

File manipulation

Opening a file C-x C-f
Saving a file C-x C-s
Writing a file C-x C-w

Multiple open files (Buffers)

  • List buffers: C-x b

    Think of it like tabs! Use arrows + enter to open a buffer

  • Close a buffer: C-x k

Multiple open 'frames'

Split horizontally C-x 2
Split vertically C-x 3
Close frame C-x 0
Maximize frame C-x 1
Switch frame C-x o
Switch to frame M-1, M-2,…

Editing in Emacs

8fingers.png

Copy/Paste

  • No Copy/Paste~

    Here we Kill and Yank!

  • Even more important: the kill ring!
Set Mark C-SPC
Kill (Cut) C-w
(Copy) M-w
Yank (Paste) C-y
Cycle kill ring M-y

Searching and marking

Forward Search C-s
Backward Search C-r
Search and Replace M-%

Repeat to cycle occurrences.

Moving Around

  • EOL: C-e
  • SOL: C-a
  • Pgdn: C-v
  • Pgup: M-v
  • SOF: C-<
  • EOF: C->
  • Try C-x C-x

Etc

  • Undo: C-/, redo: C-S-/

    (US keyboard)

  • Anything i missed?

Configuring (Spac)emacs

M-m f e d

Enable layers:

  • org
  • git
  • version-control

Finally:

  • Restart: M-m q r
  • Quit: M-m q q

Magit

It's magit

git.png

Status, commit and push

  • Git status: magit-status: M-m g s
  • Try to press ?
  • To stage simply sure s.

    But we have more power than that!

  • Commit: c c

    C-c C-c to commit, C-c C-k to abort

  • Pull: F u
  • Push: P u

Log, branches, etc

  • Log: l l, q to quit.

    Try to open a commit

  • b, works like one expects
  • Note colours in text buffer!

org-mode

  • Carsten Dominik, 2003
  • Then: "to organize his own life and work"
  • Now: Much, much more!

And now: A live demonstration

thumb.gif

Text in a document

  • Headlines: C-RET
    • * H1
    • ** H2
    • etc…
    • Move headders around M-Arrows
    • Fold headders TAB
    • Tag with C-c C-t
  • Lists
    • Move around and fold
    • Move in and out M-Arrows
    • Tab in and out TAB
  • Tables
    • Insert another column or row
    • Full spreadsheet capabilitie
  • LaTeX
    • \(\frac{1}{2\pi}\) C-c C-x C-l

      \begin{align} e^{i\pi}-1=0 \end{align}

Exporting .org files

  • Export to almost any format!
  • C-c C-e
    • PDF
    • HTML
  • Additional formats:
    • ox-reveal
    • ox-beamer
    • Your favorite website framework?
  • Options!

Code

for i in range(2):
    pass
return type(None)
  • Snippets: <s (and <n etc)
  • Edit in 'native' editor C-c '
  • Evaluate the source block C-c C-c
  • Any language you have configured (Shell, python, elisp by default)

Additional

yas-snippets

multiple-cursors

  • Need to define your own keybindings.
    • H-., H-,, …
    • Either next line or next like marked
  • mc/insert-numbers
  • mc/insert-letters
  • mc/sort-regions
  • mc/reverse-regions
  • Haresay: mc/add-cursor-on-click
  • https://github.com/magnars/multiple-cursors.el

treemacs

  • Tree-style file explore for Emacs
  • Try ?

Projectile

  • Project relevant commands
    • A git project
    • Or something else
  • M-m p f (file in project)
  • M-m p % (replace regex in project)
  • And more!

org-noter

More to add?

Evaluering

Lav en ny .org fil, udfyld evalueringen og eksporter (C-c C-e l p) til pdf. Send til sierf16@student

  1. Hvad er din studieretning (skal udfyldes af alle)?
  2. Hvad er dit udbytte af kurset?
  3. Fik du indfriet dine forventninger?
  4. Hvad synes du om kurset f.eks. indhold, form, tidspunkt, rammer eller lignende?
  5. Har du forslag til forbedringer?
  6. (Optional) Vis os hvad du lærte