]> git.eshelyaron.com Git - emacs.git/commitdiff
Flymake: fix bug introduced recently
authorJoão Távora <joaotavora@gmail.com>
Fri, 17 Jan 2025 10:57:46 +0000 (10:57 +0000)
committerEshel Yaron <me@eshelyaron.com>
Fri, 17 Jan 2025 11:49:20 +0000 (12:49 +0100)
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.

(cherry picked from commit f7ff5f1ba4e87596cb4e055492b0e99321fd9950)

lisp/progmodes/flymake.el

index 0d1b4d6f430313567ee32a696772937dc86a0f9f..d84b55e513dbb4ee3abaa07a7dbc05cd286e22c0 100644 (file)
@@ -1641,9 +1641,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)))