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 support for Emacs Lisp #784

Merged
merged 26 commits into from
Jun 26, 2023
Merged

Add support for Emacs Lisp #784

merged 26 commits into from
Jun 26, 2023

Conversation

Sasanidas
Copy link
Member

Add support for GNU Emacs Lisp programming language, aside from the syntax highlight, I thought a couple of approaches to enable a proper REPL:

I decided to use the last one, because it works, is easy to use and in the end, I'm not that interested in Lem becoming the best Emacs Lisp editor, so having basic REPL interaction is good enough for me.

@Sasanidas
Copy link
Member Author

So, aside from the basic Emacs Lisp interaction, using https://github.com/jcaw/porthole, I build a simple rpc server and using the great JSONRPC client https://github.com/cxxxr/jsonrpc.

I would add some basic completion, description and goto definition.

@Sasanidas
Copy link
Member Author

There is also an interesting idea here, there are some packages from GNU Emacs (like org-mode) with a lot of functionality that would be long to implement in Lem.

Until a package version comes, we can leverage that heavy lifting to a GNU Emacs instance. Which can be a custom one more suited to interact with Lem (so the user don't have to install GNU Emacs nor configure anything).

@Sasanidas
Copy link
Member Author

So, I moved away the elisp file and convert it to an Emacs Lisp package (https://github.com/Sasanidas/lemmigton).

I'm having some problems with the ELTR integration with the RPC server and I think it's an Emacs limitation on threads, given that ELTR takes the main thread as an input loop.

I'll open an issue on the ELTR repository so maybe we can look for a solution. 👍

@Sasanidas Sasanidas marked this pull request as ready for review June 26, 2023 13:02
@Sasanidas
Copy link
Member Author

Still, I think this pull request is good enough for the support for Emacs Lisp, I'll open more in the future to add other capabilities 👍 (ping @cxxxr for review)

Copy link
Member

@cxxxr cxxxr left a comment

Choose a reason for hiding this comment

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

Thank you for the very nice PR!
I have a few minor comments 🙏

@@ -0,0 +1,118 @@
(defpackage :lem-elisp-mode.run-elisp
Copy link
Member

Choose a reason for hiding this comment

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

We use a / to match the delimiter of the package name
The old one has . in some places, but I will fix it in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, I changed it 👍

lem.asd Outdated
Comment on lines 175 to 178
:build-operation program-op
:build-pathname "lem"
:entry-point "lem:main"
:depends-on ("lem-ncurses"))
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the indentation is off.
I would appreciate it if you could make the indentation the standard space indentation for lem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ops! Sorry, sometimes when I don't have sly open the auto-indentation is a little off.

"Returns a list of all the Emacs Lisp symbols defined."
(mapcar (lambda (i) (format nil "~a" i))
(jsonrpc:call client "lemmington-get-completion" (list prefix)
:basic-auth '("lem" . "lem"))))
Copy link
Member

Choose a reason for hiding this comment

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

Why is basic auth required?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's because of how https://github.com/jcaw/porthole works, still, I opened a pull request cxxxr/jsonrpc#37 to add it to jsonrpc

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I see.
I've merged it.

@cxxxr
Copy link
Member

cxxxr commented Jun 26, 2023

Thank you so much!

@cxxxr cxxxr merged commit 9c707cd into lem-project:main Jun 26, 2023
1 check passed
@vindarel
Copy link
Collaborator

Bravo! Is it on lem-page's documentation yet? :D

@Sasanidas
Copy link
Member Author

Oh, not yet, I do want to make a small explanation, right not is not that straight forward to get auto-completion (I'm also waiting for this issue jcaw/porthole#3 , because I don't want the hackish way of having 2 Emacs open)

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.

None yet

3 participants