GNU bug report logs -
#73991
EditorConfig bundled with Emacs 30 does not set tab-width
Previous Next
To reply to this bug, email your comments to 73991 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Thu, 24 Oct 2024 17:51:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kenta USAMI <zonuexe <at> zonu.me>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 24 Oct 2024 17:51:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I use Emacs 30.0.91 and editorconfig-mode.
Emacs version is follows:
> This is GNU Emacs 30.0.91 (build 1, aarch64-apple-darwin23.6.0, NS
> appkit-2487.70 Version 14.7 (Build 23H124)) of 2024-10-22
I have an .editorconfig file like this:
# .editorconfig
root = true
[*.js]
indent_size = 4
indent_style = tab
# .editorconfig ends here
When I open a *.js file in the same directory, the tab-width variable is
not set.
In the editorconfig of Emacs 28.2 and NonGNU-devel ELPA 2024-Jul-28 version
installed on another machine, when I add (debug-on-variable-change
'tab-width), I get a stack trace like this:
Debugger entered--setting tab-width in buffer test.js to 4:
debug--implement-debug-watch(tab-width 4 set #<buffer test.js>)
editorconfig-set-indentation("tab" "4" "4")
editorconfig-set-local-variables(#<hash-table eql 3/65 0x15612d120fc3>)
editorconfig--advice-find-file-noselect(#<subr find-file-noselect>
"/home/tadsan/poc-emacs30-editorconfig/test.js")
apply(editorconfig--advice-find-file-noselect #<subr find-file-noselect>
"/home/tadsan/poc-emacs30-editorconfig/test.js")
find-file-noselect("/home/tadsan/poc-emacs30-editorconfig/test.js")
command-line-1(("-l" "init.el" "test.js"))
command-line()
normal-top-level()
Emacs version is follows:
> GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu) of 2023-05-14, modified by
Debian
In Emacs 30.0.91, the debugger does not respond when watching the variable.
The files I used to check the operation are below:
https://github.com/zonuexe/poc-emacs30-editorconfig
Thank you in advance for your work on the Emacs 30 release.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Thu, 24 Oct 2024 18:09:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 73991 <at> debbugs.gnu.org (full text, mbox):
tags 73991 wontfix
thanks
> From: Kenta USAMI <zonuexe <at> zonu.me>
> Date: Fri, 25 Oct 2024 02:49:08 +0900
>
> I use Emacs 30.0.91 and editorconfig-mode.
>
> Emacs version is follows:
> > This is GNU Emacs 30.0.91 (build 1, aarch64-apple-darwin23.6.0, NS
> > appkit-2487.70 Version 14.7 (Build 23H124)) of 2024-10-22
>
> I have an .editorconfig file like this:
>
> # .editorconfig
> root = true
>
> [*.js]
> indent_size = 4
> indent_style = tab
> # .editorconfig ends here
>
> When I open a *.js file in the same directory, the tab-width variable is not set.
>
> In the editorconfig of Emacs 28.2 and NonGNU-devel ELPA 2024-Jul-28 version installed on another
> machine, when I add (debug-on-variable-change 'tab-width), I get a stack trace like this:
This is identical to bug#72808, which we decided we don't currently
want to fix, for the reasons explained there.
Added tag(s) wontfix.
Request was from
Eli Zaretskii <eliz <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 24 Oct 2024 18:09:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Thu, 24 Oct 2024 19:58:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 73991 <at> debbugs.gnu.org (full text, mbox):
> 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))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 03:47:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 73991 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 <monnier <at> iro.umontreal.ca>:
> > 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))
>
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 06:22:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 73991 <at> debbugs.gnu.org (full text, mbox):
> Cc: 73991 <at> debbugs.gnu.org
> Date: Thu, 24 Oct 2024 15:56:51 -0400
> From: Stefan Monnier via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> 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`?
Please install on emacs-30, and thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 07:39:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 73991 <at> debbugs.gnu.org (full text, mbox):
> Cc: 73991 <at> debbugs.gnu.org
> From: Kenta USAMI <zonuexe <at> zonu.me>
> Date: Fri, 25 Oct 2024 12:44:31 +0900
>
> > 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.
Why not? Emacs is a major new player on this playground, so making
some minor changes for the benefit of using EditorConfig settings in
Emacs sounds justified to me.
Emacs uses tab-width in a special way, which is why we feel blindly
abiding by this setting in Emacs would be incorrect. If a way exists
to have both Emacs and the other editors happy, why not take it to
adapt?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 09:10:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 73991 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thank you for your suggestion.
However, the difference in these settings is as trivial as the color of a
bike
shed to other editor implementations that comply with the EditorConfig
specification.
I don't intend to send patches to numerous free software authors to fix
something
that isn't broken. Frankly, it would feel like spam to people who don't use
Emacs.
2024年10月25日(金) 16:38 Eli Zaretskii <eliz <at> gnu.org>:
> > Cc: 73991 <at> debbugs.gnu.org
> > From: Kenta USAMI <zonuexe <at> zonu.me>
> > Date: Fri, 25 Oct 2024 12:44:31 +0900
> >
> > > 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.
>
> Why not? Emacs is a major new player on this playground, so making
> some minor changes for the benefit of using EditorConfig settings in
> Emacs sounds justified to me.
>
> Emacs uses tab-width in a special way, which is why we feel blindly
> abiding by this setting in Emacs would be incorrect. If a way exists
> to have both Emacs and the other editors happy, why not take it to
> adapt?
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 10:20:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 73991 <at> debbugs.gnu.org (full text, mbox):
> From: Kenta USAMI <zonuexe <at> zonu.me>
> Date: Fri, 25 Oct 2024 18:07:32 +0900
> Cc: monnier <at> iro.umontreal.ca, 73991 <at> debbugs.gnu.org
>
> Thank you for your suggestion.
>
> However, the difference in these settings is as trivial as the color of a bike
> shed to other editor implementations that comply with the EditorConfig specification.
>
> I don't intend to send patches to numerous free software authors to fix something
> that isn't broken. Frankly, it would feel like spam to people who don't use Emacs.
It would feel like spam only if you accept that POV. If you agree
with the POV I presented -- that the fact Emacs now supports
EditorConfig is worth some effort to adapt -- and try convincing
others to accept that, it won't look like spam, I'm sure.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 10:51:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 73991 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The effort to change EditorConfig settings for each project is too
small-scale
compared to other meaningful discussions, such as the need to guarantee
computing freedom. Forcing users who have used Emacs and EditorConfig and
found
them useful to accept this inconvenient change when they update to Emacs 30
seems like nothing more than a negative campaign against Emacs, and an
effort
to exclude casual Emacs users.
I have no other feedback on these efforts, but I am very grateful for your
work.
Regards,
2024年10月25日(金) 19:18 Eli Zaretskii <eliz <at> gnu.org>:
> > From: Kenta USAMI <zonuexe <at> zonu.me>
> > Date: Fri, 25 Oct 2024 18:07:32 +0900
> > Cc: monnier <at> iro.umontreal.ca, 73991 <at> debbugs.gnu.org
> >
> > Thank you for your suggestion.
> >
> > However, the difference in these settings is as trivial as the color of
> a bike
> > shed to other editor implementations that comply with the EditorConfig
> specification.
> >
> > I don't intend to send patches to numerous free software authors to fix
> something
> > that isn't broken. Frankly, it would feel like spam to people who don't
> use Emacs.
>
> It would feel like spam only if you accept that POV. If you agree
> with the POV I presented -- that the fact Emacs now supports
> EditorConfig is worth some effort to adapt -- and try convincing
> others to accept that, it won't look like spam, I'm sure.
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 17:27:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 73991 <at> debbugs.gnu.org (full text, mbox):
>> You can get the same behavior with
>>
>> indent_size = tab
>> tab_width = 4
>
> The settings mean the same thing,
Do they? If so, why prefer the above formulation?
Also they don't seem to mean quite the same thing to me. The way I read
it, the above really says that an indent step should be a TAB since
that's what the first line says quite literally, whereas:
indent_size = 4
indent_style = tab
only says that an indentation step should span 4 columns, and that the
spacing inserted when indenting use TAB chars rather than spaces to move
from a the `N1 * tab_width` column to the `N2 * tab_width` column.
I think the two interpretations can only be mistaken as equivalent if
you ignore situations like
x.bar(arg1,
somefunctionwithalongname
(arg2))
where you can't align `somefunction` with TABs of width 4 (or 8 for that
matter), nor can you then properly indent `(arg2)` 4 columns further
with only TABs.
[ Admittedly, the spec of EditorConfig around `tab_width`,
`indent_size`, and `indent_style` is quite vague and hard to
interpret. OT1H it tends to conflate several notions of "TAB" and
"indentation steps" (like you're doing when you claim that both
settings mean the same), yet OTOH it goes through the trouble of
providing 3 different variables, thus recognizing that there is more
to it. ]
This said, I guess we could meet halfway and set `tab-width` to
`indent_size` when `indent_style = tab`, as in the patch below.
Stefan
diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el
index c21e12559a6..83e4ea36731 100644
--- a/lisp/editorconfig.el
+++ b/lisp/editorconfig.el
@@ -434,8 +434,10 @@ editorconfig--get-indentation
(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)))
+ ((and (equal style "tab") (editorconfig-string-integer-p size))
+ (setq tab_width (string-to-number size))))
(setq size
(cond ((editorconfig-string-integer-p size)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Fri, 25 Oct 2024 17:28:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 73991 <at> debbugs.gnu.org (full text, mbox):
> However, the difference in these settings is as trivial as the color
> of a bike shed to other editor implementations that comply with the
> EditorConfig specification.
Which begs the question: why have those three variables if many/most
of the combinations mean the same anyway.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Sat, 26 Oct 2024 15:22:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 73991 <at> debbugs.gnu.org (full text, mbox):
>>> You can get the same behavior with
>>>
>>> indent_size = tab
>>> tab_width = 4
>>
>> The settings mean the same thing,
>
> Do they? If so, why prefer the above formulation?
The weird thing about this insistence that indent_size == tab_width and
that exclusively TAB chars should be used for indentation, is that the
whole point of that style of indentation is that it looks correct
regardless of `tab-width`, making the `tab-width` into a user-preference
that does not need to be enforced in the coding convention (and thus
shouldn't be set by `.editorconfig`).
In clear, I think the `.editorconfig` file should say just
indent_size = tab
and then every user would set tab-width to the value they like in their
favorite editor's personal settings.
Anyway, I pushed the last patch, combined with the previous one, to
`emacs-30`, which I believe should fix the problem you reported.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73991
; Package
emacs
.
(Sat, 26 Oct 2024 16:23:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 73991 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I agree with your point, but since EditorConfig is meant for editor
interoperability,
it would be more productive to discuss this with other text editor
developers on
the EditorConfig mailing list than with Emacs editorconfig-mode users.
I think that bundling a built-in EditorConfig in Emacs will help many Emacs
users
and potential Emacs beginners. I'm very grateful for your work.
2024年10月27日(日) 0:21 Stefan Monnier <monnier <at> iro.umontreal.ca>:
> >>> You can get the same behavior with
> >>>
> >>> indent_size = tab
> >>> tab_width = 4
> >>
> >> The settings mean the same thing,
> >
> > Do they? If so, why prefer the above formulation?
>
> The weird thing about this insistence that indent_size == tab_width and
> that exclusively TAB chars should be used for indentation, is that the
> whole point of that style of indentation is that it looks correct
> regardless of `tab-width`, making the `tab-width` into a user-preference
> that does not need to be enforced in the coding convention (and thus
> shouldn't be set by `.editorconfig`).
>
> In clear, I think the `.editorconfig` file should say just
>
> indent_size = tab
>
> and then every user would set tab-width to the value they like in their
> favorite editor's personal settings.
>
> Anyway, I pushed the last patch, combined with the previous one, to
> `emacs-30`, which I believe should fix the problem you reported.
>
>
> Stefan
>
>
[Message part 2 (text/html, inline)]
Severity set to 'wishlist' from 'normal'
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 02 Jan 2025 02:12:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 227 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.