From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Augustin_Ch=C3=A9neau_=28BTuin=29?= Newsgroups: gmane.emacs.devel Subject: Re: In go-ts-mode, tab-width 4 inserts two tabs instead of one Date: Tue, 26 Sep 2023 13:36:58 +0200 Message-ID: <471adbcf-42a5-408e-a814-ff9f192a8590@mailo.com> References: <87ttrhchts.fsf@codeisgreat.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1341"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Emacs Development To: pankaj@codeisgreat.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 26 13:37:37 2023 Return-path: Envelope-to: ged-emacs-devel@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 1ql6Nk-000AbI-SQ for ged-emacs-devel@m.gmane-mx.org; Tue, 26 Sep 2023 13:37:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ql6NL-0005bP-VY; Tue, 26 Sep 2023 07:37:12 -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 1ql6NE-0005aG-MS for emacs-devel@gnu.org; Tue, 26 Sep 2023 07:37:08 -0400 Original-Received: from msg-2.mailo.com ([213.182.54.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ql6NC-0008Av-Dm for emacs-devel@gnu.org; Tue, 26 Sep 2023 07:37:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1695728219; bh=COBvVMXFE1Jyoc1G1pWDKdhqdkHxuddYz44KJlVrET8=; h=X-EA-Auth:Message-ID:Date:MIME-Version:Subject:To:References:Cc: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=ZP1/nPpRc0DxAT4vHHRvYYAFf9nLbSnmL16yow9YVQq5xcnfOZUoYA2Juwxa96/MY PlWH4k5b0YwPA8k9gUNPTecXh1dU1tWSPjAKk9da+ToLb6A5cmq9wdMGWS+PEVPVQ6 StadWeXP4N1peGyhjK0Mtp1BoayXPlY6NaFRoRmQ= Original-Received: by b221-6.in.mailobj.net [192.168.90.26] with ESMTP via ip-20.mailobj.net [213.182.54.20] Tue, 26 Sep 2023 13:36:59 +0200 (CEST) X-EA-Auth: glJOIlOTakyG/x1fBFd+VpOucfsQZtoULwJFCYoHySUly1UCkakjzjH7LOR9La0T6QoHxZOHUVdoXa2sCsMVIuCUadYnlpyK Content-Language: fr, en-US In-Reply-To: <87ttrhchts.fsf@codeisgreat.org> Received-SPF: pass client-ip=213.182.54.12; envelope-from=btuin@mailo.com; helo=msg-2.mailo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:311059 Archived-At: Le 26/09/2023 à 13:08, Pankaj Jangid a écrit : > Suppose I have this struct, > > #+begin_src go > package main > > type Message struct { > Response Response > Request Request > ForAPI string > } > #+end_src > > If I keep default tab-width of 8, then it works fine. But when I change > the buffer local variable tab-width to 4, /mostly/ it inserts two tab > chars instead of one, /sometimes/ it works fine. I have one file where > it works just fine. And in all other files, it inserts two tabs instead > of one. > > I am on branch emacs-29 and built with tree-sitter and gtk. > > Language mode is go-ts-mode. > That's because tab-width only controls the appearance of a tabulation. It doesn't change the actual indentation offset. In go-ts-mode, the indentation offset is set by the variable go-ts-mode-indent-offset. Since it is 8 by default and that you have set tab-width to 4, it inserts two tabs to keep the offset of 8. So you simply need to set go-ts-mode-indent-offset to 4 or directly to tab-width (with (setq go-ts-mode-indent-offset tab-width)).