Leo now supports find-def and find-var commands. They find the definitions of classes, defs or vars.
They work as follows:
- Select the word at the cursor, if text is not already selected.
- Save the find settings in effect before the command started.
- find-def sets the search pattern to "class word" or "def word" depending on whether word is capitalized.
- find-var sets the search pattern to "word =".
- Set word-find to True
- Start the search at the root position of the outline.
This will find the first definition of the word. Thereafter, you can use F3 (find-next) to find additional definitions.
When the search fails, Leo restores the Find settings to what they were previously.
A new setting, @bool find-ignore-duplicates (default False), controls
whether any search command ignores duplicate matches. Ctrl-F restarts searches, clearing a list of vnodes that have already been seen. Any failed search also clears the list of vnodes.
Obviously, this scheme is a bit naive. The search patterns could be improved. However, even this simple scheme is surprisingly useful. Furthermore, these commands have implications that I'll discuss in another thread.
Edward