From 4f8567b3d8d73f824bfa68cb92dea6f18da5e5bd Mon Sep 17 00:00:00 2001 From: CutOnBumInBandHere Date: Thu, 14 Nov 2024 12:45:10 +0100 Subject: [PATCH] Add variable to track which langs in code blocks should be formatted --- lazy-ruff.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lazy-ruff.el b/lazy-ruff.el index af709d1..87fa8dd 100644 --- a/lazy-ruff.el +++ b/lazy-ruff.el @@ -75,6 +75,8 @@ (defvar lazy-ruff-only-check-region nil "When non-nil (e.g. t), only lint the code in a region without formatting fixes.") +(defvar lazy-ruff-org-src-languages '("python") + "Defines which languages in code blocks are eligible for formatting and linting") (defun lazy-ruff-run-commands (temp-file only-format only-check) "Run the appropriate ruff commands on TEMP-FILE. @@ -113,7 +115,7 @@ Ensures cursor position is maintained. Requires `ruff` in system's PATH." (goto-char (org-element-property :end element)) (search-backward "#+END_SRC") (line-beginning-position)))) - (if (not (string= lang "python")) + (if (not (member lang lazy-ruff-org-src-languages)) (message "The source block is not Python") (with-temp-file temp-file (insert code)) (lazy-ruff-run-commands temp-file (eq lazy-ruff-only-format-block t) (eq lazy-ruff-only-check-block t))