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

acmego: allow arbitrary rc filters enclosed in [[ ]] #111

Closed
wants to merge 2 commits into from

Conversation

jacobvosmaer
Copy link

@jacobvosmaer jacobvosmaer commented Nov 4, 2023

I would like to automatically run clang-format on some but not all C files I edit. Not every project uses it and I don't want to mess up an entire file while making a one-line change.

This commit adds a new [[filter]] syntax for the tag. In my case I would write [[clang-format]] into the tag of my C file and then when I hit Put, acmego runs rc -c 'clang-format $1' /path/to/file.c.

To avoid conflicts with Edit, we ignore [[ if it occurs after Edit.

I don't know if this commit is the ideal design but I think acmego ought to be able to do something like this. It would elevate it to the same level of flexibility as Watch.

acme/acmego/main.go Outdated Show resolved Hide resolved
@jacobvosmaer jacobvosmaer force-pushed the jv-rc-filter branch 2 times, most recently from 6b7df6b to 1697ab5 Compare November 26, 2023 15:32
@jacobvosmaer
Copy link
Author

There was an issue where we could only read the first line of the tag, because of looking it up via acme/index. Added support for getting the tag via acme.Win.Info().

I also fixed a usability quirk: the first iteration required an explicit $1 in the filter to read from a file. By adding some rc glue, the filter now gets the file on stdin.

@jacobvosmaer
Copy link
Author

OK so I learned that having the filter read from stdin is not practical: it prevents clang-format from finding a local .clang-format file. By referring to the file by name, the filter can see what directory the file is in.

@jacobvosmaer
Copy link
Author

Closing in favor of #112. That one is much nicer to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant