From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes Date: Mon, 06 Jan 2025 09:14:58 -0500 Message-ID: References: <87plox4mtp.fsf@masteringemacs.org> <877cay1lqt.fsf@masteringemacs.org> <86frpma06f.fsf@gnu.org> <86ikueiekp.fsf@mail.linkov.net> <86ed4zg1cc.fsf@mail.linkov.net> <87zflac68t.fsf@mail.linkov.net> <87jzcdlxdp.fsf@mail.linkov.net> <87o71jocgs.fsf@mail.linkov.net> <87wmfwqg7e.fsf@mail.linkov.net> <8734i5fyv1.fsf@mail.linkov.net> <875xmumpzv.fsf@mail.linkov.net> <86ikqubdsd.fsf@gnu.org> <87wmf9912l.fsf@mail.linkov.net> <87a5c5v5z8.fsf@thornhill.no> <877c79qhcs.fsf@mail.linkov.net> <87sepxt4yl.fsf@thornhill.no> <87o70k9y2e.fsf@mail.linkov.net> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35454"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: mickey@masteringemacs.org, Eli Zaretskii , Theodor Thornhill , casouri@gmail.com, 73404@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 06 15:16:31 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1tUnuA-00092E-IC for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Jan 2025 15:16:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUnto-0005Ac-Pt; Mon, 06 Jan 2025 09:16:08 -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 1tUnti-00059S-I3 for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 09:16:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUnth-00088d-Uv for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 09:16:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=hqaRWWtnB4Mkt4sCqGecDViAaBfxm+VqcCLelS3dIvk=; b=dPvwJKyOQCYLwoTWhV+xQ0Kq5BLgtM/wqIQZgU3sOj5fonBht0P9sRXalydmgZQgCkhqp6axK1Z9U1LVTZDwI4sYgBbClJukR8o7lr5nLTwl8qm8Gdb0+JeufOw4VBuwxNHULsKeEoii6upZwVdSY/7FqMe+TXLyX7d7Wft6sK0q1i9u+TrIK/IY5Dy/YQapT8LQx7Q+gg3OzXSNxA4xtn16Tm4DQZQeGlaIWt9WbHx2ePrkGuCD+U5drDGf354REa9UZIWqRezuoxKS4LgCl0l/ulefh7Yh8CurHYbbFRYltnICbxUDMZBRWWZyTZ2gBTvhQC5N93auFx1zyRgN+g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUnth-0006aF-Nx for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 09:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Jan 2025 14:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73404 X-GNU-PR-Package: emacs Original-Received: via spool by 73404-submit@debbugs.gnu.org id=B73404.173617291224959 (code B ref 73404); Mon, 06 Jan 2025 14:16:01 +0000 Original-Received: (at 73404) by debbugs.gnu.org; 6 Jan 2025 14:15:12 +0000 Original-Received: from localhost ([127.0.0.1]:37417 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUnsu-0006U4-09 for submit@debbugs.gnu.org; Mon, 06 Jan 2025 09:15:12 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:24808) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUnsr-0006Sd-Qc for 73404@debbugs.gnu.org; Mon, 06 Jan 2025 09:15:10 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AC7071000EF; Mon, 6 Jan 2025 09:15:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1736172902; bh=/c2zCZ92ZIV44/zElbFY+XgWtx3FQGy57i9TLy9FyTw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gR2X+SliHn6atJYouQAo2+FOjBYW3vW5K2qkWUhvPDR1fHOt89UCTxvtLpVjeaj6t FJoNqZAliSqYTymH2Z0QxtnVLFIHk64j/EENz+BEtAmt9rtCzhdRMl2mlSQOM1N7mz zJPwNmODmudWS9z4zR2yQW9C6RLfIzy03SpQ+wIQ8yEMLf6g5xKrjjL7cqDYrS1XDV cV2Lu7vqZi0gwpapxGrfLlzZUEcprT5nanDfjAbcFPnzmY4js4AqpgeGCcYxEi1zIO 5MpFYIpMhAp+jWAqjfsS0+vTNyHUKdvI/X0K8ZrHko1tK5z0Uw8CqRLXikn4+6LCzY VTf/3YJ/27PDg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id F13FB100042; Mon, 6 Jan 2025 09:15:01 -0500 (EST) Original-Received: from pastel (69-165-162-104.dsl.teksavvy.com [69.165.162.104]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B741D120511; Mon, 6 Jan 2025 09:15:01 -0500 (EST) In-Reply-To: <87o70k9y2e.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 06 Jan 2025 09:54:49 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298663 Archived-At: >> However, deciding on what makes sense is hard, which is why I'm >> suggesting we try to define a "spec". It needn't really be much more >> than reference suggestions for mode implementors at first, then maybe >> some intersection of features crystallize across all modes. > > I don't think it's possible to find a spec better than Stefan already > defined as an AST node delimited by an opening and a closing "keyword": > (...), [...], if...fi, begin...end, ... IIUC, Theodor was talking more generally than just about "list" operations. I think "list" operations are among the clearest case (BTW, I wonder if someone has already tried to implement that functionality for Haskell or Python, where the opening and a closing "keywords" are basically newlines). > Or when looking at the commands with the 'forward-' prefix: > > forward-sexp (C-M-f) > forward-list (C-M-n) OK, we already talked about these two. We could probably start drafting a kind of guideline. > forward-symbol This one doesn't look too hard either. > forward-sentence (M-e) This one is trickier. You just provided a reasonably good start with "In languages with statements a sentence corresponds to a statement", but there are some non-trivial questions about language without statements, about use within comments, about how to handle nesting (e.g. statements within statements) and more generally the use of `M-e` from outside of statements. > forward-paragraph (M-}) This one is also tied to filling, so it's important for it to behave well w.r.t to comments to allow filling actual text paragraphs within comments. As for its behavior outside of comments ... > forward-page (C-x ]) > forward-word (M-f) I think these should be oblivious to the syntax (i.e. line `forward-line` and `forward-char`). Your list missed the "defun" unit of navigation. One other potentially useful unit of navigation that depends on the syntax would be "list element", which would do something like skip to the next/previous separator delimiting elements of the nearest enclosing paired delimiters. For {...;...;...} blocks, this would behave like `forward-sentence`, except that when used from within the args of a function call like a `foo (..., ..., ...)`, it would jump between arguments instead of skipping all the way to the next statement. Stefan