Emacs Redux: which-key is Now Built-in

Wait 5 sec.

which-key is one of those packages I recommend to pretty much everyone -newcomers and grizzled Emacs veterans alike. You start a key sequence likeC-x, pause for a moment, and it pops up a handy cheat sheet of every key thatcan follow. I’ve had it in my config for ages, and I suspect a lot of you haveas well.Here’s the good news - as of Emacs 30 you don’t need to install it anymore.which-key is now a built-in package, so there’s one less thing to fetchfrom MELPA when you set up Emacs on a fresh machine.Enabling which-keyBeing built-in doesn’t mean it’s enabled by default, though. You still have toturn it on explicitly:(which-key-mode 1)That’s the whole setup for most people. Now start any prefix key - C-x,C-c, C-h - wait a moment, and a popup appears at the bottom of the framelisting every binding under that prefix.Here’s what I get when I press C-c p, the prefix forprojectile’s command map:Instead of straining to remember whether it’s C-c p f or C-c p s s, I justpause and Emacs reminds me. Projectile has a lot of commands, so which-keyeven paginates them - notice the 1 of 3 in the bottom corner.ConfigurationThe defaults are sensible, but here are the knobs I reach for most often:;; show the popup faster (the default is a full second)(setq which-key-idle-delay 0.5);; where the popup shows up;; options: side-window (default), minibuffer, frame, custom(setq which-key-popup-type 'side-window);; and where that side window sits;; options: bottom (default), top, left, right(setq which-key-side-window-location 'bottom)I like a slightly snappier delay, but otherwise the stock configuration servesme just fine.which-key and TransientPeople sometimes ask me how which-key relates toTransient - the menu library that powersMagit’s famous popups. The two look superficially similar (both drop a bunch ofkeys and descriptions at the bottom of your frame), but they solve ratherdifferent problems.which-key is a passive, automatic reminder. It doesn’t really know anythingabout your commands - it simply reads whatever keymap you happen to be in andshows you what’s there. You get it for free, across every prefix in Emacs, withzero per-keymap work.Transient is an interactive command builder. You design a transientdeliberately, for a particular workflow, and unlike which-key it can hold state toggle switches on and off, accumulate arguments - before finally running acommand with all of that baggage attached.Projectile happens to ship both, which makes for a nice side-by-side. TheC-c p keymap you saw above is a plain keymap - which-key displays it and thengets out of the way. But Projectile 3.0 also added projectile-dispatch (boundto C-c p m), a Transient menu that mirrors the very same command map:Notice the Modifiers section at the top - those are switches you flip beforepicking a command. Want your next search to be case-sensitive, or your nextfile lookup to invalidate the cache first? Toggle -c or -i, then press thecommand key. That’s something a plain keymap (and therefore which-key) simplycan’t do.So the way I see it - reach for which-key as an always-on safety net for thethousands of bindings scattered across Emacs, and reach for Transient whenyou’re building a polished, self-contained command center for a specific task.They’re complementary, and there’s no reason not to run both. In fact, if youuse Magit or Projectile (or a dozen other modern packages), you’re alreadyusing Transient whether you realized it or not.But wait, what about C-h?Long-time Emacs users might point out that you’ve always been able to pressC-h after a prefix key to see the available bindings. That’s true! Thedifference is that which-key does it automatically, no extra keypressrequired - which makes it far more discoverable, especially for newcomers.And the two don’t step on each other. C-h after a prefix still works andgives you the traditional describe-bindings buffer, which you can scroll andsearch to your heart’s content. Think of which-key as the quick glance andC-h as the full reference.Closing ThoughtsI’ve been a happy which-key user for years, and having it in the box means oneless package to install and keep updated. If you’ve somehow never tried it, doyourself a favor and flip it on - it’s the kind of small quality-of-life featureyou stop noticing precisely because it’s always quietly helping you.Do you keep which-key on all the time, or do you prefer to lean on C-h? Andhave you started building your own Transient menus yet? I’d love to hear aboutit in the comments.That’s all I have for you today. Keep hacking (and let Emacs remember the keysfor you)!