I'm trying elint for the first time, because I just learned that it reports things that bytecode compiling doesn't.

Mainly it is showing me a few missing requires, which I'm adding.

Only a tests.el is giving many warnings and errors. Distilled example:

(require 'ert)
(ert-deftest my/test ()
  (should t))

elint-current-buffer reports:

In top level expression:
tests.el:2:Warning: Reference to unbound symbol: my/test
tests.el:2:Error: Call to undefined function: should

I figured it might have something to do with macro evaluation. And indeed this makes elint happy:

  (ert-deftest my/test ()
    (should t)))

However. I've never seen anyone do this. (Not that I've read all Elisp ever written. But I've looked at a fair amount, and even tried a quick GitHub search. I also didn't see any discussion of this in ert or elint docs/comments.)

Practically speaking, should I bother to do this?

(I realize "the value of linting" is probably an opinion-based question, which is no good. That's not my intent. I'm looking for practical advice from experienced Elisp programmers -- what sort of problems will I have from either using or not using eval-when-compile here?)

  • 1
    Does your original code also have an extra parenthesis in the require line? Provided it's not, my guess would be that lint has a "strange" way of discovering what macros are available and at what time. What would happen if instead of defining the test at compile time you instead required ert at compile time?
    – wvxvw
    Apr 15 '15 at 12:56
  • 1. Sorry, (require 'ert)) was a copy-pasta typo. 2. Yes, (eval-when-compile (require 'ert)) seems sufficient; I can remove the eval-when-compile wrapper from all the ert-deftest forms. Apr 15 '15 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.