From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Kai Ma Newsgroups: gmane.emacs.bugs Subject: bug#59807: 29.0.60; [PATCH] python-ts-mode does not auto-complete the closing quote Date: Sun, 04 Dec 2022 06:27:18 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38002"; mail-complaints-to="usenet@ciao.gmane.io" To: 59807@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 03 23:28:14 2022 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 1p1azW-0009ky-Ey for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Dec 2022 23:28:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1azM-0000kg-UY; Sat, 03 Dec 2022 17:28:04 -0500 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 1p1azL-0000kQ-HD for bug-gnu-emacs@gnu.org; Sat, 03 Dec 2022 17:28:03 -0500 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 1p1azL-0005jh-7a for bug-gnu-emacs@gnu.org; Sat, 03 Dec 2022 17:28:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1azK-0004DX-Gn for bug-gnu-emacs@gnu.org; Sat, 03 Dec 2022 17:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kai Ma Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Dec 2022 22:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59807 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167010644816202 (code B ref -1); Sat, 03 Dec 2022 22:28:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Dec 2022 22:27:28 +0000 Original-Received: from localhost ([127.0.0.1]:53657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1ayl-0004DG-Jd for submit@debbugs.gnu.org; Sat, 03 Dec 2022 17:27:28 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:35532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1ayj-0004DA-Rb for submit@debbugs.gnu.org; Sat, 03 Dec 2022 17:27:26 -0500 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 1p1ayj-0000dx-JW for bug-gnu-emacs@gnu.org; Sat, 03 Dec 2022 17:27:25 -0500 Original-Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1ayh-0004X0-RY for bug-gnu-emacs@gnu.org; Sat, 03 Dec 2022 17:27:25 -0500 Original-Received: by mail-pj1-x1044.google.com with SMTP id o12so7986161pjo.4 for ; Sat, 03 Dec 2022 14:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=UKVN5UoU1fUvrisOpULFwH1+NSfcU0s3NG/5J+S7L4U=; b=NgSZdtEvayGBqq0zoK2Ht4BVRyvJMk/XPkQKEZihFq7c52ACHHkaN6CRJ8Wx75RjEr +Xkq/hfsmlipAqaeRhqu66JzTr2v6sFl+1tXYJTkSZPf2Rt4e3w58PiR1lXVKRExlMNM 0S651WdOd9DWJSQuDgAKzqokXAuqFQUJZCI9YnJ+IQLvnbKUOKlxhtss4RorU3AgwAAe P+UFtHe/n5rKhcHv3TNe2o8maGoZzkGTu7j2eL2MiEEWI0Vj+9maaq/OoLvRq2JTzV6M 8JPk/3iiBSJN1g6R4J5cdMYMhmAdq9dclelGp/2oqLIlLkDH+LzhwvBewu6Lz54VP9kM bbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UKVN5UoU1fUvrisOpULFwH1+NSfcU0s3NG/5J+S7L4U=; b=FG1dWcAxfVsLP+WjvDSQyv8DKYTBLJRm4n6fDE6MPqQaXaxhH139YH1RNTTv8kcbom UzzFUljSZjcQiDI2oFSqy4adT1U14fNzB/Ks2R+Z0j2ENvvKGGQ5TYh7flmcOvYhZ1+7 D1DWKdbruHkjIA28JDSAYfL4543QAKhf22jCGe2HV6rVJgnn3HrWyz+IAm57a8Lvvy28 JLpY5X0/0PPh+05pcKINFS/DcChpiheklpSyG+9GZVLBM/hfpuT2M76CobSTAy83Quh5 XVFynvFSWCzeMi7AndpfYLDi2myzInZTmMpkJiTcJPK3CKXSD6A8K8iomo0OQDkt96+M 9fPw== X-Gm-Message-State: ANoB5pkhb10Ex3vZfXnfzg2nNA6TXJ7bNJGbWEsveGuEURhlGzsiuQcK 5uQYAdVOsUzQKi9/1UEI+RbLh26vfAWUJkU9 X-Google-Smtp-Source: AA0mqf4rBPZEISNC60952j2EjYLZ4p2b/dc16cY06vJ45nIS64owAaZ8aDGJXgDvwV80F0ubM1HWQA== X-Received: by 2002:a17:90a:2e83:b0:219:a290:3ae5 with SMTP id r3-20020a17090a2e8300b00219a2903ae5mr5283001pjd.246.1670106442064; Sat, 03 Dec 2022 14:27:22 -0800 (PST) Original-Received: from Kais-MacBook.local ([134.209.106.31]) by smtp.gmail.com with ESMTPSA id j5-20020a170903024500b00186ac812ab0sm7906670plh.83.2022.12.03.14.27.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 14:27:21 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=justksqsf@gmail.com; helo=mail-pj1-x1044.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 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, FROM_LOCAL_NOVOWEL=0.5, 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: 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:249886 Archived-At: --=-=-= Content-Type: text/plain When electric-pair-mode is enabled, a single quote ' should be auto completed to be '' (which means an empty string). Python-mode correctly does this, but python-ts-mode does not. This is clearly a problem regarding the syntax table. The attached patch makes python-ts-mode uses the same syntax table as python-mode's, and fixes this problem. I also checked a few other ts modes, and some also have this issue. For example, js-ts-mode does not auto complete '' either, which is also fixed by this patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-syntax-tables-of-tree-sitter-modes.patch Content-Description: Fix syntax tables of tree-sitter modes >From 7f996826bc47bcdd155eb0cc220a48c32cb2619a Mon Sep 17 00:00:00 2001 From: Kai Ma Date: Sun, 4 Dec 2022 06:15:42 +0800 Subject: [PATCH] Fix syntax tables of tree-sitter modes Tree-sitter modes should use the same syntax table as the non-tree-sitter ones. * lisp/progmodes/csharp-mode.el (csharp-mode-syntax-table) (csharp-mode): * lisp/progmodes/js.el (js-mode-syntax-table) (js-ts-mode): * lisp/progmodes/python.el (python-ts-mode): * lisp/progmodes/sh-script.el (bash-ts-mode): * lisp/textmodes/css-mode.el (css-ts-mode): --- lisp/progmodes/csharp-mode.el | 3 ++- lisp/progmodes/js.el | 3 ++- lisp/progmodes/python.el | 1 + lisp/progmodes/sh-script.el | 1 + lisp/textmodes/css-mode.el | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 3da3079f08..73f2a6ff9e 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -608,7 +608,7 @@ csharp-compilation-re-dotnet-testfail (defvar csharp-mode-syntax-table (funcall (c-lang-const c-make-mode-syntax-table csharp)) - "Syntax table used in `csharp-mode' buffers.") + "Syntax table used in `csharp-mode' and `csharp-ts-mode' buffers.") (defvar csharp-mode-map (let ((map (c-make-inherited-keymap))) @@ -890,6 +890,7 @@ csharp-mode ;;;###autoload (define-derived-mode csharp-ts-mode prog-mode "C#" "Major mode for editing C# code." + :syntax-table csharp-mode-syntax-table (unless (treesit-ready-p 'c-sharp) (error "Tree-sitter for C# isn't available")) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index ad1fe62d42..11e45178f7 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -686,7 +686,7 @@ js-mode-syntax-table (modify-syntax-entry ?$ "_" table) (modify-syntax-entry ?` "\"" table) table) - "Syntax table for `js-mode'.") + "Syntax table for `js-mode' and `js-ts-mode'.") (defvar-local js--quick-match-re nil "Autogenerated regexp used by `js-mode' to match buffer constructs.") @@ -3840,6 +3840,7 @@ js-ts-mode \\" :group 'js + :syntax-table js-mode-syntax-table (when (treesit-ready-p 'javascript) ;; Borrowed from `js-mode'. (setq-local prettify-symbols-alist js--prettify-symbols-alist) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4fc5d24e2f..c90124b6b9 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6618,6 +6618,7 @@ python-ts-mode "Major mode for editing Python files, using tree-sitter library. \\{python-ts-mode-map}" + :syntax-table python-mode-syntax-table (when (treesit-ready-p 'python) (treesit-parser-create 'python) (setq-local treesit-font-lock-feature-list diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..76e8d5b074 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1611,6 +1611,7 @@ bash-ts-mode "Major mode for editing Bash shell scripts. This mode automatically falls back to `sh-mode' if the buffer is not written in Bash or sh." + :syntax-table sh-mode-syntax-table (when (treesit-ready-p 'bash) (setq-local treesit-font-lock-feature-list '(( comment function) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index b82886e397..b3654eaa7f 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1822,6 +1822,7 @@ css-ts-mode can also be used to fill comments. \\{css-mode-map}" + :syntax-table css-mode-syntax-table (when (treesit-ready-p 'css) ;; Borrowed from `css-mode'. (add-hook 'completion-at-point-functions -- 2.37.1 (Apple Git-137.1) --=-=-= Content-Type: text/plain Kai --=-=-=--