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.devel Subject: Re: New tree-sitter mode: bison-ts-mode Date: Thu, 28 Sep 2023 00:03:10 -0700 Message-ID: <669A1BD9-ACE6-462A-B12B-EC11E1DEC8B1@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_49067481-CBBA-4655-AF7D-555FAB292447" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26294"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Eli Zaretskii , Stefan Kangas To: =?utf-8?B?IkF1Z3VzdGluIENow6luZWF1IChCVHVpbiki?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 28 09:04:40 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 1qll4h-0006XY-5L for ged-emacs-devel@m.gmane-mx.org; Thu, 28 Sep 2023 09:04:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qll3a-0003xo-3e; Thu, 28 Sep 2023 03:03:30 -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 1qll3X-0003xY-38 for emacs-devel@gnu.org; Thu, 28 Sep 2023 03:03:27 -0400 Original-Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qll3V-0004mF-Id; Thu, 28 Sep 2023 03:03:26 -0400 Original-Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-691c05bc5aaso11059034b3a.2; Thu, 28 Sep 2023 00:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695884602; x=1696489402; darn=gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=rz9Av9y019EGLWkZfgr3AO9DfNnLu0/PqxpNki1eGZc=; b=GAHVBEvRUo9a5v2O8OVzvPncwYByFH5ywbhK4lZS1BBklPr2ryi3JeshNZDdaVGnL/ eWOY4MG95FEbbCzZXw3m/hAz2cNIhe8MVZrrj48b9zfffIpOEs3lZn4jIn5dyYvWJ/lP KjB+65cIbXC03wdsK937dhfK9L49nLhBaUEniDBUDNaxB8TweOatfxCfvANRqnlU8wi6 SRS8Yl2ffofpAsPfT8rE4ztbYdSLufXhY/CUuu19ujTIqWwyteVeunu9n0XYRkV2i//F qc0w/r3QrHTmZdMztlipqo+N1il7xk7a1nBKLym2U3+QRx20aUdCHSFuKCbUOS7o7lun jG8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695884602; x=1696489402; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rz9Av9y019EGLWkZfgr3AO9DfNnLu0/PqxpNki1eGZc=; b=rOStqNYMDGLca7tebzt9FlN5/gtP5D+t6SPTJd4tYy6MezaHI0yBRqiBxagdydONqL 2Xb4+mfqnd/RreJ0B7GzglSEfxy7US+6/fdM4LDSnoj8g5w+6YuF1PWkwePdUPwwdjjP YMTHEmp+FNd3IEzZPg163cjHY8SB6jKIYLg6nf1F7rC3zIgrPbY7t7oqFNK3e+PGpPbK WIQI1Ei5Ss6y16wEzrb9jzbAXjhLo8tuluFhVHet2Q2nL8yzVjVusEVdtT1rfrc7aDYT +eenx4f0VYRZkgDqGZpsQYDHEm1RlUv11Ibe8reunva4xSo244JgOuL4Rp6/n1PROq1R OtZQ== X-Gm-Message-State: AOJu0YyiIHgegEr94wX6BZmThQ+oPZtdKNqI/NArmMnVpQFxMxX6GhNz 3tO27HRnIFqBb/r+h99r0ws= X-Google-Smtp-Source: AGHT+IERzaj6dLIlR/4zB2VKhChQJdvBmcZkwoiJdhcJLUcyTaSygyPv8if807yBup6rqPCqc+rg8w== X-Received: by 2002:a05:6a20:d42f:b0:14e:315b:d9c with SMTP id il47-20020a056a20d42f00b0014e315b0d9cmr361522pzb.22.1695884602159; Thu, 28 Sep 2023 00:03:22 -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 g9-20020a170902868900b001bbdf32f011sm14161227plo.269.2023.09.28.00.03.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2023 00:03:21 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=casouri@gmail.com; helo=mail-pf1-x434.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: 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:311126 Archived-At: --Apple-Mail=_49067481-CBBA-4655-AF7D-555FAB292447 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 26, 2023, at 4:52 AM, Augustin Ch=C3=A9neau (BTuin) = wrote: >=20 > Le 24/09/2023 =C3=A0 23:10, Yuan Fu a =C3=A9crit : >> Actually, a second thought. IIUC the reason for this change is that = without these rules, no indentation is done for variable names in code = like >> static myttype * >> variable_name; >> static myttype >> variable_name; >> This is fine in normal C code, since no indentation is the same as >> zero indentation, which is what we want. But for C embedded in = Bison, >> no indentation is not the same as zero indentation. We want it = indent >> to the top-level indentation of the embedded C. E.g., >> { >> static myttype >> variable_name; >> } >> rather than >> { >> static myttype >> variable_name; >> } >> Right? In that case, we should really add a fallback indent rule for = the embedded c in bison, such that it indents to the top-level of the = embedded c. This is more robust than trying to cover all cases in the c = rules. Does that make sense? >> Basically, add something like >> (catch-all bison-ts-mode--bison-parent ,bison-ts-mode-indent-offset) >> To the end of C=E2=80=99s indent rules. >> Yuan >=20 > It does make sense, thanks. I updated bison-ts-mode to do that. Thanks. LGTM except some minor byte-compile warnings. I attached a diff, = please see if you like those changes. Once the paperwork is done I think we are good to go. Yuan --Apple-Mail=_49067481-CBBA-4655-AF7D-555FAB292447 Content-Disposition: attachment; filename=bison-comment.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="bison-comment.diff" Content-Transfer-Encoding: quoted-printable diff=20--git=20a/bison-ts-mode.el=20b/bison-ts-mode.el.1=0Aindex=20= febd2d9..913c1fa=20100644=0A---=20a/bison-ts-mode.el=0A+++=20= b/bison-ts-mode.el.1=0A@@=20-30,6=20+30,8=20@@=0A=20=0A=20(require=20= 'treesit)=0A=20(require=20'c-ts-common)=0A+(require=20'c-ts-mode)=20;=20= For=20=E2=80=98c-ts-mode--get-indent-style=E2=80=99.=0A+(require=20= 'java-ts-mode)=20;=20For=20=E2=80=98java-ts-mode--indent-rules=E2=80=99.=0A= =20=0A=20(declare-function=20treesit-parser-create=20"treesit.c")=0A=20= (declare-function=20treesit-induce-sparse-tree=20"treesit.c")=0A@@=20= -62,9=20+64,10=20@@=20It=20has=20no=20effect=20in=20the=20epilogue=20= part=20of=20the=20file."=0A=20=0A=20(defcustom=20= bison-ts-mode-autodetect-language=20t=0A=20=20=20"Search=20for=20a=20= %language=20directive=20in=20the=20file=20at=20initialization.=0A= -Changing=20the=20value=20of=20this=20directive=20in=20the=20file=20= requires=20to=20reload=20the=20mode=20to=0A-be=20effective.=20=20If=20= `bison-ts-mode-buffer-language'=20is=20set=20by=20a=20file-local=0A-=20= variable,=20the=20auto-detection=20is=20not=20run."=0A+Changing=20the=20= value=20of=20this=20directive=20in=20the=20file=20requires=20to=0A= +reload=20the=20mode=20to=20be=20effective.=20If=0A= +`bison-ts-mode-buffer-language'=20is=20set=20by=20a=20file-local=20= variable,=0A+the=20auto-detection=20is=20not=20run."=0A=20=20=20:version=20= "30.1"=0A=20=20=20:type=20'boolean=0A=20=20=20:safe=20'boolean)=0A@@=20= -108,8=20+111,8=20@@=20buffer."=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= (group=20(1+=20(in=20alpha=20"+")))=0A=20=20=20=20=20=20=20=20=20=20=20=20= =20"\"")=0A=20=20=20=20=20=20=20=20=20=20=20=20nil=0A-=20=20=20=20=20=20=20= =20=20=20=20t)))=0A-=20=20=20=20(match-string-no-properties=201)))=0A+=20= =20=20=20=20=20=20=20=20=20=20t)=0A+=20=20=20=20=20=20=20=20= (match-string-no-properties=201)))))=0A=20=0A=20=0A=20(defun=20= bison-ts-mode--detect-language=20(&optional=20buffer)=0A@@=20-366,4=20= +369,5=20@@=20ROOT-NAME=20is=20the=20highest-level=20node=20of=20the=20= embedded=20language."=0A=20=20=20=20=20(treesit-major-mode-setup)))=0A=20= =0A=20(provide=20'bison-ts-mode)=0A+=0A=20;;;=20bison-ts-mode.el=20ends=20= here=0A= --Apple-Mail=_49067481-CBBA-4655-AF7D-555FAB292447 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_49067481-CBBA-4655-AF7D-555FAB292447--