emacs-devel
[Top][All Lists]
Advanced

[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



reply via email to

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