2021-06-14 New behavior of yank-pop

I have another short Emacs tip for today. Quite recently (well, in November 2020, which – given the scale of Emacs history – is pretty recently, but I only learned that a few weeks ago or so) the yank-pop command (bound to M-y by default) acquired a very cool new feature. Its main use is (and has been for decades) to cycle through the kill-ring right after the yank command (C-y). It was one of the things that made Emacs a sophisticated editor and not a toy. Of course, M-y did nothing if pressed not immediately after C-y or another M-y, since what it could do then?

Well, it’s obvious, isn’t it? It could – and now it does – something really cool. It shows the minibuffer and lets you type the text to be yanked there. This sounds pretty useless unless you realize that it fills the minibuffer history with the contents of the kill ring. This is great even with stock Emacs completion engine, but it’s even better with Ivy (which I happen to use), since I can just C-n​/​C-p through the recent kills and select the one to yank.

Quite frankly, I can’t believe nobody thought about this years ago. Now that we have it (kudos to Juri Linkov for coding it) it feels so natural. This shows that text editing is far from a solved problem – there may be still pretty basic things we haven’t figured out yet. (And I hope that I will have something about that to add here in a few weeks, too.)

By the way, that almost makes the browse-kill-ring package obsolete. The “almost” comes from the fact that browse-kill-ring allows you to e.g. delete things from the kill ring, which is very useful with passwords. In fact, that package – contrary to what its name suggests – allows the user to manipulate the kill ring in quite a few ways. Check it out if you use the kill ring and wish for it to be a little more flexible.

Anyway, that’s it for today. See you next week!

CategoryEnglish, CategoryBlog, CategoryEmacs