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

gh-63075: IDLE editor - Auto insertion of the closers #3520

Open
wants to merge 75 commits into
base: main
Choose a base branch
from

Conversation

wohlganger
Copy link
Contributor

@wohlganger wohlganger commented Sep 12, 2017

This patch is for Auto insertion of the closing parens, brackets, and braces enhancement. It includes necessary changes to config-extensions.def, and idlelib.test.test_config. It has its own test which covers all non - init statements. As of writing this, idlelib.tests passes on all tests other than calltips, which appears to be a preexisting problem.

https://bugs.python.org/issue18875

wohlganger and others added 30 commits June 29, 2017 15:11
adds fg color, bg color, font, and underline options for parens highlighting
How did the change to the __doc__ of append not get fixed in the tests earlier?
Used incorrect / old python for testing.
Fixing code conflict ate highlighting options. Needed to be re-introduced.
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

Now that we are no longer implementing new features as extensions, this patch needs to be rewritten before it can be properly review in action. If someone else wants to do so before I get to it, please say so in a comment.

The comments below indicate the major changes needed.

@@ -0,0 +1,115 @@
"""
Copy link
Member

Choose a reason for hiding this comment

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

Add ParenClose to parenmatch.py.

When you hit left paren or tick,
automatically creates the closing paren or tick.

Author: Charles M. Wohlganger
Copy link
Member

Choose a reason for hiding this comment

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

Remove. This already has input from 3 other people. I will list Charles as original author in the news entry.

Add to the end of config-extensions.def :

[ParenClose]
enable = True
Copy link
Member

Choose a reason for hiding this comment

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

Delete.

paren_close = True
tick_close = True
skip_closures = True
mutual_delete = True
Copy link
Member

Choose a reason for hiding this comment

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

I think defaults should be 'off', as in no change from current behavior. I am not sure what latter 2 mean. See below.

Copy link
Member

Choose a reason for hiding this comment

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

Changing the specification of the new feature by adding action on deletion should have been discussed on the issue. (This applies generally to changing specs.) Notepad++ does do anything special on deletion. Binding the deletion keys here prevents binding them elsewhere, and I have an idea of where it might be needed, as opposed to optional. I also think sometimes delete more and sometimes not is confusing. The deletion part of 2f19ca8 and anything later should be reverted unless and until there is a clear agreement on adding this.

tick_close = True
skip_closures = True
mutual_delete = True
[ParenClose_cfgBindings]
Copy link
Member

Choose a reason for hiding this comment

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

Delete section. Not needed for hard-coded features.

deleted before the new one is typed, effectively skipping over the closure.
If the cursor is between two closures and mutual_delete or mutual_backspace
is True, when the respective command is given, both closures are deleted.
'''
Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand these.

@@ -63,3 +63,17 @@ z-text= Z
z-in= <Control-Shift-KeyRelease-Insert>
[ZzDummy_bindings]
z-out= <Control-Shift-KeyRelease-Delete>

Copy link
Member

Choose a reason for hiding this comment

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

As I said above, put in config-general.

eq(iGE(), ['ZzDummy', 'ParenClose'])
eq(iGE(editor_only=True), ['ZzDummy', 'ParenClose'])
eq(iGE(active_only=False), ['ZzDummy', 'ParenClose', 'DISABLE'])
eq(iGE(active_only=False, editor_only=True), ['ZzDummy', 'ParenClose', 'DISABLE'])
Copy link
Member

Choose a reason for hiding this comment

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

I believe that all these changes to test_config only apply to extensions, and are therefore not needed.

@@ -0,0 +1,97 @@
'''Test idlelib.parenclose.
Copy link
Member

Choose a reason for hiding this comment

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

Add MockEvent and ParenCloseTest to test_parenmatch. I have not reviewed in detail, but have a couple of comments.

delete = p.delete_event
for paren_close_set, tick_close_set, skip_closures_set, mutual_b_set, \
mutual_d_set, insert, func, pos, char, result, posend in [
(1, 1, 1, 1, 1, 'def abuse', p_open, '1.9', '(',
Copy link
Member

Choose a reason for hiding this comment

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

for test_tuple in [<list of tuples>] would allow test_tuple to be passed to a helper function.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Trigger a retest to see if CI produces same odd failures as on another PR.
@csabella
Copy link
Contributor

csabella commented Apr 6, 2018

I would like to help out, but I believe Charles would need to make the changes. I don't have 'push access' to his branch.

@ghost
Copy link

ghost commented May 5, 2019

Hi,
this would be really helpful in IDLE; it's not just for lazy people, but to reduce errors caused by accidentally forgetting to close a (, ", [ or { .
It happens to me every day, and because of that, I'm considering switching to another editor.
Thanks for working on it!

Is it possible to somehow include this patch manually, after installation of Python, even if it's not fully worked-on here?

@terryjreedy
Copy link
Member

This PR makes a unrelated changes to the unix file mode of Tools/ssl/multissltests.py. This must be reverted between this can be applied. I don't think I can do so in Windows. Clicking ... to the right gives an option to 'Delete file'. I have the impression that this actually adds file deletion to the PR rather than removing the file change from the PR.

@terryjreedy
Copy link
Member

There is no patch to the IDLE doc. I now think that this perhaps even be the first thing to do, rather than a possibly delayed afterthought.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 21, 2022
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jul 29, 2022
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Aug 30, 2022
@terryjreedy terryjreedy changed the title bpo-18875 Auto insertion of the closing parens, brackets, braces, and ticks gh-63075: IDLE editor - Auto insertion of the closers Aug 30, 2022
@terryjreedy terryjreedy self-assigned this Aug 30, 2022
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 31, 2022
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes stale Stale PR or inactive for long period of time. topic-IDLE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants