Text Editor Integration and Directory Traversal
Tuesday, February 12, 2008
To edit a word in Factor you pass the edit
word a defspec, like \ + edit
or { float + } edit
, or you press CTRL-SHIFT-E on a word. If an
editor path is already set, then the word definition should pop up in your
editor at the line of the definition. However, if you haven’t configured
your text editor, a restart will be thrown and you can select it from a
list. If you selected gvim, previously it would use a braindead algorithm
that makes a list of all paths in \Program Files and then traverses that
list looking for the gvim.exe
binary. This caused it to hang while doing
tons of disk IO.
Now it’s better in two ways – it only looks in \Program Files\vim\ (oops),
and secondly you can search with find-file-breadth
or
find-file-depth
. The implementation is pretty simple – breadth first
search uses a dlist, pushes the new traversal results to the back of the
list, and traverses the list in order. Depth first also pushes newly found
directories to the end of the list, but it pops them from the end.
The next step is to extract out the depth/breadth first algorithm so it’s generally useful, but I need to continue working on the database library.