On Fri, Apr 10, 2020 at 5:09 PM João Távora <joaotavora@gmail.com> wrote:

> leaves me wondering if there isn't a hook ordering bug here. Maybe it's
> just a question of delaying entry in tabulated-list-mode until important stuff
> is set up.

Or maybe all that's needed is this (100% untested) change:

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 25a2152f00..72171f5f8b 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1378,10 +1378,10 @@ flymake-show-diagnostics-buffer
          (source (current-buffer))
          (target (or (get-buffer name)
                      (with-current-buffer (get-buffer-create name)
+                       (setq flymake--diagnostics-buffer-source source)
                        (flymake-diagnostics-buffer-mode)
                        (current-buffer)))))
     (with-current-buffer target
-      (setq flymake--diagnostics-buffer-source source)
       (revert-buffer)
       (display-buffer (current-buffer)))))