Subject: bug#51549: 29.0.50; flymake error when filename contain '%'

From: Stefan Kangas <[email-masked]>
Date: Sat, 6 Nov 2021 01:30:53 -0700

tags 51549 + confirmed
thanks

Ola x Nilsson <[email-masked]> writes:

> Flymake includes the buffer name in `warning-type-format' (see
> `flymake--log-1').
> When the file name - and the buffer name - contain a % character it is
> very probable that the `format' call in `display-warning' either fails
> or produce unexpected results.
>
> In my case I used a file name arm-trusted-firmware-2.4_%.bbappend with a
> local flymake backend running a local linter.
> The local backend uses a process sentinel to process errors and generate
> flymake diagnostic objects with
>
>    (flymake-make-diagnostic source beg end type msg)
>
> where
> source is the buffer visiting arm-trusted-firmware-2.4_%.bbappend,
> bed and end set from `flymake-diag-region'
> type is :warning
> and msg is a string with the error message from the linter.

Thanks for the bug report.  I can reproduce this using this contrived
example:

./src/emacs -Q --eval "(progn (require 'flymake) (find-file
\"/tmp/foo%sbar.c\") \
    (flymake--log-1 :emergency nil \"foo\"))"

I now see in the *Warnings* buffer:

    Emergency [flymake fooflymakebar.c]: foo

The expected output is:

    Emergency [flymake foo%sbar.c]: foo

Your analysis of why the problem happens seems correct to me, but I'm
not sure how to best fix it.  João, what do you think?