gh-89520: IDLE - Make extentions use user's keys, not all defaults#28713
Conversation
I was trying to write an extension for Idle, and was noticing extension keys defined in ~/.idlerc weren't being used, so I looked into it and found `GetExtensionKeys`, `__GetRawExtensionKeys`, and `GetKeyBinding` would never check for user keys, always assuming default keys have everything. This is not always true. In a system with multiple users, you would not want to modify the default config file for a custom extension, as that is used for everyone. This pull request is changing aforementioned functions to also check user config files, and overwrite values acquired from the default config file if the user config redefined one.
Config saving and loading also weren't working quite right for extensions.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
gpshead
left a comment
There was a problem hiding this comment.
manually tested in addition to the unittests, it appears to work. i refactored the change with claude a bit to polish it up and address any remaining issues.
|
Thank you so much! I've been waiting to get this merged for five years now, glad this is finally done. |
…fig (pythonGH-28713) Extension keybindings defined in ~/.idlerc/config-extensions.cfg were silently ignored because GetExtensionKeys, __GetRawExtensionKeys, and GetExtensionBindings only checked default config. Fix these to check user config as well, and update the extensions config dialog to handle user-only extensions correctly. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
Sorry, @CoolCat467 and @gpshead, I could not cleanly backport this to Same failure for 3.13. I thought issue might have been in editor.py because an earlier issue added several lines there. After backporting that PR, I tried again but cherry-picker failed again. Issue was in test_zzdummy.py where the swapping of blocks did not get done correctly, leading to an apparent conflict. After I fixed that, cherry_picker could not quite finish so I pushed its corrected backport and made the PR reported below. I will try to backport to 3.13 from the 3.14 backport even though not standard. Otherwise would have to redo conflict resolution. |
|
GH-152992 is a backport of this pull request to the 3.14 branch. |
…nfig (GH-28713) (#152992) Extension keybindings defined in ~/.idlerc/config-extensions.cfg were silently ignored because GetExtensionKeys, __GetRawExtensionKeys, and GetExtensionBindings only checked default config. Fix these to check user config as well, and update the extensions config dialog to handle user-only extensions correctly. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> (cherry picked from commit 208195d)
…nfig (GH-28713) (GH-152992) (#152993) [3.14] gh-89520: Load extension settings and keybindings from user config (GH-28713) (GH-152992) Extension keybindings defined in ~/.idlerc/config-extensions.cfg were silently ignored because GetExtensionKeys, __GetRawExtensionKeys, and GetExtensionBindings only checked default config. Fix these to check user config as well, and update the extensions config dialog to handle user-only extensions correctly. --------- (cherry picked from commit 8a8c8ee) (cherry picked from commit 208195d) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
I was trying to write an extension for Idle, and was noticing extension keys defined in ~/.idlerc weren't being used, so I looked into it and found that in idlelib.config.idleConf,
GetExtensionKeys,__GetRawExtensionKeys, andGetKeyBindingwould never check for user keys, always assuming default keys have everything. This is not always true. In a system with multiple users, you would not want to modify the default config file for a custom extension, as that is used for everyone. This pull request is changing aforementioned functions to also check user config files, and overwrite values acquired from the default config file if the user config redefined one.Edit:
The especially interesting part is that extensions are loaded anyways if they have an entry in the user's IDLE configuration file, but their keybinds are only loaded properly if they are defined in the root configuration file at the moment. This pull request is fixing this difference and allows extension keybinds to be loaded from the user's IDLE configuration file, making user extensions work just as well as root extensions.