From: Yuan Fu <casouri@gmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: emacs-devel@gnu.org
Subject: Re: Remove js--treesit-backward-up-list or fix it
Date: Sat, 29 Oct 2022 12:07:19 -0700 [thread overview]
Message-ID: <092C50FE-FCA3-43A2-B296-A3D61C88F2E3@gmail.com> (raw)
In-Reply-To: <87h6zmscqj.fsf@thornhill.no>
> On Oct 29, 2022, at 11:31 AM, Theodor Thornhill <theo@thornhill.no> wrote:
>
>
> (added back in emacs-devel)
>
> Hi!
>
>>>
>>> ```
>>> const fooClient = new Foo(() => ({
>>> | // <---- point is there
>>> }));
>>> ```
>>> Which is not what we want. If we can keep that correct behavior in any
>>> case I say we remove the hack. We could make an anchor helper named
>>> something like 'parent-then-bol', but because there is no node here, we
>>> cannot find the parent.
>>>
>>> What do you think?
>
>>
>> I added a rule that fixes it. Actually, when there is no node at
>> point, parent is set to the smaller node that spans point, kind of
>> like the immediate “parent” of that point. I’ve added some explanation
>> in the manual.
>>
>
> Yes, It's probably a remnant from when the semantics were a bit
> different between the treesit-node-on and treesit-node-at. I see it was
> never there in ts-mode ;-)
That was actually deliberate semantic (which I forgot to document), I broke it when introducing the new semantic for treesit-node-at...
>
>>>
>>> However, there are some problems with the newest revisions. During
>>> })
>>> .catch((r) => {
>>> if (r.status < 200 || r.status >= 300) {
>>> console.log(r);
>>> }
>>> });
>>> };
>>> ```
>>
>> Yes, sorry. I was naive with my implementation. Now it should be fixed.
>>
>
> Absolutely! Great work!
>
> However... Try creating a js-mode buffer and type:
>
> ```
> const foo = foo(() => {});
> ```
>
> Because of all the stuff we set before we init tree sitter we get a
> super unwanted behavior of the cursor jumping back to indentation for
> every () {} etc. This is because of these settings, which are IMO pretty
> bad defaults:
> ```
> (setq-local electric-indent-chars
> (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*".
> (setq-local electric-layout-rules
> '((?\; . after) (?\{ . after) (?\} . before)))
> ```
>
> This could just be something forgotten in the indent implementation, but
> in my book this is yet another example for why we shouldn't init like
> this ;-)
I don’t have anything intelligent to say about the init process (except that we definitely need a way for js2-mode to turn off tree-sitter setup made by js-mode even if it is enabled by the user), but I fixed the indent problem you observed :-)
Yuan
next prev parent reply other threads:[~2022-10-29 19:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8B978AF7-B1CA-4C8A-9E89-84D0DEC7884C@gmail.com>
[not found] ` <87h6znxkr0.fsf@thornhill.no>
[not found] ` <0849BE6B-B5B4-47E0-B4EA-F93F6947C2B7@gmail.com>
2022-10-29 18:31 ` Remove js--treesit-backward-up-list or fix it Theodor Thornhill via Emacs development discussions.
2022-10-29 19:07 ` Yuan Fu [this message]
2022-10-29 19:31 ` Theodor Thornhill via Emacs development discussions.
2022-10-29 20:08 ` Yuan Fu
2022-10-29 20:12 ` Theodor Thornhill via Emacs development discussions.
2022-10-29 19:20 ` Stefan Monnier
2022-10-29 19:30 ` Theodor Thornhill via Emacs development discussions.
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=092C50FE-FCA3-43A2-B296-A3D61C88F2E3@gmail.com \
--to=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=theo@thornhill.no \
/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).