Skip to content

feat(target flag): -t expands formats#4903

Open
daneofmanythings wants to merge 1 commit into
tmux:masterfrom
daneofmanythings:t-expands-formats
Open

feat(target flag): -t expands formats#4903
daneofmanythings wants to merge 1 commit into
tmux:masterfrom
daneofmanythings:t-expands-formats

Conversation

@daneofmanythings

Copy link
Copy Markdown
Member

This is an implementation of the todo list item:
Expand targets as formats. Should this be done by default or require a prefix (maybe a leading + or just look for #{)?
which is feature request from issue #3407. The code treats targets as formats, though this behavior can easily be adjusted to look for a prefix like '+'. The new function args_get_target has the same behavior as args_get and is a drop-in replacement for calls to args_get(args, 't').

One part that I'm not sure about is in cmdq_find_flag where I expand both targets and sources to keep the code footprint light. I believe that this would amount to a no-op on sources, but I am unsure of potential side effects. If there are unwanted side effects, I would either add if checks or split it into two functions.

Am I on the right track?

@nicm

nicm commented Mar 2, 2026

Copy link
Copy Markdown
Member

I do think a prefix might be better or we are going to risk breaking configs? What do you think?

@daneofmanythings

Copy link
Copy Markdown
Member Author

Oh, of course. I wasn't sure what the motivation behind a prefix was. You had mentioned in the todo list that '+' was a possible prefix, is this still the case, so we would then be looking at target formats being of the form -t+"#{...}"?

@nicm

nicm commented Mar 3, 2026

Copy link
Copy Markdown
Member

+ is maybe not a good choice since it is already used for window offsets, although that is maybe not very common. There are not many special characters left though, so not sure what to use.

Maybe we just bite the bullet and expand by default. How many people are going to have #{ in their targets at the moment?

Bit of a pity we couldn't use -T, but it is already used by a few commands.

@daneofmanythings

daneofmanythings commented Mar 3, 2026

Copy link
Copy Markdown
Member Author

I initially did not consider that format expansion may break some configs probably because I couldn't imagine a use case for a target looking like a format expansion. I would also estimate that the risk is very low.

I am a bit smitten with the idea of -T being the flag for target format expansion, and have compiled a list (the most recent commit) of the current commands that contain a -T flag which would need to be reworked. Some of them seem very low risk, while others WILL break a LOT of configs, those being key binding (key-table specification) and menu display (titles) commands. I really like the idea, but I don't think it is worth it. What is tmux's history with config breaking releases? Take a look at the list and see what you think.

If we were to do a prefix, I would suggest '#' because it is on theme, so a target with expansion would look like -t#"#{...}". Makes the most sense to me.

I find it so unlikely that configs would break that I am comfortable shipping default expansion, though I wouldn't say my intuition is calibrated yet.

@nicm

nicm commented Mar 4, 2026

Copy link
Copy Markdown
Member

People hate it when we break configs and it will cause a lot of confusion and complaining. Realistically we cannot change -T for bind-key.

TBH I would be inclined just to do it by default. How many people are really using -t with #{} in it?

@daneofmanythings

Copy link
Copy Markdown
Member Author

That works for me! Ready for review then.

@daneofmanythings daneofmanythings marked this pull request as ready for review March 4, 2026 20:35
@nicm

nicm commented Mar 9, 2026

Copy link
Copy Markdown
Member

Thanks, looks good, I'm probably going to wait for a while see how I like the idea of doing it by default in a few more days...

@nicm nicm moved this from Not Started to In Review in All Issues & PRs Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: For Review

Development

Successfully merging this pull request may close these issues.

3 participants