-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintain context across calls #2
Comments
Looking into this further, I think it would work well to allow a query like:
Which would search for "async" then immediately select result 2. This way I could write my command like this:
And we avoid any conflict between multiple scripts, the cache makes this plenty fast :) |
I see what you mean. You may find it difficult to do it using It might be more worth it to have an editor command that would drop you into an interactive session in Currently this is not possible as the only two modes are interactive, which has no starting search, or non-interactive, which accepts a term to search but exits immediately. A new flag could be added, |
@lazamar, it would've been great if you could implement it. |
@andreystepanov I'm away from my computer now, but does it work if you pass the input through stdin instead of as an argument? |
@lazamar Thanks for quick reply. It seems i can pass selection number using this command: echo -e "map\n2" | hdc And the output would be: ...
3 map :: (Word8 -> Word8) -> ByteString -> ByteString
bytestring Data.ByteString, bytestring Data.ByteString.Lazy,
rio RIO.ByteString, rio RIO.ByteString.Lazy
2 map :: (a -> b) -> NonEmpty a -> NonEmpty b
base Data.List.NonEmpty, base-compat Data.List.NonEmpty.Compat,
rio RIO.NonEmpty
1 map :: (a -> b) -> [a] -> [b]
base Prelude, base Data.List, base GHC.Base, base GHC.List, base GHC.OldList,
ghc GHC.Prelude.Basic, base-compat Prelude.Compat,
haskell-gi-base Data.GI.Base.ShortPrelude, relude Relude.List.Reexport
search: map
==================================================
map :: (a -> b) -> NonEmpty a -> NonEmpty b
base Data.List.NonEmpty, base-compat Data.List.NonEmpty.Compat, rio RIO.NonEmpty
Map a function over a NonEmpty stream.
https://hackage.haskell.org/package/rio/docs/RIO-NonEmpty.html#v:map
https://hackage.haskell.org/package/base-compat/docs/Data-List-NonEmpty-Compat.html#v:map
https://hackage.haskell.org/package/base/docs/Data-List-NonEmpty.html#v:map
==================================================
search: map
> ⏎ So it first sends function name to search for, and then selection number. But i still exits immediately, and the plan was to stay in interactive mode and play around with different searched (in case i selected a wrong option). |
Figured I'd drop a note here to ask your opinion before I go implement anything; for context:
My goal is to rig up some fzf vim commands to very quickly search docs without leaving the editor.
I'm imagining running something like this:
Breaking it down:
hdc $currentWord
: Search hoogle for the word under the cursor (or type one myself)rg '^\d+'
use ripgrep to find the list of possible results (all result rows start with a number)fzf --tac
use the fzf fuzzyfinder to interactively select which result I want docs forrg '^(\d+)' -or '$1' | hdc
pull out only the number from the selected line and pass it tohdc
to give me the docs.Currently this doesn't work because
hdc
loses all of its context in between invocations.I'm wondering, do you have ideas on how best to solve this? Ideally
hdc
would have fuzzy-find built-in, but that might be a bit too much to ask, and would only help support this very specific workflow.Although it's a bit of a hack since it might cause confusion if multiple scripts are running at once, I'm wondering if stashing the context on exit and re-loading it on startup would be a reasonable solution here?
Perhaps a more reasonable solution would be to simply rely on the search being cached and provide a full query as the second search?
Let me know your thoughts, thanks!
The text was updated successfully, but these errors were encountered: