Installing Emacs packages from GitHub

2025-12-12

Recent versions of Emacs include a new :vc keyword for the use-package macro that allows you to install packages from a version control repository. I had heard of this but hadn’t actually used it before this week, when I found a very small package called hide-comnt.el on the Emacs Wiki. This package was so small and apparently unmaintained1 that I decided to fork the mirror I found on GitHub and install my version instead of trying to find it on elpa or melpa.

My first attempt at using :vc looked something like this:

(use-package hide-comnt
  :vc
  (hide-comnt
   :url "https://github.com/ntBre/hide-comnt"))

Evaluating this immediately installed the package, and I was able to give it a try by running the interactive hide/show-comments function. But my excitement was short-lived. I quickly realized that several of the autoload functions and variables, namely hide-whitespace-before-comment-flag, were missing. After a somewhat embarrassingly long time debugging, I went to the git repo in ~/.emacs.d/elpa/hide-comnt and saw that the commit that package-vc had installed was not the most recent commit. Macro-expanding my use-package invocation quickly revealed the problem:

(progn
  (use-package-vc-install
   '(hide-comnt (:url "https://github.com/ntBre/hide-comnt") :last-release) nil)
  (defvar use-package--warning65
    #'(lambda (keyword err)
        (let
            ((msg
              (format "%s/%s: %s" 'hide-comnt keyword (error-message-string err))))
          (display-warning 'use-package msg :error))))
  (condition-case-unless-debug err
      (if (not (require 'hide-comnt nil t))
          (display-warning 'use-package (format "Cannot load %s" 'hide-comnt)
                           :error))
    (error (funcall use-package--warning65 :catch err))))

Note the extra :last-release keyword in the hide-comnt list. This default setting tries to install the latest release from the repository rather than the latest commit, so even adding the :branch keyword, which I had also tried, was not helping. I’m still not sure how package-vc chose this specific commit because it checked out the 17th commit backwards from master and the 8th commit from the start of the history, despite hide-comnt not having any tags or releases. My best guess without reading the code is that it picked the last commit in an arbitrary search range.

Anyway, the solution was to pass :rev :newest instead of :last-release, giving this final invocation:

(use-package hide-comnt
  :vc
  (hide-comnt
   :url "https://github.com/ntBre/hide-comnt"
   :branch "master"
   :rev :newest))

I think I’ll definitely be using this in the future, now that I resolved this point of confusion about the default version!


  1. Not that such a small package needs to be maintained. Based on my usage this week, I think it’s a “finished” package and doesn’t need maintenance. But that makes it an even better candidate to fork and avoid the chance of future unexpected updates.↩︎