[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 23:56:17 +0100 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> +(defvar-local transpose-sexps-function nil
>> + "If non-nil, `transpose-sexps' delegates to this function.
>> +
>> +The return value of this function is expected to be a cons of two
>> +conses, denoting the positions in the current buffer to be
>> +transposed. If no such pair of positions is available, signal
>> +USER-ERROR.")
>
> This docstring needs to tell what args are passed to the function.
>
> I see you make it return a pair of pairs, so it has to handle all the
> semantics of `transpose-sexps`. My intuition told me to go with
> a function that returns a pair of positions (i.e. it takes an ARG and
> returns the BEG..END of the ARGth sibling). I suspect it would fit
> within `transpose-subr` a bit better.
>
Yeah, I could do that. It may be simpler than to try to surgically add
another behavior inside that function.
>> + (if transpose-sexps-function transpose-sexps-function
>> + (lambda (arg)
>
> Aka (or transpose-sexps-function (lambda (arg) ...))
> But even better is to put the `lambda` in the default value of the
> variable, so you just use `transpose-sexps-function` unconditionally.
>
Yeah, I actually did that in an experiment earlier, but decided against
it in favor of smaller changes. I'll make that change now, though.
>> + (let* ((aux (if special mover
>> + (lambda (x)
>> + (cons (progn (funcall mover x) (point))
>> + (progn (funcall mover (- x)) (point))))))
>
> If `mover` is changed to return a pair of positions, than the above can
> just be:
>
>> + (let* ((aux (if special mover
>> + (lambda (x)
>> + (cons (progn (funcall mover x) (point))
>> + (progn (funcall mover (- x)) (point))))))
>
>
I'll try to make it work without changing the protocol. I'll add the
patch to the bugreport, and let's continue this particular discussion
there? :-)
Theo
- Re: Plug treesit.el into other emacs constructs, (continued)
- 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, 2022/12/26
- 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 <=
- 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
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Eli Zaretskii, 2022/12/15
- 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/14
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 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/13