From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73991: EditorConfig bundled with Emacs 30 does not set tab-width Date: Fri, 25 Oct 2024 13:25:23 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16153"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 73991@debbugs.gnu.org To: Kenta USAMI Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 25 19:27:11 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t4O5e-0003wZ-CE for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Oct 2024 19:27:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4O53-0002kr-7M; Fri, 25 Oct 2024 13:26:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4O50-0002kG-W1 for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2024 13:26:31 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t4O50-0006nJ-GP for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2024 13:26:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=dNigO8vnWdiMVBRb0vAncBgbSvUZI7LWkDCJGaHijIk=; b=H9dSWKTin5ovlOcxrbLYPuBmIbwCupnAXsn/1y/yghx8ZJNex9M3eEuJAGvMk2z1jQf5JjwszwnzpgcRSAUxGsufqmDIc1e9G3Yw1qpHJVQGamHoVhEWthxehWzEQALMkpBlYxWlmubcsfiDuWacEe0o7S8HezFU4X3q/CMhKbdMRhxeqcNPIFQ9QK4aR+vIaOou+Y2z53wMrlTBN/KUFoswdyGlKg0BTgd/Qy1wfLX4Vf1LZxs27TSrkLCeMPEJAROvGDJT5IXwnY/PbFFunik0YEBqY+pjhvcr8MCRDTZx71LbdW4vcSwP08h7J/6nic8edh8uOfegB/vhf6xfmg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t4O5W-0007Mw-Fo for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2024 13:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Oct 2024 17:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73991 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 73991-submit@debbugs.gnu.org id=B73991.172987717328254 (code B ref 73991); Fri, 25 Oct 2024 17:27:02 +0000 Original-Received: (at 73991) by debbugs.gnu.org; 25 Oct 2024 17:26:13 +0000 Original-Received: from localhost ([127.0.0.1]:39374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4O4i-0007Ld-LM for submit@debbugs.gnu.org; Fri, 25 Oct 2024 13:26:13 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40375) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4O4g-0007LR-5s for 73991@debbugs.gnu.org; Fri, 25 Oct 2024 13:26:11 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0F9DB440A0D; Fri, 25 Oct 2024 13:25:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1729877125; bh=tXPMNtlVeGUj8lxTXY272rzedNxOmv32tPtXP+bhKBY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ew4uQVj1rHDibsulNUK3Q9kcELigxDZSD65oEc+WLZ84wVUABGrBTiqX6XZFUPnVU 1EBYqfbpsCRJZePherEaFEn1wdEg/d0yIrhCcC79Yv27lIUbmNe5TVka63dqyt3ZU9 qyUHLQoA657I9JrpoZLC+7PMgd/k/bOS/gUcbaGVd8bKNAosgfGHeyvZg06rcmPCP3 7UCUnYRw49u7YPjsdsvzqWSFzpuNkwlmupIhgMJtH5ESuR8D28vk0LFx3oZZs5LB0T aijAQTj0sbxuCHzb5kc5nh0liJNlCqGFfkeCONNJaa1dKsrovwzL8h0tXmXRKAyPUm DoU7EqJh86QDg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B72304409F1; Fri, 25 Oct 2024 13:25:25 -0400 (EDT) Original-Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9983A120D41; Fri, 25 Oct 2024 13:25:25 -0400 (EDT) In-Reply-To: (Kenta USAMI's message of "Fri, 25 Oct 2024 12:44:31 +0900") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294234 Archived-At: >> 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)