Note that functions already don't expand the passed arguments. Fish expands them _before_ executing the function, so what you are asking for is a major layering violation.
E.g. you can do this:
function a
b $argv
end
function b
string escape -- $argv
end
a 'something * with ? loads {} of $pecial char"acters'
and the output will come out right. You only need to quote it once.>This would enable us to pass e.g. URLs to a function without quote them
I'm assuming what you are asking for isn't _passing_ URLs to functions, but rather _pasting_ URLs into the commandline.
In which case fish has a feature I like to call "magic paste". When you paste with an open single quote (`somecommand '`), it'll escape single quotes (and backslashes). So you type the closing single quote and your argument will be passed to the command you are calling as the exact text you pasted.
>The key should be displayed and if the user selects a completion-item, the corresponding value should be passed to a fish-function from which arbitrary actions could be triggered.
We have "descriptions" for completions, which will be displayed _alongside_ the argument (i.e. the "value"). To generate them dynamically, simply separate them with a tab character (`\t`) from the argument, and separate these pairs with newlines.
So
printf '%s\t%s\n' 'argument' 'description' 'argument2' 'description2'
will be displayed as argument (description) argument2 (description2)
We use this to great effect in numerous places. E.g. the git completions will offer commit hashes with the summary line as description, so when I type `git revert <TAB>` I get something like 0a129475 (Replace opts.stdout with opts.to_stdout)
I'm not sure I like the idea of hiding the real argument from the user.>Maybe supporting JSON input here would be nice too.
The best completions are those that actually call the stuff they are completing (because that makes them really reactive), and not many commandline tools actually generate JSON. Anything in particular you're thinking about here?
(And now I'm hoping that HN doesn't hopelessly mangle this comment)