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

Add variable to track which langs in code blocks should be formatted #7

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

cutonbuminband
Copy link
Contributor

I just converted a project to use ruff rather than black for formatting, and started using this excellent tool to help me format my buffers.

One pain point which came up was that I had a number of code blocks in org files that I wanted formatted as python, but which had a :language property that wasn't just the string "python", but rather "jupyter-python".

The language variable of code blocks can be just about anything, so this pull request adds a list of languages that should be considered pythons. Then, instead of checking whether the languages exactly matches the string "python", the code instead checks for membership in this list.

I've kept the original value of the list as just ("python"), so the default behavior is unchanged. Users who want to change which languages are considered pythons should modify the value of the variable.

@christophermadsen
Copy link
Owner

christophermadsen commented Nov 14, 2024

Hiya @cutonbuminband, thank You for your kind words about lazy-ruff, and thank You for your contribution.

I was wondering, do you strictly use jupyter-python for your src blocks?

@cutonbuminband
Copy link
Contributor Author

No, I use both python and jupyter-python at different times, so alongside the change I made to the package here, I have a line in my init.el where I add jupyter-python to the list of languages, so that the formatting will work for both.

@cutonbuminband
Copy link
Contributor Author

Hi - just following up on this! Is there anything I need to do before you'd be willing to merge the pull request?

@christophermadsen
Copy link
Owner

I think it's a neat and accommodating solution. I will go ahead and merge your changes.

Thank you once again for contributing 🙏🏻

@christophermadsen christophermadsen merged commit f7f6975 into christophermadsen:main Nov 27, 2024
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.

2 participants