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

Emacs: Add electric-pair-mode support for triple-quoted strings #8570

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

aathn
Copy link
Contributor

@aathn aathn commented Jun 13, 2024

This adds support for automatically inserting the closing delimiter for triple-quoted string literals in the Emacs mode.

If erlang-mode and electric-pair-mode are enabled, it works as follows, if | is the cursor position and a double quote is inserted.

""|  ->  """|"""

This is accomplished by adding a function to post-self-insert-hook checking whenever electric-pair-mode is enabled and a third double quote is inserted, and then inserting three more. The approach is taken from python.el, which has the same feature for Python's triple-quote strings.

@CLAassistant
Copy link

CLAassistant commented Jun 13, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

github-actions bot commented Jun 13, 2024

CT Test Results

  2 files   22 suites   6m 7s ⏱️
222 tests 219 ✅ 3 💤 0 ❌
248 runs  245 ✅ 3 💤 0 ❌

Results for commit 36a35ce.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@rickard-green rickard-green added the team:PS Assigned to OTP team PS label Jun 17, 2024
@dgud
Copy link
Contributor

dgud commented Jun 25, 2024

Shouldn't we add a newline before closing """ as well?

@u3s u3s added the waiting waiting for changes/input from author label Jul 2, 2024
@IngelaAndin
Copy link
Contributor

@aathn ping

@aathn
Copy link
Contributor Author

aathn commented Aug 27, 2024

Shouldn't we add a newline before closing """ as well?

We could -- I suppose it's a matter of personal taste. In languages with brace-enclosed blocks { ... }, I'm usually happy to have the closing brace added automatically, but opening the newline myself. Of course, in those languages, it's typically syntactically correct even without the newline, whereas with the triple-quoted string syntax the newline is required

@dgud
Copy link
Contributor

dgud commented Sep 20, 2024

I do think I want that in this case since it is required, I see that as a remainder and education, also it is a new feature
which at least I tend to forget that the newline is required there.

Can you add it please.

@aathn
Copy link
Contributor Author

aathn commented Sep 21, 2024

Done. Now it works as follows:

""| 
->
"""
|
"""

Does that look okay?

@dgud
Copy link
Contributor

dgud commented Sep 24, 2024

Thanks

@dgud dgud merged commit 5ee148b into erlang:master Sep 24, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:PS Assigned to OTP team PS waiting waiting for changes/input from author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants