The LeoServer class in leoserver.py defines lists of "good" and "bad" Leo commands. This Engineering Notebook post discusses speculative ideas for reducing, eliminating, or rethinking these lists.
The comment associated with the "bad" list is: "command names that connected clients should ignore." This list appears essential. Some commands don't make sense inside vs-code.
For example, the debugger commands (db-*) imply that calls to pdb.set_trace exist inside Leo. Hmm. Maybe it's time to retire Leo's 'debug' and 'db-*' commands. I'll look into this.
vs-code will supersede some Leo commands, such as:
- Leo's autocompletion and calltips commands.
- Leo's shell commands.
- Commands related to clicks in Leo's (qt) window.
- Commands related to Leo's free_layout plugin.
- Commands related to other (Leo) plugins.
etc.!
In short, most items in the "bad" list should remain.
The good list
The comment associated with the "good" list is: "Defined commands that should be available in a connected client."
Leo has various dictionaries that describe available commands.
Naively, I would suppose that all of Leo's commands might be part of the "good" list, except for:
1. Commands in the "bad" list, and
2. Commands that require user interaction from Leo's gui.
Yes, we could add all interactive commands to the bad list, but we might not need to do this. For example, many (all?) of Leo's interactive find commands call find.start_state_machine. Suppose this method raises, say, g.InteractionError if g.in_leo_server is True. The LeoServer class would catch InteractionError and add the attempted command to the bad list.
Another idea: A decorator, say @override, could mark all LeoServer methods that override Leo commands. The effect of this decorator might be to add items to the "good" list. But this may not be necessary!
Summary
The "bad" list probably must remain, possibly with a few tweaks. It may be time to retire Leo's 'debug' and 'db-*' commands.
Perhaps a script could help create the "good" list.
I throw these ideas out for comment and discussion. There is no urgent need to change leoserver.py.
Félix, please comment.
Edward