Subject: Re: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width

From: Kenta USAMI <[email-masked]>
Date: Fri, 25 Oct 2024 12:44:31 +0900

Hi Stefan,

> You can get the same behavior with
>
>    indent_size = tab
>    tab_width = 4

The settings mean the same thing, but I contribute to several projects on
GitHub, so it wouldn't make sense to rewrite them all.

I accidentally replied to Eli about bug#72808 instead of to ML, so I'm
resending it.

-----

I read bug #72808 and I don't quite understand what you and Stefan are
saying.

> > Yes, I consciously disagreed with the standard here.  IMO, this better
> > reflects Emacs's habitual behavior, so it makes more sense for Emacs
users.
My feedback is as follows:

Without tab-width being honored, editing code in a project based on this
setting would easily cause Emacs to break the indentation of that file.
I've been an editorconfig-mode user since 2014 and I don't think the
behavior is reasonable.
If that were the default behavior I could correct it with advice, but
forcing that on a large number of users would be terrible.
At the very least, I wish they would document it and make tab_width an
opt-in option via a customization variable.

2024年10月25日(金) 4:56 Stefan Monnier <[email-masked]>:

> > In Emacs 30.0.91, the debugger does not respond when watching the
> variable.
>
> You can get the same behavior with
>
>     indent_size = tab
>     tab_width = 4
>
> BTW, I think the patch below is in order: if the user sets
> "indent_size=tab", which means that the "indentation step" should be
> equal to `tab-width`, then we should default `indent-tabs-mode` to
> t (which in EditorConfig parlance means to default `indent_style` to
> `tab`).
>
> Can I push this to `emacs-30` or do you, dear maintainers, prefer that
> I push it to `master`?
>
>
>         Stefan
>
>
> diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el
> index c21e12559a6..478d94a2dc1 100644
> --- a/lisp/editorconfig.el
> +++ b/lisp/editorconfig.el
> @@ -437,6 +437,11 @@ editorconfig--get-indentation
>      (when tab_width
>        (setq tab_width (string-to-number tab_width)))
>
> +    ;; 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)
>                   (string-to-number size))
>
>