Skip to content

Add command: eglot-execute-server-command#846

Open
nemethf wants to merge 1 commit into
masterfrom
scratch/execute-command
Open

Add command: eglot-execute-server-command#846
nemethf wants to merge 1 commit into
masterfrom
scratch/execute-command

Conversation

@nemethf

@nemethf nemethf commented Feb 25, 2022

Copy link
Copy Markdown
Collaborator

The new command's discoverability or usability can later be improved by putting the possible commands into Eglot's mode-line-menu. (If someday PR #808 or something similar is merged.)

Besides my own unreleased toy server, I know only one server that advertises its commands. It's pygls' example server: json-extension. I'm guessing this is because you always need to specify these commands in package.json for VS Code. Or so it seems.


The new command allows the users to ask the server to execute a
command advertised in the server's initial capabilities
(:executeCommandProvider/:commands).

  • eglot.el (eglot-execute-server-command): New command.

The new command allows the users to ask the server to execute a
command advertised in the server's initial capabilities
(:executeCommandProvider/:commands).

* eglot.el (eglot-execute-server-command): New command.
Comment thread eglot.el
"Ask current server to execute COMMAND
(Server announces the available commands in its _initialize_ reply.)"
;; This defun simply calls cl-defmethod `eglot-execute-command', because
;; that cannot be interactive.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really? it can't? What a pity.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, (info "(elisp) Generic Functions") says

     Functions defined using ‘cl-defmethod’ cannot be made interactive,
     i.e. commands (*note Defining Commands::), by adding the
     ‘interactive’ form to them.  If you need a polymorphic command, we
     recommend defining a normal command that calls a polymorphic
     function defined via ‘cl-defgeneric’ and ‘cl-defmethod’.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢 maybe @monnier can explain this. I can't see a technical reason why Emacs wouldn't allow this, but surely there must be one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants