From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#34418: 27.0.50; Flymake adds markup to buffers not specified in `flymake-make-diagnostic' Date: Sat, 02 Nov 2019 16:04:15 +0000 Message-ID: <87o8xumfi8.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="240699"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 34418@debbugs.gnu.org To: Philipp Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 02 17:05:34 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iQvu9-0010UZ-Rm for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Nov 2019 17:05:34 +0100 Original-Received: from localhost ([::1]:48998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQvu8-0002Lm-Nq for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Nov 2019 12:05:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35804) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQvtg-00023Z-K6 for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2019 12:05:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQvtf-0006gT-D0 for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2019 12:05:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQvte-0006dJ-Sf for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2019 12:05:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iQvte-0003ja-L8 for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2019 12:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Nov 2019 16:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34418 X-GNU-PR-Package: emacs Original-Received: via spool by 34418-submit@debbugs.gnu.org id=B34418.157271067014309 (code B ref 34418); Sat, 02 Nov 2019 16:05:02 +0000 Original-Received: (at 34418) by debbugs.gnu.org; 2 Nov 2019 16:04:30 +0000 Original-Received: from localhost ([127.0.0.1]:32906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQvt7-0003ij-Ut for submit@debbugs.gnu.org; Sat, 02 Nov 2019 12:04:30 -0400 Original-Received: from mail-wm1-f67.google.com ([209.85.128.67]:56262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQvt6-0003iT-DE for 34418@debbugs.gnu.org; Sat, 02 Nov 2019 12:04:29 -0400 Original-Received: by mail-wm1-f67.google.com with SMTP id m17so3101963wmi.5 for <34418@debbugs.gnu.org>; Sat, 02 Nov 2019 09:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=Jxv+VPpC+OAoXuThRpGuYDjXCC93eZkpNt0u/CxOgEo=; b=kuLlBq+FVCJj7WPYJN41FVf5Fuj7wRA9nB/rHwc+stWtGfqnvophLNo8BRMNfALI1k 4K7bDL0F8WamulGuwXHJMNMhpofPW85osGE/QqXrbwIsrdWHW9uWJuNdDg7HGqVuKk+M sApFzTw69IJ9nVzfb2jy66IaiKKQwuedKBS22sfuQJgSJXF4rJRyLdLg8CASV9a6gX0h GDhZqO4h8vB2yY5+t7xSNlah61e+UcU+eFHqo8DZFZmcMvtLpcIgDMr794hNz0w0jgOU IYA/EeTgJRArCibBw9+so0YMOPOLC4ZmksgQDIzBrCeB/Ee1056uhPGeFfxrkVuxnutQ BcCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=Jxv+VPpC+OAoXuThRpGuYDjXCC93eZkpNt0u/CxOgEo=; b=J3MiuaGNYaBhmX0XVrsURW6F7WPNrPHgZosJpKh1rKUNf2JEidBnGFqMC9YEDOuG0o meFGLj2e+MZg5ElWC7UDIXejxqSbxYWwZNkIX0+BTpiDAavoZSUxPw0fQf9fV3ugsbCc j1WLUg5d9SCPbqfDVwMjKitey2RI/g9j79DqTaNrLA4WC889GsqLCdvztmpIKtgJk4L5 70iEEAxjvlN+foJ17ns0pJNeoLaLbRENcQQcaqK+qFzaM1ei8xcIanXUMCKJxKMhEOzH 3nkHZZ4rUO0od5VpPmhsgKn+S3bv2ct8U7UL3FppZhXwEgL0bmK840HJAUfo+vqeNRGQ oXnQ== X-Gm-Message-State: APjAAAWBzp4/EXydBl0AV9jY9OU/5bNeKQky3YSTdcQDLvk214Fb0JZO /T/PJWbNp0WIbIDrBkshamilcQbY X-Google-Smtp-Source: APXvYqx4FLZyAftKbbP8tgMUG0M3lcJ/yllpboji/CmTL4nTXhvaQhJzrVXjj3oPxS1wFMHTSgOlDQ== X-Received: by 2002:a1c:4089:: with SMTP id n131mr16161875wma.86.1572710660931; Sat, 02 Nov 2019 09:04:20 -0700 (PDT) Original-Received: from lolita.yourcompany.com ([2001:818:d820:9500:1ebb:afd8:ab26:f0f6]) by smtp.gmail.com with ESMTPSA id x8sm10878097wrr.43.2019.11.02.09.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Nov 2019 09:04:20 -0700 (PDT) In-Reply-To: (Philipp's message of "Sun, 10 Feb 2019 20:35:35 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170820 Archived-At: Philipp writes: > 1. Create two scratch buffers *a* and *b* (e.g. C-x b *a* RET). > > 2. Insert some text into the buffers (e.g. "text a" and "text b", > respectively) > > 3. Add a trivial Flymake backend to buffer *b*. E.g., select *b* and > run M-: with the following code: >=20=20=20=20 > (add-hook 'flymake-diagnostic-functions > (lambda (report-fn &rest _args) > (funcall report-fn (list (with-current-buffer "*a*" > (flymake-make-diagnostic (current-buffer) > (point-min) (point-max) > :error "message")))))) >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > Note that this backend adds a diagnostic for buffer *a*, not *b*. >=20=20=20=20 > 4. Enable Flymake mode in buffer *b*. > > Buffer *b* will now show a diagnostic, even though it was reported for > buffer *a*. This should either add a diagnostic for buffer *a* or > signal an error. Hi Phillip, Sorry for the very slow turnaround. The behaviour for handling the mismatch between the (1) the buffer passed to flymake-make-diagnostic (2) the buffer where the report function executes is unspecified and it is so by design. I've yet to come to a good conclusion on what that behaviour should be, and maybe you can help me. Let's see some plausible real-world scenarios. 1. Some uses of Flymake, notably Eglot's via LSP (Language Server Protocol) can possibly take advantage of a good definition of this behaviour, for aggregating the errors reports across a project for example. So `flymake-make-diagnostic` could be specified to take a BUFFER-OR-FILE, and we could heuristically decide to add the diagnostic to, say, a per-project database. 2. In another simpler scenario, checking .c file might issue errors for included .h files, and if that file is open in a buffer, we could go there and highlight the error. Could we really? Maybe not, because the error was probably generated for the on-disk copy of the .h file, whose contents might differ wildly from the buffer's. Then again, a smart backend could consider that. So maybe your "error" proposal makes sense, maybe it doesn't. I'd rather not commit to an API right now that could block evolution. For now I've added a note to the manual's description of flymake-make-diagnostic and a protection to flymake--handle-report that will ignore such diagnostics. What do you think? Jo=C3=A3o