1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Fix non-existing editorconfig-set-indentation-python-mode

* lisp/editorconfig.el (editorconfig--get-indentation-python-mode):
New function.
(editorconfig-indentation-alist): Use it.
(editorconfig-indent-size-vars): Improve docstring.
(editorconfig--default-indent-size-function): Add docstring.
This commit is contained in:
Stefan Monnier 2024-06-22 12:26:09 -04:00
parent 3f3c08bcc7
commit 99161fb714

View file

@ -226,8 +226,8 @@ This hook will be run even when there are no matching sections in
(ps-mode ps-mode-tab) (ps-mode ps-mode-tab)
(pug-mode pug-tab-width) (pug-mode pug-tab-width)
(puppet-mode puppet-indent-level) (puppet-mode puppet-indent-level)
(python-mode . editorconfig-set-indentation-python-mode) (python-mode . editorconfig--get-indentation-python-mode)
(python-ts-mode . editorconfig-set-indentation-python-mode) (python-ts-mode . editorconfig--get-indentation-python-mode)
(rjsx-mode js-indent-level sgml-basic-offset) (rjsx-mode js-indent-level sgml-basic-offset)
(ruby-mode ruby-indent-level) (ruby-mode ruby-indent-level)
(ruby-ts-mode ruby-indent-level) (ruby-ts-mode ruby-indent-level)
@ -323,6 +323,11 @@ Make a message by passing ARGS to `format-message'."
(web-mode-script-padding . ,size) (web-mode-script-padding . ,size)
(web-mode-style-padding . ,size))) (web-mode-style-padding . ,size)))
(defun editorconfig--get-indentation-python-mode (size)
"Vars to set `python-mode' indent size to SIZE."
`((python-indent-offset . ,size) ;For python.el
(py-indent-offset . ,size))) ;For python-mode.el
(defun editorconfig--get-indentation-latex-mode (size) (defun editorconfig--get-indentation-latex-mode (size)
"Vars to set `latex-mode' indent size to SIZE." "Vars to set `latex-mode' indent size to SIZE."
`((tex-indent-basic . ,size) `((tex-indent-basic . ,size)
@ -361,12 +366,19 @@ Make a message by passing ARGS to `format-message'."
(defvar editorconfig-indent-size-vars (defvar editorconfig-indent-size-vars
#'editorconfig--default-indent-size-function #'editorconfig--default-indent-size-function
"Rule to use to set a given `indent_size'. "Rule to use to set a given `indent_size'.
Can take the form of a function, in which case we call it with a single SIZE This should hold the list of variables that need to be set to SIZE
argument (an integer) and it should return a list of (VAR . VAL) pairs. to tell the indentation code of the current major mode to use a basic
Otherwise it can be a list of symbols (those which should be set to SIZE). indentation step of size SIZE.
It can also take the form of a function, in which case we call it with
a single SIZE argument (an integer) and it should return a list
of (VAR . VAL) pairs indicating the variables to set and the values to
set them to.
Major modes are expected to set this buffer-locally.") Major modes are expected to set this buffer-locally.")
(defun editorconfig--default-indent-size-function (size) (defun editorconfig--default-indent-size-function (size)
"Guess which variables to set to for the indentation step to have size SIZE.
This relies on `editorconfig-indentation-alist' supplemented with a crude
heuristic for those modes not found there."
(let ((parents (if (fboundp 'derived-mode-all-parents) ;Emacs-30 (let ((parents (if (fboundp 'derived-mode-all-parents) ;Emacs-30
(derived-mode-all-parents major-mode) (derived-mode-all-parents major-mode)
(let ((modes nil) (let ((modes nil)