From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.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: Mon, 5 Jul 2021 17:56:31 +0100 Message-ID: References: <87o8xumfi8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24890"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 34418@debbugs.gnu.org To: Philipp Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 05 18:57:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0RuC-0006MR-MA for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 18:57:12 +0200 Original-Received: from localhost ([::1]:36318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0RuB-00024e-O2 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 12:57:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0Ru1-00022V-Qh for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 12:57:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0Ru1-0005dm-Iq for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 12:57:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0Ru1-0000Tj-JP for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 12:57:01 -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: Mon, 05 Jul 2021 16:57:01 +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.16255042101819 (code B ref 34418); Mon, 05 Jul 2021 16:57:01 +0000 Original-Received: (at 34418) by debbugs.gnu.org; 5 Jul 2021 16:56:50 +0000 Original-Received: from localhost ([127.0.0.1]:46597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0Rtq-0000TG-D9 for submit@debbugs.gnu.org; Mon, 05 Jul 2021 12:56:50 -0400 Original-Received: from mail-pj1-f42.google.com ([209.85.216.42]:55889) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0Rtp-0000T4-Bt for 34418@debbugs.gnu.org; Mon, 05 Jul 2021 12:56:49 -0400 Original-Received: by mail-pj1-f42.google.com with SMTP id l11so12015549pji.5 for <34418@debbugs.gnu.org>; Mon, 05 Jul 2021 09:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1metvXRzwBRAtC30uhrAsVq4hK2mT+AhQMf5wuIUGWM=; b=b6ZVgmYNdZ2sS6TBMbeuCl/CL3tGijsY5k5UoHD7beqM4LlEXy30/woryNQABMy4Ij I6jays3/kGORjpyYXKIYLwV7E1vZXUYqQKYfunja+Oy2/35OOvkqPQs0Eo0IeT8/JyZx 1/m5mzPL64eaAJypmtneDdmnAFVIZ1LQ99BDRBXSBqbb2l62tnayq2OjpcMzhKGb0n0n az6biRWgZ3o6qFIY4KQTbKNz+Pklz0+04gSC7ruW2gnwbStHCHj4wR7CrA5UtKTVFVeE QmtgeNO7XrtkyBhzfICBVQSGtZtDAQ5YERXCkDzAgW401AzqqCkEgLuCOaleFvpMRpV/ c5TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1metvXRzwBRAtC30uhrAsVq4hK2mT+AhQMf5wuIUGWM=; b=CdavFewd+HUNJiIRbdltzKOdZGAbaaoIBEuCh6mHtO+/ZzvnupWKQddpkBZ9Bg0nJ4 dwCTvkmwBaH44CU+dMwC9m67i1+ApPJrHB0bbks9EN8RjFg6cwhPv9retMClLdOa3NgN KJkwI00kLkcGs3LoaiYpL2jj8MCPY5ti7MKb01IZltVTeN3HsKnRHCvA5gG9OONEM+gr bQeoYnKTbMUtq0DpG+2tYoGHWeuterCGVjmQ3c6W6CE1FiAKW+FV2fuTvR9UJhUNPlh8 MFP/MSqdijNhJDh7RAqSgLs+0g+eQccn/FH9FgRHMlyNXaRvQSLs6GSfGxhxM1s5lvoU o/qw== X-Gm-Message-State: AOAM531WwGFdf9CyQcXb4HE0oODRS0jshBZj3YR6mjM9s6Qs/xHVUW0B QTFLaehpLYpIINhTJphfsPKXlQzaGqyIIjGaj4o= X-Google-Smtp-Source: ABdhPJya+fk4qd9ljhJg2whKpvfx+UWn0huq3/LRxoOtzsn4en2ZfXKH4NJ+8Xo5JCaXrOdDQdKkXMDJHjPmnbbS7mU= X-Received: by 2002:a17:902:7b87:b029:128:345d:f596 with SMTP id w7-20020a1709027b87b0290128345df596mr13195573pll.36.1625504203367; Mon, 05 Jul 2021 09:56:43 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209478 Archived-At: On Mon, Jul 5, 2021 at 5:51 PM Philipp wrote: > > > > > Am 02.11.2019 um 17:04 schrieb Jo=C3=A3o T=C3=A1vora : > > > > 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: > >> > >> (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")))))) > >> > >> Note that this backend adds a diagnostic for buffer *a*, not *b*. > >> > >> 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 scenari= os. > > > > 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. > > I wouldn't say signaling an error now would block evolution. I don't thi= nk we have a principle like "anything that signals an error now will contin= ue doing so in the future." And yet, but experience shows that programs rely on externally observable behaviour again and again, and I have little reason to believe errors are an exception to that. So unless we're reasonably sure that the changes we make to a piece of behavior make sense in the long run, better not do them. I think there's prior art with negative overlay priorities, for example: last I checked manual said "please don't use these, as we haven't decided on what they might mean". Or something like that. I don't think an error make sense there, either. Jo=C3=A3o