all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eshel Yaron <me@eshelyaron.com>
Cc: Spencer Baugh <sbaugh@janestreet.com>, emacs-devel@gnu.org
Subject: Re: Adding fix suggestions to Flymake diagnostics
Date: Mon, 27 May 2024 15:02:52 +0100	[thread overview]
Message-ID: <CALDnm51v8-ciBZULosoL724hTvLRH3_FmK3h+9Mpgtfh+NNepQ@mail.gmail.com> (raw)
In-Reply-To: <m17cffxxgg.fsf@dazzs-mbp.kpn>

On Mon, May 27, 2024 at 1:15 PM Eshel Yaron <me@eshelyaron.com> wrote:

> That's not strictly my goal, although it could be a nice side effect.
> What's important is to have a good, backend-agnostic, experience for
> fixing diagnostics.  Such a standard UI may subsume some of Eglot's
> bespoke UI, but it may also be complementary and the two can coexist,
> perhaps with some LSP-specific use cases only provided by Eglot.

I don't think there's anything complex in Eglot's diagnostic-fixing UI that
can't be subsumed by any reasonable interface.

> for example, it could rely
> on some overlay property that backends would add to diagnostics and the
> UI of the new library would look for.  If we really don't want to teach
> Flymake about fixes, I think that could work.  WDYT?

What you're describing is similar, if not exactly identical to what
happens today

1. The overlay property you suggest exists.  It is 'keymap'
2. it's added to flymake diagnostics overlays via the diagnostic type property
   'flymake-overlay-control', part of Flymake's generic API for adding things
   to the overlay diagnostic.
3. The overlay _value_ is a simple keymap mapping the '[mouse-2]' binding to
   a function.  I think some users add more mappings to the keymap, which is
   bound to eglot-diagnostics-map.
4. The function is Eglot's.  It mixes UI and LSP logic, alas.
4.1 it expects the diagnostic at the mouse point to have a way to "produce"
    code edits (at first I thought this was async, but you're in luck: it's
    sync, which greatly simplified matters).
4.2 calls upon this logic to gather said edits
4.3 presents them to the user and applies them.  This is UI.

If you're suggesting to wrap all this setup in some function/macro of
newlibrary.el (the file name for your "new library") so that only the
complexity of 4.2 remains in eglot.el, then that's exactly what I'm
suggesting.

I just note that  newlibrary.el _will_ have to know about "edit-producing
diagnostics", which means knowing about edits, or at least a way to
apply them.
It will likely have to require 'refactor.el',  which is where the "edit" format
will live, and call on it to present and eventually apply those edits.

In fact, in my mind, newlibrary.el is so short that there's little
reason it shouldn't just be a small section of refactor.el.

But if it motivates you to start with a separate file, then newlibrary.el
(or whatever name you want to give it) is absolutely fine.

João



  reply	other threads:[~2024-05-27 14:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-26 13:37 Adding fix suggestions to Flymake diagnostics Eshel Yaron
2024-05-26 14:38 ` João Távora
2024-05-26 15:56   ` Eshel Yaron
2024-05-26 20:24     ` João Távora
2024-05-27 12:15       ` Eshel Yaron
2024-05-27 14:02         ` João Távora [this message]
2024-05-27 17:40           ` Eshel Yaron
2024-05-27 22:03             ` João Távora
2024-05-31  7:15               ` Eshel Yaron
2024-05-31  8:55                 ` João Távora
2024-06-03 18:10                   ` Eshel Yaron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALDnm51v8-ciBZULosoL724hTvLRH3_FmK3h+9Mpgtfh+NNepQ@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=me@eshelyaron.com \
    --cc=sbaugh@janestreet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.