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#50244: 28.0.50; Support project-wide diagnostics reports in flymake.el Date: Sun, 29 Aug 2021 01:53:08 +0100 Message-ID: <87bl5hm5qj.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="12409"; mail-complaints-to="usenet@ciao.gmane.io" To: 50244@debbugs.gnu.org, theo@thornhill.no, p.stephani2@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 29 02:54:16 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 1mK95T-00031Z-V0 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Aug 2021 02:54:16 +0200 Original-Received: from localhost ([::1]:53244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mK95S-0003vw-KA for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 20:54:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mK95G-0003vk-Ku for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 20:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mK95G-0007HN-Dc for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 20:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mK95G-0006R4-CW for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 20:54: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: Sun, 29 Aug 2021 00:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50244 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Theodor Thornhill , p.stephani2@gmail.com Original-Received: via spool by submit@debbugs.gnu.org id=B.163019839824658 (code B ref -1); Sun, 29 Aug 2021 00:54:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Aug 2021 00:53:18 +0000 Original-Received: from localhost ([127.0.0.1]:55183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mK94Y-0006Pe-B5 for submit@debbugs.gnu.org; Sat, 28 Aug 2021 20:53:18 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56650) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mK94W-0006PS-DS for submit@debbugs.gnu.org; Sat, 28 Aug 2021 20:53:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mK94V-0003uE-Ts for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 20:53:15 -0400 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:38597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mK94U-0006mm-6e for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 20:53:15 -0400 Original-Received: by mail-wr1-x42a.google.com with SMTP id u16so16638058wrn.5 for ; Sat, 28 Aug 2021 17:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GSA/SjyYHCyH0SwZr94dAyPnUKaLZqkKta4uvWKYfBc=; b=g7gui8q8PYIqe7GyW2uOy6P9csxpUVV2uRjYVfJFS0X3ODl4bEXSlNEitiE6Z8ve7a c3jV7vhdmDePBPl7L5rshm0X0g/zBVtrB2Q4tL6Qr5vTYFuwWv9mLia8USvDRkz7+Wug M9LBtYsh1gyv6NdYdscDcmZUIczIwJ4MDhQmKB+u+shGHooSuh9znm4vPfl7R7nBxZoK Bqv78v8k3MB7NIdO+Nn0Fn0i0O3+59wvLkoLpMJBZInMoG7P8K06ecs85pC7JrT/HkUe YccD65Llllb904FZ51cu8XCk+QsAgssOWHDo+K+1mDC2jN8RwoHnNxQECa+38NroQjzR Jnfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GSA/SjyYHCyH0SwZr94dAyPnUKaLZqkKta4uvWKYfBc=; b=tgetEj3Vo1MqPsCT8VYEfSsVufA8eyMjN1bSzBu+ZW8CPZ3NoV/QbEEFUd+sHLwPwB Fd+qB/DxmsFFFpTXMTWCec5vVh4Lgbj6EH9AEiQUl8P9BchBpLp4VxDWTJFreEsITHdk VzgA3c24bhoHFHR6Ew7AQn7MZNrkDPBh2S+LIJCRpzQw4aE2EjJUWbyiNxgpChjgZo5p tus2yM7b7BstHT1C36K/FTZKutS9/C8QdkZuMlTDlHoSVpTClRMxfyfpS/B15pKZbdJx 2vCYH6cgYdKKmCvoeOJZhN1JvMv0Hlc9QvwFXwmp1+L+Ecj9Ud4awncyDhW2yEnH7j/i JSCA== X-Gm-Message-State: AOAM533nUZENMpuh3RXJYRvvjKmmPAyEF/FN9L7dIkSqnsZd3vTd/3HA axPJ4pK1e4qrU91p9PVOLqU= X-Google-Smtp-Source: ABdhPJyepuMdhVMYhF0IQaX+yho5GvX38w1A51mvc7tH0rUNVmsdzxuIXja5kgULm+OyjEAdRRLAXg== X-Received: by 2002:adf:9f05:: with SMTP id l5mr17858423wrf.188.1630198391548; Sat, 28 Aug 2021 17:53:11 -0700 (PDT) Original-Received: from krug (a94-133-103-226.cpe.netcabo.pt. [94.133.103.226]) by smtp.gmail.com with ESMTPSA id y6sm12910910wrm.54.2021.08.28.17.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Aug 2021 17:53:11 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=joaotavora@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:212906 Archived-At: This is coming from: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D34418 https://github.com/joaotavora/eglot/pull/640 In the first, Philip wonders why the BUFFER argument to flymake-make-diagnostic is mostly ignored. In the second, Theodor requests that the Eglot LSP client manage and display the diagnostics reported by the LSP server not only for the current buffer being edited, but for other buffers or files. The connection between the two will hopefully become apparent soon. Normally, diagnostics reports are emitted by diagnostic backend for a single file, usually as a result of a change performed shortly before in the buffer visiting that file. This is true for most LSP servers when acting as Flymake backends. But some LSP servers seem to take this opportunity to also "piggy-back" diagnostics for other files, in a kind of "side-band signal". Other servers yet will sometimes report diagnostics upfront for all files in a given project, whether visited by a buffer or not. Theodor's pull request handles this side band signal for LSP specifically in the Eglot client, but it contains some twists and turns that should not be taken in Eglot. This functionality should be supported in Flymake. * What kind of new API support for Flymake backends is needed for this? This is the good news: I think not much. The helper function flymake-make-diagnostic, used by Flymake backends such as Eglot's, already supports a BUFFER first argument, but, as the manual states. =20=20=20 Currently, it is unspecified behavior to make diagnostics for buffers other than the buffer that the Flymake backend is responsible for. =20=20=20 My idea is to make it specified. As floated in bug#34418 I think the idea of generalizing the argument to mean BUFFER-OR-FILE is decent and sufficient. * What kind of infrastructure changes in Flymake are needed for this? That's more complicated: substantial, but not insane. Here's a top-level plan: the current buffer-local variable flymake--backend-state should probably first become a global hash table indexed by buffer, which should be mostly indistinguishable from a buffer-local var. If that works, then it should be possible to store the piggy-backed diagnostics in (1) file-indexed entries to that global hash table, for files which are not being visited by buffers. It should also be possible to add (2) buffer-indexed entries to it for buffers which, though live, don't have Flymake properly activated or don't have that specific piggy-backing backend in their running backend list. These new types of entries will likely not contain the full-blown flymake--backend-state structs, i.e. they will be missing the 'running', 'reported-p' and 'disabled' slots. All they will have is a non-nil list 'diags'. If, for situations (1) or (2), we discover that a "proper" buffer-indexed entry already exists in the global hash table, we must decide if the information in them should take priority. I'm not sure of the answer to this yet. Anyway, in flymake--handle-report is where the recording of information should happen. We can have a look at the current aforementioned "unspecified" behavior: (setq new-diags (cl-remove-if-not (lambda (diag) (eq (flymake--diag-buffer diag) (current-buff= er))) report-action)) (As we can see, the current "unspecification" is just ignoring reports for BUFFERs other than the current.) * In what new UI parts is the augmented information to be useful? Currently, I see only one place, the diagnostic listing buffer obtained by M-x flymake-show-diagnostics-buffer. That buffer is usually associated with only one source buffer (flymake--diagnostics-buffer-source). Now it should start listing all the diagnostics for buffers or files known to belong to the same project, using 'project.el' functionality for that. Jo=C3=A3o