Flymake ignores buffer specified in `flymake-make-diagnostic'?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Flymake ignores buffer specified in `flymake-make-diagnostic'?

Philipp Stephani
Hi,

I've noticed that Flymake ignores the buffer passed to
`flymake-make-diagnostic' and always uses the source buffer. For
example, in *scratch*:

(require 'flymake)
(with-temp-buffer
  (flymake-mode)
  (insert "text a")
  (let ((buf-a (current-buffer)))
    (with-temp-buffer
      (flymake-mode)
      (insert "text b")
      (let ((buf-b (current-buffer)))
        (add-hook 'flymake-diagnostic-functions
                  (lambda (report-fn &rest _args)
                    (funcall report-fn (list (with-current-buffer buf-a

(flymake-make-diagnostic buf-a (point-min) (point-max)

 :error "message"))) ))
                  nil :local)
        (flymake-start)
        (sit-for 1)
        (list (cons 'buf-a (with-current-buffer buf-a (flymake-diagnostics)))
              (cons 'buf-b (with-current-buffer buf-b
(flymake-diagnostics))))))))

⇒ ((buf-a) (buf-b #s(flymake--diag #<killed buffer> 1 7 :error
"message" (lambda ... ...) nil #<overlay in no buffer>)))

This seems a bit surprising, and I couldn't find documentation on it.
Is this working as intended? If so, would it be possible to clarify
the documentation a bit? Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Flymake ignores buffer specified in `flymake-make-diagnostic'?

João Távora
I stumbled upon this by chance (I don't systematically read
help-gnu-emacs).

Can you make a bug report out of this, and explain what the
problem is in terms of user UI and Emacs -Q? Your code example is
a bit too convoluted for me to grok an understand right now.  Are
you running into trouble writing a new backend?

Also, flymake-make-diagnostic doesn't ignore the buffer passed to
it, flymake-show-diagnostic uses it.  But it is currently unspecified
behaviour if you make a diagnostic for any buffer other than
the one you're explicitly checking.  It might be specified to do
something useful in the future (think checking a .c file
including a .h file).

João

On Wed, Dec 12, 2018 at 8:11 PM Philipp Stephani <[hidden email]> wrote:

>
> Hi,
>
> I've noticed that Flymake ignores the buffer passed to
> `flymake-make-diagnostic' and always uses the source buffer. For
> example, in *scratch*:
>
> (require 'flymake)
> (with-temp-buffer
>   (flymake-mode)
>   (insert "text a")
>   (let ((buf-a (current-buffer)))
>     (with-temp-buffer
>       (flymake-mode)
>       (insert "text b")
>       (let ((buf-b (current-buffer)))
>         (add-hook 'flymake-diagnostic-functions
>                   (lambda (report-fn &rest _args)
>                     (funcall report-fn (list (with-current-buffer buf-a
>
> (flymake-make-diagnostic buf-a (point-min) (point-max)
>
>  :error "message"))) ))
>                   nil :local)
>         (flymake-start)
>         (sit-for 1)
>         (list (cons 'buf-a (with-current-buffer buf-a (flymake-diagnostics)))
>               (cons 'buf-b (with-current-buffer buf-b
> (flymake-diagnostics))))))))
>
> ⇒ ((buf-a) (buf-b #s(flymake--diag #<killed buffer> 1 7 :error
> "message" (lambda ... ...) nil #<overlay in no buffer>)))
>
> This seems a bit surprising, and I couldn't find documentation on it.
> Is this working as intended? If so, would it be possible to clarify
> the documentation a bit? Thanks!
>

Reply | Threaded
Open this post in threaded view
|

Re: Flymake ignores buffer specified in `flymake-make-diagnostic'?

Philipp Stephani
Am Do., 3. Jan. 2019 um 16:40 Uhr schrieb João Távora <[hidden email]>:
>
> I stumbled upon this by chance (I don't systematically read
> help-gnu-emacs).
>
> Can you make a bug report out of this, and explain what the
> problem is in terms of user UI and Emacs -Q?

Done (see bug#34418).

> Your code example is
> a bit too convoluted for me to grok an understand right now.  Are
> you running into trouble writing a new backend?
>
> Also, flymake-make-diagnostic doesn't ignore the buffer passed to
> it, flymake-show-diagnostic uses it.  But it is currently unspecified
> behaviour if you make a diagnostic for any buffer other than
> the one you're explicitly checking.  It might be specified to do
> something useful in the future (think checking a .c file
> including a .h file).

I think it should either signal an error or use the diagnostic for the
other buffer. At the very least, please document this fact in
https://www.gnu.org/software/emacs/manual/html_node/flymake/Backend-functions.html.



>
> João
>
> On Wed, Dec 12, 2018 at 8:11 PM Philipp Stephani <[hidden email]> wrote:
> >
> > Hi,
> >
> > I've noticed that Flymake ignores the buffer passed to
> > `flymake-make-diagnostic' and always uses the source buffer. For
> > example, in *scratch*:
> >
> > (require 'flymake)
> > (with-temp-buffer
> >   (flymake-mode)
> >   (insert "text a")
> >   (let ((buf-a (current-buffer)))
> >     (with-temp-buffer
> >       (flymake-mode)
> >       (insert "text b")
> >       (let ((buf-b (current-buffer)))
> >         (add-hook 'flymake-diagnostic-functions
> >                   (lambda (report-fn &rest _args)
> >                     (funcall report-fn (list (with-current-buffer buf-a
> >
> > (flymake-make-diagnostic buf-a (point-min) (point-max)
> >
> >  :error "message"))) ))
> >                   nil :local)
> >         (flymake-start)
> >         (sit-for 1)
> >         (list (cons 'buf-a (with-current-buffer buf-a (flymake-diagnostics)))
> >               (cons 'buf-b (with-current-buffer buf-b
> > (flymake-diagnostics))))))))
> >
> > ⇒ ((buf-a) (buf-b #s(flymake--diag #<killed buffer> 1 7 :error
> > "message" (lambda ... ...) nil #<overlay in no buffer>)))
> >
> > This seems a bit surprising, and I couldn't find documentation on it.
> > Is this working as intended? If so, would it be possible to clarify
> > the documentation a bit? Thanks!
> >