emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove js--treesit-backward-up-list or fix it


From: Theodor Thornhill
Subject: Re: Remove js--treesit-backward-up-list or fix it
Date: Sat, 29 Oct 2022 20:31:32 +0200

(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 ;-)

>> 
>> 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 ;-)

-- 
Theo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]