-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat: auto tangle #1413
feat: auto tangle #1413
Conversation
7733184
to
226cb46
Compare
Sorry for taking a while to get around to this. I generally disagree with the lenient tag checking (allowing arbitrary indentation), because it will cause some confusion amongst users. The reason all this behaviour exists in the first place is because you can't correctly "guess" where the start of the indentation is unless you have a strong rule like we do. Imagine someone does the following:
I'd much rather have a single case which can fail: "you've dedented too far". This is much less ambiguous and better UX than trying to guess what the user meant and then being unpredictable in our output :) |
For most practical purposes tangled code need not be indented perfectly. Python and haskal are the two exceptions. Could there be a list of languages to allow correction on? Can it be configurable? The main reason I changed the intent handling was to avoid annoying/excessive error messages while I was editing code with auto tangle. Because I use an auto save plugin, it was very easy to trigger those errors. We could also make it a diagnostic warning instead of error for languages other than Python and haskal. That way it's hard for users to unknowingly have an intent error. |
If the errors are annoying on auto-save, then I see two paths forward:
I'm personally more fond of the second approach. I really feel like lenient tag checks are a source of confusion, especially since ill-indented code will produce garbled output. More convenience is not a good reason for invalid output. |
226cb46
to
95f40fe
Compare
@vhyrro I updated this PR with some customizable behavior for the error messages |
ty! |
Adds the
tangle_on_write
option to the tangle module. Defaults to false, when true, call:Neorg tangle current-file
onBufWritePost
.Fixes an annoying "bug" where tangling fails when code is de-dented. This is just a qol thing, I don't see a point in failing with a loud error in this case when we can easily handle the error and correctly export anyway.