Emacs Config Gems - Part 3
My actual configs start with pretty usual stuff you’d see across many other Emacs configs. As I was going through these however, I started to wonder how things work and why they ended up the way we have them today. In turn, that led to reading about the intention behind those, which led to more options I didn’t think about. Also, it’s kind of fun. I’ve made two more passes for this part alone in the last couple of weeks, and I could probably go for a third. When reading this post, if you want the good stuff (in my opinion), get lost in the footnotes as I did. There’s a lot to explore. I just scratched the surface.
Load Melpa
Melpa is where many Emacs packages live. The story behind it (from what I can tell) revolves around one of Emacs’ maintainers, Bozhidar Batsov, who pointed to Melpa at some point in 2012, when Emacs’s then go-to third-party package repository went offline. He is not its creator — Melpa has been around before this post — but this seems to be the turning point where Emacs package maintainers started to really use it. I don’t have good coder/repository maintainer knowledge, but from what I read, it’s built on the same idea as Homebrew (for Mac), which was familiar to many of the Emacs folks at the time.
So let’s get Melpa:
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
UI and Fundamental Emacs tweaks:
Most Emacs folks with a config file like this like to kill the toolbar, scrollbar, and menu bar. I find that the menu bar makes Emacs look more like the other programs, especially in macOS1. Besides, it’s nice to look every now and then and be reminded of good Emacs kung-fu I forgot exists (org-sort, I’m sorry my friend, I’ll keep saying hi more often).
This is why the menu-bar is commented out in my config; I want it, but I also want to remember I could turn it off if I wanted:
(tool-bar-mode -1)
(scroll-bar-mode -1)
;; (menu-bar-mode -1)
By default, help commands2 display the help buffer in a new window without selecting it. I find this annoying: if I bring up the help window, it’s usually because I want to scroll down to find something or copy (yank) something. On the other hand, if I just want to skim quickly in the help buffer, it’s helpful that the marker is on it for a quick q for quit.
In addition, we want to be able to navigate help menus as Emacs intended if we follow the links in a help buffer. help-window-keep-selected allows us to keep help in its own dedicated window, so it won’t open in a separate window once we follow a link. Going back to the original is the same as we do in other browser-like buffers in Emacs, with l (like in Eww, for example). Likewise, we can go forward with r. I should also expand here on various help options; they definitely deserve a mention, but this is another huge topic (you can get an idea from the footer) that will take a couple of weeks. I will come back to this someday.
(setq help-window-select t)
(setq help-window-keep-selected t)
Lisp is full of parentheses, and it’s easy to lose track. Turning show-paren-mode on means that standing on an open or closed parentheses highlights its matching counterpart, which is handy.
In addition, while we’re here: when we stand on an expression that is only showing a portion of an expression (meaning, we need to scroll down to see the rest) Emacs can highlight the expression for us to make sure we don’t get confused — this is the mixed option below for show-paren-style. If you want to see the whole expression highlighted every time you’re on it, there’s the option expression, which I’m leaving here for reference for myself. For now, I think it’s too much visual noise, especially since we’re using org-edit-special, which also highlights what we’re working on.
(show-paren-mode t)
(setq show-paren-style 'mixed)
;; (setq show-paren-style 'expression)
And now, a true Emacs classic. I don’t think I’ve seen a config without it: shortening “yes” or “no,” answer to “y” or “n” like any other program known to mankind. use-short-answers was introduced in Emacs 28.1, which is a more graceful way to do this, intended exactly for this purpose. Before that, back when I started to use Emacs, it was done with (fset 'yes-or-no-p 'y-or-n-p). If you have an older Emacs version, you’d need it.
;; (fset 'yes-or-no-p 'y-or-n-p)
(setq use-short-answers t)
This one was annoying until I learned this option exists from someone else’s config years ago: “Emacs, please stop asking me if I want to kill process when exiting Emacs (Shell, etc.), just do it!” Yep.
(setq confirm-kill-processes nil)
Emacs has two annoying keyboard shortcuts that I should have disabled as soon as I started using it: C-x C-c (exit Emacs) and C-z (minimize Emacs). Both of them are too easy to press by mistake, especially C-z, which is undo in many other programs. If I had a penny for each time I minimized Emacs by mistake… When we want to minimize Emacs (and why would you want to do that? Emacs deserves a prominent space on your screen), we can just do it by clicking the minimize window itself, shamefully using our mouse, as we do with other apps. And Exiting Emacs? With a shortcut that seems like it fits somewhere in org-mode? No thanks. Let’s disable those:
(global-unset-key (kbd "C-x C-c"))
(global-unset-key (kbd "C-z"))
Turn off the annoying error beep, which I first discovered in SUSE Linux by turning on a visual warning (a flash) instead. This will flash the top and bottom lines of our window instead of going “beep!”
(setq visible-bell t)
Turn on visual line mode so text lines “wrap” inside the frame and don’t continue beyond the window’s edge. This is essential; I can’t read in Emacs without it. And a newcomer I discovered recently: since Emacs 30, we also have global-visual-wrap-prefix-mode, which preserves indentation on wrapped lines. For example, in a list in org-mode (made of dashes one under the other), a long line of text that wraps will align under its starting point (dash) in the list instead of jumping back to column 0 (the start of the window, to the most left). This has been a huge pet peeve. Finally!
(global-visual-line-mode t)
(global-visual-wrap-prefix-mode t)
Winner mode (included in Emacs) is sort of “undo” for changes in windows’ layout in Emacs. C-c ← goes back to our previous setting, and C-c → will “redo” the layout we just left. I use it all the time as in “oops, I closed the wrong window”3.
(winner-mode t)
Saw this over at https://emacsredux.com/blog/2026/04/07/stealing-from-the-best-emacs-configs/. This is a nice little trick, and it requires a bit of reading to understand what exactly it does: preventing Emacs from deleting whatever we have in the system’s clipboard when we kill a line, so it’s still in the kill ring. Here’s an example to help you grasp the idea and why it’s useful:
- We’re visiting a website with our default browser and copy its URL because we want to write about it in Emacs
- We go to Emacs, and we kill the line we’re on because we need some space
- Crap! Now we lost our paste in the clipboard, and we have to go back to the browser and grab that URL again!
- Wait, which tab was it? Did we close it? Should we look in our browsing history? Ugh!
Not anymore! With this little guy, when we kill the line (step 2 above), Emacs “injects” it into the kill ring. Now, when we yank with C-y, we will still get the last line we killed, yes, butlook up the kill ring with M-y and voilà! Your URL is there. No need to go find that URL again:
(setq save-interprogram-paste-before-kill t)
You know how for years Emacs “jumped” when you scrolled down large embedded images in your org buffers? Let’s turn on pixel-scroll-precision-mode for pixel scrolling instead of the default line scrolling to fix this. It’s pretty much what it reads: the default old way would “scroll” (it’s actually not scrolling at all) by a line of text at a time. Since our image of, say, 600px in height is treated as a single line of text, it will jump to the end of it. With this option turned on, Emacs would read the pixels from your mouse wheels as you scroll, and we get the smooth scrolling we’re used to.
Interesting to know: moving up and down the line without a mouse (arrows, or C-p and C-n) is moving by text lines, utilizing auto-windows-vscroll and line-move, which basically does in Emacs what arrow movement seems to be doing in modern applications: these apply this principle from the other direction — they natively work with pixels, so they treat these arrow movements as a fixed number of pixel movements, which is approximately a line of text. So, when you move up and down a large image (or say a PDF) in a browser, the browser thinks “ok, the user is moving up one line of text, which is.. hm.. let’s see… ah, it says it’s exactly 40 pixels, so let me show that”.
(pixel-scroll-precision-mode t)
Footnotes
In fact, if you’re curious about help and Emacs help, I suggest you head over there now and read that post. It expands on how to approach Emacs help by how to think Emacs, which is something that experienced Emacs users struggle to explain to newcomers. I know, because I was there, and I’m sure many of you who are new to Emacs just shake your head.
As for the history of help in Emacs, I think it’s pretty safe to say it’s been there since the start, or at least since Emacs became intended for public use, sometime around the 1980s. By that point, most of the core help parts we know today (the tutorial, C-h t; the Emacs Manual, C-h R; as well as the framework itself) were already in place. The help system was there before GNU Emacs, back in the days of TECO Emacs that RMS worked on at MIT in the 1970s. You could browse the original code from then (preserved by MIT) and see Stallman writing what certain commands do in emacs.doc inside that repository. Another interesting find about Emacs itself (and the help system that comes with it) is the EMACS paper written by RMS back in 1981. For the help system, take a look at page 17: “6. Self-Documentation and Extensibility” and the following chapter in page 18: “7. History”. Fascinating stuff.
Emacs is the editor of tinkerers and artisans; those who are eternally dissatisfied with all other tools because of their adamantine rigidity. Crafting, or shaping, your tools to meet your exacting needs is what Emacs excels at. Because of that, Emacs is – much to the chagrin of everyone who picks it up for the first time – squarely aimed at people who already know Emacs.
In fact, if you’re curious about help and Emacs help, I suggest you head over there now and read that post. It expands on how to approach Emacs help by how to think Emacs, which is something that experienced Emacs users struggle to explain to new comers. I know, because I was there, and I’m sure many of you who are new to Emacs just shake your head.
As for the history of help in Emacs, I think it’s pretty safe to say it’s been there since the start, or at least since Emacs become intended for public use, sometime around the 1980s. By that point, most of the core help parts we know today (the tutorial, C-h t; the Emacs Manual, C-h R; as well as the framework itself) were already in place. The help system was there before GNU Emacs, back in the days of TECO Emacs that RMS worked on at MIT in the 1970s. You could browse the original code from then (preserved by MIT) and see Stallman writing what certain commands do in emacs.doc inside that repository. Another interesting find about Emacs itself (and the help system that comes with it) is the EMACS paper written by RMS back in 1981. For the help system, take a look at page 17: “6. Self-Documentation and Extensibility” and the following chapter in page 18: “7. History”. Fascinating stuff.
-
And here, dear reader, I fell down a deep rabbit hole, one that pushed this post a couple of days. There are two parts to this. The Emacs part, which I will explore at some point in the near future, has to do with Emacs’ menu itself, which is controlled by
easymenu.el. This is an old Emacs package that’s been around since 1994, written by RMS himself — kind of. It was first created by Per Abrahamsen (who seems to be a bit of a mystery, but that’s digging for another day). In turn, this package was taken fromlmenu.el, which was part of yet a different Emacs fork at the time. In a regular Emacs style, the menu bar can be completely reconstructed and changed — and that’s something I want to explore soon as a way to recall useful functions I keep forgetting exist (like having an “organize” menu with something like “org-sort” under it). This will be a fun project of its own for another day. Meanwhile, the other, bigger rabbit hole is the story of the GUI menu itself as we have it today. Apple has a big role here, back in the days before Steve Jobs left Apple and worked on the Lisa. This seems to be the first usage of a graphical interface in personal computers, and the menu, which was taken from Xerox, was a big part of it (there’s a short YouTube video there that would give you a quick brief of what happened). This means that I am right on keeping the menu in theme with the rest of the Mac apps, based on history! ↩︎ -
Emacs’ built-in help deserves its own series of posts. Looking at it now, from the eyes of someone who used it for a couple of years, I find Micky’s description satisfying and accurate, reflecting what I felt at the time: ↩︎
-
I forget how exactly, but some research into
winner-modehistory (turns out it’s been around since 1997 — also, a lot of goodies here to look into!) led me down the path of tabs in Emacs,tab-barin particular. I didn’t think much about tabs in Emacs, but since I’ve been using Kubuntu for a while and experimented with its Workspaces, I understand the concept better. I looked into BSAG’s post, and it looks like you can hide the tabs while still displaying them on the mode line, and of course, you don’t have to use the mouse. The concept of having a whole workplace completed with its unique window arrangement available with a single keyboard shortcut is alluring. Now, instead of playing around with where and how I want my windows to display, I can just save (or re-create) those, and I always have a “work” environment vs a “personal” environment within the same Emacs frame. This can be a good organizational feature. I’m going to dig more into this one. ↩︎