From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.help Subject: Re: c++-ts-mode and namespace indentation Date: Thu, 14 Sep 2023 19:56:56 -0700 Message-ID: <8653AEB5-6A7D-4331-840E-5EF4C257870B@gmail.com> References: <1233373768.1916206.1694014644263@privateemail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31897"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "help-gnu-emacs@gnu.org" To: "gagnonlg@protonmail.com" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 15 04:57:57 2023 Return-path: Envelope-to: geh-help-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 1qgz1n-0007zL-Qe for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 15 Sep 2023 04:57:55 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgz19-0004XJ-0K; Thu, 14 Sep 2023 22:57:15 -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 1qgz16-0004X4-1R for help-gnu-emacs@gnu.org; Thu, 14 Sep 2023 22:57:12 -0400 Original-Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgz14-00047E-B1 for help-gnu-emacs@gnu.org; Thu, 14 Sep 2023 22:57:11 -0400 Original-Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1c504386374so982811fac.3 for ; Thu, 14 Sep 2023 19:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694746629; x=1695351429; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oNSxrWSCLOug65OVZO3bM8EJBvO68SinwL+KluFzw6k=; b=fq6phBGTVz+5EZb1mdYMBrx4Izxndq9tcF8zvUVwboMAa6Kl3WxhJkWKthbw+QEXlo CmnmI3Nvh1TmcBTMSNr6J/lm4hYsjLZwUdumcXebrFKDWgOZOi9sLMdMMZG6/7J3wayr 0Sr2MltSFnXu6lR4Hv2H6lP8zfb0gOkrCHTdJdiwrvHt2vvtpo8xdeJB6bx2qUioy52l 9uyd6Vua4K7vhgWELzdczjDmFQ6Duj+tfcA0P3C0ZbE+mmHCTU6tD8PvZ9pWaJNY8544 h5YtMwNmsXBeXPM7acpM1QYP4yH1j8i/UjDx9JEvdkR4IDBfpi8xDmz8lDTgVRpv1lq1 7WwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694746629; x=1695351429; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oNSxrWSCLOug65OVZO3bM8EJBvO68SinwL+KluFzw6k=; b=wkr8ooOBGqMrfur17Z18K52rhAPqviY8ke9zUdkOXIiXw+zHVOunTMgWejnVrDRLBo SQye385ZPVOCykhnuMcm8jA8bGk4ll12g5fJxJZYAvwT1MGS+ZibXfnDrnsCFMlq7F9d gpp50G8+FJXEbci6i41eN68crtw7RNaOfempYSswW0Fsm8AiTBGxrsldAhngp/0ntZGr YU8qX0JzPWnpaaxOm00Udr1+8adwUuyZMISQ23EP1z3uuCexMklmFpECY2h5xviPtBBC ZaUp3mOedK0DnWV10FKoIAG0LypA9UhqAjVUztFjXrHLPZ1agDAMp6K9k/LtJfLBq4oF bgQA== X-Gm-Message-State: AOJu0YzaOA7hR6TpEvdaHF19zNTdfSGeKK59csoYxF8dRRHD0JifgN8W LyZs2OSyvXx8EIR5oZmaFY8= X-Google-Smtp-Source: AGHT+IHU4J1rRUIZiBPErwwRIrdq1NaBxuS+CPtnJJtBng5i9Z/S+ABEQhgCjeMPR3lubdXvm8DFkw== X-Received: by 2002:a05:6870:f10d:b0:1bb:c0ee:5536 with SMTP id k13-20020a056870f10d00b001bbc0ee5536mr612997oac.47.1694746628630; Thu, 14 Sep 2023 19:57:08 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id t23-20020a656097000000b005740ba1d649sm1567032pgu.88.2023.09.14.19.57.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2023 19:57:08 -0700 (PDT) X-Priority: 3 In-Reply-To: <1233373768.1916206.1694014644263@privateemail.com> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2001:4860:4864:20::35; envelope-from=casouri@gmail.com; helo=mail-oa1-x35.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145128 Archived-At: > On Sep 6, 2023, at 8:37 AM, xzhou@xeechou.net xzhou@xeechou.net = wrote: >=20 >> Date: Thu, 24 Aug 2023 09:04:55 +0000 >> From: Louis-Guillaume Gagnon >>=20 >> I've recently switched to the new c++-ts-mode (a game changer for = source >> code featuring deeply nested templates!). I'm quite pleased with it, = but >> I can't figure out how to make it such that a namespace block doesn't >> increase the indentation level. I previously achieved this with >> (c-set-offset 'innamespace 0); Can anyone spell out how to achieve = this >> under treesitter? >=20 > Hi, >=20 >=20 > I managed to create an simple function to archive the same goal >=20 > (defun my/indent-rules () > `(;;here is my custom rules > ((parent-is "namespace_definition") parent-bol 0) > ,@(alist-get 'bsd (c-ts-mode--indent-styles 'cpp))) > ) >=20 >=20 > Then you would simply (setq c-ts-mode-indent-style #'my-indent-style). = I=20 > followed some guides here: = https://casouri.github.io/note/2023/tree-sitter-starter-guide/html-manual/= Parser_002dbased-Indentation.html. An alternative that avoids using c-ts-mode--indent-styles: (defun c++-ts-mode-config () (push '((parent-is "namespace_definition") parent-bol 0) treesit-simple-indent-rules)) (add-hook 'c++-ts-mode-hook #'c++-ts-mode-config) Yuan=