Suggest.el v0.4 is now out, and it offers some really interesting new ways of making suggestions.
Suppose the user gives us the input
'(a b c d) and desired output
'a. We would already suggest
car, but that only gets the first
element of the list. They may have wanted
nth, which get
elements at a specific position.
We now try adding constants to the user’s inputs, specifically
2. This makes suggest.el much more
Here’s the example we mentioned:
We can now suggest grouping items in a list pairwise:
Converting a vector to a list:
Choosing good values for constants is difficult, but the current set seems to be a good tradeoff between performance, the likelihood of finding a result, and the number of useful results.
Now we have more possibilities, ordering our suggestions is more complex. The first prototype didn’t always get the ordering correct:
The user is probably looking for the increment function,
1) feels like stating the obvious.
Suggest.el prefers function calls that don’t require extra arguments, giving us a better order:
If suggest.el tries a function and it returns, we save it. If it isn’t the value we’re looking for, it’s saved to a list of ‘intermediate’ values. This is important for finding nested function calls.
Some intermediate values are very common, especially when exploring arithmetic. There are many ways you can convert an integer to the same float value, for example:
Suggest.el previously considered every single way of generating the same value. v0.4 only tries each unique value 3 times. This allows us to explore more unique possibilities, increasing the likelihood of finding a result before giving up.
Finally, I’ve spent some time researching similar tools, and documented them in the related projects section.
Not only has it been interesting to see other approaches, suggest.el has benefited from the comparisons. The Smalltalk Finder, for example, also explores bitwise operations, so suggest.el does too!
If there are simple code snippets that you think suggest.el should find, please file a bug. I’m routinely surprised by the results it finds, but I’m sure it could be smarter still.