1

I often use rgrep to find files I need to change and then a macro to go through these files, do the change and save it. It's a very neat flow with one downside: I have prettier check each file on save and flycheck (using eslint) also goes absolutely crazy and maxes out my CPU.

So I wondered, if there is any good way to globally (as my macro visits a lot of files) disable temporarily (as I want these modes after the macro finished) certain modes, most importantly flycheck?

I didn't find anything related, any ideas on how this could be done?

EDIT:

This is how I load flycheck e.g. in rjsx-mode:

;; disable jshint since we prefer eslint checking
(setq-default flycheck-disabled-checkers
              (append flycheck-disabled-checkers
                      '(javascript-jshint)))

;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
              (append flycheck-disabled-checkers
                      '(json-jsonlist)))


;; use eslint with web-mode for jsx files
(defun my/use-eslint-from-node-modules ()
  (let* ((root (locate-dominating-file
                (or (buffer-file-name) default-directory)
                "node_modules"))
         (eslint (and root
                      (expand-file-name "node_modules/eslint/bin/eslint.js"
                                        root))))
    (when (and eslint (file-executable-p eslint))
      (setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
(flycheck-add-mode 'javascript-eslint 'rjsx-mode)

(Full emacs config here: https://github.com/phuhl/sheeshmacs)

Thx

user3637541
  • 675
  • 4
  • 15
  • 1
    Just a recommnedation, post your question here instead :) [https://emacs.stackexchange.com/](https://emacs.stackexchange.com/) – Lars Nielsen Sep 21 '22 at 11:15
  • As flycheck isn't enabled (or even installed) by default, show how you are *enabling* it for these files in the first place, and then someone will likely be able to help. – phils Sep 21 '22 at 13:33
  • @phils, good point, I added it to the question – user3637541 Sep 22 '22 at 18:33

1 Answers1

1

Try changing your macro to open files with find-file-literally. This will always open files in Fundamental mode, preventing flycheck from running (well, assuming you have no flycheck hooks for Fundamental mode.)

See C-h f find-file-literally or Visiting in the Emacs manual.

nega
  • 2,526
  • 20
  • 25
  • Thanks, that's a great suggestion! With a little helper function I just wrote, you can easily open files from dired also: ``` (defun dired-find-file-lit () "In Dired, visit the file or directory named on this line." (interactive) (dired--find-file #'find-file-literally (dired-get-file-for-visit))) ``` – user3637541 Oct 11 '22 at 12:35