Description
Initially, cheatsheet was designed to display the entire hierarchy in a single Helm buffer (as seen in the screenshot at https://github.com/clojure-emacs/clojure-cheatsheet), allowing the user to search through the entire cheatsheet at once. However, the current implementation using completing-read
requires us to navigate one level of the hierarchy at a time. This is much less convenient because we need to know where the item we are looking for is located, and even if we do know, it takes additional steps to do so.
Instead of having multiple completions for each level of the hierarchy, we can represent the hierarchy in a flat view, so a single line will display the full path to an item, with the path elements separated by a specific separator. For example, lines might look like Collections > Maps > Change > clojure.core/assoc
with >
as the separator. Using a fuzzy completion style (such as the one provided by the orderless.el
package), we will be able to search for any element within the path, potentially displaying matches from multiple sections at the same time, which is especially convenient when displaying completions vertically (for example, with the vertico.el
package).
This can be implemented by transforming the hierarchy into an appropriate flat format that will be displayed using completing-read
. When the user selects a line, we split it by the separator and get the last item, which is the symbol. Then, we show the documentation for it as usual. I can do this, but I'm not sure if it's better to implement it as a separate function that can be called alternatively to cider-cheatsheet
(something like cider-cheatsheet-flat
) or to alternate the behavior of cider-cheatsheet
when a prefix argument is passed.