classification
Title: Idle: Auto insertion of the closing parens, brackets, and braces
Type: enhancement Stage: patch review
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: 3068 Superseder:
Assigned To: terry.reedy Nosy List: irdb, louielu, terry.reedy, wohlganger
Priority: normal Keywords: patch

Created on 2013-08-29 11:58 by irdb, last changed 2017-09-28 06:58 by taleinat.

Files
File name Uploaded Description Edit
ParenClose.py wohlganger, 2017-07-17 20:39 Extension to close parens, brackets, braces, ticks, and quotes
ParenClose.py wohlganger, 2017-07-18 13:47 version 0.2, added docstring, pep8 fixes
test_parenclose.py wohlganger, 2017-07-20 20:53 parenclose test
ParenClose.py wohlganger, 2017-07-20 20:59 version 0.4, made it easier to test, fixed problems found in testing
test_parenclose.py wohlganger, 2017-07-21 15:15 parenclose test 0.2 - pep8-ified, fixed minor bug
Pull Requests
URL Status Linked Edit
PR 3520 open wohlganger, 2017-09-12 19:24
Messages (12)
msg196456 - (view) Author: (irdb) Date: 2013-08-29 11:58
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?
msg196593 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-08-30 22:30
I have thought about such a feature also. I would at least like to have patch to try it out. Possible? I suspect so.
msg220632 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-15 13:18
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.
msg220651 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-15 16:49
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?
msg220653 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2014-06-15 17:16
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.
msg220664 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2014-06-15 18:55
Well, I was wrong. I can't find anything of the sort in my old IDLE files.
msg228254 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-02 20:15
This would have to be an extension, default off unless overridden, which is why I added config-extensions as dependency.
msg298554 - (view) Author: Charles Wohlganger (wohlganger) * Date: 2017-07-17 20:39
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.
msg298573 - (view) Author: Louie Lu (louielu) * Date: 2017-07-18 03:57
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 PEP8. I can help you on GitHub to review this patch.
msg298586 - (view) Author: Charles Wohlganger (wohlganger) * Date: 2017-07-18 13:47
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 pep8 until it gave no errors. Namespaces should conform to PEP8, apart from the module name, which must match the class name due to how IDLE works with extensions.
msg298750 - (view) Author: Charles Wohlganger (wohlganger) * Date: 2017-07-20 20:59
I've uploaded a test file and updated ParenClose.
msg302620 - (view) Author: Charles Wohlganger (wohlganger) * Date: 2017-09-20 14:19
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.
History
Date User Action Args
2017-09-28 06:58:19taleinatsetnosy: - taleinat
2017-09-20 14:19:39wohlgangersetmessages: + msg302620
2017-09-12 19:24:04wohlgangersetkeywords: + patch
stage: patch review
pull_requests: + pull_request3517
2017-07-21 15:15:55wohlgangersetfiles: + test_parenclose.py
2017-07-20 20:59:57wohlgangersetfiles: + ParenClose.py

messages: + msg298750
2017-07-20 20:53:58wohlgangersetfiles: + test_parenclose.py
2017-07-18 13:47:11wohlgangersetfiles: + ParenClose.py

messages: + msg298586
2017-07-18 03:57:42louielusetnosy: + louielu
messages: + msg298573
2017-07-17 20:39:57wohlgangersetfiles: + ParenClose.py
nosy: + wohlganger
messages: + msg298554

2017-06-30 00:53:54terry.reedysetassignee: terry.reedy

nosy: - BreamoreBoy
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2014-10-02 20:16:00terry.reedysettitle: Automatic insertion of the closing parentheses, brackets, and braces -> Idle: Auto insertion of the closing parens, brackets, and braces
dependencies: + IDLE - Add an extension configuration dialog
messages: + msg228254
versions: + Python 2.7, Python 3.4
2014-06-15 18:55:25taleinatsetmessages: + msg220664
2014-06-15 17:16:15taleinatsetmessages: + msg220653
2014-06-15 16:49:57terry.reedysetnosy: + taleinat
messages: + msg220651
2014-06-15 13:18:13BreamoreBoysetnosy: + BreamoreBoy

messages: + msg220632
versions: + Python 3.5, - Python 3.4
2013-08-30 22:30:07terry.reedysetnosy: + terry.reedy

messages: + msg196593
versions: + Python 3.4, - Python 2.7
2013-08-29 11:58:18irdbcreate