-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Allow inserting closing delimiters for non-autoskip pairs #712
Conversation
94f502d
to
3f9edcb
Compare
For a test, would something like this be appropriate? (ert-deftest sp-test-sp-dont-inhibit-closing-pair-unless-autoskip ()
(sp-test-with-temp-buffer "" nil
(let ((sp-pairs sp-pairs))
(smartparens-strict-mode)
(sp-local-pair major-mode "{" "}" :actions '(insert autoskip navigate wrap))
(execute-kbd-macro "}")
(should (eq (char-before) nil))
(sp-local-pair major-mode "{" "}" :actions '(:rem autoskip))
(execute-kbd-macro "}")
(should (eq (char-before) ?\}))))) |
Pull request to address the issue (as I see it) in Smartparens: Fuco1/smartparens#712
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 think we can go with autoskip
for now. Later I have some thoughts of making the system a bit more fine-grained so we can have a permission for autoskip and for the insertion inhibition as separate things (as well as the regular insert action)
smartparens.el
Outdated
last (sp--get-allowed-pair-list)) | ||
(-when-let (pair (sp--char-is-part-of-closing | ||
last (sp--get-allowed-pair-list))) | ||
(memq 'autoskip (plist-get (sp-get-pair (car pair)) :actions))) |
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.
We can pass the keyword as an argument to sp-get-pair
which I think is slightly better if we later decide to change the internal representation.
The test is fine if it works :) |
3f9edcb
to
1738ef5
Compare
Don't inhibit inserting closing delimiters for pairs that don't use the autoskip action.
1738ef5
to
249ac32
Compare
Thanks for taking a look and for the feedback. I force-pushed an updated commit using the optional argument for |
Great! Sorry it took me so long. In the future don't hesitate to @ ping me if I take too long. My github workflow suck and I get tasks lost so often :/ |
No need to apologize but I will ping in the future - didn't want to be a bother if you just hadn't had a chance to get to it :) Thanks for reviewing/merging! |
Don't inhibit inserting closing delimiters for pairs that don't use the
autoskip
action.Commit a677859 added code to prevent closing delimiters from being inserted in strict mode. Typing a closing delimiter will either skip over the delimiter that was automatically inserted, or emit a message that an unbalanced delimiter was blocked from insertion. I think it makes sense to exempt from this pairs that don't use the
autoskip
action (and/or theinsert
action? more on that below), since in that case the only reason to type the closing delimiter is if you want to insert it.I ran into this because, in C-like modes, I set up
{}
for thenavigate
andwrap
actions, but notinsert
orautoskip
.It may also make sense to exempt pairs without the
insert
action, for basically the same reason - if you've configured Smartparens not to insert the closing delimiter for you, you probably intend to type it yourself. However, I never useinsert
withoutautoskip
or vice versa, so I'm not sure. Of the two, I went withautoskip
because it is more directly connected to typing a closing delimiter.