Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nemethf
Copy link
Collaborator

@nemethf nemethf commented Feb 25, 2022

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.
"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
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
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
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