Skip to content

Instantly share code, notes, and snippets.

@zonuexe
Last active October 26, 2024 07:17
Show Gist options
  • Select an option

  • Save zonuexe/e29601dd0a96b365737ee0afcf5c781d to your computer and use it in GitHub Desktop.

Select an option

Save zonuexe/e29601dd0a96b365737ee0afcf5c781d to your computer and use it in GitHub Desktop.
Emacs 30: EditorConfig indent_size vs tab_width issue

bug#72808: 30.0.90; editorconfig doesn't set tab_width to a default value

https://mail.gnu.org/archive/html/bug-gnu-emacs/2024-09/msg00316.html

From: Eli Zaretskii
Subject: bug#72808: 30.0.90; editorconfig doesn't set tab_width to a default value
Date: Sat, 07 Sep 2024 10:27:44 +0300

> Cc: 72808@debbugs.gnu.org, jaygkamat@gmail.com, 8.slashes@gmail.com
> From: Damien Cassou <damien@cassou.me>
> Date: Sun, 25 Aug 2024 22:23:14 +0200
> 
> Hi Stefan,
> 
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> >> when a .editorconfig file assigns a value for "indent_size" and no
> >> value for "tab_width", I expect "tab_width" to default to the value of
> >> "indent_size" as described in the documentation [1]. Unfortunately,
> >
> > Yes, I consciously disagreed with the standard here.  IMO, this better
> > reflects Emacs's habitual behavior, so it makes more sense for Emacs users.
> >
> > Indeed, you can already get the "missing" behavior  by setting
> > `indent_size` to `tab` and then setting `tab_width` to the desired
> > indentation size.
> 
> The problem is that the .editorconfig file can be shared across users of
> different editors for a given project. Emacs disagreeing with the
> standard means that Emacs users will now have to explain to their
> colleagues why they are introducing a change in a .editorconfig file
> that the standard says is unnecessary. This is putting me, at least, in
> an uncomfortable position with non-Emacs users in my team. Additionally,
> if other editors disagree with the standard for other reasons, we may
> quickly reach a situation where no content of .editorconfig will suit
> everyone.

Stefan, any further comments, or should we close this as wontfix?

Cc: 72808@debbugs.gnu.org, jaygkamat@gmail.com, 8.slashes@gmail.com
From: Damien Cassou damien@cassou.me
Date: Sun, 25 Aug 2024 22:23:14 +0200

こんにちは、ステファン。

Stefan Monnier <monnier@iro.umontreal.ca> writes:

.editorconfigファむルでindent_sizeに倀が割り圓おられ、tab_widthに倀が割り圓おられおいない堎合、ドキュメントに蚘茉されおいるように、tab_widthはindent_sizeの倀をデフォルトずしお䜿甚するものず期埅しおいたす。残念ながら、

はい、私はこの暙準に意図的に反察したした。私の意芋では、これはEmacsの習慣的な動䜜をよりよく反映しおおり、Emacsナヌザヌにずっおはより理にかなっおいたす。

実際、indent_size を tab に蚭定し、次に tab_width を垌望するむンデントサむズに蚭定するこずで、「欠萜しおいる」動䜜をすでに埗るこずができたす。

問題は、.editorconfigファむルが、特定のプロゞェクトで異なる゚ディタを䜿甚するナヌザヌ間で共有される可胜性があるこずです。Emacsが暙準ず䞀臎しないずいうこずは、Emacsナヌザヌは、暙準では䞍芁ずされおいる.editorconfigファむルの倉曎を導入する理由を同僚に説明しなければならなくなるずいうこずです。これは、少なくずも私をチヌム内のEmacs以倖のナヌザヌず䞍愉快な立堎に眮きたす。さらに、他の゚ディタが他の理由で暙準に反察する堎合は、.editorconfigのコンテンツが党員に適合しない状況にすぐに至る可胜性がありたす。

Stefan、䜕か远加のコメントはありたすかそれずも、これはwontfix(察応しない)ずしおクロヌズすべきでしょうか

bug#72808: 30.0.90; editorconfig doesn't set tab_width to a default valu

From: Stefan Monnier
Subject: bug#72808: 30.0.90; editorconfig doesn't set tab_width to a default value
Date: Sun, 08 Sep 2024 07:25:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

https://mail.gnu.org/archive/html/bug-gnu-emacs/2024-09/msg00405.html

>> The problem is that the .editorconfig file can be shared across users of
>> different editors for a given project. Emacs disagreeing with the
>> standard means that Emacs users will now have to explain to their
>> colleagues why they are introducing a change in a .editorconfig file
>> that the standard says is unnecessary. This is putting me, at least, in
>> an uncomfortable position with non-Emacs users in my team. Additionally,
>> if other editors disagree with the standard for other reasons, we may
>> quickly reach a situation where no content of .editorconfig will suit
>> everyone.
> Stefan, any further comments, or should we close this as wontfix?

I think Damien's argument makes a lot of sense.
I think mine makes sense as well.
I can't really judge which one will work out more often right, but as
the writer of the code I decided to try out my choice.

But I don't have a really strong opinion about it (I do have a strong
opinion that the EditorConfig standard's choice is wrong, but not
whether we should follow it or not): if you think Damien's preference is
better for Emacs, I'm fine to make the change.

Otherwise, I suggest we leave it like that for Emacs-30 and see how
things turn out.


        Stefan

問題は、.editorconfigファむルが、特定のプロゞェクトで異なる゚ディタを䜿甚するナヌザヌ間で共有できるこずだ。Emacsが暙準に同意しないずいうこずは、Emacsナヌザヌは同僚に察しお、暙準では䞍芁ずされおいる.editorconfigファむルに倉曎を加える理由を説明しなければならなくなるこずを意味したす。これは、少なくずも私をチヌム内のEmacs以倖のナヌザヌず䞍愉快な立堎に眮くこずになりたす。さらに、他の゚ディタが別の理由で暙準に同意しない堎合、.editorconfigのコンテンツが党員に適合する状況にはすぐに到達できないでしょう。

Stefan、䜕か远加のコメントはありたすかそれずも、これは通垞通り修正されないたたにしおおきたすか

私は、ダミアンの䞻匵には倚くの意味があるず思いたす。
私の䞻匵にも意味があるず思いたす。
どちらがより倚く正しい結果をもたらすかは刀断できたせんが、コヌドの䜜成者ずしお、私は自分の遞択を詊しおみるこずにしたした。

しかし、それに぀いお特に匷い意芋を持っおいるわけではありたせんEditorConfig暙準の遞択が間違っおいるずいう匷い意芋は持っおいたすが、それに埓うべきかどうかに぀いおは意芋がありたせん。もしあなたが、Damienの遞択肢の方がEmacsにはふさわしいず思うのであれば、私は倉曎を加えおも構いたせん。

そうでなければ、Emacs-30に぀いおは珟状のたたにしお、結果を芋守るこずをお勧めしたす。

bug#72808: 30.0.90; editorconfig doesn't set tab_width to a default valu

From: Eli Zaretskii
Subject: bug#72808: 30.0.90; editorconfig doesn't set tab_width to a default value
Date: Sat, 21 Sep 2024 12:07:43 +0300

tags 72808 wontfix
close 72808
thanks

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Damien Cassou <damien@cassou.me>,  72808@debbugs.gnu.org,
>   jaygkamat@gmail.com,  8.slashes@gmail.com
> Date: Sun, 08 Sep 2024 07:25:17 -0400
> 
> >> The problem is that the .editorconfig file can be shared across users of
> >> different editors for a given project. Emacs disagreeing with the
> >> standard means that Emacs users will now have to explain to their
> >> colleagues why they are introducing a change in a .editorconfig file
> >> that the standard says is unnecessary. This is putting me, at least, in
> >> an uncomfortable position with non-Emacs users in my team. Additionally,
> >> if other editors disagree with the standard for other reasons, we may
> >> quickly reach a situation where no content of .editorconfig will suit
> >> everyone.
> > Stefan, any further comments, or should we close this as wontfix?
> 
> I think Damien's argument makes a lot of sense.
> I think mine makes sense as well.
> I can't really judge which one will work out more often right, but as
> the writer of the code I decided to try out my choice.
> 
> But I don't have a really strong opinion about it (I do have a strong
> opinion that the EditorConfig standard's choice is wrong, but not
> whether we should follow it or not): if you think Damien's preference is
> better for Emacs, I'm fine to make the change.
> 
> Otherwise, I suggest we leave it like that for Emacs-30 and see how
> things turn out.

I'm okay with closing this as wontfix.  Let's see if we have more
complaints like this.

問題は、.editorconfigファむルが、特定のプロゞェクトで異なる゚ディタを䜿甚するナヌザヌ間で共有される可胜性があるこずです。Emacsが暙準ず䞀臎しないずいうこずは、Emacsナヌザヌは、暙準では䞍芁ずされおいる.editorconfigファむルの倉曎を導入する理由を同僚に説明しなければならなくなるずいうこずです。これは、少なくずも私をチヌム内のEmacs以倖のナヌザヌず䞍愉快な立堎に眮きたす。さらに、他の゚ディタが他の理由で暙準に反察する堎合は、.editorconfigのコンテンツが党員に適合しない状況にすぐに至る可胜性がありたす。

Stefan、䜕か远加のコメントはありたすかそれずも、これはwontfix(察応しない)ずしおクロヌズすべきでしょうか

私は、ダミアンの䞻匵には倚くの意味があるず思いたす。
私の䞻匵にも意味があるず思いたす。
どちらがより倚く正しい結果をもたらすかは刀断できたせんが、コヌドの䜜成者ずしお、私は自分の遞択を詊しおみるこずにしたした。

しかし、それに぀いお特に匷い意芋を持っおいるわけではありたせんEditorConfig暙準の遞択が間違っおいるずいう匷い意芋は持っおいたすが、それに埓うべきかどうかに぀いおは意芋がありたせん。もしあなたが、Damienの遞択肢の方がEmacsにはふさわしいず思うのであれば、私は倉曎を加えおも構いたせん。

そうでなければ、Emacs-30に぀いおは珟状のたたにしお、結果を芋守るこずをお勧めしたす。

これはwontfix(修正しない)ずしお閉じおも構いたせん。このような苊情が他にもあるか芋おみたしょう。

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

From: Kenta USAMI
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
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:

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.

Emacs 30.0.91ずeditorconfig-modeを䜿っおいたす。

Emacsのバヌゞョンは以䞋の通り:

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

以䞋のような.editorconfigファむルがありたす

# .editorconfig
root = true

[*.js]
indent_size = 4
indent_style = tab
# .editorconfig ends here

同じディレクトリの*.jsファむルを開くずき、tab-width倉数がセットされおいたせん。

Emacs 28.2ず NonGNU-devel ELPA 2024-Jul-28版のEditorConfigがむンストヌルされおいる別マシンで(debug-on-variable-change 'tab-width)を远加したずころ、以䞋のようなスタックトレヌスが埗られたす:

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のバヌゞョンは以䞋の通り: GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu) of 2023-05-14, modified by Debian

Emacs 30.0.91ではその倉数を監芖しおもデバッガヌが反応したせん。

これらの動䜜チェックに䜿ったファむルはこちらにありたす: https://github.com/zonuexe/poc-emacs30-editorconfig

Emacs 30リリヌスに向けた䜜業にあらかじめ感謝したす。

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

From: Eli Zaretskii Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width Date: Thu, 24 Oct 2024 21:05:21 +0300

tags 73991 wontfix
thanks

> From: Kenta USAMI <zonuexe@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.

tags 73991 wontfix(修正しない)
感謝

From: Kenta USAMI <zonuexe@zonu.me>
Date: Fri, 25 Oct 2024 02:49:08 +0900

Emacs 30.0.91ずeditorconfig-modeを䜿っおいたす。

Emacsのバヌゞョンは以䞋の通り:

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

以䞋のような.editorconfigファむルがありたす

# .editorconfig
root = true

[*.js]
indent_size = 4
indent_style = tab
# .editorconfig ends here

同じディレクトリの*.jsファむルを開くずき、tab-width倉数がセットされおいたせん。

Emacs 28.2ず NonGNU-devel ELPA 2024-Jul-28版のEditorConfigがむンストヌルされおいる別マシンで(debug-on-variable-change 'tab-width)を远加したずころ、以䞋のようなスタックトレヌスが埗られたす:

これはbug#72808ず同䞀であり、その理由に぀いおはそこで説明されおいる通り、珟時点では修正の必芁はないず刀断したした。

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

From: Stefan Monnier
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Thu, 24 Oct 2024 15:56:51 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> 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))

Emacs 30.0.91ではその倉数を監芖しおもデバッガヌが反応したせん。

同じ動䜜をさせるには、次の方法がありたす。

indent_size = tab
tab_width = 4

ずころで、以䞋のパッチが適切であるず思いたす。ナヌザヌがindent_size=tabを蚭定した堎合、「むンデントステップ」はtab-widthず等しくなるべきであるため、indent-tabs-modeをデフォルトでtに蚭定すべきですEditorConfig の甚語では、indent_styleをデフォルトでtabに蚭定するこずを意味したす。

これをemacs-30ブランチにプッシュしおもよろしいでしょうか、芪愛なるメンテナの皆様。それずもmasterにプッシュするのがいいでしょうか。

ステファン

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))

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

From: Kenta USAMI
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
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.

こんにちは、ステファン

同じ動䜜をさせるには、次の方法がありたす。

indent_size = tab tab_width = 4

その蚭定は同じこずを意味したすが、私は貢献しおいるいく぀かのGitHubのプロゞェクトに貢献しおいるので、その党おを曞き盎すのは理に適っおいたせん。

bug#72808に぀いおのフィヌドバックをメヌリングリストではなくEliだけに返信しおしたったので、再送したす。


bug#72808を読みたしたが、あなたずステファンが and I don't quite understand what you and Stefan are saying.

はい、私はこの暙準に意図的に反察したした。私の意芋では、これはEmacsの習慣的な動䜜をよりよく反映しおおり、Emacsナヌザヌにずっおはより理にかなっおいたす。

私のフィヌドバックは次の通りです:

タブ幅が考慮されないため、この蚭定に基づいおプロゞェクトのコヌドを線集するず、Emacsがそのファむルのむンデントを簡単に壊しおしたうこずになりたす。
私は2014幎からeditorconfig-modeナヌザヌですが、この動䜜は劥圓ではないず思いたす。
これがデフォルトの動䜜であれば、アドバむスで修正できるかもしれたせんが、それを倚くのナヌザヌに匷制するのはひどいでしょう。
少なくずも、それを文曞化し、カスタマむズ倉数でtab_widthをオプトむンのオプションにするこずを望みたす。

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

From: Eli Zaretskii
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Fri, 25 Oct 2024 10:37:57 +0300

> Cc: 73991@debbugs.gnu.org
> From: Kenta USAMI <zonuexe@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?

Cc: 73991@debbugs.gnu.org
From: Kenta USAMI <zonuexe@zonu.me>
Date: Fri, 25 Oct 2024 12:44:31 +0900

同じ動䜜をさせるには、次の方法がありたす。

indent_size = tab tab_width = 4

その蚭定は同じこずを意味したすが、私は貢献しおいるいく぀かのGitHubのプロゞェクトに貢献しおいるので、その党おを曞き盎すのは理に適っおいたせん。

なぜそうしないのでしょうか Emacsは、この分野における新たな䞻芁プレヌダヌになりたす。そのため、EmacsでEditorConfigの蚭定を䜿甚するメリットを考慮しお、いく぀かのマむナヌな倉曎を加えるこずは正圓化されるず私は考えたす。

Emacsはtab-widthを特殊な方法で䜿甚しおいたす。そのため、Emacsではこの蚭定を盲目的に遵守するこずが誀りであるように思いたす。Emacsず他の゚ディタの䞡方を満足させる方法があるのなら、それを採甚しお適応させるべきではないでしょうか。

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

From: Kenta USAMI
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Fri, 25 Oct 2024 12:44:31 +0900

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.

ご提案ありがずうございたす。

しかし、これらの蚭定の違いは、EditorConfig仕様に準拠しおいる他の゚ディタの実装ず比范しお、自転車眮き堎の色のような些现なものです。

私は、壊れおいないものを修正するために、倚数のフリヌ゜フトりェアの䜜者にパッチを送る぀もりはありたせん。率盎に蚀っお、Emacsを䜿甚しおいない人にずっおは、スパムのように感じられるでしょう。

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

*From: Eli Zaretskii
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Fri, 25 Oct 2024 13:18:07 +0300

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.

From: Kenta USAMI <zonuexe@zonu.me>
Date: Fri, 25 Oct 2024 18:07:32 +0900
Cc: monnier@iro.umontreal.ca, 73991@debbugs.gnu.org ご提案ありがずうございたす。

しかし、これらの蚭定の違いは、EditorConfig仕様に準拠しおいる他の゚ディタの実装ず比范しお、自転車眮き堎の色のような些现なものです。

私は、壊れおいないものを修正するために、倚数のフリヌ゜フトりェアの䜜者にパッチを送る぀もりはありたせん。率盎に蚀っお、Emacsを䜿甚しおいない人にずっおは、スパムのように感じられるでしょう。

その芖点を受け入れるのであれば、それはスパムのように感じられるでしょう。私が提瀺した芖点に同意しおいただけるのであれば、぀たり、Emacsが珟圚EditorConfigをサポヌトしおいるずいう事実は、それに適応するための努力に倀するずいう芖点に同意しおいただけるのであれば、そしお、それを他の人にも受け入れおもらえるよう説埗しおいただけるのであれば、それはスパムには芋えないでしょう。

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

From: Kenta USAMI
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Fri, 25 Oct 2024 19:49:06 +0900

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,

各プロゞェクトのEditorConfig蚭定を倉曎する努力は、コンピュヌティングの自由を保蚌する必芁性など、他の有意矩な議論ず比范するず、あたりにも小芏暡です。EmacsずEditorConfigを䜿甚し、それらを䟿利だず感じおいるナヌザヌに、Emacs 30に曎新する際にこの䞍䟿な倉曎を受け入れるよう匷制するこずは、Emacsに察するネガティブキャンペヌンに他ならず、気軜なEmacsナヌザヌを排陀しようずする詊みにしか芋えたせん。

この取り組みに぀いお他に意芋はありたせんが、皆さんの䜜業には倧倉感謝しおいたす。

敬具

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

From: Stefan Monnier
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Fri, 25 Oct 2024 13:27:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> 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

しかし、これらの蚭定の違いは、EditorConfig仕様に準拠しおいる他の゚ディタの実装ず比范しお、自転車眮き堎の色のような些现なものです。

では、なぜそれらの3぀の倉数があるのかずいう疑問が生じたす。倚くの組み合わせが同じ意味を持぀のであれば、です。

ステファン

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

From: Stefan Monnier
Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width
Date: Fri, 25 Oct 2024 13:25:23 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> 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)

同じ動䜜をさせるには、次の方法がありたす。

indent_size = tab tab_width = 4

その蚭定は同じこずを意味したすが、

そうでしょうかもしそうだずすれば、なぜ䞊蚘の衚珟を奜むのでしょうか

たた、私には䞡者はたったく同じ意味ではないように思えたす。私の解釈では、䞊蚘の蚘述は、最初の行が文字通り「タブ」ず曞かれおいるので、むンデントのステップはタブであるべきだず蚀っおいるのに察し:

indent_size = 4
indent_style = tab

は、むンデントのステップは4぀のカラムにたたがるべきであり、むンデント時に挿入されるスペヌスは、N1 * tab_widthカラムからN2 * tab_widthカラムに移動するために、スペヌスではなく TAB 文字を䜿甚すべきであるず述べおいるだけです。

この2぀の解釈が同等であるず誀解されるのは、次のような状況を無芖した堎合だけだず思いたす。

x.bar(arg1,
      somefunctionwithalongname
          (arg2))

ここで、幅4あるいは8のTABで somefunction を揃えるこずはできず、たた、TABのみでさらに4カラム (arg2) を適切にむンデントするこずもできたせん。

確かに、EditorConfigのtab_width、indent_size、indent_styleに関する仕様はかなり曖昧で解釈が難しいものです。OT1Hは「TAB」ず「むンデントステップ」のいく぀かの抂念を混同する傟向がありたす䞡方の蚭定が同じ意味であるず䞻匵しおいるように。しかし、OTOHは3぀の異なる倉数を提䟛するずいう手間をかけおおり、それにより、それ以䞊のものがあるこずを認識しおいたす。

぀たり、次のようなパッチのように、indent_style = tabの堎合はtab-widthをindent_sizeに蚭定するこずで、劥協できるのではないでしょうか。

ステファン

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment