Skip to content

Instantly share code, notes, and snippets.

@zonuexe
Last active October 26, 2024 07:17
Show Gist options
  • Save zonuexe/e29601dd0a96b365737ee0afcf5c781d to your computer and use it in GitHub Desktop.
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: [email protected], [email protected], [email protected]
> From: Damien Cassou <[email protected]>
> Date: Sun, 25 Aug 2024 22:23:14 +0200
> 
> Hi Stefan,
> 
> Stefan Monnier <[email protected]> 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: [email protected], [email protected], [email protected]
From: Damien Cassou [email protected]
Date: Sun, 25 Aug 2024 22:23:14 +0200

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

Stefan Monnier <[email protected]> writes:

.editorconfigファイルでindent_sizeに値が割り当てられ、tab_widthに値が割り当てられていない場合、ドキュメントに記載されているように、tab_widthindent_sizeの値をデフォルトとして使用するものと期待しています。残念ながら、

はい、私はこの標準に意図的に反対しました。私の意見では、これはEmacsの習慣的な動作をよりよく反映しており、Emacsユーザーにとってはより理にかなっています。

実際、indent_sizetab に設定し、次に 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 <[email protected]>
> Cc: Damien Cassou <[email protected]>,  [email protected],
>   [email protected],  [email protected]
> 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 <[email protected]>
> 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 <[email protected]>
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: [email protected]
> From: Kenta USAMI <[email protected]>
> 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: [email protected]
From: Kenta USAMI <[email protected]>
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 <[email protected]>
Date: Fri, 25 Oct 2024 18:07:32 +0900
Cc: [email protected], [email protected] ご提案ありがとうございます。

しかし、これらの設定の違いは、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_widthindent_sizeindent_styleに関する仕様はかなり曖昧で解釈が難しいものです。OT1Hは「TAB」と「インデントステップ」のいくつかの概念を混同する傾向があります(両方の設定が同じ意味であると主張しているように)。しかし、OTOHは3つの異なる変数を提供するという手間をかけており、それにより、それ以上のものがあることを認識しています。]

つまり、次のようなパッチのように、indent_style = tabの場合はtab-widthindent_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