unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Spencer Baugh <sbaugh@catern.com>
Cc: emacs-devel@gnu.org
Subject: Re: Adding support for xref jumping to headers/interfaces
Date: Fri, 10 Nov 2023 13:59:10 +0000	[thread overview]
Message-ID: <CALDnm53oBXAuH7-oeGvKF+B6EY23Gpy9k6Ag0OpNv_PM9C0itA@mail.gmail.com> (raw)
In-Reply-To: <87il697r5g.fsf@catern.com>

On Fri, Nov 10, 2023 at 12:15 PM Spencer Baugh <sbaugh@catern.com> wrote:

> I think we should be somewhat "selfish", and let our design here be
> guided by "Things which make sense for Elisp, and also many other
> languages".  Declarations and implementations, I think, are an instance
> of that.

Not really.  "Declarations" don't make much sense in Elisp. I'll
explain below.

And I don't think we should code xref.el with "selfishness" in mind
at least if we're serious about making it reusable.  elisp-mode.el
should have things that make sense fo Elisp.  Vast amounts of Emacs
users couldn't care less for Elisp, and that's fine.

> > LSP, the protocol has the same problem, and their 5 categories
> > (definitions, references, implementation, declaration, typeDefinition)
> > are awkward as heck and don't make any sense for many languages.
> > They're probably coming from large commercial languages such as Java
> > and C#,  Typescript, etc not suprising given it's all a Microso$t
> > gig. But it's just poor design that I'd rather not have bleed into
> > Emacs xref.el.
> >
> > Emacs is older than LSP and my bet is that it will outlive LSP.
>
> Absolutely, of course, but just because LSP has "declarations" and
> "implementations" doesn't mean it's not good for Emacs.

Doesn't mean it's any good either.  Emacs precedes LSP by many
years in being flexible enough to support many languages.
And it absolutely trounces LSP in that respect.  LSP's main point
here is that it supports many editors, and so reusable language servers
appear for many languages not motivated by Emacs, and Emacs,
using Eglot, profits from that.  But LSP makes tremendous tradeoffs
in flexibility, tradeoff that we don't have to make or even consider,
because we support only one editor, ourselves.

> > Of course Dmitry is the person to convince here, not me.
> >
> >> We don't have to include the concepts in xref.el per-se.  All I suggest
> >> is that instead of supporting 'eglot--xref-implementation as a kind,
> >> eglot should support 'implementation as a kind.
> >
> > By the the symbol you quoted is an internal implementation detail.
> > The fact that it can't be represented well under the current
> > patch is under discussion with Dmitry and it's super-easy to fix
> > whatever the outcome of that discussion is.  IOW that prompt should
> > show "Implementation".
> >
> >> If a backend doesn't support 'implementation, that works fine with the
> >> current patch - the backend just errors when kind=implementation is
> >> passed to xref-find-extra.  No awkward structure, no hacks.
> >
> > Oh, big awkward:
> >
> > 1. You lose the consistency you wanted so much.  I can't
> >    take my muscle memory from backend A to backend B.  I'll just get
> >    errors.
>
> Eh?  You'll only get an error if backend B doesn't support one of the
> core kinds.

Exactly, and you wrote "the backend just errors when kind=implemetation"
So you admit it's going to happen.

> I also get errors today if the backend doesn't support
> xref-find-references.  That doesn't make M-? (xref-find-references) any
> less of a consistent UI for modes that support it.

Yes, the notion of definition and reference are much less
controversial.

> > 2. If backend C supports many more things other than implementation
> >    typeDefinition, etc, they're either going to be awkwardly
> >    organized into those drawers or available as backend-specific
> >    commands you wanted to avoid in the first place.
>
> That is fine and exactly what I want.  I see an area where a degree of
> consistency is possible, so I see no reason not to get that degree of
> consistency.

But incomplete consistency contains, by definition, inconsistency!  IOW
"degree of consistency" is a fine example of an oxymoron.

> > When I get around to finishing refactor.el which will inherit most of
> > Eglot's UI for doing refactorings, I don't plan to burn the concepts of
> > "organizeImports" and "quickfix" into it.  They are LSP things.
>
> Sure, that sounds good.  But do you hope to eventually add a standard
> keybinding for accessing refactor.el?  I hope so.

Sure, for refactor-code-actions, which will work much like xref-find-extras,
aka xref-find-by-kind (or maybe it should be named only xref-find, or
why not only
xref).

But there won't be a command refactor-quickfix or refactor-organizeImports
because not all potential refactor.el backends support those LSP concepts.

It's exactly the same here.

> for these xref commands.  (but not for Eglot and LSP's sake!  My
> inspiration for making this thread is not Eglot and LSP, it's my own
> xref backend which also has these concepts)
>
> >> Practically, I don't want to have a different UI for these commands in
> >> every individual language and mode, I'd like a common set of bindings
> >> which are usable for every language which supports these concepts.
> >
> > And I'd like speakers of foreign languages to understand Portuguese
> > "go there go!".  And I yet I fail, and it's impossible to  explain.
> >
> >
> >> Which I think is most languages - including Elisp.
> >
> > "declarations" really?  Sure you could cram declare-function into
> > there, and it kind of emulates the forward-declaration meaning of it
> > in C/C++ which is clearly LSP got the idea from.  Fine.  But then what
> > about compiler-macro declarations and edebug declarations, etc, the
> > ones you use with `(declare (debug...))` in the beginning of functions
> > (sometimes not)?  They're an entirely different concept and yet known
> > as "declarations" for any Elisp (or Common Lisp) user. It's awkward to
> > find both mixed when you're thinking of just one.
>
> That's not what I'm suggesting.  I suggest that find-declarations when
> run on a generic should give the cl-defgeneric, and find-implementations
> should give the cl-defmethods.

Doesn't make sense to me, sorry.  In Elisp you work with symbols.  So
a given symbol has many possible meanings (a so-called lisp-2 has two
standard ones: variable and function bindings).  But you can add your
own, class definition, generic function, setf expander, autoload-function,
docstring, whatever crosses your mind.  In current Elisp-- but not
necessarily future Elisp--you alreadyhave two completely different concepts
of "declaration".   One is declaring functions early so the byte-compiler
doesn't complain about them and another is optional `declare` forms you find
in the first form of a function's body.  Completely different concepts,
miles apart.  Now you want to add a symbol's generic function definition
to the "declaration" family. Even more miles apart. So one day I find
a symbol, I press your desired xref-find-declarations on it and I get
this awkward salad of totally unrelated things.

I'd certainly like to be able to use xref to find the source code
loci for all these different things that a symbol might mean, of course
I do.  But xref-find-declaration is a awful way to do it.

Mind you that xref-find-references is much less problematic.
A "reference" is in essence any manifestation of a given
symbol/name/identifier in the source material, _regardless_ of
the specific kind of manifestation.

> I think that would be a really helpful new feature, apart from all the
> rest of this.
>
> If the term "declarations" and "implementations" are a problem, we could
> totally give them another name.
>
> How about "find-generic" and "find-methods"?  Just literally copying
> what Elisp calls them.  Then we can set aside all this worry about
> sharing terms with LSP.
>
> So let me restate my proposal in those terms:
>
> I'd like an xref-find-generic which in Elisp jumps to the cl-defgeneric,

So what would xref-find-generic do in C++ code?  It has no generics.
Most languages have no generics.  Most programmers I know have never
even heard of "generics".  "generic functions" even less so.  Why do
you want to burden these non-Lisp people with this new concept
from Common Lisp that they'll have to map to their own favourite
language they want to do their work on?  And no, never will "generic"
map clearly to the fundamental C/C++  concept of a declaration, for
example.  Not to mention Java has templates called "generics".
And C++ has templates called templates. Completely different concepts.

So IMO this is just a very bad idea, I'm afraid.

But I think we have made both our positions clear.  I understand what
you want to do and I am completely against it, but this is not just
up for me to decide.  The only thing that is, is that if I like the
new interfaces in xref.el I will implement them in eglot.el.  The
UI that xref.el provides I can't control.  Of course I recommend
keeping at least the current UI of xref-find-extra, not least because
it's something that has actually been implemented and I have
spent time integrating.  And I also like your idea of KIND=nil to
make it show a sectioned listing using whatever kinds the backend
declares as section headings.

In the end, people will be able to continue using LSP and xref.el
without any problems, with eglot-find-declaration, etc, that's a
given.

Joao



  reply	other threads:[~2023-11-10 13:59 UTC|newest]

Thread overview: 204+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 19:56 Adding support for xref jumping to headers/interfaces Spencer Baugh
2023-02-24 20:04 ` Eli Zaretskii
2023-02-24 21:29   ` Dmitry Gutov
2023-02-27 23:12     ` Stephen Leake
2023-02-27 23:34       ` Dmitry Gutov
2023-02-28  0:18         ` Yuan Fu
2023-02-28 16:05           ` Filipp Gunbin
2023-03-01  4:33             ` Richard Stallman
2023-03-01 12:50               ` Eli Zaretskii
2023-03-01 17:51                 ` John Yates
2023-03-04 18:54                   ` Stephen Leake
2023-03-04 22:24                     ` Dmitry Gutov
2023-03-05  6:11                       ` Eli Zaretskii
2023-03-05 12:06                         ` Dmitry Gutov
2023-03-07 22:41                           ` Dmitry Gutov
2023-03-08 14:58                             ` Eli Zaretskii
2023-03-08 18:23                               ` Dmitry Gutov
2023-03-08 19:49                                 ` Eli Zaretskii
2023-03-08 20:15                                   ` Dmitry Gutov
2023-03-09  6:13                                     ` Eli Zaretskii
2023-03-09 13:04                                       ` Dmitry Gutov
2023-03-09 15:36                                         ` Eli Zaretskii
2023-03-09 16:53                                           ` Dmitry Gutov
2023-03-09 17:31                                             ` Eli Zaretskii
2023-03-09 17:37                                               ` Dmitry Gutov
2023-05-16 21:10                                                 ` Spencer Baugh
2023-05-17 11:46                                                   ` Eli Zaretskii
2023-06-17  1:53                                                   ` Dmitry Gutov
2023-06-20 15:31                                                     ` João Távora
2023-06-22 19:22                                                       ` Spencer Baugh
2023-06-23  5:52                                                         ` Eli Zaretskii
2023-06-23 14:37                                                           ` Spencer Baugh
2023-06-23 14:53                                                             ` Eli Zaretskii
2023-06-23 15:03                                                         ` João Távora
2023-06-28 13:31                                                           ` Spencer Baugh
2023-11-04 22:43                                                           ` Dmitry Gutov
2023-11-04 22:00                                                       ` Dmitry Gutov
2023-11-04 22:24                                                         ` João Távora
2023-11-04 22:29                                                           ` Dmitry Gutov
2023-11-04 22:36                                                             ` João Távora
2023-11-04 23:20                                                               ` Dmitry Gutov
2023-11-04 23:16                                                   ` Dmitry Gutov
2023-11-04 23:21                                                     ` Dmitry Gutov
2023-11-04 23:24                                                     ` João Távora
2023-11-04 23:27                                                       ` Dmitry Gutov
     [not found]                                                         ` <CALDnm51sWvw4wiipYkJRB8za_8zpWg2-0jpoJDy_5urEa5okzQ@mail.gmail.com>
     [not found]                                                           ` <2752892c-4d27-1249-ca0a-6c24abbf1078@yandex.ru>
     [not found]                                                             ` <CALDnm51P5kfWNofybvxbzVZNnF9DwV5f2ZDGx9ziToBF7cJR6w@mail.gmail.com>
     [not found]                                                               ` <e043f63b-e997-805b-7f9a-64dcc0a9062e@yandex.ru>
     [not found]                                                                 ` <87zfzrybl1.fsf@gmail.com>
     [not found]                                                                   ` <57e53aae-bef9-d267-f7da-d4936fc37153@yandex.ru>
2023-11-07  9:36                                                                     ` João Távora
2023-11-07 22:56                                                                       ` Dmitry Gutov
2023-11-08  0:14                                                                         ` João Távora
2023-11-05  8:16                                                     ` Eshel Yaron
2023-11-07  2:12                                                       ` Dmitry Gutov
2023-11-07 17:09                                                         ` Spencer Baugh
2023-11-07 23:02                                                           ` Dmitry Gutov
2023-11-07 21:30                                                         ` Eshel Yaron
2023-11-07 23:17                                                           ` Dmitry Gutov
2023-11-08  0:21                                                             ` João Távora
2023-11-08  0:33                                                               ` Dmitry Gutov
2023-11-08  1:19                                                                 ` João Távora
2023-11-08 22:58                                                                   ` Dmitry Gutov
2023-11-08 23:22                                                                     ` João Távora
2023-11-08 23:34                                                                       ` Dmitry Gutov
2023-11-09  0:50                                                                         ` João Távora
2023-11-09 16:59                                                                           ` Spencer Baugh
2023-11-09 20:44                                                                             ` João Távora
2023-11-09 21:11                                                                               ` Spencer Baugh
2023-11-10 10:06                                                                                 ` João Távora
2023-11-10 12:02                                                                                   ` Spencer Baugh
2023-11-10 13:59                                                                                     ` João Távora [this message]
2023-11-10 17:36                                                                                       ` Spencer Baugh
2023-11-11 10:45                                                                                         ` Dmitry Gutov
2023-11-11 11:17                                                                                         ` João Távora
2023-11-11 12:38                                                                                           ` Spencer Baugh
2023-11-11 20:49                                                                                             ` Dmitry Gutov
2023-11-15 21:32                                                                                               ` Spencer Baugh
2023-11-24  1:37                                                                                                 ` Dmitry Gutov
2023-11-24 21:43                                                                                                   ` Felician Nemeth
2023-11-25  2:20                                                                                                     ` Dmitry Gutov
2023-11-26 16:08                                                                                                       ` Felician Nemeth
2023-11-26 20:15                                                                                                         ` Dmitry Gutov
2023-11-26 20:37                                                                                                           ` João Távora
2023-11-27 14:35                                                                                                             ` Dmitry Gutov
2023-11-27 15:03                                                                                                               ` João Távora
2023-11-27 15:45                                                                                                                 ` Dmitry Gutov
2023-11-27 16:04                                                                                                                   ` João Távora
2023-11-27 16:23                                                                                                                     ` Dmitry Gutov
2023-11-27 16:41                                                                                                                       ` João Távora
2023-11-27 17:05                                                                                                                         ` Dmitry Gutov
2023-11-27 17:09                                                                                                                           ` João Távora
2023-11-26 20:40                                                                                                         ` João Távora
2023-11-27 14:43                                                                                                           ` Dmitry Gutov
2023-11-27 14:49                                                                                                             ` João Távora
2023-11-27 15:01                                                                                                               ` Dmitry Gutov
2023-11-27 15:19                                                                                                                 ` João Távora
2023-11-28  0:18                                                                                                                   ` Dmitry Gutov
2023-11-28  9:51                                                                                                                     ` João Távora
2023-11-28 12:45                                                                                                                       ` Dmitry Gutov
2023-11-28 15:02                                                                                                                         ` João Távora
2023-11-28 16:32                                                                                                                           ` Dmitry Gutov
2023-11-28 17:16                                                                                                                             ` João Távora
2023-11-28 17:25                                                                                                                               ` Dmitry Gutov
2023-11-28 18:38                                                                                                                                 ` João Távora
2023-11-27 15:28                                                                                                                 ` Eli Zaretskii
2023-11-27 16:37                                                                                                                   ` Dmitry Gutov
2023-11-27 16:45                                                                                                                     ` João Távora
2023-11-27 17:40                                                                                                                     ` Eli Zaretskii
2023-11-27 18:26                                                                                                                       ` Dmitry Gutov
2023-11-27 20:50                                                                                                                         ` Eli Zaretskii
2023-11-27 20:53                                                                                                                           ` Dmitry Gutov
2023-11-26 20:30                                                                                                   ` João Távora
2023-11-27 15:17                                                                                                     ` Dmitry Gutov
2023-11-27 15:45                                                                                                       ` João Távora
2023-11-27 16:04                                                                                                         ` Dmitry Gutov
2023-11-27 16:27                                                                                                           ` João Távora
2023-11-27 17:22                                                                                                             ` Dmitry Gutov
2023-11-27 17:46                                                                                                               ` João Távora
2023-11-27 18:12                                                                                                                 ` Dmitry Gutov
2023-11-27 23:25                                                                                                                   ` João Távora
2023-11-28  0:30                                                                                                                     ` Dmitry Gutov
2023-11-28  0:43                                                                                                                       ` João Távora
2023-11-11  1:01                                                                                     ` Dmitry Gutov
2023-11-11  1:04                                                                                   ` Dmitry Gutov
2023-11-11 11:30                                                                                     ` João Távora
2023-11-11 21:01                                                                                       ` Dmitry Gutov
2023-11-12 18:40                                                                                         ` João Távora
2023-11-13  0:27                                                                                           ` Dmitry Gutov
2023-11-13  1:03                                                                                             ` João Távora
2023-11-13  1:05                                                                                               ` Dmitry Gutov
2023-11-13  1:16                                                                                                 ` João Távora
2023-11-13  1:41                                                                                                   ` electric-pair-mode vs paredit, was: " Dmitry Gutov
2023-11-13  1:53                                                                                                     ` João Távora
2023-11-11  0:58                                                                               ` Dmitry Gutov
2023-11-11 11:44                                                                                 ` João Távora
2023-11-11 21:37                                                                                   ` Dmitry Gutov
2023-11-12 18:59                                                                                     ` João Távora
2023-11-13  1:37                                                                                       ` Dmitry Gutov
2023-11-11  1:08                                                                               ` Dmitry Gutov
2023-11-11 11:22                                                                                 ` João Távora
2023-11-11 20:54                                                                                   ` Dmitry Gutov
2023-11-08 16:11                                                               ` Spencer Baugh
2023-11-08 17:20                                                                 ` João Távora
2023-11-08 17:40                                                                   ` Spencer Baugh
2023-11-08 23:08                                                                     ` João Távora
2023-11-09 16:52                                                                       ` CCing thread participants through gnus+gmane Spencer Baugh
2023-11-10 15:51                                                                         ` Eric Abrahamsen
2023-11-10 16:18                                                                         ` Visuwesh
2023-11-09 17:07                                                                       ` Adding support for xref jumping to headers/interfaces Spencer Baugh
2023-11-11  0:07                                                                         ` Dmitry Gutov
2023-11-11 12:39                                                                           ` Spencer Baugh
2023-11-11 20:45                                                                             ` Dmitry Gutov
2023-11-08 23:06                                                                 ` Dmitry Gutov
2023-11-07 16:51                                                     ` Spencer Baugh
2023-11-07 23:30                                                       ` Dmitry Gutov
2023-11-08 17:25                                                         ` Spencer Baugh
2023-11-09  0:08                                                           ` Dmitry Gutov
2023-11-09  0:26                                                             ` Dmitry Gutov
2023-11-09  1:06                                                               ` João Távora
2023-11-11  0:16                                                                 ` Dmitry Gutov
2023-11-09 17:57                                                             ` Spencer Baugh
2023-11-11  0:42                                                               ` Dmitry Gutov
2023-11-11 13:00                                                                 ` Spencer Baugh
2023-11-12  1:50                                                                   ` Dmitry Gutov
2023-11-12  2:08                                                                     ` João Távora
2023-11-12  2:09                                                                       ` Dmitry Gutov
2023-11-12  2:25                                                                         ` João Távora
2023-11-13  1:02                                                                           ` Dmitry Gutov
2023-11-13  1:24                                                                             ` João Távora
2023-03-01 15:00               ` [External] : " Drew Adams
2023-02-28 21:40           ` John Yates
2023-02-28 21:53             ` Dmitry Gutov
2023-02-28 22:44               ` Konstantin Kharlamov
2023-03-05  9:59 ` Helmut Eller
2023-03-05 12:03   ` Dmitry Gutov
2023-03-05 15:57     ` Helmut Eller
2023-03-05 16:33       ` Dmitry Gutov
2023-03-05 17:19         ` Stephen Leake
2023-03-05 20:10   ` João Távora
2023-03-05 20:32     ` João Távora
2023-03-05 20:40       ` Dmitry Gutov
2023-03-05 21:04         ` João Távora
2023-03-05 21:21           ` Dmitry Gutov
2023-03-05 21:48             ` João Távora
2023-03-05 22:08               ` Dmitry Gutov
2023-03-05 23:00                 ` João Távora
2023-03-05 23:40                 ` John Yates
2023-03-06 12:22                   ` Felician Nemeth
2023-03-06 13:15                     ` João Távora
2023-03-06 13:23                       ` Dmitry Gutov
2023-03-06 13:38                         ` João Távora
2023-03-06 13:46                           ` Dmitry Gutov
2023-03-06 13:52                             ` João Távora
2023-03-06 13:50                           ` Dmitry Gutov
2023-03-07  7:15                             ` Yuan Fu
2023-03-07 19:58                               ` Felician Nemeth
2023-03-07 20:44                                 ` Yuan Fu
2023-03-07 21:03                                 ` Dmitry Gutov
2023-03-06 14:09                   ` Dmitry Gutov
2023-03-06 14:15                     ` John Yates
2023-03-06 14:23                       ` Dmitry Gutov
2023-03-06 14:43                         ` John Yates
2023-03-10  0:57                     ` Ergus
2023-03-10 21:55                       ` Dmitry Gutov
2023-03-10 22:18                         ` João Távora
2023-03-10 22:25                           ` Dmitry Gutov
2023-03-11 11:50                             ` João Távora
2023-03-10 23:45                         ` Ergus

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CALDnm53oBXAuH7-oeGvKF+B6EY23Gpy9k6Ag0OpNv_PM9C0itA@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=sbaugh@catern.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).