Subject: Re: bug#65517: 30.0.50; Eglot: word list input

From: João Távora <[email-masked]>
Date: Fri, 25 Aug 2023 10:05:00 +0100

Gerd Möllmann <[email-masked]> writes:

> THe prompt of C-M-. advertises that the user can enter a list of words
> for search for, but that doesn't seem to be supported ATM.

C-M-. is bound to the command 'xref-find-apropos'.  Eglot has installed
a backend for this command.  

   (cl-defmethod xref-backend-apropos ((_backend (eql eglot)) pattern)

If you look into the implementation you'll see it uses the LSP
'workspace/symbol' request.  That interface is described in

   https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_symbol

The sparsely described 'query' field doesn't seem to explicitly support
'multiple word' searches of 'multiple word fragment' searches out of the
box.  Furthermore each LSP server implementation can more or less
interpret this freely.  Some LSP server implementation might even
support pattern-matching or even regexps there but it doesn't seem like
'clangd' (the server I presume you are using) does this.

You can see the communication in the Eglot events buffer.  For example
here's me trying to query for "ma loc" and getting no replies:

   [client-request] (id:32) Fri Aug 25 09:48:56 2023:
   (:jsonrpc "2.0" :id 32 :method "workspace/symbol" :params
             (:query "ma loc"))
   [stderr] I[09:48:56.386] <-- workspace/symbol(32)
   [server-reply] (id:32) Fri Aug 25 09:48:56 2023:
   (:id 32 :jsonrpc "2.0" :result [])

If I query for 'malloc' instead, I get loads of hits.

João