astoff / devdocs.el

Emacs viewer for DevDocs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a devdocs-at-point to search for a specific word under point

thermopyle opened this issue · comments

Thanks for a great package!

If you want to search for a specific word you either type the word into the "Go to documentation:" buffer presented by devdocs-lookup, or you select the region with the word and then call devdocs-lookup without the need to type the word to lookup. To make this more efficient it would be nice to have a devdocs-at-point (inspired by dash-at-point) which pre-selects the word at point (without the need to select a region) and runs a search for the word.

Emacs has this cool feature of "future history". So instead of going back M-p in the minibuffer history M-n puts the current "symbol" into the minibuffer. See https://github.com/astoff/devdocs.el/blob/main/devdocs.el#L558 for the implementation.

Example: When invoking devdocs-lookup with the point at os.path.re|alpath M-n gives me realpath good enough to filter os.path.realpath as the first hit.

To complement what @matzebond said, devdocs-lookup accepts an INITIAL-INPUT argument so you can define your own command with this behavior. Note that it can be tricky to make it work well in some cases since the thing at point can have several matching entries in the documentation index, which is one of the reasons I don't want to provide such a command in the package.