unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Йордан Миладинов" <yordanm@proton.me>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dev@rjt.dev, casouri@gmail.com, 63708@debbugs.gnu.org
Subject: bug#63708: 29.0.60; rust-ts-mode not properly handling apostrophe
Date: Mon, 29 May 2023 14:54:15 +0000	[thread overview]
Message-ID: <LRqBQWtaNnSFNln0RIAIFyN4WUYWq1juTn7IvGv7R1tLvefcQ6v5fvI1tvvcWVTMElJHRW0pvNJiinGiTSpqUh-TgsfEcjehCUVAtXORV14=@proton.me> (raw)
In-Reply-To: <83edmzgqm9.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

Here's a patch that takes into account both your and Randy's remarks. It fixes both rust-ts-mode and go-ts-mode in a total of 15 lines.

$ git diff --stat HEAD~ HEAD
 lisp/progmodes/go-ts-mode.el   |  1 +
 lisp/progmodes/rust-ts-mode.el | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

If that doesn't work as well, I don't mind Randy re-implementing and committing the fixes.

On Monday, May 29th, 2023 at 5:26 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> I see in the discussion of that commit (bug#10893) you say you
> submitted the copyright assignment form, but I don't see your
> assignment on file. Did the process ever end, and if so, do you have
> somewhere the signed PDF file of your assignment, which you are
> supposed to receive when the process ends?

If I remember correctly, I sent the agreement over the post, but I never received any confirmation or response. As for the scanned PDF, it's long lost, I believe.

If you agree, I can sign a new one, complete the procedure and then examine all ts-modes for the same bug.

Cheers! YM

[-- Attachment #2: 0001-Fix-apostrophe-handling-in-rust-ts-mode-and-go-ts-mo.patch --]
[-- Type: application/octet-stream, Size: 2977 bytes --]

From 15da2c1d7e92b771a88f0dd066f3fa15b1e98c53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=99=D0=BE=D1=80=D0=B4=D0=B0=D0=BD=20=D0=9C=D0=B8=D0=BB?=
 =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D0=BD=D0=BE=D0=B2?= <yordanm@pm.me>
Date: Fri, 26 May 2023 17:23:26 +0300
Subject: [PATCH] Fix apostrophe handling in rust-ts-mode and go-ts-mode

* 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.
---
 lisp/progmodes/go-ts-mode.el   |  1 +
 lisp/progmodes/rust-ts-mode.el | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index b8705ecc4d0..32d86f44235 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -59,6 +59,7 @@ go-ts-mode--syntax-table
     (modify-syntax-entry ?<   "."      table)
     (modify-syntax-entry ?>   "."      table)
     (modify-syntax-entry ?\\  "\\"     table)
+    (modify-syntax-entry ?\'  "\""     table)
     (modify-syntax-entry ?/   ". 124b" table)
     (modify-syntax-entry ?*   ". 23"   table)
     (modify-syntax-entry ?\n  "> b"    table)
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index be06acde3e3..360fcc89491 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -350,7 +350,10 @@ rust-ts-mode--defun-name
       (treesit-node-child-by-field-name node "name") t))))
 
 (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.
+
+' should be treated as string when used for char literals.
 
 < and > are usually punctuation, e.g., as greater/less-than.  But
 when used for types, they should be considered pairs.
@@ -359,11 +362,18 @@ rust-ts-mode--syntax-propertize
 appropriate text property to alter the syntax of template
 delimiters < and >'s."
   (goto-char beg)
+  (while (search-forward "'" end t)
+    (when (string-equal "char_literal"
+                        (treesit-node-type
+                         (treesit-node-at (match-beginning 0))))
+      (put-text-property (match-beginning 0) (match-end 0)
+                         'syntax-table (string-to-syntax "\""))))
+  (goto-char beg)
   (while (re-search-forward (rx (or "<" ">")) end t)
     (pcase (treesit-node-type
             (treesit-node-parent
              (treesit-node-at (match-beginning 0))))
-      ("type_arguments"
+      ((or "type_arguments" "type_parameters")
        (put-text-property (match-beginning 0)
                           (match-end 0)
                           'syntax-table
-- 
2.40.1


  reply	other threads:[~2023-05-29 14:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 21:40 bug#63708: 29.0.60; rust-ts-mode not properly handling apostrophe yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-24 22:05 ` bug#63709: " yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-25  5:28   ` Eli Zaretskii
2023-05-25  5:31 ` bug#63708: " Eli Zaretskii
2023-05-25 12:52   ` Randy Taylor
2023-05-25 13:13     ` Eli Zaretskii
2023-05-26  2:21       ` Randy Taylor
2023-05-26 19:14         ` yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-27  3:00           ` Randy Taylor
2023-05-28 19:51             ` yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-28 19:52               ` yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-29 11:25                 ` Eli Zaretskii
2023-05-29 13:34                   ` Randy Taylor
2023-05-29  1:29               ` Randy Taylor
2023-05-29 12:13                 ` Eli Zaretskii
2023-05-29 12:18                   ` Randy Taylor
2023-05-29 13:13                     ` Eli Zaretskii
2023-05-29 13:20                       ` Randy Taylor
2023-05-29 14:13                   ` yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-29 14:27                     ` Eli Zaretskii
2023-05-29 14:54                       ` Йордан Миладинов [this message]
2023-05-29 14:59                         ` Eli Zaretskii
2023-05-30  0:14                         ` Randy Taylor
2023-05-30  9:44                           ` yordanm--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-03  8:35                             ` Eli Zaretskii
2023-05-30  9:10 ` Йордан Миладинов

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='LRqBQWtaNnSFNln0RIAIFyN4WUYWq1juTn7IvGv7R1tLvefcQ6v5fvI1tvvcWVTMElJHRW0pvNJiinGiTSpqUh-TgsfEcjehCUVAtXORV14=@proton.me' \
    --to=yordanm@proton.me \
    --cc=63708@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=dev@rjt.dev \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).