Flymake: fix bug introduced recently

Must protect against flymake--state never having been a hash
table at all, so that flymake-mode can be safely turned off even
if it never turned on in the first place.

Github-reference: https://github.com/joaotavora/eglot/discussions/1480

* lisp/progmodes/flymake.el (flymake-mode): Fix bug.
This commit is contained in:
João Távora 2025-01-17 10:57:46 +00:00
parent c9196cf64e
commit f7ff5f1ba4

View file

@ -1451,9 +1451,10 @@ special *Flymake log* buffer." :group 'flymake :lighter
(cancel-timer flymake-timer)
(setq flymake-timer nil))
(mapc #'flymake--delete-overlay (flymake--really-all-overlays))
(maphash (lambda (_backend state)
(flymake--clear-foreign-diags state))
flymake--state)))
(when flymake--state
(maphash (lambda (_backend state)
(flymake--clear-foreign-diags state))
flymake--state))))
;; turning Flymake on or off has consequences for listings
(flymake--update-diagnostics-listings (current-buffer)))