From: Kai Ma <justksqsf@gmail.com>
To: 59807@debbugs.gnu.org
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 [thread overview]
Message-ID: <m21qpgazsp.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix syntax tables of tree-sitter modes --]
[-- Type: text/x-patch, Size: 3727 bytes --]
From 7f996826bc47bcdd155eb0cc220a48c32cb2619a Mon Sep 17 00:00:00 2001
From: Kai Ma <justksqsf@gmail.com>
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
\\<js-ts-mode-map>"
: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)
[-- Attachment #3: Type: text/plain, Size: 5 bytes --]
Kai
next reply other threads:[~2022-12-03 22:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-03 22:27 Kai Ma [this message]
2022-12-04 7:19 ` bug#59807: 29.0.60; [PATCH] python-ts-mode does not auto-complete the closing quote Eli Zaretskii
2022-12-04 7:28 ` Yuan Fu
2022-12-04 8:07 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-04 12:32 ` Kai Ma
2022-12-05 6:28 ` Yuan Fu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 6:48 ` Kai Ma
2022-12-13 1:20 ` Kai Ma
2022-12-13 2:24 ` Stefan Kangas
2022-12-13 5:28 ` Yuan Fu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 12:17 ` Eli Zaretskii
2022-12-05 8:22 ` Eli Zaretskii
2022-12-14 2:08 ` Yuan Fu
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=m21qpgazsp.fsf@gmail.com \
--to=justksqsf@gmail.com \
--cc=59807@debbugs.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).