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

Idle: Auto insertion of the closing parens, brackets, and braces #63075

Open
THRlWiTi mannequin opened this issue Aug 29, 2013 · 14 comments
Open

Idle: Auto insertion of the closing parens, brackets, and braces #63075

THRlWiTi mannequin opened this issue Aug 29, 2013 · 14 comments
Assignees
Labels
3.10 only security fixes topic-IDLE type-feature A feature request or enhancement

Comments

@THRlWiTi
Copy link
Mannequin

THRlWiTi mannequin commented Aug 29, 2013

BPO 18875
Nosy @terryjreedy, @mlouielu, @wohlganger
PRs
  • gh-63075: IDLE editor - Auto insertion of the closers #3520
  • Files
  • ParenClose.py: Extension to close parens, brackets, braces, ticks, and quotes
  • ParenClose.py: version 0.2, added docstring, pep8 fixes
  • test_parenclose.py: parenclose test
  • ParenClose.py: version 0.4, made it easier to test, fixed problems found in testing
  • test_parenclose.py: parenclose test 0.2 - pep8-ified, fixed minor bug
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = None
    created_at = <Date 2013-08-29.11:58:18.555>
    labels = ['expert-IDLE', 'type-feature', '3.10']
    title = 'Idle: Auto insertion of the closing parens, brackets, and braces'
    updated_at = <Date 2020-07-21.02:59:16.139>
    user = 'https://bugs.python.org/THRlWiTi'

    bugs.python.org fields:

    activity = <Date 2020-07-21.02:59:16.139>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = False
    closed_date = None
    closer = None
    components = ['IDLE']
    creation = <Date 2013-08-29.11:58:18.555>
    creator = 'THRlWiTi'
    dependencies = []
    files = ['47021', '47023', '47029', '47030', '47031']
    hgrepos = []
    issue_num = 18875
    keywords = ['patch']
    message_count = 14.0
    messages = ['196456', '196593', '220632', '220651', '220653', '220664', '228254', '298554', '298573', '298586', '298750', '302620', '315009', '374049']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'THRlWiTi', 'louielu', 'wohlganger']
    pr_nums = ['3520']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue18875'
    versions = ['Python 3.10']

    @THRlWiTi
    Copy link
    Mannequin Author

    THRlWiTi mannequin commented Aug 29, 2013

    Many other IDE's have this feature that allows automatic insertion of closing parentheses as user is typing something. I think it saves time and increases programming speed. Is it possible to have this on IDLE, too?

    @THRlWiTi THRlWiTi mannequin added topic-IDLE type-feature A feature request or enhancement labels Aug 29, 2013
    @terryjreedy
    Copy link
    Member

    I have thought about such a feature also. I would at least like to have patch to try it out. Possible? I suspect so.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 15, 2014

    I'd like to see this feature as I've been using IDLE quite a lot recently and I'm so used to seeing it in other IDEs.

    @terryjreedy
    Copy link
    Member

    I have never actually used this feature, and I do not see it in Notepad++. I worry that some people, especially beginners with no experience of this 'feature' would hate this, so it would have to be optional.

    Do you literally mean 'parentheses' or also square and curly brackets? How about quotes? An autocloser here would be useful as Idle would not mishighlight the remainer of the text.

    How does it increase speed? Hitting -> to skip over the closer is hardly faster that typing the closer. It might reduce errors though.

    Tal, any opinion on this?

    @taleinat
    Copy link
    Contributor

    I like the idea, though it's really just nice to have. This is a very common in IDEs these days, and whoever finds it annoying will be able to disable it.

    If we do this, we should go all the way and close square and curly brackets, parenthesis, and quotes (including triple quotes!).

    Also, any implementation must allow typing the closing parenthesis to actually just move the cursor beyond the automatically generated closer. Getting this right is more difficult than it sounds! But certainly possible.

    I actually seem to recall having seen this implemented for IDLE quite a few years ago. I might even have been the one to implement it... I can't see any mention in IDLE-Spoon, IdleX or VIDLE, though. I'll take a look through my old files when I get the chance back home.

    @taleinat
    Copy link
    Contributor

    Well, I was wrong. I can't find anything of the sort in my old IDLE files.

    @terryjreedy
    Copy link
    Member

    This would have to be an extension, default off unless overridden, which is why I added config-extensions as dependency.

    @terryjreedy terryjreedy changed the title Automatic insertion of the closing parentheses, brackets, and braces Idle: Auto insertion of the closing parens, brackets, and braces Oct 2, 2014
    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Jun 30, 2017
    @terryjreedy terryjreedy self-assigned this Jun 30, 2017
    @wohlganger
    Copy link
    Mannequin

    wohlganger mannequin commented Jul 17, 2017

    I've written an extension (see file) that does auto insertion of closing parens, brackets, braces, ticks, and quotes. It also (optionally) skips the closers when they are typed right next to the already exiting one. It also takes into account triple-ticks / triple-quotes.

    @mlouielu
    Copy link
    Mannequin

    mlouielu mannequin commented Jul 18, 2017

    Charles, good to saw the patch, would you like to convert it into GitHub PR? also, it would have to adjust some coding style to satisfy PEP-8. I can help you on GitHub to review this patch.

    @wohlganger
    Copy link
    Mannequin

    wohlganger mannequin commented Jul 18, 2017

    I (foolishly) was committing to master for a different IDLE enhancement. Until that one is pulled, I don't think I can make a new PR without it also having all the changes from my previous one.

    New uploaded file has docstrings for the ParenClose class and I've run and fixed it against PEP-8 until it gave no errors. Namespaces should conform to PEP-8, apart from the module name, which must match the class name due to how IDLE works with extensions.

    @wohlganger
    Copy link
    Mannequin

    wohlganger mannequin commented Jul 20, 2017

    I've uploaded a test file and updated ParenClose.

    @wohlganger
    Copy link
    Mannequin

    wohlganger mannequin commented Sep 20, 2017

    The PR contains all the requested features, as well as mutual deletion (requested on PR page), and I have separated out the options for mutual deletion triggered by delete or triggered by backspace. I've found in usage that it was irritating to have both, but nice to only have one. Let users pick one, both, or none.

    @terryjreedy
    Copy link
    Member

    My question about the idea is whether beginners would use this, or if it is the sort of 'expert' feature that IDLE should avoid. I may ask on python-list for more opinions.

    https://stackoverflow.com/questions/49677886/python-idle-symbol-completion/49684824#49684824 adds a vote in favor. It also prompted me to review the patch.

    Since I said, 4 years ago, that the feature should be an extension, we have converted extensions to features. So the patch needs re-writing, as I outlined.

    (Although there is now an extension configuration dialog, it is no longer a dependency of this issue.)

    I am not convinced that we need 5 configuration options, especially since I do not understand 2 of them ;-). Do symbol and quote fences need to be separately enabled? Does anyone known what other IDEs do?

    @terryjreedy terryjreedy added the 3.8 (EOL) end of life label Apr 6, 2018
    @terryjreedy
    Copy link
    Member

    terryjreedy commented Jul 21, 2020

    I found this in Notepad++ under Settings -> Preferences -> Auto-completion -> Auto-insert with separate checkboxes for (, {, [, ', ", html/xml tags, and up to 3 custom pairs. Way too elaborate for IDLE. The only question to me is whether to have just one option for all 5 openers or separate option to complete ([{ versus quotes.

    Concerns: a) matching triple quotes is a bit baroque, though possible the most useful part of the feature; b) except for completing tripple quotes, no keystrokes are saved, and then only if one used End to skip three chars at once. On the other hand, at least some people who have use the feature elsewhere consider it a net win.

    Implementation notes: 1. IDLE editors uses two mechanisms to respond to keystrokes. The delegator mechanism checks all keystrokes and responds to some. IDLE otherwise binds keystrokes to event-handlers or to pseudoevent bound to event-handlers. Perhaps these could be unified and made more efficient.

    1. In the meanwhile... Menu items are bound to pseudoevents, along with corresponding hot keys. This issue will *not* add a menu entry "Add matching closer". So the openers can be bound directly to event handlers that look at the opener.

    @terryjreedy terryjreedy added 3.10 only security fixes and removed 3.7 (EOL) end of life 3.8 (EOL) end of life labels Jul 21, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @erlend-aasland erlend-aasland moved this to In Progress in IDLE Issues Jul 27, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes topic-IDLE type-feature A feature request or enhancement
    Projects
    Status: In Progress
    Development

    No branches or pull requests

    2 participants