From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: Plug treesit.el into other emacs constructs Date: Mon, 26 Dec 2022 23:56:17 +0100 Message-ID: <87tu1hg4fi.fsf@thornhill.no> References: <87wn6whete.fsf@thornhill.no> <4E3940CA-67A6-45B7-8785-4E60FDECCDFB@gmail.com> <4315EFC6-7AA8-4A48-845C-9CA8B88034D9@thornhill.no> <87bko521n0.fsf@thornhill.no> <87359h1ybt.fsf@thornhill.no> <871qp01msi.fsf@thornhill.no> <87v8mczb6b.fsf@thornhill.no> <87sfhgz9s8.fsf@thornhill.no> <87pmckz8p0.fsf@thornhill.no> <5DF07C4E-2CCD-4561-AFFB-D5D81D67BFE0@thornhill.no> <87o7rq7zf2.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39454"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , emacs-devel@gnu.org, eliz@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 26 23:56:52 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p9wOp-000A3R-Oq for ged-emacs-devel@m.gmane-mx.org; Mon, 26 Dec 2022 23:56:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9wOP-0004Qe-9J; Mon, 26 Dec 2022 17:56:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9wON-0004QL-OY for emacs-devel@gnu.org; Mon, 26 Dec 2022 17:56:23 -0500 Original-Received: from out-149.mta0.migadu.com ([91.218.175.149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9wOK-0002bH-Lj for emacs-devel@gnu.org; Mon, 26 Dec 2022 17:56:23 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1672095378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZKoZcj7XBUAXMFwJGA97Z/i/xH+AU8NoN5QrmjP7e58=; b=qu3pceSzahvUF0p2bdI1eEmfniHMC1DgOfmrMgqd0xml1ptK9HiPwi0stdWEllrAU+rw7f MrEljli0JpBrnUTw2tyPqFdmc4bKRBk9ZljxMrqzmubftC5h+P2kKa216I7CFMWOyFpszo I7zGYtb4WrWEp4vSkb81LEXBs7iGwTOot6aVoa/jDnj5XA7hSXNuoeaL2GTIhPFpxw3afl GUO7Yxrl/NhpYo8rl5Eajv7lnHLofgYqTXn2nyhWEH0mUf+5GYRMQyhFI6HIq8VbdUHGCB tMSfWTuHfEbmgChsMy35GbS7Jq4LFohuFnjY6xvY+8i3+0RTK4kS+tyko/hfzg== In-Reply-To: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.149; envelope-from=theo@thornhill.no; helo=out-149.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301946 Archived-At: Stefan Monnier 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