Extending Emacs

For those using a RSS reader, subscribe here: rss.xml

Coming from Notepad++ as my main editor, not having to rely on fancy editors was a given.

Maybe this deserves it’ own story, but what is important for now is that Doom Emacs is my main editor. It is perfect as it is so full of features, and convinced me fully on the beauty of lisp. Ow, and don’t get started on how great org-mode is, it is being used as this article is written :)

Writing a bit of Emacs Lisp

As I was standardizing my Doom Emacs dotfiles today, the choice of terminal was a tough one initially.

  • eshell ; the elisp shell that works everywhere
  • shell ; simple shell REPL for Emacs
  • term ; basic terminal emulator for Emacs
  • vterm ; the best terminal emulation in Emacs

Of these four, eshell did not respond to the `SPC o t` keybind, and directly calling it takes up your current buffer.

So this inspired an idea: let just make it work just like the rest.

Improving the default eshell experience

To solve it taking your current buffer, we can split before calling `eshell`

  (+evil/window-split-and-follow)
  (eshell)

As it will be a command, lets wrap it:

(defun split-and-term ()
  "Make eshell a proper terminal."
  (interactive)
  (+evil/window-split-and-follow)
  (eshell))

And now map it to the right keybind:

(map! :leader
      :desc "Open eshell as a terminal"
      "o t" 'split-and-term)

Hacking it in can be as easy as that, and wow it is fun to do.

Result

This simple addition makes the powerful as available as the rest of the terminals If you are not familiar with eshell, it is a shell that allows you to also write elisp, which together looks like this:

extending-emacs-completion.png

Figure 1: Auto-completion on file navigation inside the elisp shell

extending-emacs-demo.png

Figure 2: Demonstration of calling shell commands and elisp expressions inside the elisp shell