From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: c-ts-mode Date: Fri, 08 Sep 2023 09:14:39 +0300 Message-ID: <83msxxxkc0.fsf@gnu.org> References: <5F73CB5D-DB00-439F-AD7C-7E209EC83A35@gmail.com> <83jzt2z5mk.fsf@gnu.org> <83y1hhykni.fsf@gnu.org> <877cp1lvih.fsf@gmail.com> <83v8clyhqi.fsf@gnu.org> <83tts5ygv2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24444"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= , Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 08 08:15:42 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 1qeUmL-00069b-UR for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Sep 2023 08:15:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUlZ-0006C7-MN; Fri, 08 Sep 2023 02:14:53 -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 1qeUlX-0005tV-I7 for emacs-devel@gnu.org; Fri, 08 Sep 2023 02:14:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeUlV-0000uh-T6; Fri, 08 Sep 2023 02:14:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=hdeC1fohKIX8U5cmUt1NesjmLJWct09u4/32RjaSquU=; b=jVX8gyeHg6v52QxBuVgW je8SGJx/QIsTcdWp4lIQGT8P1OxvtWsPywGcdb2xwRrtm2DLxBDAQpzJh6KssAgwusQL0yZO+4QEq EtZO8jb20MI5J4zaSwYdnIKz1+Ae8jh5Wu99v68qGI6mNdp8rK8h0QRwPfiLAQgDJWLNHQ0/oqkAF WWF+zexhE+RuUKRNQj4rpe3Ipmy4ntvLeefRrSJOTaUSVJKrK0I0S0TkC7AJ96bjJdhBya2+JJ5xP DDqWnOE0M+iIeSfxHItJmNFRlYYA7RhFBmrcpSYb8sw/VhDRhhPzcmqQrXBFtrBk2nU89ylyI6Nl3 2o0VIGhHOVxlMw==; In-Reply-To: (message from =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= on Thu, 7 Sep 2023 23:01:58 +0100) 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:310306 Archived-At: > From: João Távora > Date: Thu, 7 Sep 2023 23:01:58 +0100 > Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org > > On Thu, Sep 7, 2023 at 7:32 PM Eli Zaretskii wrote: > > > > > From: João Távora > > > Date: Thu, 7 Sep 2023 19:23:33 +0100 > > > Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org > > > > > > The real challenge is writing the rules themselves. I'm missing > > > a kind of "debug rule" that doesn't do anything but prints out > > > contextual information from the node, parent-node, grandparents. > > > I made one but it's not very good. Is there something like that? > > > Wouldn't even need to be an indentation rule, more like a "describe > > > AST at point"... > > > > Did you try "M-x treesit-explore-mode RET"? > > That's a great find, and so is M-x treesit-inspect-mode. > > My rules are now done. > > (setq c-ts-mode-indent-style > (lambda () > (append '(((n-p-gp nil nil "namespace_definition") grand-parent 0) > ((n-p-gp nil nil "linkage_specification") grand-parent 0)) > (alist-get 'gnu (c-ts-mode--indent-styles 'cpp))))) > > The lambda, cl-list*, the alist-get and the '--' are ugly but > beyond that, it's better than cc-mode's system, to be honest. > > Anyway, to get the ugly out, here's an idea. > > IMHO making c-ts-mode--indent-styles a public CL-style > generic function would be a good possibility. Sorry, I don't understand: since we already allow c-ts-mode-indent-style to be a function, why do we need any other function-based feature? If the only reason is that the function form of c-ts-mode-indent-style looks ugly to you, then I think this is in the eyes of the beholder; it doesn't look ugly to me, FWIW. > A defcustom-style thing for customize lovers can also be added, > later for people that don't like defgeneric. Seems like a pretty > large DSL to code up in customize, though. What I had in mind was a simple alist, like CC Mode uses, with an infrastructure function to install it. Patches are welcome. Yuan and Theo, would you like to work on adding such feature to c-ts-common?