From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Plug treesit.el into other emacs constructs Date: Thu, 15 Dec 2022 09:09:38 +0200 Message-ID: <83wn6tkurx.fsf@gnu.org> References: <87wn6whete.fsf@thornhill.no> <87r0x3gnv5.fsf@thornhill.no> <04BB786A-3ED1-4918-8583-17AA01A1E453@gmail.com> <4E3940CA-67A6-45B7-8785-4E60FDECCDFB@gmail.com> <0CA63C32-432C-42C5-BBAD-C6E1A7CE1806@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2525"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, theo@thornhill.no, emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 15 08:12:19 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 1p5iPi-0000RQ-Td for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Dec 2022 08:12:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5iNC-0007T0-Fh; Thu, 15 Dec 2022 02:09:42 -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 1p5iNB-0007Sc-Dw for emacs-devel@gnu.org; Thu, 15 Dec 2022 02:09:41 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5iNA-00082m-Ey; Thu, 15 Dec 2022 02:09:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=WoAt+P2jvqvdaNZyCIB2/Qj6TT/ABiyVpIgssmiy7Ss=; b=EOLLbTC8TQpRVv/1cfS7 FArd95PRVdCy6ybSda9RwK5rAJb+exsQVrs4h60L3e5RxRKn++D+9K3xyEig1Zqe+iNga7jMdmh86 Uv1zu9wzBO9A5lnfcLJThG1PZkEPlaa1yOMFtjsDmMJ6zMXji3xZV3ziQMrBN4kBNcrNwYbBFAwG0 bn7LM2g1RrnewJL8tgJFrqO8pjvDZApraB+qOWmJeXRPBy7fSUh1Tc/rTkg9omvJB1aJPtZDbCHOy h1QNkdK7WkrtnqVXNwajw4Lsh/EEhzApKqtyjPCc/FS6ze5LHs7IbnW8LS6GhLnz3OnUCvOmNp0L4 oPONMNe8D0/vZg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5iN9-0005GO-F8; Thu, 15 Dec 2022 02:09:39 -0500 In-Reply-To: (message from Yuan Fu on Wed, 14 Dec 2022 16:05:10 -0800) 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:301441 Archived-At: > From: Yuan Fu > Date: Wed, 14 Dec 2022 16:05:10 -0800 > Cc: Theodor Thornhill , > emacs-devel , > eliz@gnu.org > > > I see, so maybe sexp means the general, flexible AST entity. And thinking of it, my idea is just forward-list :-) And we definitely should include forward-list into the list of navigation commands we want to support, among the ones that are already brought up. > > Ok, upon closer inspection, forward-list isn’t exactly what I’m thinking about, it moves over lists, but I’m thinking about moving over elements of a list. > > If you think about it, there are two kinds of constructs in an AST/grammar: those are repeatable, and those are not. Statements are repeatable, you can stack multiple ones together and it still makes sense. Identifiers are not repeatable, put two together doesn’t make sense (in most languages). > > And these repeatable constructs appears at every level of the AST, from top-level stuff like function definition, to statements, to small stuff like arguments in an argument list. That makes them very good unit of navigation. > > Navigation commands, IMO, needs to be extremely easy to predict and requires no thinking. That’s the reason why avy never grow on me: yes you can move to anywhere you want, but it takes so much cognitive load to use. Much better to type a few C-n, C-M-f, etc to get their, because I don’t need to think about it. FWIW, for me, "sexp" in its C/C++ interpretation always means "expression". So in foobar (a, b + c, 2 * d - f / 10 + pow (g, x), y); C-M-f should move to the next comma on the top level (i.e. the comma inside the 'pow' call doesn't count), and C-M-f inside the 'pow' call should move by commas on that level. More generally, C-M-f should move to the next expression _on_the_same_level_, without entering inner levels. Exactly like we do in Lisp.