tig icon indicating copy to clipboard operation
tig copied to clipboard

%(prompt) can't take a list and expand it properly

Open sim590 opened this issue 3 years ago • 3 comments

I get a similar issue as #371 when I try to list multiple tokens inside a single %(prompt) call. Sometimes you want to list multiple tokens to be given to the command template.

For example

I want to do the following:

bind generic <C-o>   :set main-options = "%(prompt set main-options = )"

But when I am prompted to enter the arguments and I try the following:

--grep=hook --author=Simon

then the log doesn't refresh appropriately. Usually, the history window ends up empty.

If for instance, I only enter either --grep=hook or --author=Simon, then it works. But I can't join both together.

Intuition

It is clear that it has to do with the expansion of "%(prompt)" which seems to keep the quotes and treat the whole thing as a single argument. I would like for a way to expand %(prompt) as multiple separate arguments so that the use case that I mentioned above would work.

What I tried

I did try to remove the quotes, but then pressing Ctrl+o ends up with Tig showing:

Failed to format arguments

in the output down in the interface on the last line.

sim590 avatar Jul 19 '22 19:07 sim590

Another thing. Entering literally the command in Tig without using a binding does work around the issue, but I have to enter the part :set main-options = everytime. So what I mean, is that in Tig, I would hit the following keys:

:set main-options = --grep=hook --author=Simon

then press Enter and it works. But, the whole point of the issue I'm raising is to avoid writing :set main-options = by setting a binding to do it and I need %(prompt) for that.

sim590 avatar Jul 20 '22 20:07 sim590

Perhaps we should have an :eval command:

bind generic <C-o>   :eval "set main-options = %(prompt set main-options = )"

In general, I think the expansion system could use some love but it's not so straightforward

krobelus avatar Jul 20 '22 20:07 krobelus

On a related note, doing

:set main-options = --grep="hook"

doesn't work while the following does:

:set main-options = --grep=hook

So, simply putting quotes breaks this functionality... And here, I mean writing this literally on Tig's command line (with key :) and not using a custom keybind.

sim590 avatar Jul 26 '22 21:07 sim590