10

I have a emacs-lisp block in org-mode and when I try to edit it by press C-c ', flycheck always report errors as below:

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)
1     warning         You should have a section marked ";;; Code:"... (emacs-lisp-checkdoc)

How could I turn it off when edit it source block?

Enze Chi
  • 1,410
  • 12
  • 28

1 Answers1

18

tl;dr

Disable the checker emacs-lisp-checkdoc with the org-src-mode-hook.

(defun disable-fylcheck-in-org-src-block ()
  (setq-local flycheck-disabled-checkers '(emacs-lisp-checkdoc)))

(add-hook 'org-src-mode-hook 'disable-fylcheck-in-org-src-block)

Detailed walkthrough how to find this information

First search for possible variables which change the behaviour of Flycheck. There are several ways to do this:

  • Use M-x describe-variable.

  • If there are a lot of them then M-x customize-group <package> RET is always a good place to look up common candidates.

  • A third way would be to use M-x apropos-documentation which searches the dosctrings of all symbols in Emacs.

  • Yet another way to find information would be to look up if there is an info page for the package. In case of Flycheck there is. M-x info. Use M-x Info-menu to jump to desired Info page and search around there.M-x Info-index and M-x Info-search are useful for this.

I would highly recommend to use a completion framework like helm, ido, icicles or any other because with enhanced minibuffer completion the methods above a far more convenient.

In this case after some digging and trying out the methods above one may find:

> Flycheck Disabled Checkers:
  Syntax checkers excluded from automatic selection. 

Ok now we know the variable we want to change. We only want to change it when editing source blocks in org-mode. If you check M-x describe-mode and look for an enabled minor-mode that starts with org you will find:

Org-Src minor mode (no indicator):
Minor mode for language major mode buffers generated by org.

Know that we know the mode we search for a hook for this mode. As almost always it is just a -hook appended to the mode name: org-src-mode-hook.

Most of the time there are multiple methods in Emacs to do stuff. I hope this helps beginners, I know how I was lost in the beginning. Don't be intimidated, when you use the techniques above several times you don't think about it anymore.

clemera
  • 3,401
  • 13
  • 40