Background Data:
I am developing a package which has a configuration item that is a LIST of strings. Every time this list changes, it also has to be changed in 2 hard-coded regular expressions that are part of CONTEXT dictionary list for a COMMAND and a KEY MAP entry.
Reason: It is intended that the end user be able to modify and/or add to that list, and to make it simpler (and more maintainable), I want to make it so that the LIST becomes the sole source, and the 2 RegExes get updated when the package gets initialized.
Example:
- Given this configurable list: ["/*", “//”, “#”]
- internally build this RegEx: (/\*|//|#), then
- insert that regular expression as part of a dictionary into the CONTEXT list of one COMMAND and one KEY-MAPPED COMMAND, e.g.
{ "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*(/\\*|//|#)(.[ht]|.)?$", "match_all": true },
Question:
Is it possible to get access to a keymap entry as well as a COMMAND to make that modification dynamically (e.g. during package initialization)? If so, where should I look to find how to access these structures in memory?
Partial Info
Note: I have some code from a utility that makes a list of global commands, so I see how that is iterated through using these top-level variables in sublime_plugin.py:
- application_command_classes = []
- window_command_classes = []
- text_command_classes = []
So I am hopeful this leads to an answer for the COMMAND. However, I have never seen anything that allows plugin access to the global keymap, and specifically, the ability to modify the “context” list of dictionaries for a command as described above. Is there a way to do it?