[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Plug treesit.el into other emacs constructs
From: |
Theodor Thornhill |
Subject: |
Re: Plug treesit.el into other emacs constructs |
Date: |
Mon, 26 Dec 2022 20:11:45 +0100 |
uld we use a `transpose-sexp-function` variable, which `treesit` can
>>then set, so `simple.el` doesn't need to know about `treesit` at all?
>>
>
> Yes absolutely! I'll make that change. It makes sense, because we need not
> really rely on forward-foo anyways:)
>
>>> (defun transpose-lines (arg)
>>> @@ -8521,6 +8524,9 @@ transpose-subr
>>> (progn (funcall mover (- x)) (point))))))
>>> pos1 pos2)
>>> (cond
>>> + ((treesit-parser-list)
>>> + (cl-multiple-value-bind (p1 p2) (funcall aux arg)
>>> + (transpose-subr-1 p1 p2)))
>>> ((= arg 0)
>>> (save-excursion
>>> (setq pos1 (funcall aux 1))
>>
>>Please use `pcase-let` instead of `cl-multiple-value-bind` (especially
>>since you use it to decompose something built with `list` rather than
>>with `cl-values`).
>>
>>Also to avid re-testing `treesit-parser-list`, I'd recommend you extend
>>the semantics of `mover` so it can either return a position (the old
>>protocol) or directly return a pair of positions. You could even add
>>a 3rd kind of return value to explicitly trigger the error message
>>instead of relying on the (cons 0 1) hack.
>>
>>
>> Stefan
>>
>
> Yeah! I believe this either wasn't the latest patch, or i forgot to
> send it. I'll see what lies around my system and wrap things up.
What do you think about something like this?
It feels a little iffy how to handle the separate return values, but it
works. I'd be super happy for some feedback on how to best solve that,
though :)
Also, I made the treesit-transpose-sexps a little better imo, in that we
only find named nodes to swap, but use every available node for the
entry. We rarely, if ever want to swap the unnamed nodes.
Theo
0001-Add-treesit-transpose-sexps-bug-60128.patch
Description: Text Data
- Re: Plug treesit.el into other emacs constructs, (continued)
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Eli Zaretskii, 2022/12/24
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/24
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/24
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/24
- Re: Plug treesit.el into other emacs constructs,
Theodor Thornhill <=
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/26
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/26
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/27
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/27
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/28
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/28
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/28
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/26
- Re: Plug treesit.el into other emacs constructs, Lynn Winebarger, 2022/12/27
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/14