Skip to content
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

Parse pipe-composition of commands #5

Open
ELLIOTTCABLE opened this issue Mar 19, 2019 · 4 comments
Open

Parse pipe-composition of commands #5

ELLIOTTCABLE opened this issue Mar 19, 2019 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ELLIOTTCABLE
Copy link
Owner

This needs discussion, though I haven't thought about it in detail yet. Obviously the existing hack using composite can be done away with entirely. Less-obviously, I think we aren't going to see any of the problems that Vim's excmds have with the pipe — i.e. needing to conditionally support pipe-as-composition with some commands, but not others?

Thoughts and feedback welcome. Probably going to throw together naive, command | another_command support pretty soon; and can develop edge-cases from there.

This is one place where good examples of real-world uses of composite would be great.

@ELLIOTTCABLE ELLIOTTCABLE added enhancement New feature or request good first issue Good for newcomers labels Mar 19, 2019
@ELLIOTTCABLE
Copy link
Owner Author

Oh crap, search terms. This may require more thought …

@ELLIOTTCABLE ELLIOTTCABLE changed the title Implement pipe-composition Implement pipe-composition of commands Mar 19, 2019
@ELLIOTTCABLE ELLIOTTCABLE changed the title Implement pipe-composition of commands Parse pipe-composition of commands Mar 19, 2019
@glacambre
Copy link
Collaborator

glacambre commented Mar 19, 2019

Yeah, search terms are going to be annoying. There's also js if (something || other), exclaim cat file | grep pattern and bind key composite command1 | command2 that will probably make things harder.

Here are the composite commands I can find in my .tridactylrc:

composite js Array.from(document.querySelectorAll("li.list-group-item > span:nth-child(1) > a:nth-child(2)")).map(e => e.href) | jsb -p JS_ARG.forEach(url => tri.excmds.tabopen(url))
composite url2args | fillcmdline open
alias gitclone jsb -p tri.native.run("git clone '" + JS_ARG + "' /home/me/prog/" + JS_ARG.split("/").slice(-1))
composite js window.location.href | gitclone
composite hint -pipe a href | exclaim_quiet mpv --ontop --keepaspect-window --profile=protocol.http

@ELLIOTTCABLE
Copy link
Owner Author

Awesome! I was planning to come ask y'all for a corpus of example commands 🤣

For bind, I can't believe I haven't written it down anywhere, but I guess I was quietly assuming we'd support parenthetical disambiguation of expressions of some form! For example:

bind key (command1 | command2)
// vs.
bind key command1 | command2

@ELLIOTTCABLE
Copy link
Owner Author

Oh, and I explicitly, strongly, very very very strongly do not want to try to support complicated usages of js or exclaim as simple commands, without quoting, by the way. That Array.from composite is a monster! See #7 — but I'm sure you can see all the problems off the top of your head. Something like js window.location.href | gitclone looks fine, though?

I'm sure we can add some interim heuristics on the exclaim and js commands, early on, providing user-friendly, excellent feedback on that breaking change — but we definately shouldn't support it moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants