I am trying to disable a minor mode (flycheck) for the latex major mode. This is what I have so far.

(defun disable-flycheck-in-tex-src-block ()
  (flycheck-mode -1))

(add-hook 'latex-mode-hook 'disable-flycheck-in-tex-src-block)

However, after I put this into my init.el, flycheck is still enabled when I open a .tex file.

I am using Steve Purcell's emacs configuration here:


I have added the disable code into lisp/init-local.el, which I thought runs after all the default configuration.

As far as I can tell,

in the init.el, there is a

(require 'init-flycheck)

Then there is a file called lisp/init-flycheck.el, that looks like this:

(when (maybe-require-package 'flycheck)
  (add-hook 'after-init-hook 'global-flycheck-mode)

  ;; Override default flycheck triggers
  (setq flycheck-check-syntax-automatically '(save idle-change mode-enabled)
        flycheck-idle-change-delay 0.8)

  (setq flycheck-display-errors-function #'flycheck-display-error-messages-unless-error-list))

(provide 'init-flycheck)
  • 1
    Show us how you are enabling flycheck-mode -- it wouldn't be getting enabled unless you've asked for it, and obviously the order is important...
    – phils
    Mar 18, 2016 at 1:00
  • Ok I have added a description of where flycheck is enabled.
    – bkmoney
    Mar 18, 2016 at 1:13
  • 1
    Right, you're using a globalized mode. That explains your problem. This is a duplicate of stackoverflow.com/questions/6837511/…
    – phils
    Mar 18, 2016 at 1:37
  • That said, I think flycheck is exceedingly unlikely to offer a globalized minor mode without also providing mechanisms to control the buffers for which it will enable flycheck-mode, because it's just not sane for flycheck to run everywhere. So I suspect you'll find a clean solution in flycheck itself. Check its documentation.
    – phils
    Mar 18, 2016 at 1:42

2 Answers 2


As per comments, this is because you're using a globalized minor mode: https://stackoverflow.com/questions/6837511/automatically-disable-a-global-minor-mode-for-a-specific-major-mode

C-hf global-flycheck-mode led me to
C-hf flycheck-may-enable-mode and
C-hv flycheck-global-modes which tells me:

flycheck-global-modes is a variable defined in `flycheck.el'.
Its value is t

  This variable may be risky if used as a file-local variable.

Modes for which `flycheck-mode' is turned on by `global-flycheck-mode'.

If t, Flycheck Mode is turned on for all major modes.  If a list,
Flycheck Mode is turned on for all `major-mode' symbols in that
list.  If the `car' of the list is `not', Flycheck Mode is turned
on for all `major-mode' symbols _not_ in that list.  If nil,
Flycheck Mode is never turned on by `global-flycheck-mode'.

Note that Flycheck is never turned on for modes whose
`mode-class' property is `special' (see Info node `(elisp)Major
Mode Conventions'), regardless of the value of this option.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 0.23 of the flycheck package.

So while it's not too flexible, if your current value is t then the following is what you need to exclude only these specific modes:

(setq flycheck-global-modes '(not LaTeX-mode latex-mode))
  • I have done this, but flycheck is still enabled. Doing C-h v, I get "flycheck-global-modes is a variable defined in `flycheck.el'. Its value is (not LaTeX-mode) Original value was t "
    – bkmoney
    Mar 18, 2016 at 2:07
  • 1
    I'm guessing it's actually latex-mode rather than LaTeX-mode, then. I've updated the answer to cover both.
    – phils
    Mar 18, 2016 at 2:19
  • You're welcome. The list at the end of emacs.stackexchange.com/a/20915 might also help to clarify matters.
    – phils
    Mar 18, 2016 at 2:41
  • 1
    Can every Emacs SE answer show the process of how the correct answer was found as you demonstrated here? Wish I could +10 this
    – haff
    Nov 13, 2017 at 17:46

The variables are CaSe-SeNsItIvE.


(add-hook 'LaTeX-mode-hook #'disable-flycheck-in-tex-src-block)

I figured out that exact hook name by doing C-h v followed by checking what was available..

  • Is there supposed to be a # there? I tried changing the case and it is still not working.
    – bkmoney
    Mar 17, 2016 at 22:36
  • That # is optional. Look up online on "elisp sharp quote" convention for function symbols. Mar 17, 2016 at 22:37
  • Ok any idea why flycheck is still enabled?
    – bkmoney
    Mar 17, 2016 at 22:39
  • Also, when i do describe mode, I see that "Entering Latex mode runs the hook text-mode-hook, then tex-mode-hook, and finally latex-mode-hook. When the special subshell is initiated, tex-shell-hook' is run." Thats why I put latex-mode-hook instead of LaTeX-mode-hook.
    – bkmoney
    Mar 17, 2016 at 22:44
  • latex-mode is the stock emacs LaTeX mode. LaTeX-mode is the LaTeX mode from GNU AUCTeX, so it depends on what you are using. Mar 20, 2016 at 19:23

Your Answer

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

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