(redirected from Homepage)

Strona domowa

Witam na mojej prywatnej stronie internetowej!

[If this is all Polish to you, click here: English]

Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.

Marcin ‘mbork’ Borkowski

2026-05-09 describe-personal-keybindings

Some time ago one Emacs user made themselves a local web app showing various Emacs keybindings – basically, a web-based Emacs cheatsheet. It’s definitely a nice project even if not for me – if I were to create something like that, it would run in Emacs and not in the browser, it would definitely mention transpose-.* commands, and it would never be dark-mode-only;-). But it’s a really cool and nice project nevertheless!

That’s not the topic of this post, however. In a Reddit discussion about this tool someone mentioned a command that blew me away: describe-personal-keybindings. It is part of the use-package package (which has been part of core Emacs for quite some time now), and it’s purpose is to show, well, all personal bindings of the user.

I ran it in my Emacs (of course), and I was a little disappointed – it only showed less than a dozen keybindings. Surely I have more of them in my init.el! I started to dig a bit and it turned out that in order to see a keybinding in its output, I must use the bind-key macro (only briefly mentioned in the manual). I have to admit that I don’t use use-package much – a good part of my init.el predates its existence, and probably most of my init.el predates its inclusion into Emacs, and frankly I don’t update my init.el whenever Emacs introduces new ways of configuring itself. (For example, some time ago Emacs 29 introduced keymap-set, and I only learned about it recently – thus I have more instances of define-key than of keymap-set in my init.el.) I might convert most of them to bind-key though, since a list of all personal bindings is a very cool thing to have. It’s especially useful because it tells you whether your keybinding overwrote any preexisting one. This means that when one of the keys you have used in your personal bindings, previously unbound, is bound to something in a newer version of Emacs, you can learn about it and decide whether to keep the binding or not.

It’s even better than this, though. The bind-key macro (and its friends) can do more things. See the source to learn more. For example, there is the bind-key* macro, which is “stronger” than bind-key in the sense that it overrides any minor modes which might bind a given key. There is also unbind-key (with obvious semantics) and bind-keys​/​bind-keys* which allow to bind many keys at once.

I have to admit that discovering this package was one of the things that made me decide to refactor my init.el to use use-package and :bind (which uses bind-keys under the hood) more. This change, along with what I wrote a year ago, would be another way of solving the problem of defining some personal settings in my init.el and then forgetting about them. (Although I think that the best way to solve that issue is to add things to init.el very slowly and examining whether they are genuinely useful.)

That’s it for today, until next time!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

More...