4 ms·
>Then such a call would be possible: yt https://www.youtube.com/watch?v=mqma6GpM7vM https://www.youtube.com/watch?v=mqma6GpM7vM Okay, so I did understand what
by faho 9y ago
>Then such a call would be possible: yt https://www.youtube.com/watch?v=mqma6GpM7vM https://www.youtube.com/watch?v=mqma6GpM7vM
Okay, so I did understand what you are saying.
Like I said, that's a rather large layering violation, since the function has nothing to do with the expansions happening on its arguments. They are expanded before they ever reach the function. It's essentially allowing functions to modify the syntax around them.
How exactly would this treat e.g.
yt $URL/somefile
Would the variable still be expanded? Would an asterisk glob be? If I _did_ want it to expand something even though the function is declared "pure", how would that work?
Now I couldn't be sure how my arguments would be interpreted, or I'd have to go checking for everything I invoke.
I use youtube-dl myself quite often, and what I do is just type
youtube-dl '
then press ctrl-v (which is a keybinding that uses xsel or pbpaste to get the clipboard contents and insert them into the commandline) or ctrl-shift-v (which is my terminal's paste binding). Then I press `'` again and can download the video.
Additionally, it's looking like 3.0 will remove the `?` glob, which is the thing that is most annoying with URLs (though "&" is also a thing).
> I would like to be able to write 'm foobar' and then press tab to get a vertical completion-list. When the user selects a completion-list-item I would like to pass the result-path to the cd command.
I would assume the reason you failed is that the argument you want doesn't match the argument the user typed. Because fish's completions undergo filtering (with some fuzzy-matching, so e.g. `f_c_i` matches `fish_config_interactive`). Otherwise every completion script would have to implement that by itself, and consistently to not confuse people.
For completions, that's the right thing to do.
What you want, I'd argue, isn's a completion. What you want is a selection menu. Which could be implemented with fish's completion pager (we have an open issue about making it accessible to the outside), but isn't the same thing.
JSON here is a red herring, since you don't just want to add items (with descriptions), but also control the behavior of the pager ("orientation" and "on_single_result"). That you could do just with arguments to this `select` command (`list_of_items | select --orientation=vertical --on-single=choose`).
- thibran 9y ago> How exactly would this treat e.g. yt $URL/somefile > Would the variable still be expanded? Would an asterisk glob be? No. Pure should mean don't do anything from here on, just pass the arguments to the function. > If I _did_ want it to expand something even though the function is declared "pure", how would that work? If expanding should be possible in a pure context, then maybe by using a known syntax like: yt ($URL)/somefile Eshell expands Lisp code when using (lisp-code-here) which is kind of elegant. So when in a pure context, you would have to switch to expansion-mode by using curly braces.