GNU bug report logs -
#59498
29.0.50; c++-ts-mode get wrong-type-argument error when enabled
Previous Next
Reported by: Eason Huang <aqua0210 <at> foxmail.com>
Date: Wed, 23 Nov 2022 02:26:02 UTC
Severity: normal
Tags: patch
Found in version 29.0.50
Fixed in version 29.1
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59498 in the body.
You can then email your comments to 59498 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Wed, 23 Nov 2022 02:26:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Eason Huang <aqua0210 <at> foxmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 23 Nov 2022 02:26:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi emacs-devel,
I just tried the c++-ts-mode, but it didn't worked.
steps to reproduce:
1. luanch Emacs with emacs -Q
2. C-x, C-f ~/test.cpp
3. M-x, toggle-debug-on-error
4. M-x, c++-ts-mode, now you will get the errors as bellow:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
treesit-ready-p(cpp)
c++-ts-mode()
funcall-interactively(c++-ts-mode)
command-execute(c++-ts-mode record)
execute-extended-command(nil "c++-ts-mode" "c++-ts")
funcall-interactively(execute-extended-command nil "c++-ts-mode" "c++-ts")
command-execute(execute-extended-command)
By the way, python-ts-mode works well.
I builded Emacs 29.0.50 with this commit:
https://github.com/emacs-mirror/emacs/commit/057901f55ad12ebbc9cf092dd6ad0f02539849f9
----
Eason Huang
In GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin22.1.0, NS
appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2022-11-23 built on
macbook
Windowing system distributor 'Apple', version 10.3.2299
System Description: macOS 13.0.1
Configured using:
'configure --with-native-compilation=aot 'CPPFLAGS=-I/opt/local/include
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-rpath
/opt/local/lib/gcc12
-Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
-arch x86_64''
Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB
Important settings:
value of $LC_CTYPE: en_US.UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Text
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
indent-tabs-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 mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-fns
radix-tree cl-print byte-opt debug backtrace find-func c-ts-mode treesit
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs cl-loaddefs comp comp-cstr warnings icons subr-x rx
cl-seq cl-macs gv cl-extra help-mode bytecomp byte-compile cl-lib
cus-start cus-load 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 lcms2
multi-tty make-network-process native-compile emacs)
Memory information:
((conses 16 124747 11782)
(symbols 48 10326 0)
(strings 32 29161 1312)
(string-bytes 1 989243)
(vectors 16 19575)
(vector-slots 8 393723 16844)
(floats 8 35 39)
(intervals 56 419 0)
(buffers 992 15))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Wed, 23 Nov 2022 08:45:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 59498 <at> debbugs.gnu.org (full text, mbox):
Eason Huang <aqua0210 <at> foxmail.com> writes:
> Hi emacs-devel,
>
> I just tried the c++-ts-mode, but it didn't worked.
>
> steps to reproduce:
>
> 1. luanch Emacs with emacs -Q
> 2. C-x, C-f ~/test.cpp
> 3. M-x, toggle-debug-on-error
> 4. M-x, c++-ts-mode, now you will get the errors as bellow:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
> treesit-ready-p(cpp)
> c++-ts-mode()
> funcall-interactively(c++-ts-mode)
> command-execute(c++-ts-mode record)
> execute-extended-command(nil "c++-ts-mode" "c++-ts")
> funcall-interactively(execute-extended-command nil "c++-ts-mode" "c++-ts")
> command-execute(execute-extended-command)
>
> By the way, python-ts-mode works well.
>
> I builded Emacs 29.0.50 with this commit:
> https://github.com/emacs-mirror/emacs/commit/057901f55ad12ebbc9cf092dd6ad0f02539849f9
Could you try an Emacs build that contains commit c69858b3f0? This is
the same bug as bug#59497. Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Wed, 23 Nov 2022 10:54:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 59498 <at> debbugs.gnu.org (full text, mbox):
Daniel Martín <mardani29 <at> yahoo.es> writes:
> Eason Huang <aqua0210 <at> foxmail.com> writes:
>
>> Hi emacs-devel,
>>
>> I just tried the c++-ts-mode, but it didn't worked.
>>
>> steps to reproduce:
>>
>> 1. luanch Emacs with emacs -Q
>> 2. C-x, C-f ~/test.cpp
>> 3. M-x, toggle-debug-on-error
>> 4. M-x, c++-ts-mode, now you will get the errors as bellow:
>>
>> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>> treesit-ready-p(cpp)
>> c++-ts-mode()
>> funcall-interactively(c++-ts-mode)
>> command-execute(c++-ts-mode record)
>> execute-extended-command(nil "c++-ts-mode" "c++-ts")
>> funcall-interactively(execute-extended-command nil "c++-ts-mode" "c++-ts")
>> command-execute(execute-extended-command)
>>
>> By the way, python-ts-mode works well.
>>
>> I builded Emacs 29.0.50 with this commit:
>> https://github.com/emacs-mirror/emacs/commit/057901f55ad12ebbc9cf092dd6ad0f02539849f9
>
> Could you try an Emacs build that contains commit c69858b3f0? This is
> the same bug as bug#59497. Thanks.
Hi Daniel,
I build the latest commit(9f4306cd) and try it a again. This issue have
been fixed.
But when I try to indent code,
it will raise the error (Wrong type argument: stringp, nil) again.
It should be a different bug.
Steps to reproduce:
After the step 4, try to type the code as below:
int main(){
<-- put you cursor at the first colum 1, and then hit TAB(indent-for-tab-command)
}
after you hit TAB at the above code, you will get the backtrace error as
below:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
looking-at(nil t)
#f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)(nil #<treesit-node (compound_statement) in 11-15> 13)
#f(compiled-function (fn) #<bytecode 0x188c898311f019af>)(#f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>))
mapcar(#f(compiled-function (fn) #<bytecode 0x188c898311f019af>) (#f(compiled-function (n parent &rest _) #<bytecode 0x149caa867664fee9>) #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)))
#f(compiled-function (node parent bol &rest _) #<bytecode -0xb869f433d8fc770>)(nil #<treesit-node (compound_statement) in 11-15> 13)
treesit--simple-indent-eval(((and (parent-is "comment") comment-end) nil #<treesit-node (compound_statement) in 11-15> 13))
treesit-simple-indent(nil #<treesit-node (compound_statement) in 11-15> 13)
treesit--indent-1()
treesit-indent()
indent-according-to-mode()
electric-indent-post-self-insert-function()
newline(nil 1)
funcall-interactively(newline nil 1)
command-execute(newline)
--
Eason Huang
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Thu, 24 Nov 2022 14:40:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 59498 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wednesday, November 23rd, 2022 at 05:53, Eason Huang <aqua0210 <at> foxmail.com> wrote:
>
>
> But when I try to indent code,
> it will raise the error (Wrong type argument: stringp, nil) again.
> It should be a different bug.
>
> Steps to reproduce:
>
> After the step 4, try to type the code as below:
>
> int main(){
> <-- put you cursor at the first colum 1, and then hit TAB(indent-for-tab-command)
>
> }
>
> after you hit TAB at the above code, you will get the backtrace error as
> below:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> looking-at(nil t)
> #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)(nil #<treesit-node (compound_statement) in 11-15> 13)
>
> #f(compiled-function (fn) #<bytecode 0x188c898311f019af>)(#f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>))
>
> mapcar(#f(compiled-function (fn) #<bytecode 0x188c898311f019af>) (#f(compiled-function (n parent &rest _) #<bytecode 0x149caa867664fee9>) #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)))
>
> #f(compiled-function (node parent bol &rest _) #<bytecode -0xb869f433d8fc770>)(nil #<treesit-node (compound_statement) in 11-15> 13)
>
> treesit--simple-indent-eval(((and (parent-is "comment") comment-end) nil #<treesit-node (compound_statement) in 11-15> 13))
>
> treesit-simple-indent(nil #<treesit-node (compound_statement) in 11-15> 13)
>
> treesit--indent-1()
> treesit-indent()
> indent-according-to-mode()
> electric-indent-post-self-insert-function()
> newline(nil 1)
> funcall-interactively(newline nil 1)
> command-execute(newline)
>
>
> --
> Eason Huang
>
The attached patch fixes it for me.
[0001-Fix-c-ts-mode-indentation-Bug-59498.patch (text/x-patch, attachment)]
Added tag(s) patch.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 24 Nov 2022 18:28:05 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Fri, 25 Nov 2022 12:57:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 59498 <at> debbugs.gnu.org (full text, mbox):
Randy Taylor <dev <at> rjt.dev> writes:
> On Wednesday, November 23rd, 2022 at 05:53, Eason Huang <aqua0210 <at> foxmail.com> wrote:
>
>>
>>
>> But when I try to indent code,
>> it will raise the error (Wrong type argument: stringp, nil) again.
>> It should be a different bug.
>>
>> Steps to reproduce:
>>
>> After the step 4, try to type the code as below:
>>
>> int main(){
>> <-- put you cursor at the first colum 1, and then hit TAB(indent-for-tab-command)
>>
>> }
>>
>> after you hit TAB at the above code, you will get the backtrace error as
>> below:
>>
>> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>> looking-at(nil t)
>> #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)(nil #<treesit-node (compound_statement) in 11-15> 13)
>>
>> #f(compiled-function (fn) #<bytecode 0x188c898311f019af>)(#f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>))
>>
>> mapcar(#f(compiled-function (fn) #<bytecode 0x188c898311f019af>)
>> (#f(compiled-function (n parent &rest _) #<bytecode
>> 0x149caa867664fee9>) #f(compiled-function (&rest _) #<bytecode
>> 0x18b0dfc57c56ebd8>)))
>>
>> #f(compiled-function (node parent bol &rest _) #<bytecode -0xb869f433d8fc770>)(nil #<treesit-node (compound_statement) in 11-15> 13)
>>
>> treesit--simple-indent-eval(((and (parent-is "comment") comment-end) nil #<treesit-node (compound_statement) in 11-15> 13))
>>
>> treesit-simple-indent(nil #<treesit-node (compound_statement) in 11-15> 13)
>>
>> treesit--indent-1()
>> treesit-indent()
>> indent-according-to-mode()
>> electric-indent-post-self-insert-function()
>> newline(nil 1)
>> funcall-interactively(newline nil 1)
>> command-execute(newline)
>>
>>
>> --
>> Eason Huang
>>
>
> The attached patch fixes it for me.
>
>
Hi Randy,
Thanks for your patch, I tested on macOS 13.0.1. And I can confirm that it
fixes the issue of indentation.
Hope it can be merged to master.
--
Eason Huang
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sat, 26 Nov 2022 11:18:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> Cc: Yuan Fu <casouri <at> gmail.com>, 59498 <at> debbugs.gnu.org,
> Daniel Martín <mardani29 <at> yahoo.es>
> Date: Thu, 24 Nov 2022 14:39:19 +0000
> From: Randy Taylor <dev <at> rjt.dev>
>
> diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
> index fc35d9aedda..48f504214e2 100644
> --- a/lisp/progmodes/c-ts-mode.el
> +++ b/lisp/progmodes/c-ts-mode.el
> @@ -570,6 +570,8 @@ c++-ts-mode
> (setq-local comment-start "// ")
> (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *")
> (setq-local comment-end "")
> + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*"))))
> + (setq-local treesit-comment-end (rx (+ (or "*")) "/"))
>
> (treesit-parser-create 'cpp)
Thanks, but this doesn't look right to me: why should c++-ts-mode set
variables for treesit.el? It is more likely that treesit.el should use the
buffer-local values of comment-start and comment-end instead, and fall back
on generic values (if they make sense) only if the local values are not set.
Yuan, WDYT?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sat, 26 Nov 2022 22:13:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> On Nov 26, 2022, at 3:18 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> Cc: Yuan Fu <casouri <at> gmail.com>, 59498 <at> debbugs.gnu.org,
>> Daniel Martín <mardani29 <at> yahoo.es>
>> Date: Thu, 24 Nov 2022 14:39:19 +0000
>> From: Randy Taylor <dev <at> rjt.dev>
>>
>> diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
>> index fc35d9aedda..48f504214e2 100644
>> --- a/lisp/progmodes/c-ts-mode.el
>> +++ b/lisp/progmodes/c-ts-mode.el
>> @@ -570,6 +570,8 @@ c++-ts-mode
>> (setq-local comment-start "// ")
>> (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *")
>> (setq-local comment-end "")
>> + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*"))))
>> + (setq-local treesit-comment-end (rx (+ (or "*")) "/"))
>>
>> (treesit-parser-create 'cpp)
>
> Thanks, but this doesn't look right to me: why should c++-ts-mode set
> variables for treesit.el? It is more likely that treesit.el should use the
> buffer-local values of comment-start and comment-end instead, and fall back
> on generic values (if they make sense) only if the local values are not set.
>
> Yuan, WDYT?
I added treesit-comment-start/end to help indenting comments. So this is the correct way to use them. The following comment explains why I created new variables:
;; `comment-start' and `comment-end' assume there is only one type of
;; comment, and that the comment spans only one line. So they are not
;; sufficient for our purpose.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 27 Nov 2022 06:25:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Sat, 26 Nov 2022 14:11:48 -0800
> Cc: Randy Taylor <dev <at> rjt.dev>,
> aqua0210 <at> foxmail.com,
> 59498 <at> debbugs.gnu.org,
> mardani29 <at> yahoo.es
>
> >> + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*"))))
> >> + (setq-local treesit-comment-end (rx (+ (or "*")) "/"))
> >>
> >> (treesit-parser-create 'cpp)
> >
> > Thanks, but this doesn't look right to me: why should c++-ts-mode set
> > variables for treesit.el? It is more likely that treesit.el should use the
> > buffer-local values of comment-start and comment-end instead, and fall back
> > on generic values (if they make sense) only if the local values are not set.
> >
> > Yuan, WDYT?
>
> I added treesit-comment-start/end to help indenting comments. So this is the correct way to use them. The following comment explains why I created new variables:
>
> ;; `comment-start' and `comment-end' assume there is only one type of
> ;; comment, and that the comment spans only one line. So they are not
> ;; sufficient for our purpose.
??? This is surprisingly unclean, IMO. For starters, the names of the
variables are confusing. The need to define two sets of comment-start and
comment-end regexps is also a nuisance and a source of errors.
How do non-treesit modes handle this issue? Why do the treesit-based modes
need something special here?
Stefan, any ideas?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 27 Nov 2022 07:19:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 59498 <at> debbugs.gnu.org (full text, mbox):
>> I added treesit-comment-start/end to help indenting comments. So this is
>> the correct way to use them. The following comment explains why I created
>> new variables:
>>
>> ;; `comment-start' and `comment-end' assume there is only one type of
>> ;; comment, and that the comment spans only one line. So they are not
>> ;; sufficient for our purpose.
>
> ??? This is surprisingly unclean, IMO. For starters, the names of the
> variables are confusing. The need to define two sets of comment-start and
> comment-end regexps is also a nuisance and a source of errors.
>
> How do non-treesit modes handle this issue? Why do the treesit-based modes
> need something special here?
>
> Stefan, any ideas?
`comment-start` and `comment-end` do not describe the set of possible
comment delimiters. They describe the comment delimiters that should be
*inserted* when we do things like `comment-dwim`.
To find/match comment delimiters we have `comment-start-skip` and
`comment-end-skip`. They're not ideal, but they've been good enough so far.
They don't say which comment starter matches which comment-ender (that
was done by the syntax-tables), but tree-sitter should be able to tell
us that when we need it.
It would be nice if we could avoid the need to set/use
`comment-start-skip` and `comment-end-skip` when using tree-sitter.
Maybe we can compute their values from the tree-sitter grammar.
But getting rid of uses of those vars will take a fair bit more work,
I think.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 27 Nov 2022 07:25:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Yuan Fu <casouri <at> gmail.com>, dev <at> rjt.dev, aqua0210 <at> foxmail.com,
> 59498 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
> Date: Sun, 27 Nov 2022 02:18:06 -0500
>
> >> I added treesit-comment-start/end to help indenting comments. So this is
> >> the correct way to use them. The following comment explains why I created
> >> new variables:
> >>
> >> ;; `comment-start' and `comment-end' assume there is only one type of
> >> ;; comment, and that the comment spans only one line. So they are not
> >> ;; sufficient for our purpose.
> >
> > ??? This is surprisingly unclean, IMO. For starters, the names of the
> > variables are confusing. The need to define two sets of comment-start and
> > comment-end regexps is also a nuisance and a source of errors.
> >
> > How do non-treesit modes handle this issue? Why do the treesit-based modes
> > need something special here?
> >
> > Stefan, any ideas?
>
> `comment-start` and `comment-end` do not describe the set of possible
> comment delimiters. They describe the comment delimiters that should be
> *inserted* when we do things like `comment-dwim`.
>
> To find/match comment delimiters we have `comment-start-skip` and
> `comment-end-skip`. They're not ideal, but they've been good enough so far.
> They don't say which comment starter matches which comment-ender (that
> was done by the syntax-tables), but tree-sitter should be able to tell
> us that when we need it.
>
> It would be nice if we could avoid the need to set/use
> `comment-start-skip` and `comment-end-skip` when using tree-sitter.
> Maybe we can compute their values from the tree-sitter grammar.
> But getting rid of uses of those vars will take a fair bit more work,
> I think.
OK, but do you agree that adding yet another pair of variables,
treesit-comment-start/end, is the opposite of what we want?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 27 Nov 2022 22:01:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> On Nov 26, 2022, at 11:18 PM, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>
>>> I added treesit-comment-start/end to help indenting comments. So this is
>>> the correct way to use them. The following comment explains why I created
>>> new variables:
>>>
>>> ;; `comment-start' and `comment-end' assume there is only one type of
>>> ;; comment, and that the comment spans only one line. So they are not
>>> ;; sufficient for our purpose.
>>
>> ??? This is surprisingly unclean, IMO. For starters, the names of the
>> variables are confusing. The need to define two sets of comment-start and
>> comment-end regexps is also a nuisance and a source of errors.
>>
>> How do non-treesit modes handle this issue? Why do the treesit-based modes
>> need something special here?
>>
>> Stefan, any ideas?
>
> `comment-start` and `comment-end` do not describe the set of possible
> comment delimiters. They describe the comment delimiters that should be
> *inserted* when we do things like `comment-dwim`.
>
> To find/match comment delimiters we have `comment-start-skip` and
> `comment-end-skip`. They're not ideal, but they've been good enough so far.
> They don't say which comment starter matches which comment-ender (that
> was done by the syntax-tables), but tree-sitter should be able to tell
> us that when we need it.
Ah, I should’ve done more research, sorry. comment-start/end-skip can completely replace treesit-comment-start/end.
> It would be nice if we could avoid the need to set/use
> `comment-start-skip` and `comment-end-skip` when using tree-sitter.
> Maybe we can compute their values from the tree-sitter grammar.
> But getting rid of uses of those vars will take a fair bit more work,
> I think.
Tree-sitter puts the whole comment in a single “comment” node, so there is no hope getting comment-start/end from it, sadly.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 27 Nov 2022 22:22:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> On Nov 26, 2022, at 11:24 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
>> Cc: Yuan Fu <casouri <at> gmail.com>, dev <at> rjt.dev, aqua0210 <at> foxmail.com,
>> 59498 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
>> Date: Sun, 27 Nov 2022 02:18:06 -0500
>>
>>>> I added treesit-comment-start/end to help indenting comments. So this is
>>>> the correct way to use them. The following comment explains why I created
>>>> new variables:
>>>>
>>>> ;; `comment-start' and `comment-end' assume there is only one type of
>>>> ;; comment, and that the comment spans only one line. So they are not
>>>> ;; sufficient for our purpose.
>>>
>>> ??? This is surprisingly unclean, IMO. For starters, the names of the
>>> variables are confusing. The need to define two sets of comment-start and
>>> comment-end regexps is also a nuisance and a source of errors.
>>>
>>> How do non-treesit modes handle this issue? Why do the treesit-based modes
>>> need something special here?
>>>
>>> Stefan, any ideas?
>>
>> `comment-start` and `comment-end` do not describe the set of possible
>> comment delimiters. They describe the comment delimiters that should be
>> *inserted* when we do things like `comment-dwim`.
>>
>> To find/match comment delimiters we have `comment-start-skip` and
>> `comment-end-skip`. They're not ideal, but they've been good enough so far.
>> They don't say which comment starter matches which comment-ender (that
>> was done by the syntax-tables), but tree-sitter should be able to tell
>> us that when we need it.
>>
>> It would be nice if we could avoid the need to set/use
>> `comment-start-skip` and `comment-end-skip` when using tree-sitter.
>> Maybe we can compute their values from the tree-sitter grammar.
>> But getting rid of uses of those vars will take a fair bit more work,
>> I think.
>
> OK, but do you agree that adding yet another pair of variables,
> treesit-comment-start/end, is the opposite of what we want?
Yes. I removed them in d5dc1dbf7cb.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Mon, 28 Nov 2022 00:25:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 59498 <at> debbugs.gnu.org (full text, mbox):
Yuan Fu <casouri <at> gmail.com> writes:
>> OK, but do you agree that adding yet another pair of variables,
>> treesit-comment-start/end, is the opposite of what we want?
>
> Yes. I removed them in d5dc1dbf7cb.
I also think some documentation updates might be needed:
admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html
191: defined by regular expression <code>treesit-comment-end</code>
192: (see <a href="Tree_002dsitter-major-modes.html">treesit-comment-end</a>).
239: expression <code>treesit-comment-start</code> (see <a
href="Tree_002dsitter-major-modes.html">treesit-comment-start</a>).
This function assumes <var>parent</var> is
248: <code>treesit-comment-start</code>. This function assumes
<var>parent</var> is
doc/lispref/modes.texi
4974: defined by regular expression @code{treesit-comment-end}
4975: (@pxref{Tree-sitter major modes, treesit-comment-end}).
5014: expression @code{treesit-comment-start} (@pxref{Tree-sitter major
5015: modes, treesit-comment-start}). This function assumes @var{parent} is
5023: @code{treesit-comment-start}. This function assumes @var{parent} is
doc/lispref/parsing.texi
1733: @defvar treesit-comment-start
1739: @defvar treesit-comment-end
lisp/treesit.el
1180: Matches if text after point matches `treesit-comment-end'.
1215: Returns the position after a match for `treesit-comment-start'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Mon, 28 Nov 2022 14:00:02 GMT)
Full text and
rfc822 format available.
Message #46 received at 59498 <at> debbugs.gnu.org (full text, mbox):
Yuan Fu <casouri <at> gmail.com> writes:
>> On Nov 26, 2022, at 11:24 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>
>>> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
>>> Cc: Yuan Fu <casouri <at> gmail.com>, dev <at> rjt.dev, aqua0210 <at> foxmail.com,
>>> 59498 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
>>> Date: Sun, 27 Nov 2022 02:18:06 -0500
>>>
>>>>> I added treesit-comment-start/end to help indenting comments. So this is
>>>>> the correct way to use them. The following comment explains why I created
>>>>> new variables:
>>>>>
>>>>> ;; `comment-start' and `comment-end' assume there is only one type of
>>>>> ;; comment, and that the comment spans only one line. So they are not
>>>>> ;; sufficient for our purpose.
>>>>
>>>> ??? This is surprisingly unclean, IMO. For starters, the names of the
>>>> variables are confusing. The need to define two sets of comment-start and
>>>> comment-end regexps is also a nuisance and a source of errors.
>>>>
>>>> How do non-treesit modes handle this issue? Why do the treesit-based modes
>>>> need something special here?
>>>>
>>>> Stefan, any ideas?
>>>
>>> `comment-start` and `comment-end` do not describe the set of possible
>>> comment delimiters. They describe the comment delimiters that should be
>>> *inserted* when we do things like `comment-dwim`.
>>>
>>> To find/match comment delimiters we have `comment-start-skip` and
>>> `comment-end-skip`. They're not ideal, but they've been good enough so far.
>>> They don't say which comment starter matches which comment-ender (that
>>> was done by the syntax-tables), but tree-sitter should be able to tell
>>> us that when we need it.
>>>
>>> It would be nice if we could avoid the need to set/use
>>> `comment-start-skip` and `comment-end-skip` when using tree-sitter.
>>> Maybe we can compute their values from the tree-sitter grammar.
>>> But getting rid of uses of those vars will take a fair bit more work,
>>> I think.
>>
>> OK, but do you agree that adding yet another pair of variables,
>> treesit-comment-start/end, is the opposite of what we want?
>
> Yes. I removed them in d5dc1dbf7cb.
>
Hi Yuan,
I build Emacs with the commit a85ff22300, which contain d5dc1dbf7cb,
I can confirm that the indent issue has been fixed.
Thanks you very much.
--
Eason Huang
bug marked as fixed in version 29.1, send any further explanations to
59498 <at> debbugs.gnu.org and Eason Huang <aqua0210 <at> foxmail.com>
Request was from
Yuan Fu <casouri <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 30 Nov 2022 21:33:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Wed, 30 Nov 2022 21:34:01 GMT)
Full text and
rfc822 format available.
Message #51 received at 59498 <at> debbugs.gnu.org (full text, mbox):
Eason Huang <aqua0210 <at> foxmail.com> writes:
> Yuan Fu <casouri <at> gmail.com> writes:
>
>>> On Nov 26, 2022, at 11:24 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>
>>>> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
>>>> Cc: Yuan Fu <casouri <at> gmail.com>, dev <at> rjt.dev, aqua0210 <at> foxmail.com,
>>>> 59498 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
>>>> Date: Sun, 27 Nov 2022 02:18:06 -0500
>>>>
>>>>>> I added treesit-comment-start/end to help indenting comments. So this is
>>>>>> the correct way to use them. The following comment explains why I created
>>>>>> new variables:
>>>>>>
>>>>>> ;; `comment-start' and `comment-end' assume there is only one type of
>>>>>> ;; comment, and that the comment spans only one line. So they are not
>>>>>> ;; sufficient for our purpose.
>>>>>
>>>>> ??? This is surprisingly unclean, IMO. For starters, the names of the
>>>>> variables are confusing. The need to define two sets of comment-start and
>>>>> comment-end regexps is also a nuisance and a source of errors.
>>>>>
>>>>> How do non-treesit modes handle this issue? Why do the treesit-based modes
>>>>> need something special here?
>>>>>
>>>>> Stefan, any ideas?
>>>>
>>>> `comment-start` and `comment-end` do not describe the set of possible
>>>> comment delimiters. They describe the comment delimiters that should be
>>>> *inserted* when we do things like `comment-dwim`.
>>>>
>>>> To find/match comment delimiters we have `comment-start-skip` and
>>>> `comment-end-skip`. They're not ideal, but they've been good enough so far.
>>>> They don't say which comment starter matches which comment-ender (that
>>>> was done by the syntax-tables), but tree-sitter should be able to tell
>>>> us that when we need it.
>>>>
>>>> It would be nice if we could avoid the need to set/use
>>>> `comment-start-skip` and `comment-end-skip` when using tree-sitter.
>>>> Maybe we can compute their values from the tree-sitter grammar.
>>>> But getting rid of uses of those vars will take a fair bit more work,
>>>> I think.
>>>
>>> OK, but do you agree that adding yet another pair of variables,
>>> treesit-comment-start/end, is the opposite of what we want?
>>
>> Yes. I removed them in d5dc1dbf7cb.
>>
>
>
> Hi Yuan,
>
> I build Emacs with the commit a85ff22300, which contain d5dc1dbf7cb,
> I can confirm that the indent issue has been fixed.
> Thanks you very much.
Thanks for verifying!
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 18 Dec 2022 09:58:02 GMT)
Full text and
rfc822 format available.
Message #54 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Sun, 27 Nov 2022 16:24:07 -0800
> Cc: dev <at> rjt.dev, aqua0210 <at> foxmail.com,
> Stefan Monnier <monnier <at> iro.umontreal.ca>, 59498 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
>
> Yuan Fu <casouri <at> gmail.com> writes:
>
> >> OK, but do you agree that adding yet another pair of variables,
> >> treesit-comment-start/end, is the opposite of what we want?
> >
> > Yes. I removed them in d5dc1dbf7cb.
>
> I also think some documentation updates might be needed:
>
> admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html
> 191: defined by regular expression <code>treesit-comment-end</code>
> 192: (see <a href="Tree_002dsitter-major-modes.html">treesit-comment-end</a>).
> 239: expression <code>treesit-comment-start</code> (see <a
> href="Tree_002dsitter-major-modes.html">treesit-comment-start</a>).
> This function assumes <var>parent</var> is
> 248: <code>treesit-comment-start</code>. This function assumes
> <var>parent</var> is
>
> doc/lispref/modes.texi
> 4974: defined by regular expression @code{treesit-comment-end}
> 4975: (@pxref{Tree-sitter major modes, treesit-comment-end}).
> 5014: expression @code{treesit-comment-start} (@pxref{Tree-sitter major
> 5015: modes, treesit-comment-start}). This function assumes @var{parent} is
> 5023: @code{treesit-comment-start}. This function assumes @var{parent} is
>
> doc/lispref/parsing.texi
> 1733: @defvar treesit-comment-start
> 1739: @defvar treesit-comment-end
>
> lisp/treesit.el
> 1180: Matches if text after point matches `treesit-comment-end'.
> 1215: Returns the position after a match for `treesit-comment-start'.
Yuan, would you please update the above places to remove references to
these two variables that no longer exist?
TIA
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Sun, 18 Dec 2022 22:50:02 GMT)
Full text and
rfc822 format available.
Message #57 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> On Dec 18, 2022, at 1:57 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> From: Stefan Kangas <stefankangas <at> gmail.com>
>> Date: Sun, 27 Nov 2022 16:24:07 -0800
>> Cc: dev <at> rjt.dev, aqua0210 <at> foxmail.com,
>> Stefan Monnier <monnier <at> iro.umontreal.ca>, 59498 <at> debbugs.gnu.org, mardani29 <at> yahoo.es
>>
>> Yuan Fu <casouri <at> gmail.com> writes:
>>
>>>> OK, but do you agree that adding yet another pair of variables,
>>>> treesit-comment-start/end, is the opposite of what we want?
>>>
>>> Yes. I removed them in d5dc1dbf7cb.
>>
>> I also think some documentation updates might be needed:
>>
>> admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html
>> 191: defined by regular expression <code>treesit-comment-end</code>
>> 192: (see <a href="Tree_002dsitter-major-modes.html">treesit-comment-end</a>).
>> 239: expression <code>treesit-comment-start</code> (see <a
>> href="Tree_002dsitter-major-modes.html">treesit-comment-start</a>).
>> This function assumes <var>parent</var> is
>> 248: <code>treesit-comment-start</code>. This function assumes
>> <var>parent</var> is
>>
>> doc/lispref/modes.texi
>> 4974: defined by regular expression @code{treesit-comment-end}
>> 4975: (@pxref{Tree-sitter major modes, treesit-comment-end}).
>> 5014: expression @code{treesit-comment-start} (@pxref{Tree-sitter major
>> 5015: modes, treesit-comment-start}). This function assumes @var{parent} is
>> 5023: @code{treesit-comment-start}. This function assumes @var{parent} is
>>
>> doc/lispref/parsing.texi
>> 1733: @defvar treesit-comment-start
>> 1739: @defvar treesit-comment-end
>>
>> lisp/treesit.el
>> 1180: Matches if text after point matches `treesit-comment-end'.
>> 1215: Returns the position after a match for `treesit-comment-start'.
>
> Yuan, would you please update the above places to remove references to
> these two variables that no longer exist?
>
> TIA
Ah, yes, sorry. I made the change.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Mon, 19 Dec 2022 13:52:02 GMT)
Full text and
rfc822 format available.
Message #60 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Sun, 18 Dec 2022 14:49:12 -0800
> Cc: Randy Taylor <dev <at> rjt.dev>,
> aqua0210 <at> foxmail.com,
> Stefan Monnier <monnier <at> iro.umontreal.ca>,
> 59498 <at> debbugs.gnu.org,
> Daniel Martín <mardani29 <at> yahoo.es>,
> Stefan Kangas <stefankangas <at> gmail.com>
>
> > Yuan, would you please update the above places to remove references to
> > these two variables that no longer exist?
> >
> > TIA
>
> Ah, yes, sorry. I made the change.
Thanks. This part seems like an incomplete sentence:
+\(n-p-gp NODE-TYPE PARENT-TYPE GRANDPARENT-TYPE)
+
+ Checks that NODE, its parent, and its grandparent's type.
Check that what?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Tue, 20 Dec 2022 01:57:02 GMT)
Full text and
rfc822 format available.
Message #63 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> On Dec 19, 2022, at 5:51 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Sun, 18 Dec 2022 14:49:12 -0800
>> Cc: Randy Taylor <dev <at> rjt.dev>,
>> aqua0210 <at> foxmail.com,
>> Stefan Monnier <monnier <at> iro.umontreal.ca>,
>> 59498 <at> debbugs.gnu.org,
>> Daniel Martín <mardani29 <at> yahoo.es>,
>> Stefan Kangas <stefankangas <at> gmail.com>
>>
>>> Yuan, would you please update the above places to remove references to
>>> these two variables that no longer exist?
>>>
>>> TIA
>>
>> Ah, yes, sorry. I made the change.
>
> Thanks. This part seems like an incomplete sentence:
>
> +\(n-p-gp NODE-TYPE PARENT-TYPE GRANDPARENT-TYPE)
> +
> + Checks that NODE, its parent, and its grandparent's type.
>
> Check that what?
I fixed that, the change will be pushed later with other changes.
Yuan [who can’t write errorless sentences with less than 10 reviews]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Tue, 20 Dec 2022 15:19:02 GMT)
Full text and
rfc822 format available.
Message #66 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Mon, 19 Dec 2022 17:56:17 -0800
> Cc: Randy Taylor <dev <at> rjt.dev>,
> aqua0210 <at> foxmail.com,
> monnier <at> iro.umontreal.ca,
> 59498 <at> debbugs.gnu.org,
> mardani29 <at> yahoo.es,
> stefankangas <at> gmail.com
>
> > +\(n-p-gp NODE-TYPE PARENT-TYPE GRANDPARENT-TYPE)
> > +
> > + Checks that NODE, its parent, and its grandparent's type.
> >
> > Check that what?
>
> I fixed that, the change will be pushed later with other changes.
>
> Yuan [who can’t write errorless sentences with less than 10 reviews]
Thanks. And you have absolutely nothing to be ashamed of. It is a
known fact that finding such blunders in text written by someone else
is much easier than in text written by yourself.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59498
; Package
emacs
.
(Wed, 21 Dec 2022 00:38:01 GMT)
Full text and
rfc822 format available.
Message #69 received at 59498 <at> debbugs.gnu.org (full text, mbox):
> On Dec 20, 2022, at 7:18 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Mon, 19 Dec 2022 17:56:17 -0800
>> Cc: Randy Taylor <dev <at> rjt.dev>,
>> aqua0210 <at> foxmail.com,
>> monnier <at> iro.umontreal.ca,
>> 59498 <at> debbugs.gnu.org,
>> mardani29 <at> yahoo.es,
>> stefankangas <at> gmail.com
>>
>>> +\(n-p-gp NODE-TYPE PARENT-TYPE GRANDPARENT-TYPE)
>>> +
>>> + Checks that NODE, its parent, and its grandparent's type.
>>>
>>> Check that what?
>>
>> I fixed that, the change will be pushed later with other changes.
>>
>> Yuan [who can’t write errorless sentences with less than 10 reviews]
>
> Thanks. And you have absolutely nothing to be ashamed of. It is a
> known fact that finding such blunders in text written by someone else
> is much easier than in text written by yourself.
Thanks, I feel better now :-) I’ll strive to blunder as little as possible :-)
Yuan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 18 Jan 2023 12:24:11 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 177 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.