2021-01-04 Current Emacs commit revisited

Almost four years ago I described a simple command to insert the current Emacs version at point, together with the commit hash taken from the repo.

Guess what? A few days ago I found a bug in it. Here’s the problem: the emacs-repository-get-version function goes to the Emacs source Git repo and just takes the commit hash of the HEAD, which (obviously) may be very different from the value it had during compilation.

Of course, this is Emacs, so the problem is solvable (and in fact, solved) – there is a variable which holds the commit hash, and a second one which holds the branch name current during compilation. They are called emacs-repository-version and emacs-repository-branch respectively.

So, to make the command I defined in 2017 work, you’d need to change it into this:

(defun insert-debug-version-info ()
      "Insert version of Emacs and 7 characters of the commit hash."
       (format "GNU Emacs %s (commit %s)"
	       (substring emacs-repository-version 0 7))))

CategoryEnglish, CategoryBlog, CategoryEmacs