2024-07-22 New things in new Emacs

Some time ago I wrote about a few new things in Emacs 29. Well, even though Emacs 30 is not out yet, I use Emacs compiled from source on the master branch, and while I do not compile a new version very often, I still have a version newer than what my distro offers. (Well technically, Arch has the emacs-git package, but I am so accustomed to have my own Emacs sources that I can see no point in using that.)

So, I went through the NEWS.30 in my Emacs Git repo, and – as usual – found a few gems. For example, advice-remove is now a command, it shows a list of functions which have an advice added, and when you select one of them, it shows a list of advices and lets you select one. (Of course, this is because I have ivy installed – with vanilla Emacs it just uses the default completion mechanism. But from what I’ve heard, the default completion is getting better all the time, and it probably can also be configured to show a list etc.)

It turns out that some of my personal customizations may no longer be needed – for example, Emacs now has 'kill-ring-deindent-mode, which mostly supersedes my own copy-snippet-deindented command.

You can now give a regex and a replacement, and instead of applying the replacement interactively like query-replace-regexp does, see a diff of the changes you would have made and – for example – apply individual hunks (M-x replace-regexp-as-diff). This may be very useful to review and selectively apply complex changes.

There is a lot of new functionality for keyboard macros. One area that got improved is keyboard macro counters, which can now be e.g. compared to registers and conditionally incremented if smaller or greater than the registers’ contents, or copied to and from registers. I don’t have (yet?) any idea about how this could be useful, but here’s another great thing: you can now see a list of all keyboard macros and use it to inspect and edit them, their counters etc. This seems an extremely useful thing if you happen to use keyboard macros often!

There are numerous other changes – I strongly advise you to look through your NEWS file every time you upgrade your Emacs – but I saved the one I may like the most until now. I mentioned last time that Emacs 29 introduced the Info-goto-node-web command (bound to G in Info by default), opening the current node in a browser. I mentioned then that
As of now, it lacks two things: it only works in the Emacs manual and the Elisp reference (and it really should work in the Org manual and in Chassell’s An Introduction to Programming in Emacs Lisp!), and it doesn’t do anything special with a prefix argument (and it definitely should put the link on the kill ring then).
and voilà: the former is now corrected, and it works in over 60 manuals! As for the latter, well, it’s not difficult to write a quick-and-dirty solution:

(defun Info-copy-url-to-kill-ring (&rest ignored)
  "Copy the URL of the current node to the kill ring."
  (when current-prefix-arg
    (kill-new (Info-url-for-node
               (format "(%s)%s"
                       (file-name-sans-extension
                        (file-name-nondirectory
                         Info-current-file))
                       Info-current-node)))))

(advice-add 'Info-goto-node-web
            :after
            #'Info-copy-url-to-kill-ring)

That’s it for today!

CategoryEnglish, CategoryBlog, CategoryEmacs