Fix bug#34418.
* doc/misc/flymake.texi (Flymake utility functions): Add note to
flymake-make-diagnostic.
* lisp/progmodes/flymake.el (flymake--handle-report): Discard
diagnostics from other buffers.
Make a Flymake diagnostic for @var{buffer}'s region from @var{beg} to
@var{end}. @var{type} is a diagnostic symbol (@pxref{Flymake error
types}), and @var{text} is a description of the problem detected in
-this region.
+this region. Currently, it is unspecified behaviour to make
+diagnostics for buffers other than the buffer that the Flymake backend
+is responsible for.
@end deffn
@cindex access diagnostic object
(format "Unknown action %S" report-action))
(flymake-error "Expected report, but got unknown key %s" report-action))
(t
- (setq new-diags report-action)
+ (setq new-diags
+ (cl-remove-if-not
+ (lambda (diag) (eq (flymake--diag-buffer diag) (current-buffer)))
+ report-action))
(save-restriction
(widen)
;; Before adding to backend's diagnostic list, decide if