3

I am trying to make flycheck run locally for Python files, but not have flycheck run when working with python files on a remote machine. I have the problem that flycheck slows down saving and it seems to send a second file that sometimes ends up freezing up emacs. I wrote the two functions below but it doesn't seem to work correctly. I want it to disable fly-check if it is a remote file (connected through tramp) or enable flycheck-mode for all other python files. Currently, it just enables flycheck mode for all files.

(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'jj/flycheck-mode))
(defun jj/flycheck-mode ()
  "Don't enable flycheck mode for remote buffers."
  (interactive)
  (if (file-remote-p default-directory)
      (flycheck-mode nil)
    (flycheck-mode t)))

Any way to fix this script? Or another approach?

J Spen
  • 2,614
  • 4
  • 26
  • 41
  • @Drew Updated. I expected it to not enable flycheck over tramp in python-mode, but it still enables flycheck over tramp in python-mode and enables flycheck on local files. – J Spen Jun 28 '20 at 18:26
  • Did you try to use the Elisp Debugger to understand what's going wrong? – viam0Zah Jul 13 '20 at 10:45

1 Answers1

0

To fix this script just replace (flycheck-mode nil) by (flycheck-mode -1).

nil
  • 1