Subject: Re: bug#61506: 30.0.50; [PATCH]: Send command in eglot completion exit-function

From: Theodor Thornhill <[email-masked]>
Date: Mon, 20 Feb 2023 15:13:36 +0100

João Távora <[email-masked]> writes:

> On Sat, Feb 18, 2023 at 10:20 PM Theodor Thornhill <[email-masked]> wrote:
>
>  Ping :-)
>
> Presuming you meant to ping me, I'm not sure I can provide much more input
> at the moment.  As I wrote, if someone is familiar with this part of the standard 
> I'll be happy to review a patch adding this to Eglot.  
>
> I share with Felician a concern: if the notification can be sent from the exit-function 
> it's one thing, and the patch is possibly a one or two-liner.  If, OTOH, the notification 
> has to be sent after the didChange that follows a completion choice, then it's 
> probably a much more complicated change.
>

Yeah, the patch add this only to the exit-function, which also sends a
didChange. No need to add this to anything else than the exit-function,
I believe. Not sure whether you looked at the patch, but here it is
inlined:

```
Send command in eglot completion exit-function

* lisp/progmodes/eglot.el: Destructure optional argument command.
(eglot-completion-at-point): Send command if supplied by server.

1 file changed, 4 insertions(+), 1 deletion(-)
lisp/progmodes/eglot.el | 5 ++++-

modified   lisp/progmodes/eglot.el
@@ -2925,7 +2925,7 @@ eglot-completion-at-point
                                     (window-buffer (minibuffer-selected-window))
                                   (current-buffer))
              (eglot--dbind ((CompletionItem) insertTextFormat
-                            insertText textEdit additionalTextEdits label)
+                            insertText textEdit additionalTextEdits label command)
                  (funcall
                   resolve-maybe
                   (or (get-text-property 0 'eglot--lsp-item proxy)
@@ -2965,6 +2965,9 @@ eglot-completion-at-point
                  (when (cl-plusp (length additionalTextEdits))
                    (eglot--apply-text-edits additionalTextEdits)))
                (eglot--signal-textDocument/didChange)
+               (when command
+                 (eglot--dbind ((Command) command arguments) command
+                   (eglot-execute-command server (intern command) arguments)))
                (eldoc)))))))))
 
 (defun eglot--hover-info (contents &optional _range)
```