* bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
@ 2025-01-07 16:02 Kohei Tsuruta
2025-01-07 17:44 ` Juri Linkov
0 siblings, 1 reply; 6+ messages in thread
From: Kohei Tsuruta @ 2025-01-07 16:02 UTC (permalink / raw)
To: 75422
[-- Attachment #1: Type: text/plain, Size: 753 bytes --]
Steps to reproduce
- emacs -Q test.tsx
- (tsx-ts-mode)
- Move point at the end of the comment at line 3
- (backward-sexp)
The expected point position after (backward-sexp) is "treesit-thing-|settings"
or at least stay inside of the comment line, however, point moves to the
beginning of "Hello".
Likewise, if you C-x C-e at the end of the comment line, it evaluates "Hello".
--- test.tsx (| is point) ---
export const App = () => {
const greeting = "Hello"
// treesit-thing-settings|
return <>{greeting}</>
}
--- END test.tsx ---
It happens because tsx-ts-mode doesn't recognize comments. In
typescript-ts-base-mode, treesit-thing-settings is set to have "text" as
a thing for typescript but it's missing in tsx-ts-mode when it's set for
tsx.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-text-as-a-thing-in-tsx-ts-mode.patch --]
[-- Type: text/x-patch, Size: 1162 bytes --]
From d1c5aa45213e4011dfb641edb0d064e5d02e370d Mon Sep 17 00:00:00 2001
From: Kohei Tsuruta <seventhepg@gmail.com>
Date: Tue, 7 Jan 2025 07:36:14 -0800
Subject: [PATCH] Add "text" as a thing in tsx-ts-mode
* lisp/progmodes/typescript-ts-mode.el (tsx-ts-mode):
Add definition of "text"
---
lisp/progmodes/typescript-ts-mode.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index 4a38d1da596..0ffcb144771 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -564,7 +564,9 @@ tsx-ts-mode
(sentence ,(regexp-opt
(append typescript-ts-mode--sentence-nodes
'("jsx_element"
- "jsx_self_closing_element")))))))
+ "jsx_self_closing_element"))))
+ (text ,(regexp-opt '("comment"
+ "template_string"))))))
;; Font-lock.
(setq-local treesit-font-lock-settings
--
2.39.5 (Apple Git-154)
[-- Attachment #3: Type: text/plain, Size: 4952 bytes --]
In GNU Emacs 30.0.93 (build 3, aarch64-apple-darwin24.1.0, NS
appkit-2575.20 Version 15.1.1 (Build 24B91)) of 2025-01-05 built on
mac.lan
Repository revision: 505c1123e18a8a710fc60e05a4c870497bf580f4
Repository branch: emacs-30
System Description: macOS 15.1.1
Configured using:
'configure --with-native-compilation --disable-ns-self-contained
--with-tree-sitter'
Configured features:
ACL GNUTLS LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER SQLITE3
THREADS TOOLKIT_SCROLL_BARS TREE_SITTER ZLIB
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: ELisp/l
Minor modes in effect:
bug-reference-prog-mode: t
paredit-mode: t
rainbow-delimiters-mode: t
whitespace-mode: t
which-function-mode: t
corfu-terminal-mode: t
corfu-history-mode: t
global-corfu-mode: t
corfu-mode: t
marginalia-mode: t
vertico-mode: t
savehist-mode: t
recentf-mode: t
winner-mode: t
repeat-mode: t
save-place-mode: t
delete-selection-mode: t
electric-pair-mode: t
minibuffer-depth-indicate-mode: t
override-global-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
minibuffer-regexp-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
None found.
Features:
(shadow sort emacsbug mail-extr ispell log-edit message sendmail
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev
mail-utils gmm-utils mailheader pcvs-util vc consult-imenu help-fns
radix-tree cl-print debug backtrace find-func dabbrev vertico-directory
c++-ts-mode c-ts-mode js c-ts-common treesit cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs time-date
misearch multi-isearch vc-git diff-mode track-changes vc-dispatcher
bug-reference descr-text grep embark-consult embark ffap texinfo
texinfo-loaddefs files-x consult bookmark pp add-log term/xterm xterm
paredit cape rainbow-delimiters disp-table whitespace merge-n-save
flymake project compile text-property-search comint ansi-osc ansi-color
thingatpt which-func imenu corfu-terminal popon corfu-history corfu
orderless marginalia vertico compat savehist recentf tree-widget
wid-edit winner ring repeat saveplace delsel elec-pair finder-inf
solarized-light-theme solarized-theme solarized solarized-faces color
edmacro kmacro mb-depth delight comp comp-cstr warnings comp-run
comp-common rx cl-extra help-mode use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core avy-autoloads cape-autoloads
corfu-terminal-autoloads corfu-autoloads delight-autoloads
dumb-jump-autoloads dash-autoloads embark-consult-autoloads
consult-autoloads embark-autoloads exec-path-from-shell-autoloads
expand-region-autoloads marginalia-autoloads markdown-mode-autoloads
info orderless-autoloads paredit-autoloads popon-autoloads
popup-autoloads rainbow-delimiters-autoloads s-autoloads
solarized-theme-autoloads vertico-autoloads package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns multi-tty
make-network-process native-compile emacs)
Memory information:
((conses 16 334937 64735) (symbols 48 32870 14)
(strings 32 126791 4029) (string-bytes 1 4022076) (vectors 16 34459)
(vector-slots 8 436900 32986) (floats 8 362 7583)
(intervals 56 3954 480) (buffers 992 27))
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
2025-01-07 16:02 bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode Kohei Tsuruta
@ 2025-01-07 17:44 ` Juri Linkov
2025-01-08 2:29 ` Yuan Fu
0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2025-01-07 17:44 UTC (permalink / raw)
To: Kohei Tsuruta; +Cc: Yuan Fu, 75422
> Steps to reproduce
> - emacs -Q test.tsx
> - (tsx-ts-mode)
> - Move point at the end of the comment at line 3
> - (backward-sexp)
>
> The expected point position after (backward-sexp) is "treesit-thing-|settings"
> or at least stay inside of the comment line, however, point moves to the
> beginning of "Hello".
> Likewise, if you C-x C-e at the end of the comment line, it evaluates "Hello".
>
> --- test.tsx (| is point) ---
> export const App = () => {
> const greeting = "Hello"
> // treesit-thing-settings|
> return <>{greeting}</>
> }
> --- END test.tsx ---
>
> It happens because tsx-ts-mode doesn't recognize comments. In
> typescript-ts-base-mode, treesit-thing-settings is set to have "text" as
> a thing for typescript but it's missing in tsx-ts-mode when it's set for
> tsx.
Thanks for the report. This is fixed in Emacs 31.
However, maybe Yuan will agree to add this small fix to Emacs 30?
> diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
> index 4a38d1da596..0ffcb144771 100644
> --- a/lisp/progmodes/typescript-ts-mode.el
> +++ b/lisp/progmodes/typescript-ts-mode.el
> @@ -564,7 +564,9 @@ tsx-ts-mode
> (sentence ,(regexp-opt
> (append typescript-ts-mode--sentence-nodes
> '("jsx_element"
> - "jsx_self_closing_element")))))))
> + "jsx_self_closing_element"))))
> + (text ,(regexp-opt '("comment"
> + "template_string"))))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
2025-01-07 17:44 ` Juri Linkov
@ 2025-01-08 2:29 ` Yuan Fu
2025-01-08 7:44 ` Juri Linkov
0 siblings, 1 reply; 6+ messages in thread
From: Yuan Fu @ 2025-01-08 2:29 UTC (permalink / raw)
To: Juri Linkov; +Cc: Kohei Tsuruta, Eli Zaretskii, 75422
> On Jan 7, 2025, at 9:44 AM, Juri Linkov <juri@linkov.net> wrote:
>
>> Steps to reproduce
>> - emacs -Q test.tsx
>> - (tsx-ts-mode)
>> - Move point at the end of the comment at line 3
>> - (backward-sexp)
>>
>> The expected point position after (backward-sexp) is "treesit-thing-|settings"
>> or at least stay inside of the comment line, however, point moves to the
>> beginning of "Hello".
>> Likewise, if you C-x C-e at the end of the comment line, it evaluates "Hello".
>>
>> --- test.tsx (| is point) ---
>> export const App = () => {
>> const greeting = "Hello"
>> // treesit-thing-settings|
>> return <>{greeting}</>
>> }
>> --- END test.tsx ---
>>
>> It happens because tsx-ts-mode doesn't recognize comments. In
>> typescript-ts-base-mode, treesit-thing-settings is set to have "text" as
>> a thing for typescript but it's missing in tsx-ts-mode when it's set for
>> tsx.
>
> Thanks for the report. This is fixed in Emacs 31.
>
> However, maybe Yuan will agree to add this small fix to Emacs 30?
>
>> diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
>> index 4a38d1da596..0ffcb144771 100644
>> --- a/lisp/progmodes/typescript-ts-mode.el
>> +++ b/lisp/progmodes/typescript-ts-mode.el
>> @@ -564,7 +564,9 @@ tsx-ts-mode
>> (sentence ,(regexp-opt
>> (append typescript-ts-mode--sentence-nodes
>> '("jsx_element"
>> - "jsx_self_closing_element")))))))
>> + "jsx_self_closing_element"))))
>> + (text ,(regexp-opt '("comment"
>> + "template_string"))))))
I think it’s fine. Though it’s for Eli to decide.
Yuan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
2025-01-08 2:29 ` Yuan Fu
@ 2025-01-08 7:44 ` Juri Linkov
2025-01-08 13:12 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2025-01-08 7:44 UTC (permalink / raw)
To: Yuan Fu; +Cc: Kohei Tsuruta, Eli Zaretskii, 75422
>>> diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
>>> index 4a38d1da596..0ffcb144771 100644
>>> --- a/lisp/progmodes/typescript-ts-mode.el
>>> +++ b/lisp/progmodes/typescript-ts-mode.el
>>> @@ -564,7 +564,9 @@ tsx-ts-mode
>>> (sentence ,(regexp-opt
>>> (append typescript-ts-mode--sentence-nodes
>>> '("jsx_element"
>>> - "jsx_self_closing_element")))))))
>>> + "jsx_self_closing_element"))))
>>> + (text ,(regexp-opt '("comment"
>>> + "template_string"))))))
>
> I think it’s fine. Though it’s for Eli to decide.
Eli, is it ok to push this patch to emacs-30?
It fills the omission that the thing 'text' is defined
only for 'typescript', but not for its counterpart 'tsx'.
BTW, in master we need to clean up typescript-ts-base-mode
that defines only 'typescript', but not 'tsx', i.e. we need
to create better inheritance for 'treesit-thing-settings'.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
2025-01-08 7:44 ` Juri Linkov
@ 2025-01-08 13:12 ` Eli Zaretskii
2025-01-09 7:51 ` Juri Linkov
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2025-01-08 13:12 UTC (permalink / raw)
To: Juri Linkov; +Cc: seventhepg, casouri, 75422
> From: Juri Linkov <juri@linkov.net>
> Cc: Kohei Tsuruta <seventhepg@gmail.com>, 75422@debbugs.gnu.org, Eli
> Zaretskii <eliz@gnu.org>
> Date: Wed, 08 Jan 2025 09:44:48 +0200
>
> >>> --- a/lisp/progmodes/typescript-ts-mode.el
> >>> +++ b/lisp/progmodes/typescript-ts-mode.el
> >>> @@ -564,7 +564,9 @@ tsx-ts-mode
> >>> (sentence ,(regexp-opt
> >>> (append typescript-ts-mode--sentence-nodes
> >>> '("jsx_element"
> >>> - "jsx_self_closing_element")))))))
> >>> + "jsx_self_closing_element"))))
> >>> + (text ,(regexp-opt '("comment"
> >>> + "template_string"))))))
> >
> > I think it’s fine. Though it’s for Eli to decide.
>
> Eli, is it ok to push this patch to emacs-30?
Yes, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
2025-01-08 13:12 ` Eli Zaretskii
@ 2025-01-09 7:51 ` Juri Linkov
0 siblings, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2025-01-09 7:51 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: seventhepg, casouri, 75422
close 75422 30.0.93
thanks
>> >>> @@ -564,7 +564,9 @@ tsx-ts-mode
>> >>> (sentence ,(regexp-opt
>> >>> (append typescript-ts-mode--sentence-nodes
>> >>> '("jsx_element"
>> >>> - "jsx_self_closing_element")))))))
>> >>> + "jsx_self_closing_element"))))
>> >>> + (text ,(regexp-opt '("comment"
>> >>> + "template_string"))))))
>> >
>> > I think it’s fine. Though it’s for Eli to decide.
>>
>> Eli, is it ok to push this patch to emacs-30?
>
> Yes, thanks.
So now pushed to emacs-30, and closed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-09 7:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-07 16:02 bug#75422: 30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode Kohei Tsuruta
2025-01-07 17:44 ` Juri Linkov
2025-01-08 2:29 ` Yuan Fu
2025-01-08 7:44 ` Juri Linkov
2025-01-08 13:12 ` Eli Zaretskii
2025-01-09 7:51 ` Juri Linkov
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.