(or emacs irrelevant)

New in Emacs - run checkdoc in batch mode

More checkdoc goodness

If you're doing some Elisp coding, you should definitely check out the built-in checkdoc command. Too bad it's (was) interactive-only. With a small modification, I've made it suitable for batch.

You can check out how I did it in the avy (or lispy) repository. Here's my compile target in the Makefile:

emacs ?= emacs

compile:
    $(emacs) -batch -l targets/avy-init.el

And here are the contents of avy-init.el:

(add-to-list 'load-path default-directory)
(mapc #'byte-compile-file '("avy.el"))
(require 'avy)
(require 'checkdoc)
(with-current-buffer (find-file "avy.el")
  (checkdoc-current-buffer t))

I made compile target a dependency of the all target, so with a single make I can:

  • run the tests
  • check for compiler warnings
  • check for checkdoc style warnings

compile over ansi-term

There's no reason to use ansi-term (or an external shell) over compile in this case. Using M-x compile (or actually M-x helm-make) I can navigate to any compilation or style warning or failed test from the *compilation* buffer.

For the lazy, it's possible to jump to errors with a mouse, but navigating errors is a breeze with this Hydra:

(defhydra hydra-error (global-map "M-g")
  "goto-error"
  ("h" first-error "first")
  ("j" next-error "next")
  ("k" previous-error "prev")
  ("v" recenter-top-bottom "recenter")
  ("q" nil "quit"))

There is also ace-link-compilation, but I tend not to use it often.

I make good use of one of the coolest compilation-mode features: pressing g will restart the compilation process.

Outro

Check out the new feature, I think it's really cool. Another incentive to try is that lately the emacs trunk has been extremely stable: I'm on Emacs25 almost all the time now, since it feels a lot faster.

Here are my aliasing settings:

$ which newemacs
/usr/local/bin/newemacs
$ readlink -f `which newemacs`
/home/oleh/git/gnu-emacs/src/emacs

To run the tests with newemacs instead of emacs (since that's the one for which checkdoc works in batch), use M-x setenv -> emacs -> newemacs.