Flymake: more ambitious cleanup in flymake-mode (bug#69809)
Further improve flymake-mode idempotency by not nuke existing overlays.
This means multiple flymake-mode invocations do the same as just one
one, with minimal or no additional side effects. This is good for
people with lots of 'flymake-mode' in hooks.
The foreign diagnostic importation has been refactored into a separate
function and moved to the "really start" section of 'flymake-start'.
The duplication problem appears to be avoided by some heuristics in
flymake-highlight-line.
A new test has been added.
* lisp/progmodes/flymake.el (flymake--import-foreign-diagnostics): New helper
(flymake-start): Use it.
(flymake-mode): Don't nuke overlays here.
* test/lisp/progmodes/flymake-tests.el (foreign-diagnostics): New
test.
(cherry picked from commit
0ff82eb48725e15bb87a75d4f937b75c2482c59b)