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.bugs Subject: bug#63708: 29.0.60; rust-ts-mode not properly handling apostrophe Date: Mon, 29 May 2023 14:25:50 +0300 Message-ID: <83wn0rgz0h.fsf@gnu.org> References: <83pm6pm0yz.fsf@gnu.org> <2MdRTHLlZtWDlCx6Ky-LFtla6-aBBs4PlNgTuatIC-h4OIuKdPmsmWsIokUQ9LBMHNvH_ooIvMUlQH8F8XOjNrEUUdC9FtR1l_e6RZSy7xU=@rjt.dev> <837cswmu5a.fsf@gnu.org> <8T8C4l5XryyVmB2cBTnmhGMnoELwHA2y1u1ZeMlg1WaQKzrPeOoe6L5hOQq3JPdsnG9r-puSlQfNZ091qBCGpVco-mC6ruhsQs0SvaPjkjQ=@proton.me> <_LWjNGLzmmtpm2gEwOaBZlTVCwvU9yxUyJzIl3yo3ol48dKWbMabBOpLzZ2UhWJ2_yPjVT-j2Jb-oUP8nLaju6ztGjFTNq-2PZqgTjv5gSM=@proton.me> 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="7079"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dev@rjt.dev, casouri@gmail.com, 63708@debbugs.gnu.org To: =?UTF-8?Q?=D0=99=D0=BE=D1=80=D0=B4=D0=B0=D0=BD_?= =?UTF-8?Q?=D0=9C=D0=B8=D0=BB=D0=B0=D0=B4=D0=B8=D0=BD=D0=BE=D0=B2?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 29 13:26:24 2023 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 1q3b16-0001bp-I2 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 May 2023 13:26:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3b0l-0006Mf-3f; Mon, 29 May 2023 07:26:03 -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 1q3b0k-0006MS-6j for bug-gnu-emacs@gnu.org; Mon, 29 May 2023 07:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q3b0j-0006g5-VD for bug-gnu-emacs@gnu.org; Mon, 29 May 2023 07:26:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q3b0j-0001Uc-O9 for bug-gnu-emacs@gnu.org; Mon, 29 May 2023 07:26:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 May 2023 11:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63708 X-GNU-PR-Package: emacs Original-Received: via spool by 63708-submit@debbugs.gnu.org id=B63708.16853595335696 (code B ref 63708); Mon, 29 May 2023 11:26:01 +0000 Original-Received: (at 63708) by debbugs.gnu.org; 29 May 2023 11:25:33 +0000 Original-Received: from localhost ([127.0.0.1]:57234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3b0H-0001To-4N for submit@debbugs.gnu.org; Mon, 29 May 2023 07:25:33 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3b0E-0001TW-G8 for 63708@debbugs.gnu.org; Mon, 29 May 2023 07:25:31 -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 1q3b08-0006Wi-KH; Mon, 29 May 2023 07:25:24 -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=AmHCRS1/HQfwCNgqLnjP6LYWxNc8gQx5ADXZI+03R+k=; b=dVn5n4aLWkjSQf3a8UIH OTCXhQFNmF3CfiCf/kTgfatrwjxlvyiURsK/IcucmZ1sO7+PrXPMi/ph6tIpqpgLzqZZwVaXcVHM1 mvPx+lFZ1TliJmj7SufGU5v5+1Z+FnV1lySz08LOS0agSm4uoFLfK6bYGVPChqCxZySLYpL0K6XnB 7fw4ShQSmF1dUE56sTX3fJRZEw7WmWUTz4shuBzQJijpe34zCCnV7/XS4ib+IIietnGMK1IIBqa72 ztE5L41bzngE4+Enls8KwuZMotKhdgwVCULqhuTP9YiyjV+5VviTCbFFLYd9aHBfcHQtcyeNfZxya Bi5pMKVwtM4yOw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3azw-0000B0-F4; Mon, 29 May 2023 07:25:24 -0400 In-Reply-To: (message from =?UTF-8?Q?=D0=99=D0=BE=D1=80=D0=B4=D0=B0=D0=BD_?= =?UTF-8?Q?=D0=9C=D0=B8=D0=BB=D0=B0=D0=B4=D0=B8=D0=BD=D0=BE=D0=B2?= on Sun, 28 May 2023 19:52:38 +0000) 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:262566 Archived-At: > Date: Sun, 28 May 2023 19:52:38 +0000 > From: Йордан Миладинов > Cc: Eli Zaretskii , 63708@debbugs.gnu.org, casouri@gmail.com > > And here's the patch... Thanks, a few comments below: > * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--syntax-propertize) > > Treat apostrophes as strings if used to define character literals. > > Treat LT and GT as pairs if used to define type parameters (formerly > they were treated as pairs only for type arguments). > > * lisp/progmodes/go-ts-mode.el (go-ts-mode) > > Treat apostrophes as strings if used to define rune literals. We don't leave empty lines between the name of the function and the description of the change. Like this: * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--syntax-propertize): Treat apostrophes as strings if used to define character literals. Treat LT and GT as pairs if used to define type parameters (formerly they were treated as pairs only for type arguments). * lisp/progmodes/go-ts-mode.el (go-ts-mode): Treat apostrophes as strings if used to define rune literals. Also note: no indentation, and a colon before the description. > +(defun go-ts-mode--syntax-propertize (beg end) > + "Apply syntax properties to various special characters with > +contextual meaning between BEG and END. The first line of a doc string should be a single full sentence, and should not exceed 78 characters. > (defun rust-ts-mode--syntax-propertize (beg end) > - "Apply syntax text property to template delimiters between BEG and END. > + "Apply syntax properties to various special characters with > +contextual meaning between BEG and END. Same here. > +This function scans the changed RANGES for these special > +characters and applies the appropriate text properties to reflect > +their syntactical meaning." This uses "RANGES", upper-case, which is our convention for arguments, but there's no argument RANGES in this function. (Yes, I know that the original doc string also had this problem.) > (while (re-search-forward (rx (or "<" ">")) end t) > - (pcase (treesit-node-type > - (treesit-node-parent > - (treesit-node-at (match-beginning 0)))) > - ("type_arguments" > - (put-text-property (match-beginning 0) > - (match-end 0) > - 'syntax-table > - (pcase (char-before) > - (?< '(4 . ?>)) > - (?> '(5 . ?<)))))))) > + (let ((parent-type (treesit-node-type > + (treesit-node-parent > + (treesit-node-at (match-beginning 0)))))) > + (when (or (string-equal parent-type "type_arguments") > + (string-equal parent-type "type_parameters")) > + (put-text-property (match-beginning 0) > + (match-end 0) > + 'syntax-table > + (pcase (char-before) > + (?< '(4 . ?>)) > + (?> '(5 . ?<)))))))) Here, AFAIU you needed to add a single line, but instead you rewrote a 'pcase' as a 'when', and got a much larger change. Was that really needed? I also don't understand how a bug for go-ts-mode led to a change that also affects rust-ts-mode. Can you explain? Finally, and most importantly: I don't see a copyright assignment from you on file, which means we can only accept a small contribution from you, less than 15 non-trivial lines of changes. This patch is significantly larger. So we can only accept it if you start your legal paperwork now, and only after the paperwork is finished. Would you like to start the papers rolling at this time? If yes, I will send you the form to fill. Thanks again for working on this.