Toggling Ghostel

Randy Ridenour is living proof that you don’t have to be a young nerd to master Emacs and Elisp. Ridenour, a professor of Philosophy, has shown repeatedly that it’s possible for a nontechnical person to become sufficiently proficient with Emacs and Elisp to bend the editor to his will and make it work as he needs it to.

Irreal has recounted some examples of Ridenour’s past use of Elisp to customize his work environment and now there’s a new one. Lately he decided to try ghostel for his terminal emulator. He was already using ghostty as his macOS terminal emulator so the change made sense.

The change worked out well and Ridenour was pleased with the result except for one thing. With his previous Emacs terminal emulator, eat, he was able to toggle the emulator on and off easily but it didn’t work with ghostel. Rather than look for another package to solve this, he decided to fix it himself.

The desired functionality was

  1. If no instance of ghostel is running, start one in the current window.
  2. If there is already a ghostel instance running in another window, switch to it.
  3. If there is a ghostel instance running in the current window, bury it.

Ridenour implemented that functionality with two functions. The first gets the active buffer of any running instance of ghostel or returns nil if there is none. The second function implements the three steps above in a straightforward way. The code is in his post and easy to understand so take a look if you have a similar need.

This entry was posted in General and tagged . Bookmark the permalink.