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).

xuhdev
  • 1,839
  • 13
  • 26

3 Answers3

15

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

(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
  • It doesn't work for me... same errors. – xuhdev Apr 17 '16 at 19:03
  • @xuhdev What's the result of C-h v flycheck-disabled-checkers in an Emacs Lisp buffer? –  Apr 17 '16 at 19:19
  • "flycheck-disabled-checker's value is (emacs-lisp-checkdoc)" – xuhdev Apr 17 '16 at 20:10
  • I tried to put that line before and after `(global-flycheck-mode)` but neither works. – xuhdev Apr 17 '16 at 20:12
  • 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 '16 at 03: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. –  Apr 18 '16 at 07:09
  • @xuhdev Can you please edit your question to add a minimal example that shows how to produce this error despite this setting? The setting should really disable checkdoc and this remove this warning; if it doesn't that'd be a bug in Flycheck. –  Apr 18 '16 at 07:12
  • @lunaryorn Question updated. – xuhdev Apr 20 '16 at 00:12
  • @zck The best thing I can think of is to make `flycheck-disabled-checker` a buffer local variable in the `init.el` buffer... – xuhdev Apr 20 '16 at 00:14
  • @xuhdev It's flycheck-disabled-checkers (plural). Sorry I had a typo in my answer. –  Apr 20 '16 at 06:47
  • Reading doc for flycheck-disabled-checkers reveals that it is buffer local. So, setting it in one place may not set it the buffer you need it set it. That's why setq-default is used above, but that won't rebind buffers that already have buffer local binding. – Ben Hyde Sep 27 '19 at 17:34
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

mpettigr
  • 121
  • 1
  • 2
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
quazgar
  • 341
  • 1
  • 11