Emacs as a programming IDE

Author

Marie-Hélène Burle

Content from the webinar slides for easier browsing.

I am not trying to start an editor war here.

https://cube-drone.com

Particularly as there are now excellent IDEs for Python, Julia, and R without Emacs learning curve (think VS Code, RStudio, or JupyterLab).

 

Why I still use (and love) Emacs

  • Bookmarking
  • Fully customizable
  • Kbd for everything
  • Org mode (org tables!)
  • Organization of windows
  • Search and replace with regexp
  • Ediff
  • Macros
  • Emacs everywhere (emails, Slack, Telegram with mu4e, emacs-slack, telega)

Helm

  • Searching in buffer
  • Navigating open buffers and recent files
  • Navigating file sections
  • Selecting from kill ring
  • Moving in mark ring
  • Looking at active modes

Completion

Undoing/redoing with undo-tree

Classic undo/redo

The classic undo/redo in the vast majority of software follows a linear systems:

Have some file.

Make some edits.

Make more edits.

Make more edits.

Can undo.

Undo some more.

Can redo.

Make new edits.

Can still undo.

Can still undo.

And can redo.

But some edits are forever lost.


This system is basic, unsophisticated, and frustrating each time you loose edits.

Emacs undo/undo

Emacs offers a very interesting approach: while still a linear system, no edits are ever lost because Emacs does not have any redo. To redo, you undo the undo.

1

Have some file.

1

2

Make some edits.

1

2

3

Make more edits.

1

2

3

4

Make more edits.

1

2

3

4

3

The first undo adds a new point to the chain of edits.

1

2

3

4

3

2

More undoing keeps adding points to the chain.

1

2

3

4

3

2

3

There is no redo: you stop undoing, then start again to undo the undo.

1

2

3

4

3

2

3

5

You can make new edits.
Nothing ever gets lost, but you might get headaches.
Example: let’s go back to the starting point.

1

2

3

4

3

2

3

5

3

2

3

4

3

2

1


While this works, it quickly becomes an absolute hell not to get lost in the growing chain of undos, undo the undos, undo the undos of the undos… not to mention that if you enter any non-undo command in the chain, you break it and you will have to do it all over again (plus the new undos you did before breaking the chain 🤯).

Undo-tree

The obvious solution is to use a non-linear system, that is a tree system.

Have some file.

Make some edits.

Make some edits.

Make some edits.

Undo.

Undo.

Redo.

Make new edits.

Undo.

Switch branch and redo the old version.

Nothing gets lost and it is more sane to navigate the history.


This is truly great (undo-tree was actually first implemented in Vim, but 🤫).

Emacs with Python

Emacs comes with a Python mode that provides syntax highlighting. For a full IDE experience, there are multiple options, the most popular of which being the elpy package:

Code from matplotlib

Emacs with R

R is—as Emacs—GNU software and has been integrated with Emacs via the ESS (Emacs Speaks Statistics) package for a very long time:

Emacs with Julia

The julia-mode package provides syntax highlighting and the julia-repl package implements a fully functional Julia REPL, optionally with the emacs-libvterm package:

Code from Beautiful Makie

ESS also provides an IDE for Julia, but it does not allow for the funky Julia-specific REPL.

Another sophisticated option is to use julia-mode with the julia-snail package.