27

If flycheck-mode is enabled for my init.el, I got the following kinds of errors:

The first line should be of the form: ";;; package --- Summary" (emacs-lisp-checkdoc)
...
The footer should be: (provide 'init)\n;;; init.el ends here (emacs-lisp-checkdoc)

How can I stop flycheck from treating my init.el as a package?

EDIT

I tried to following minimal start up file:

;; flycheck-mode
(require 'flycheck)
(global-flycheck-mode)

(setq-default flycheck-disabled-checker '(emacs-lisp-checkdoc))

Only flycheck and its dependencies are enabled. emacs-lisp-checkdoc is in the disabled checker list but flycheck still lists errors:

0     warning         The first line should be of the form: ";;; package --- Summary" (emacs-lisp-checkdoc)
0     warning         You should have a section marked ";;; Commentary:" (emacs-lisp-checkdoc)
2   1 error           Cannot open load file: no such file or directory, flycheck (emacs-lisp)
3     warning         You should have a section marked ";;; Code:" (emacs-lisp-checkdoc)
5     warning         The footer should be: (provide 'test)\n;;; test.el ends here (emacs-lisp-checkdoc)

I'm using Emacs 24.5.1 and the latest flycheck in the git repository (26snapshot).

3 Answers 3

15

Add emacs-lisp-checkdoc to flycheck-disabled-checkers:

(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
11
  • It doesn't work for me... same errors.
    – xuhdev
    Apr 17, 2016 at 19:03
  • @xuhdev What's the result of C-h v flycheck-disabled-checkers in an Emacs Lisp buffer?
    – user227
    Apr 17, 2016 at 19:19
  • "flycheck-disabled-checker's value is (emacs-lisp-checkdoc)"
    – xuhdev
    Apr 17, 2016 at 20:10
  • 6
    This will disable the emacs-lisp checker entirely, right? There are a lot of useful things the checker does, but the one in the example is not one of them. It would be nice if there was a way to get the good flycheck errors without the unwanted ones.
    – zck
    Apr 18, 2016 at 3:38
  • 1
    @zck There is none, unfortunately. checkdoc does not provide sophisticated warning control that lets you disable specific warnings. You can at best write a custom flycheck-process-error (or so, don't remember the name) function to suppress highlighting of these errors, but they'll always appear in the error list.
    – user227
    Apr 18, 2016 at 7:09
12

Here's the format that the checker is actually expecting:

;;; init.el --- Initialization file for Emacs
;;; Commentary: Emacs Startup File --- initialization for Emacs

If you place this at the top of your init.el it'll remove the warning.

You can get emacs to insert this for you automatically by going to the menu and selecting Emacs-Lisp->Check Documentation Strings and fill in the requested fields. Source: https://github.com/purcell/emacs.d/issues/152

2
  • 6
    or M-x checkdoc Jan 8, 2020 at 13:08
  • Yeah this is what I've been looking for. No more trying to fill in the comments until flycheck stops being angry with me!
    – gypsydave5
    Jul 1, 2021 at 10:44
3

The answer by @mpettigr is mostly correct, the given lines will satisfy flycheck for the file header (except that flycheck expects a newline after Commentary:).

Especially if you start a new elisp file, you could also use the header snippet for the yasnippet template package, instead of choosing Emacs-Lisp > Check Documentation Strings from the menu. This snippet expands to the following code to which also adds the required last line ;;; foo.el ends here to your file:

;;; foo.el --- Some summary -*- lexical-binding: t -*-

;; Author: quazgar
;; Maintainer: quazgar
;; Version: version
;; Package-Requires: (dependencies)
;; Homepage: homepage
;; Keywords: keywords


;; This file is not part of GNU Emacs

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.


;;; Commentary:

;; My commentary

;;; Code:

(message "Hello World!")

(provide 'foo)

;;; foo.el ends here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.