]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/editorconfig.el (editorconfig--get-indentation): Fix bug#73991
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 26 Oct 2024 15:12:32 +0000 (11:12 -0400)
committerEshel Yaron <me@eshelyaron.com>
Tue, 29 Oct 2024 09:50:26 +0000 (10:50 +0100)
(cherry picked from commit dd52839dd9d5f5af1f961e3ace2554931ec66510)

lisp/editorconfig.el

index 9a40c30b44085e6412f8dc20fafc0d491cb37f32..7a89b964d28f0b604fab09ac5063ce307b860db6 100644 (file)
@@ -428,8 +428,18 @@ heuristic for those modes not found there."
   (let ((style (gethash 'indent_style props))
         (size (gethash 'indent_size props))
         (tab_width (gethash 'tab_width props)))
-    (when tab_width
-      (setq tab_width (string-to-number tab_width)))
+    (cond
+     (tab_width (setq tab_width (string-to-number tab_width)))
+     ;; The EditorConfig spec is excessively eager to set `tab-width'
+     ;; even when not explicitly requested (bug#73991).
+     ;; As a trade-off, we accept `indent_style=tab' as a good enough hint.
+     ((and (equal style "tab") (editorconfig-string-integer-p size))
+      (setq tab_width (string-to-number size))))
+
+    ;; When users choose `indent_size=tab', they most likely prefer
+    ;; `indent_style=tab' as well.
+    (when (and (null style) (equal size "tab"))
+      (setq style "tab"))
 
     (setq size
           (cond ((editorconfig-string-integer-p size)