all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#59807: 29.0.60; [PATCH] python-ts-mode does not auto-complete the closing quote
@ 2022-12-03 22:27 Kai Ma
  2022-12-04  7:19 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Kai Ma @ 2022-12-03 22:27 UTC (permalink / raw)
  To: 59807

[-- 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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-12-14  2:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03 22:27 bug#59807: 29.0.60; [PATCH] python-ts-mode does not auto-complete the closing quote Kai Ma
2022-12-04  7:19 ` 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.