-
-
Notifications
You must be signed in to change notification settings - Fork 235
Conversation
(following Discord:) I pull the branch, start Lem, start the mode with M-x smart-parens-mode and typing a ( inserts the pair. It works! (except it inserts too many closing parens)
daninus14
commented
Aug 13, 2025
Hm. smart-parens-mode is not showing up for me. What is your workflow? I was doing a make build after each change in the code. Are you running it from slime? How do I run it locally without building?
cxxxr
commented
Aug 13, 2025
I tried it, and make was successful.
The feature in this mode are also working.
cxxxr
commented
Aug 13, 2025
Screencast.from.2025年08月14日.01-39-12.webm
@cxxxr
cxxxr
left a comment
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 am happy to contribute to lem.
I have made a few comments.
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.
One problem with this implementation is that it implicitly relies on C-like syntax.
It would be better to refer to the syntax-table for each mode.
for example
CL-USER> (lem:syntax-open-paren-char-p #\()
(#\( . #\))
CL-USER> (lem:syntax-open-paren-char-p #\[)
(#\[ . #\])
CL-USER> (lem:syntax-open-paren-char-p #\{)
(#\{ . #\})
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.
Hm, do you mean that instead of using define-key I should use some function which gets the currently inserted character like this:
(defun close-paren (given-char) (when (lem:syntax-open-paren-char-p given-char) (apply #'editor-insert-pair (lem:syntax-open-paren-char-p given-char))))
That seems like it would only work for the parens and not the " and ' quote characters.
I don't know lem well enough. What function or macro would I pass this close-paren function to?
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.
lem/extensions/c-mode/c-mode.lisp
Line 13 in 4072439
syntax-table is defined here in C, for example.
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.
for example, like this
(defmethod execute ((mode smart-parens-mode) (command self-insert) argument)
(let ((c (get-self-insert-char)))
(alexandria:when-let (pair (syntax-open-paren-char-p c))
(editor-insert-pair (car pair) (cdr pair))
(return-from execute))
(when (syntax-string-quote-char-p c)
(editor-insert-pair c c)
(return-from execute))
(call-next-method)))
daninus14
commented
Nov 12, 2025
Ok, I realize I doubt I'll ever get to change this code. This is a stylistic issue for an optional mode, where the code works. It's based on code of existing modes. While I understand it's better to have your desired style in the code base, considering this is not even part of the main code base and it's an additional mode, following the style of other modes, I think it's reasonable to ask to accept the PR.
not currently working, this is just a draft