This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE should support platform-specific default config defaults
Type: enhancement Stage: test needed
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: 27099 Superseder:
Assigned To: terry.reedy Nosy List: markroseman, ned.deily, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2014-02-10 10:19 by ned.deily, last changed 2022-04-11 14:57 by admin.

Pull Requests
URL Status Linked Edit
PR 2494 wohlganger, 2017-08-26 20:11
Messages (15)
msg210816 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-10 10:19
There is a need for IDLE to provide different default settings depending on which platform it is running, e.g. Windows, OS X, or other UNIX.  That need need has been most acute for OS X where, for various reasons, tailoring of default key bindings for IDLE commands and extensions is either necessary or desirable to conform to platform user interface guidlines or, more importantly, platform-specific Tk behavior.  For OS X, that customization is provided in part by brute force editing of the config-main.def and config-extensions.def in Mac/Makefile target install_IDLE which is run during installation of framework builds.  While that works for that case, it is brittle and opaque and does not help for non-framework OS X installs or when running from a build directory.  And it doesn't help for other platforms.  Other OS X customization is done at run time to convert any <Alt-Key-> events to <Option-Key-> events, since none of the OS X Tk implementations support <Alt-Key-> events (see Issue20579).  It would be better to provide some way to specify these various conditional settings directly in config-main.def and config-extensions.def themselves, perhaps with platform-specific sections in the files that would be merged with and override the current general sections.  For example, in config-main.def, a possible implementation might be:

[Keys]
default= 1
name= IDLE Classic Windows

[Keys-OSX]
name= IDLE Classic OSX

[Keys-Unix]
name= IDLE Classic Unix

This might also be used to support different options for different versions of IDLE since today all versions by default share the same user configuration files.

[Keys]
...

[Keys-2.7]
...

[Keys-3]
...
msg211258 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-02-15 04:15
From what you have said here and on the other issue, reality has outgrown the current customization methods. If Python, Tk, and Idle were to run on Windows RT, I presume a different configuration would be needed than for normal desktop.

Any new scheme used in the config files should allow the config dialog to still work sensible. If a current value displaying in the dialog come from a special section, then I think user changes should propagate back to that section and not the generic setting.
msg220133 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-10 00:27
I closed #1517993 in favor of this.
msg220310 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-11 20:57
I am not completely sure what you are asking. Config-keys.def has 4 Idle Classic sections, one each for Windows, Unix, Mac (still needed?), and OSX. On my Windows install, the one for Windows is preselected. I have presumed the the appropriate selections are made for other systems. If so, your opening sentence 'provide different default settings depending on which platform it is running,' would be true already. If not, that would be a bug.

ConfigHandler.IdleConf.GetCoreKeys has hard-coded backups that probably work on Windows and Unix but not Max/OSX. I don't know if the 'Alt' to 'Option' replacement is applied to these are not.

If 'Alt' to 'Option' is insufficient for key bindings in config-extensions.def, I don't know what the answer is. Non-mac extension writers are unlikely to know what else to do.

Can any of the editing of Mac/Makefile be moved into runtime?

In "all versions by default share the same user configuration files", does versions mean 2.7, 3.4, 3.5 on one machine? If so, the statement describes a great feature that I would not change. If 'versions' means Windows Idle on one machine and OSX Idle on another machine, then the statement make no sense to me as we do not deliver user configuration files. If you mean multiple OS versions on the same machine, and it is possible to login as the same user with different Oses (I have no idea if this is so), then I could see a problem.
msg222714 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-07-10 23:41
"I have presumed the the appropriate selections are made for other systems."

As far as I know, there is nothing in IDLE itself to do that.  As I noted earlier, there is a kludge in the Mac Makefile to edit config-main.def and config-extensions.def during installs of OS X framework builds.  That doesn't help non-framework builds on OS X nor any builds on other non-Windows platforms.  They default to the values in the checked-in versions, which default to Classic Windows.

"Can any of the editing of Mac/Makefile be moved into runtime?"

If you mean move the editing of config-main.def et al into IDLE itself, sure. That would address the issue of defaults for non-framework builds for OS X and could be extended to other non-Windows cases, assuming it was desirable to change the current defaults (I don't know if that is the case).  On the other hand, that would only help when a user starts IDLE without existing .idlerc/*.cfg files, e.g. the first time the user uses IDLE and the first time was with a newer version of IDLE that had this feature.  Presumably existing .cfg files would not be edited.

"In 'all versions by default share the same user configuration files', does versions mean 2.7, 3.4, 3.5 on one machine? If so, the statement describes a great feature that I would not change."

It means all versions of IDLE, not just the latest releases of branches undergoing active maintenance.  We can't assume that the user is just using those.  For example, various versions of IDLE are shipped with many OS's or by third-party package managers; Apple ships three versions of Python - 2.5, 2.6, and 2.7 - with the current release of OS X.  That means all of those versions of IDLE and any others (newer or older) that the user has installed are all sharing the same configuration files.  Is it reasonable to guarantee compatibility across all of them?  And does it make sense to provide the same list of recent files for all versions, especially across Py2 and Py3?  I don't think there is one right answer to these questions but today users have no choice.  As IDLE continues to be enhanced and changes are made, the probability of possibly catastrophic incompatibilities will no doubt increase.  I don't know if there are any today.  I think it would be better to eliminate that risk.  There certainly are other use cases, i.e. where home directories are shared across machines of the same OS type; I think the above considerations apply to nearly all of them, as well.
msg222720 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-07-11 03:06
You appear to be saying that even though some of the per system defaults you want are present, they are not automatically used, but users must go into the options dialog to select bindings other than Windows. Correct? And you would like to change this?

The odd situation we have is that default configuration in idlelib is specific to the installation, but the same for all users, whereas user overrides are specific to the user, but the same for all installations. Thanks for the reminder that we need to be careful. I will consider this before we change the location of format width in #20579.  As I say there, some changes will need Idle What's New entries and perhaps a reminder to read it in the signon message, and access from the help menu.
msg222725 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-07-11 05:37
"Correct?"

Yes

"And you would like to change this?"

I think it should be considered, yes.
msg247636 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-07-29 21:45
While I like the fact that my font choice is used by 3 installed and 4 built pythons, I am beginning to see possible version problems.  In #5594 I propose adding a Startup tab to Idle preferences, but doing so will require carefully checking that the corresponding all-release user config file works on releases without and with the new tab.
msg251980 - (view) Author: Mark Roseman (markroseman) * Date: 2015-09-30 23:54
Before creating another layer on top of the existing layers of configuration handling, can I suggest for now at least just hard-coding the few things that are needed in the code itself? 

For example, in configHandler.py, after calling LoadCfgFiles, we could call a routine like, e.g.

    def AdjustPlatformDefaults(self):
        if sys.platform == 'darwin':
            self.defaultCfg['main'].set('Keys', 'name', 'IDLE Classic OSX')
        ...

An appropriate comment could be added to config-main.def about this default option being overridden.

That would allow getting rid of the Makefile hack.
msg260720 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-02-23 10:03
See Issue26417 for further discussion about the OS X specific tailoring of IDLE config files and changes to the 2.7 Makefiles to better match the 3.x Makefiles to reduce the risk of inadvertent platform differences.
msg268480 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-13 22:28
Ned, looking at config-keys.def, the Mac and Osx sections have a mixture of 'Command' and 'Control'.  I have the impression from what you wrote above that every 'Control' should be 'Command'.  Why are the sections as they are?
msg268483 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-06-13 22:38
"I have the impression from what you wrote above that every 'Control' should be 'Command'."

I'm not sure where I gave that impression but, no, the default IDLE keyset on OS X has command accelerators with Command- modifiers and some with Control- modifiers, as is typical of OS X applications.
msg300907 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-08-26 20:32
A. In 3.6+, the [Keys] section of config-main.def reads

[Keys]
default= 1
name=
name2=
# name2 set in user config-main.cfg for keys added after 2016 July 1

The name is no longer 'IDLE Classic Windows'.  Instead, if default is left true, the actual default is selected in config.py with

    @staticmethod
    def default_keys():
        if sys.platform[:3] == 'win':
            return 'IDLE Classic Windows'
        elif sys.platform == 'darwin':
            return 'IDLE Classic OSX'
        else:
            return 'IDLE Modern Unix'

This change accompanied the addition of the Modern Unix keyset.

If the makefile for 3.6+ still has the sed command to replace 'Windows' with 'OSX', you can remove it.


B1. #27099 is moving all built-in user-configurable key defs in config-extensions.def to individual keysets in config-keys.def.  These are:

force-open-completions = <Control-Key-space>
expand-word = <Alt-Key-slash>
force-open-calltip = <Control-Key-backslash>
format-paragraph = <Alt-Key-q>
flash-paren = <Control-Key-0>
run-module = <Key-F5>
check-module = <Alt-Key-x>
zoom-height = <Alt-Key-2>

According to my reading of
https://hg.python.org/cpython/rev/13826ff147e4
the makefile changes each 'Alt-Key-' to  'Command-Key-', with an additional change for zoom-height.  We can instead put the correct keys in the Mac and OSX keysets.

B2. Serhiy: Are any of the above 'wrong' for Unix/Linux?  Or should any alternatives be added?

B3. Custom keysets will initially be missing the new defs.  IdleConf currently replaces missing values with the windows values (hard-coded into the file).  I think it should instead get replacements from the OS-specific default -- and perhaps check for conflicts.  Then it should, if possible, write-back the complete keyset.


C. There are various proposals to add new customizable key definitions for existing and new features.  The issues in B, customizing default keysets and augmenting custom keysets, will come up repeatedly.  When I decide to add a new key definition, I could nosy you two, Ned and Serhiy, or add a note to this issue.
msg301758 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-09 03:34
I miswrote.  'Alt' becomes 'Option'. The new keybindings to be added to Classic Mac and Classic OSX in PR2494 are the following.

force-open-completions= <Control-Key-space>
expand-word= <Option-Key-slash>
force-open-calltip= <Control-Key-backslash>
format-paragraph= <Option-Key-q>
flash-paren= <Control-Key-0>
run-module= <Key-F5>
check-module= <Option-Key-x>
zoom-height= <Option-Key-0>

This leaves B3, replacing missing definitions in user files with appropriate defaults.  The only solution I can see is to use the system-appropriate builtin from idlelib/config-key.def as the default instead of the current hard-coded keyset.  If that file cannot be read properly, either from disk fault or user editing, I think it better to stop than to use a keyset that will not necessarily be usable.
msg301792 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-09 20:35
Ned, config.py currently has

    def GetCurrentKeySet(self):
        "Return CurrentKeys with 'darwin' modifications."
        result = self.GetKeySet(self.CurrentKeys())

        if sys.platform == "darwin":
            # OS X Tk variants do not support the "Alt" keyboard modifier.
            # So replace all keybingings that use "Alt" with ones that
            # use the "Option" keyboard modifier.
            # TODO (Ned?): the "Option" modifier does not work properly for
            #        Cocoa Tk and XQuartz Tk so we should not use it
            #        in default OS X KeySets.
            for k, v in result.items():
                v2 = [ x.replace('<Alt-', '<Option-') for x in v ]
                if v != v2:
                    result[k] = v2

        return result

This already did or would have done what the Makefile did.  The comment suggests that maybe you suggested that 'Alt' to 'Option' is not always correct.  What say you now?
History
Date User Action Args
2022-04-11 14:57:58adminsetgithub: 64779
2017-09-09 20:35:49terry.reedysetmessages: + msg301792
2017-09-09 03:34:23terry.reedysetmessages: + msg301758
2017-08-26 20:32:48terry.reedysetnosy: + serhiy.storchaka, - westley.martinez
2017-08-26 20:32:18terry.reedysetdependencies: + IDLE: turn built-in extensions into regular modules
messages: + msg300907
2017-08-26 20:11:53wohlgangersetpull_requests: + pull_request3253
2017-06-30 00:05:36terry.reedysetassignee: terry.reedy
versions: + Python 3.7, - Python 2.7, Python 3.5
2016-06-13 22:38:52ned.deilysetmessages: + msg268483
2016-06-13 22:28:04terry.reedysetmessages: + msg268480
2016-02-23 10:03:51ned.deilysetmessages: + msg260720
versions: - Python 3.4
2015-09-30 23:54:09markrosemansetmessages: + msg251980
2015-09-18 16:46:59markrosemansetnosy: + markroseman
2015-07-29 21:45:19terry.reedysetmessages: + msg247636
versions: + Python 3.6
2014-07-11 05:37:49ned.deilysetmessages: + msg222725
2014-07-11 03:06:40terry.reedysetmessages: + msg222720
2014-07-10 23:41:54ned.deilysetmessages: + msg222714
2014-06-11 20:57:36terry.reedysettype: enhancement
stage: test needed
messages: + msg220310
versions: + Python 3.5, - Python 3.3
2014-06-10 00:27:16terry.reedysetmessages: + msg220133
2014-06-10 00:27:05terry.reedylinkissue1517993 superseder
2014-02-28 08:08:19westley.martinezsetnosy: + westley.martinez
2014-02-15 04:15:43terry.reedysetnosy: + terry.reedy
messages: + msg211258
2014-02-10 10:19:11ned.deilycreate