Added code formatting with black or ruff - #2
Open
nilaykumar wants to merge 8 commits into
Open
Conversation
nilaykumar
force-pushed
the
feat/org-code-formatting
branch
from
January 1, 2025 20:29
7e177be to
38752e1
Compare
nilaykumar
marked this pull request as ready for review
January 11, 2025 05:16
Set the variable ob-python-extras-formatter to either "ruff" or "black".
nilaykumar
force-pushed
the
feat/org-code-formatting
branch
from
January 11, 2025 05:23
37a45f9 to
dd5dca1
Compare
Owner
|
Thanks for the pull request and the work on this project! :) Here are my thoughts:
For instance, to format a buffer with black, there's already the (python-black-buffer) We could use it like this: For ruff -- I haven't tried this package, but perhaps this: https://github.com/JoshHayes/emacs-ruff-format/blob/main/ruff-format.el ? Both python-black and ruff-format rely on https://github.com/purcell/emacs-reformatter/blob/master/reformatter.el
What do you think about this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
M-x ob-python-extras-formatto format code blocks (supports ruff and black).(add-hook 'org-babel-after-execute-hook 'ob-python-extras-format)