From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#67036: 30.0.50; treesit-forward-sexp not working properly in ruby-ts-mode Date: Sun, 14 Apr 2024 19:25:11 +0300 Organization: LINKOV.NET Message-ID: <864jc3ap3s.fsf@mail.linkov.net> References: <86bkc2nktq.fsf@mail.linkov.net> <83a5r2dw25.fsf@gnu.org> <45795de5-2064-3ab9-3cbb-c1b2018faf7c@gutov.dev> <864jh776bm.fsf@mail.linkov.net> <5a8d4404-47ec-9190-d80f-edc1fca26cf3@gutov.dev> <86msuxulvt.fsf@mail.linkov.net> <867cllrln9.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34819"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 67036@debbugs.gnu.org, Yuan Fu To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 14 18:29:15 2024 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 1rw2jD-0008uW-9i for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Apr 2024 18:29:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rw2is-0005ha-36; Sun, 14 Apr 2024 12:28:54 -0400 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 1rw2iq-0005hB-Lr for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 12:28:52 -0400 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 1rw2iq-00076c-E1 for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 12:28:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rw2j0-0000mw-GE for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 12:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Apr 2024 16:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67036 X-GNU-PR-Package: emacs Original-Received: via spool by 67036-submit@debbugs.gnu.org id=B67036.17131120832457 (code B ref 67036); Sun, 14 Apr 2024 16:29:02 +0000 Original-Received: (at 67036) by debbugs.gnu.org; 14 Apr 2024 16:28:03 +0000 Original-Received: from localhost ([127.0.0.1]:36048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rw2i1-0000d8-EC for submit@debbugs.gnu.org; Sun, 14 Apr 2024 12:28:03 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:34525) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rw2hz-0000bu-Oo for 67036@debbugs.gnu.org; Sun, 14 Apr 2024 12:28:00 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 1F1D5E0004; Sun, 14 Apr 2024 16:27:40 +0000 (UTC) In-Reply-To: <867cllrln9.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 11 Dec 2023 19:09:54 +0200") X-GND-Sasl: juri@linkov.net 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:283296 Archived-At: --=-=-= Content-Type: text/plain >>>>>>>> +# C-M-f on '[' doesn't jump to after ']' >>>>>>>> +hash['key'] >>>>>>>> + >>>>>> >>>>>> As discussed previously, there is no specific node which spans from [ to >>>>>> ]. Some custom code could probably be written (there *are* leaf nodes for [ >>>>>> and ]), but the current capabilities of treesit-thing-settings don't offer >>>>>> a good way to plug that in. >>>>> Like for point inside strings, this might require more general changes >>>>> that take into account syntax tables. >>>> >>>> Possibly, but I expect a solution that doesn't use the syntax table would >>>> be tried first. >>> Since there is no available information from treesit, handling >>> treesit-forward-sexp inside strings/comments could forward to the syntax table >>> like `prog-fill-reindent-defun' forwards to `fill-paragraph'. > > Shouldn't treesit-forward-sexp provide a way for ts-modes to override > the default handling? By default for all ts-modes such a hook could > check if point is inside strings/comments then to use syntax navigation. This is now implemented in bug#68993. So here is the patch that handles such cases as C-M-f jumping from '[' to ']' in hash[:key] hash['key'] and from '{' to '}' in "abc #{ghi} def" --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=ruby-ts-mode-text.patch diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 7133cb0b5b0..098cca2cb56 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1171,7 +1171,20 @@ ruby-ts-mode "global_variable" ) eol) - #'ruby-ts--sexp-p))))) + #'ruby-ts--sexp-p)) + (text ,(lambda (node) + (or (member (treesit-node-type node) + '("comment" "string_content")) + (and (member (treesit-node-text node) + '("[" "]")) + (equal (treesit-node-type + (treesit-node-parent node)) + "element_reference")) + (and (member (treesit-node-text node) + '("#{" "}")) + (equal (treesit-node-type + (treesit-node-parent node)) + "interpolation")))))))) ;; AFAIK, Ruby can not nest methods (setq-local treesit-defun-prefer-top-level nil) --=-=-=--