Suggest

Wilfred Hughes has contributed a cute and potentially useful package that he calls suggest. The idea is that you’re looking for an Elisp function to perform a particular calculation or transformation but don’t know the function’s name. Suggest asks you for an input and the desired output and then suggests functions to accomplish that.

One example that Hughes offers is: given

2
2

with the desired output of

4

suggest offers

(+ 2 2)
(* 2 2)
(expt 2 2)

That’s pretty neat and almost seems like magic but really amounts to taking a list of functions and applying each one to the input(s) to see if it yields the desired result. Despite the brute force, Hughes says it almost always yields an immediate result.

There’s a bit more than just trying every function available though. For example, you have to be careful about side effects. As Hughes says, you don’t won’t to delete a file as a side effect when you’re testing prospective functions. Hughes has a curated list of functions that seems to work well. He says he’s already learned a couple of new functions from the app.

If you’re trying to learn Elisp, this may be a useful tool to get you started. Take a look at Hughes’ post to see if it might help you out. Regardless, it’s a neat hack and worth playing with just for the entertainment value.

This entry was posted in General and tagged . Bookmark the permalink.