Subject: Re: bug#70752: 30.0.50; flymake: add a command for resetting state

From: Óscar Fuentes <[email-masked]>
Date: Sat, 18 May 2024 17:09:59 +0200

Spencer Baugh <[email-masked]> writes:

> Óscar Fuentes <[email-masked]> writes:
>> Sometimes flymake shows indicators of unexisting diagnostics. The only
>> method I know of clearing those indicators is killing all buffers with
>> the same mode.
>>
>> The real fix is to not show unexisting diagnostics, but since that can
>> be caused either by bugs in flymake or in third-party diagnostic
>> functions (including in the function's development) providing a command
>> or easy method to clear those diagnostics would be pragmatic and
>> convenient.
>
> Could you give an example of a flymake diagnostic function which reports
> non-existing diagnostics?
>
> Also, I expect that you would be able to clear the diagnostics by simply
> toggling flymake-mode in the buffer with undesirable diagnostics
> present.

Hello.

I've made a function for an internal language programming. The function
follows the example on the manual. The function does not report those
diagnostics, something else is at play. Anyway, fixing a faulty function
is not the point of this report. This is about flymake showing "sticky"
diagnostics that do not go away even when the function reports no
diagnostics. More specifically, this is about how to get rid of those
phantom diagnostic indicators. It happens infrequently enough (IMAO)
that having to invoke some "flymake-cleanup" command would not be a
serious nuisance.

I've seen the problem happen just after an edited buffer is reverted:
random lines on the buffer appear decorated with a diagnostic indicator.

Turning off and on flymake-mode does not work. More surprisingly,
killing the buffer and visiting it again doesn't work either: the
diagnostics are back (and I insist on the function not reporting them,
that's 100% checked). The only thing that works is to kill all the
buffers with the same major mode. Recently, I noticed that deleting the
decorated lines and simply undoing the deletion also gets rid of the
decoration.

BTW, flymake not only decorates the lines, it also adds them to the
diagnostic counter on the modeline.

So, to recap, a flymake-clean-diagnostics or somesuch command would be
handy. A quick inspection of flymake's source does not indicate an
obvious way of doing this, as it seems that the diagnostic information
is scattered over several places (including overlays on the affected
buffers.)

Thanks!