-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix: Hook into eglot-ensure, instead of eglot--executable-find #51
base: main
Are you sure you want to change the base?
Conversation
I see that there are tests around |
7300274
to
1c0a400
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too complicated and advicing too far away from the call sites of executable-find. There's both eglot
and eglot-ensure
to activate eglot, and you've only advised eglot-ensure
.
You need to advise eglot-alternatives
and eglot--guess-contact
, and in the advices, you just need to let bind file-name-handler-alist
to a separate handler to resolve the exec path to the python executables.
Okay, makes sense. Let me go through the eglot code a bit more carefully, and rewrite the commit based on your strategy. I'll do this as and when time permits this week and submit a patch. |
No worries, take your time. Thanks for the report regardless. |
Hi @wyuenho : Advising If I look at the function that The option that remains, I think, is adjusting the path before the What do you think? I can clean up the approach in the original to only run before applying |
This is incorrect for both counts. |
The call to
The lambda function returned by
|
You can advise a function even before the function to be adviced has been defined and loaded.
Ah thanks, I read the remote branch above and missed the local branch below. In that case, it's probably even easier, just replace the definition of |
I think I am completely misunderstanding the situation here. Please clear it up for me.
What am I misunderstanding? |
There are a couple of ways around this:
WRT to the lambda in Alternatively, if the above sounds insanely complex to you, you can advice |
Yes, this makes sense! In my opinion, the right approach would be to advice I have updated the commits with this approach, and tested locally that it works. One open point is that I need to write tests, which is something I'll do over the weekend. Until then, please review the code change! |
1c0a400
to
3566a6f
Compare
(defun pet-eglot-alternatives (alternatives) | ||
"Use `pet-executable-find' instead of `executable-find' in the | ||
`eglot-alternatives' closure." | ||
(lambda (&optional interactive _project) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "replacing the definition of executable-find
, I don't mean copy and paste, there's cl-flet
and cl-letf
for these kind of things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've kept the structure similar to the existing eglot code on purpose, because it makes reading and understanding the code simpler in my opnion.
Even if we were to use cl-flet
, we should still have to reproduce the entire lambda starting on line 917 because that's what the closure is. Only one line in the closure changes (replacing of executable-find
with pet-executable-find
, on line 932), but we have to copy the entire closure over anyway because the rest of the logic is still necessary.
'(python-base-mode) '(python-mode))) | ||
(let ((eglot-server-programs `(((python-mode python-ts-mode) | ||
;; Based on eglot v1.17, 2024-12-12 | ||
. ,(pet-eglot-alternatives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you advice eglot--lookup-mode
, you can just look up the executables here right? Why do you still need to advice eglot-alternatives
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not adviced eglot-alternatives
. I have just mimic'd the structure for readability purposes. I could have replaced line 966 with the closure starting on line 917, but this does not reduce complexity or improve readability in any way.
Remove the code as well as the associated tests.
`eglot--executable-find` was an internal function that has been removed in the latest version of Eglot (1.17). Due to this, `emacs-pet` no longer works with Eglot correctly, since it's advice is not used anymore. wyuenho#50 In this commit, we fix the issue by making the following changes: 1. Remove all references to unused or non-existent eglot variables. - `eglot--executable-find` no longer exists. - `eglot--uri-to-path` is not used by pet. 2. Advice `eglot--lookup-mode` to use the pet version of `eglot-server-programs`. - Provide a new closure to eglot to find LSP executables. - Use `pet-executable-find` in this closure.
fa6889e
to
b9254dd
Compare
I've rebased my changes on top of the latest |
eglot--executable-find
was an internal function that has been removed in the latest version of Eglot (1.17). Due to this,emacs-pet
no longer works with Eglot correctly, since it's advice is not used anymore. #50In this commit, we fix the issue by making the following changes:
Extract the internals of
pet-executable-find
into an independent functionpet-adjust-path-executable-find
.exec-path
andtramp-remote-path
variables, and add venv paths found by pet. Eglot can now find the path to the right executables correctly.setenv PATH
, since we don't need to modify a global system setting to make venv executables available to Eglot.Remove all references to unused or non-existent eglot variables.
eglot--executable-find
no longer exists.eglot--uri-to-path
is not used bypet
.Modify
pet-executable-find
to use our new functionpet-adjust-paths-executable-find
.Advice
eglot-ensure
, which is an Eglot public API that is always called when starting an LSP server.I've tested this change as follows:
make test
to run correctly, because of native compilation / Emacs 31 issues.