1 Reputation

1.1 Jokes

Emacs is a great OS, but it lacks a decent text editor.

1.2 Alternative acronyms

EMACS is short for “Editing MACroS”, but some fun people have come up with alternatives.

  • Eight Megabytes And Constantly Swapping
  • Even a Master of Arts Comes Simpler
  • Emacs Manuals Are Cryptic and Surreal
  • Eradication of Memory Accomplished with Complete Simplicity
  • Elsewhere Maybe Alternative Civilisations Survive
  • Easily Maintained with the Assistance of Chemical Solutions
  • Emacs May Allow Customised Screwups
  • Generally Not Used, Except by Middle-Aged Computer Scientists

1.3 XKCD

Real Programmers

1.4 Memes — 1

vim-emacs-nano.png

1.5 Memes — 2

emacs-at-work.jpg

1.6 Memes — 3

learning-curves.jpg

1.7 Memes — 4

emacs-vim-airline.png

2 So… what is Emacs?

2.1 What do the memes tell us?

  • Emacs is a thing which edits text
  • Emacs gets compared to Vim a lot
  • Emacs is versatile, it does a lot
  • Emacs is weird

2.2 A common misconception

“Emacs is a thing which edits text” … so, a text editor? \pause nope \pause

emacs-anything.png

2.3 What then?

2.3.1 A definition of Emacs

Emacs is a generic user-centric text manipulation

environment.

\pause

2.3.2 A simpler definition

This does sound quite jargony though, let’s rephrase.

Emacs is an ’app platform’ for anything text

2.4 That still sounds like a text editor

Indeed. \pause However while that definition matches a text editor, it also applies to a: \pause

Emacs can do all of that. Yep.

2.5 Oh yes, there’s a lot you can do

Ever wanted to generate memes without leaving your current app?

generate-memes.png

2.6 Emacs is … perfect?

Nope. Not by a long shot.

Emacs has it’s own (large) collection of issues.

  • Emacs has annoying quirks
  • Areas of Emacs are showing their age (naming conventions, APIs)
  • Emacs is single threaded. When something holds that thread up the whole of Emacs freezes
  • And more… :(

However, Emacs has managed to stay competitive thanks to an unparalleled ability to be tinkered with, and adapt.

2.7 Emacs is a Lisp machine

2.7.1 Lisp?

A versatile programming language with just two ingredients

  • Atoms
  • Lists

2.7.2 Lisp machine?

The core of Emacs is a Lisp dialect, with extensions to support text editing.

2.8 How useful is it?

  • Emacs has terrible defaults
  • Emacs is often a huge time sink for customisation
  • Other applications can be seen as an “off the shelf” tool, while Emacs is a raw piece of steel which must be forged and tailored for your needs
    • The effort can be great, but so is the reward

3 Doom Emacs

3.1 What is it?

A fancy configuration base to make Emacs nicer to use and easier to work with.

3.2 Duplication of effort

3.2.1 The effort

Just now:

  • Other applications can be seen as an “off the shelf” tool, while Emacs is a raw piece of steel which must be forged and tailored for your needs
    • The effort can be great, but so is the reward

3.2.2 Duplication

Does this mean that for everything you have to start from scratch?

What about common use cases?

Most people want a similar setup, are they doomed to start from nothing, and independently struggle with the same issues?

3.3 De-duplication of effort

Doom solves this by providing modules for common use cases.

e.g. JavaScript, c++, \LaTeX, markdown, …

3.4.1 The first talk

Recall all those nice things I said about modal editing and Vim?

3.4.2 Going to the evil side

Emacs has a fantastic package called EVIL, for “Extensible VI Layer”. Most popular packages (e.g. magit) have an ’evil’ companion developed (e.g. evil-magit) which adds modal functionality.

From the spacemacs project homepage:

The best editor is neither Emacs nor Vim, it’s Emacs and Vim!

4 Let’s get started

4.2 Join the discord server

People there are quite useful. https://discord.gg/qvGgnVx

4.3 What have you got?

Let’s look at how Emacs is now. Open the Emacs app.

Expect it to appear with your other applications. On Linux/Mac you can call emacs in a terminal.

4.4 The doom binary

Doom has a executable which is used for some updating doom, installing packages, troubleshooting, and more.

Mac/Linux
~/.emacs.d/bin/doom
Windows
C:\Users\USERNAME\.emacs.d\bin\doom

Consider either adding the bin folder to your PATH, or (on Mac/Linux) using an alias with:

Shell Script
#
alias doom=~/.emacs.d/bin/doom

4.5 Configuration

Doom has three configuration files.

  • init.el
  • config.el
  • packages.el

On Mac/Linux these will probably be in ~/.doom.d. On windows try C:\Users\USERNAME\.doom.d as long as you set your HOME, else try C:\Users\USERNAME\AppData\Roaming.

4.6 Configuration — init.el

Remember those ’modules’ I mentioned?

Emacs Lisp
#
       :checkers
       syntax              ; tasing you for every semicolon you forget
       ;;spell             ; tasing you for misspelling mispelling
       ;;grammar           ; tasing grammar mistake every you make
Emacs Lisp
#
       :lang
       ;;agda              ; types of types of types of types...
       ;;cc                ; C/C++/Obj-C madness
Emacs Lisp
#
       ;;latex             ; writing papers in Emacs has never been so fun
       ;;lean
       ;;factor
       ;;ledger            ; an accounting system in Emacs
       ;;lua               ; one-based indices? one-based indices
       markdown          ; writing docs for people to ignore
       ;;nim               ; python + lisp at the speed of c
       ;;nix               ; I hereby declare "nix geht mehr!"
       ;;ocaml             ; an objective camel
       org               ; organize your plain life in plain text
       ;;php               ; perl's insecure younger brother

4.7 Configuration — modules

  1. Uncomment the ones you like the look of — like latex, which we’ll be looking at next week.
  2. Once you’ve done that call doom sync and all the required packages will be downloaded etc.

Want to read about modules? Press SPC h d m and you’ll be presented with a list of modules, picking one gives you the documentation.

4.8 Configuration — config.el

Basically everything. All your configuration beyond init.el. We’ll go over some example stuff later.

4.9 Configuration — packages.el

Any packages you want to use other than those installed from modules.

Read the comments for details, but often you’ll use something of the form:

Emacs Lisp
#
(package! something)

Just remember to run doom sync.

4.10 Aside: why are we so obsessed with using a keyboard

This can be explained quite simply. Most people can type 50 wpm. Assuming an average word length of 5, that’s 250 keystrokes per minute!

  1. Try comparing that to how many actions/clicks you can preform with a mouse.
  2. Enabling a fully keyboard-driven workflow meas you never have to take your hands off the keyboard.

4.11 Leader key

Take a menu bar.

app-menu-bar.png

How might you access those items with a keyboard? Perhaps following some trigger you could use f to get to file, e to edit, v to view, etc.

Doom does this, using SPC as a trigger. doom-leaders.png

4.12 Basic actions

  • SPC f f find (and open) file
  • SPC f s save file
  • SPC b b switch buffer
  • SPC b k kill (close) buffer
  • SPC p p switch project

4.13 Fumbling around

The help is great.

  • SPC h has a lot of help under it
  • SPC h v look at variables
  • M-x call an interactive function

Want to set a variable in your config? Add something like this to your config.el.

Emacs Lisp
#
(setq variable value)

5 Try it out

5.1 Killer apps

magit
a fantastic git interface
org-mode
an exceptionally versatile plaintext format
dired
powerful file manager
tramp
lets you act on remote servers with ease

5.2 Elisp

It’s the language used by everything in Emacs. It’s a Lisp, so it probably looks a bit strange. Consider reading a bit about the syntax if/when you feel like configuring Emacs :)

Date: 2020-07-05

Author: Timothy

Created: 2020-07-20 Mon 10:31