From 64b1556e5acd165112827e4219d29cb0f5d24c7b Mon Sep 17 00:00:00 2001 From: Aaron Ji Date: Sat, 29 Jun 2024 20:53:49 +0800 Subject: [PATCH] Compatible with editorconfig #13 use `tab-width` with default while the mode's value of editorconfig-indentation-alist is a function --- tabnine-util.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tabnine-util.el b/tabnine-util.el index cf1d05f..1d3e9c5 100644 --- a/tabnine-util.el +++ b/tabnine-util.el @@ -66,22 +66,26 @@ (defconst tabnine-util--indentation-alist (append '((latex-mode tex-indent-basic) (nxml-mode nxml-child-indent) + (emacs-lisp-mode lisp-indent-offset) (python-mode python-indent py-indent-offset python-indent-offset) (python-ts-mode python-indent py-indent-offset python-indent-offset) (web-mode web-mode-markup-indent-offset web-mode-html-offset)) - editorconfig-indentation-alist) + editorconfig-indentation-alist) "Alist of `major-mode' to indentation map with optional fallbacks.") (defun tabnine-util--infer-indentation-offset () "Infer indentation offset." - (or (let ((mode major-mode)) + (or (let ((mode major-mode) + (indentation-cons)) (while (and (not (assq mode tabnine-util--indentation-alist)) (setq mode (get mode 'derived-mode-parent)))) (when mode - (cl-some (lambda (s) - (when (boundp s) - (symbol-value s))) - (alist-get mode tabnine-util--indentation-alist)))) + (setq indentation-cons (alist-get mode tabnine-util--indentation-alist)) + (unless (symbolp indentation-cons) + (cl-some (lambda (s) + (when (boundp s) + (symbol-value s))) + indentation-cons)))) tab-width)) ;; code from eglot