From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 02 03:54:07 2025 Received: (at submit) by debbugs.gnu.org; 2 Mar 2025 08:54:07 +0000 Received: from localhost ([127.0.0.1]:52954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tof5J-0002rq-Lu for submit@debbugs.gnu.org; Sun, 02 Mar 2025 03:54:06 -0500 Received: from lists.gnu.org ([2001:470:142::17]:48304) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tof5F-0002qU-JN for submit@debbugs.gnu.org; Sun, 02 Mar 2025 03:54:03 -0500 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 1tof59-0006ox-VZ for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2025 03:53:56 -0500 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 1tof59-00013a-Mz for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2025 03:53:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Subject:To:From:Date:mime-version:in-reply-to: references; bh=YwUd/0B1m7a4iodb8TFCY0fwziNMTpX7f3lgOpcJa1g=; b=QJJZ9ItrcVoKE2 AsxfQdnQCh+r85adyej+aTFnbjm0WCKbgkeOw9TCC+uMB48OOZvC37enJsfNDImAR9u3rfcTC0OVm t0PBhWSWClky7YSfN4QA4mnAyvjcXnoYvFD4JRuBx79HRL27RaqFSI5/T5v7gJB85MwDcN/zg1Lq7 qu1jJ+Pj55l/yWj23yQ2rpuJUqnM/u4FMnyOHnuiaNrJf7v4uQNYPUZx9NTaofSw3hr48Ei88VuU2 Ks+UyZKA7b6k+Ts19ZT5YbPSccquqX14rN+At1w7qd5BuxKni/ntj1KMGQZFihudYNUCpW1VMfi+E 6g1ievvXC4GmiFaJNeAg==; Date: Sun, 02 Mar 2025 10:53:52 +0200 Message-Id: <86bjujolsv.fsf@gnu.org> From: Eli Zaretskii To: bug-gnu-emacs@gnu.org Subject: 30.1.50; C-M-b in c-ts-mode moves too far X-Debbugs-Cc: Yuan Fu X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) To reproduce: emacs -Q C-x C-f src/xdisp.c C-u 20722 M-g g If xdisp.c is from the master branch, that should place you on the closing brace at the end of the following fragment (else modify the line number accordingly or just move point to that brace): /* Try to scroll by specified few lines. */ if ((0 < scroll_conservatively /* FIXME: the option is supposed to affect minibuffers, but we test MINI_WINDOW_P, which can also catch uses of mini-windows for displaying the echo area. Do we need to distinguish these two use cases? */ || (scroll_minibuffer_conservatively && MINI_WINDOW_P (w)) || 0 < emacs_scroll_step || temp_scroll_step || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)) || NUMBERP (BVAR (current_buffer, scroll_down_aggressively))) && CHARPOS (startp) >= BEGV && CHARPOS (startp) <= ZV) { /* The function returns -1 if new fonts were loaded, 1 if successful, 0 if not successful. */ int ss = try_scrolling (window, just_this_one_p, ((scroll_minibuffer_conservatively && MINI_WINDOW_P (w)) ? SCROLL_LIMIT + 1 : scroll_conservatively), emacs_scroll_step, temp_scroll_step, last_line_misfit); switch (ss) { case SCROLLING_SUCCESS: goto done; case SCROLLING_NEED_LARGER_MATRICES: goto need_larger_matrices; case SCROLLING_FAILED: break; default: emacs_abort (); } } Now type C-M-b. The expected result is that point moves to the corresponding opening brace, as shown below: /* Try to scroll by specified few lines. */ if ((0 < scroll_conservatively /* FIXME: the option is supposed to affect minibuffers, but we test MINI_WINDOW_P, which can also catch uses of mini-windows for displaying the echo area. Do we need to distinguish these two use cases? */ || (scroll_minibuffer_conservatively && MINI_WINDOW_P (w)) || 0 < emacs_scroll_step || temp_scroll_step || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)) || NUMBERP (BVAR (current_buffer, scroll_down_aggressively))) && CHARPOS (startp) >= BEGV && CHARPOS (startp) <= ZV) { <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /* The function returns -1 if new fonts were loaded, 1 if successful, 0 if not successful. */ But in fact, point moves to the first character of 'if' before that: if ((0 < scroll_conservatively Let me know if I can supply more information. In GNU Emacs 30.1.50 (build 9, i686-pc-mingw32) of 2025-03-01 built on ELIZ-PC Repository revision: 3998dea566aee807922e6edf8d1b20f3da89b4fc Repository branch: emacs-30 Windowing system distributor 'Microsoft Corp.', version 10.0.26100 System Description: Microsoft Windows 10 Enterprise (v10.0.2009.26100.3194) Configured using: 'configure -C --prefix=/d/usr --with-wide-int --enable-checking=yes,glyphs --without-native-compilation 'CFLAGS=-O0 -gdwarf-4 -g3'' Configured features: ACL GIF GMP GNUTLS HARFBUZZ JPEG LCMS2 LIBXML2 MODULES NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB Important settings: value of $LANG: ENU locale-coding-system: cp1252 Major mode: C/* Minor modes in effect: bug-reference-prog-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq c++-ts-mode c-ts-mode c-ts-common treesit vc-git diff-mode track-changes easy-mmode vc vc-dispatcher bug-reference byte-opt gv bytecomp byte-compile thingatpt cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel touch-screen dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty move-toolbar make-network-process emacs) Memory information: ((conses 16 92841 16422) (symbols 48 10144 0) (strings 16 28304 2881) (string-bytes 1 808502) (vectors 16 15855) (vector-slots 8 166559 10406) (floats 8 29 64) (intervals 40 3862 76) (buffers 896 11)) From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 02:44:50 2025 Received: (at 76676) by debbugs.gnu.org; 3 Mar 2025 07:44:50 +0000 Received: from localhost ([127.0.0.1]:44027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tp0Tq-0007nS-HL for submit@debbugs.gnu.org; Mon, 03 Mar 2025 02:44:50 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:36917) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tp0Tn-0007mt-Ge for 76676@debbugs.gnu.org; Mon, 03 Mar 2025 02:44:48 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 05B9B44320; Mon, 3 Mar 2025 07:44:35 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far In-Reply-To: <86bjujolsv.fsf@gnu.org> Organization: LINKOV.NET References: <86bjujolsv.fsf@gnu.org> Date: Mon, 03 Mar 2025 09:27:14 +0200 Message-ID: <87ikoq60bx.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdelkeehhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefujghofhffkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecuggftrfgrthhtvghrnhepffegteefveelhfeljeefueehieduiedtfffhuddtkeeffffghfevheetgeeukeehnecukfhppeeluddruddvledruddthedruddujeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeluddruddvledruddthedruddujedphhgvlhhopehmrghilhdrghgrnhguihdrnhgvthdpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomhdprhgtphhtthhopeejieeijeeiseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepvghlihiisehgnhhurdhorhhg X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76676 Cc: Yuan Fu , 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > But in fact, point moves to the first character of 'if' before that: > > if ((0 < scroll_conservatively > > Let me know if I can supply more information. > > In GNU Emacs 30.1.50 (build 9, i686-pc-mingw32) This is already fixed in GNU Emacs 31.0.50. Should this fix be backported into 30.1.50? From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 08:45:02 2025 Received: (at 76676) by debbugs.gnu.org; 3 Mar 2025 13:45:02 +0000 Received: from localhost ([127.0.0.1]:46363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tp66P-0003gb-9I for submit@debbugs.gnu.org; Mon, 03 Mar 2025 08:45:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55800) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tp66N-0003g5-05 for 76676@debbugs.gnu.org; Mon, 03 Mar 2025 08:45:00 -0500 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 1tp66G-0002UV-HC; Mon, 03 Mar 2025 08:44:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=fewWzxIOGT+anv76eAWlUEHSQs8MGesnV/BUjMMVS+Y=; b=Grg9rT72Sjcq /8yHIlhJkK4jOocdsNmizcA8Qyv9RkPia6FP4P+LUIzeTHGQQy20zLK4Kz/qxdmuYicX/zv2a62az 109VRqdd4YZM0J4Q/iVHHilMEpx+Wujz60IZeyAT8uvsHiyoZNipp7mr0nfavNfPiGy7Y8nxFrXJc zzfYQIMcFUBJUfW5mGS23sZ3aLbEcf8rR8KxSqpsp+Zvrpa3kDGAlmeq3dMXUTzj8UIQvNnsUfYfb ExypcAtopm5vxDEZMG4Gxn07EpDgNzhaho+NhGF/Kbvqsfs/ewkQH+0NxcUjGM7LOuNzP8q/EGI0w GNP1Ctf4RqGaXHmzU76YNQ==; Date: Mon, 03 Mar 2025 15:44:47 +0200 Message-Id: <8634fumdo0.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87ikoq60bx.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 03 Mar 2025 09:27:14 +0200) Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far References: <86bjujolsv.fsf@gnu.org> <87ikoq60bx.fsf@mail.linkov.net> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 76676 Cc: casouri@gmail.com, 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Juri Linkov > Cc: 76676@debbugs.gnu.org, Yuan Fu > Date: Mon, 03 Mar 2025 09:27:14 +0200 > > > But in fact, point moves to the first character of 'if' before that: > > > > if ((0 < scroll_conservatively > > > > Let me know if I can supply more information. > > > > In GNU Emacs 30.1.50 (build 9, i686-pc-mingw32) > > This is already fixed in GNU Emacs 31.0.50. Thanks, good to know. > Should this fix be backported into 30.1.50? Can you point me to the commit(s) which fixed that? If they are safe, I will backport them. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 12:57:54 2025 Received: (at 76676) by debbugs.gnu.org; 3 Mar 2025 17:57:54 +0000 Received: from localhost ([127.0.0.1]:51378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tpA37-0007wZ-Pz for submit@debbugs.gnu.org; Mon, 03 Mar 2025 12:57:54 -0500 Received: from relay6-d.mail.gandi.net ([2001:4b98:dc4:8::226]:49841) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tpA35-0007vr-9U for 76676@debbugs.gnu.org; Mon, 03 Mar 2025 12:57:51 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 8EFF4442AE; Mon, 3 Mar 2025 17:57:41 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far In-Reply-To: <8634fumdo0.fsf@gnu.org> Organization: LINKOV.NET References: <86bjujolsv.fsf@gnu.org> <87ikoq60bx.fsf@mail.linkov.net> <8634fumdo0.fsf@gnu.org> Date: Mon, 03 Mar 2025 19:56:32 +0200 Message-ID: <87r03e3smn.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdelleejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefujghofhffkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecuggftrfgrthhtvghrnhepffegteefveelhfeljeefueehieduiedtfffhuddtkeeffffghfevheetgeeukeehnecukfhppeeluddruddvledruddthedruddujeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeluddruddvledruddthedruddujedphhgvlhhopehmrghilhdrghgrnhguihdrnhgvthdpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomhdprhgtphhtthhopeejieeijeeiseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepvghlihiisehgnhhurdhorhhg X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76676 Cc: casouri@gmail.com, 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> > But in fact, point moves to the first character of 'if' before that: >> > >> > if ((0 < scroll_conservatively >> > >> > Let me know if I can supply more information. >> > >> > In GNU Emacs 30.1.50 (build 9, i686-pc-mingw32) >> >> This is already fixed in GNU Emacs 31.0.50. > > Thanks, good to know. > >> Should this fix be backported into 30.1.50? > > Can you point me to the commit(s) which fixed that? If they are safe, > I will backport them. There are too many commits during the previous 5 months. Maybe easier would be to sync whole treesit.c, treesit.el and ts-mode files to emacs-30? From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 14:37:24 2025 Received: (at 76676-done) by debbugs.gnu.org; 3 Mar 2025 19:37:24 +0000 Received: from localhost ([127.0.0.1]:52099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tpBbQ-0006lX-Bj for submit@debbugs.gnu.org; Mon, 03 Mar 2025 14:37:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53964) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tpBbN-0006lG-PT for 76676-done@debbugs.gnu.org; Mon, 03 Mar 2025 14:37:22 -0500 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 1tpBbH-0007DC-J1; Mon, 03 Mar 2025 14:37:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1BGN8VW0U7mdhLfMiLSg72h048kDKfXF+afdgr8olSc=; b=bW67cSRJbn1f fAg1Gx/uS3Uh3t/q2ypznJXhpw9tPWc6IaDMW9RyfmPtAK88oDLnd7Mp58z9a7dbhd8CtdccIaM2S OR/7C/BEGFeLYpQV0CUdCNQk50XZonUlDDvMkBYkc5qBivqvz1tAVMl/H3+jUXRnA14WFx7Q+/rQ6 +zzHJTymEKfNM1WiG2xR7ZF/FlXG+WuiNA9l5ueBDt2jJV+hKYNdji1DDQj5SzM/nrko52mIrllIv ZM+yt1vpegZouwEkyy8wPFbi4XRGNNfcAWaxW9L7d50nQteYz208pe8K672DHjHvnFvt+089K+yBA gXx9VraPYOkWli+Lg01QTg==; Date: Mon, 03 Mar 2025 21:37:09 +0200 Message-Id: <86wmd5kisa.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87r03e3smn.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 03 Mar 2025 19:56:32 +0200) Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far References: <86bjujolsv.fsf@gnu.org> <87ikoq60bx.fsf@mail.linkov.net> <8634fumdo0.fsf@gnu.org> <87r03e3smn.fsf@mail.linkov.net> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 76676-done Cc: 76676-done@debbugs.gnu.org, casouri@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Juri Linkov > Cc: 76676@debbugs.gnu.org, casouri@gmail.com > Date: Mon, 03 Mar 2025 19:56:32 +0200 > > >> > But in fact, point moves to the first character of 'if' before that: > >> > > >> > if ((0 < scroll_conservatively > >> > > >> > Let me know if I can supply more information. > >> > > >> > In GNU Emacs 30.1.50 (build 9, i686-pc-mingw32) > >> > >> This is already fixed in GNU Emacs 31.0.50. > > > > Thanks, good to know. > > > >> Should this fix be backported into 30.1.50? > > > > Can you point me to the commit(s) which fixed that? If they are safe, > > I will backport them. > > There are too many commits during the previous 5 months. > Maybe easier would be to sync whole treesit.c, treesit.el > and ts-mode files to emacs-30? No, that's too many non-trivial changes for my palate. I thought you knew which changeset on master fixed that, but if you don't, then the fix will have to wait till Emacs 31. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 04 18:16:44 2025 Received: (at 76676-done) by debbugs.gnu.org; 4 Mar 2025 23:16:44 +0000 Received: from localhost ([127.0.0.1]:33488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tpbVE-0001Cb-Hc for submit@debbugs.gnu.org; Tue, 04 Mar 2025 18:16:44 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:44352) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tpbVB-0001CJ-8i for 76676-done@debbugs.gnu.org; Tue, 04 Mar 2025 18:16:42 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-22339936bbfso92638835ad.1 for <76676-done@debbugs.gnu.org>; Tue, 04 Mar 2025 15:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741130195; x=1741734995; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1l/Mmp1eRiCWKhOYM8Rq+LpO7moVr/hkvsuJwFpY+9c=; b=Jp5orOnaZxddpzt4S8qXgNl/Q94Fl0FT7+zS4uhtLA4GaWK3SxfMhpiBB9/wF+2T+j T2IeNkzErnNY/GXZBKsWQiIyVgFzv+rB7Cu1jltlHQ7o8NSBnn8qGKBL5hyRYnToY0TG Vhl2upO6Omjah787izjkBvz0bb9bKCdlx8L+W312PlxYPP/Bc9bTg9frXye6uBL41SlQ z0Z7apt6m0WYhNtMWizaCMiZNtfmUrRSPiBYsZpeqjfaosZqhoI71emXnyjNF7T9NAA6 e7jDLf28BY9QFe6Sz1UVF7jCnbuon52xRHw6pDt+SrEBlB4mwhTlLNZnVLa3/9/RPkyk 5Dhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741130195; x=1741734995; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1l/Mmp1eRiCWKhOYM8Rq+LpO7moVr/hkvsuJwFpY+9c=; b=wR4Kd2VwAN2Pn60WyISfGnmDDjvNNxiNUtzFRUyaSC9N0TR1ld6vP8loy5EOWBVe/+ S0VE6t+XedZbYERdHoYG6/AYTy9p8VmgktLIN9drI42AzaqUoao31vIkKvgVW8R15DPT BUzoYjXwnvvUCMl+j6U1aBPqTznnCjIZfIQXWJd9vQHpsjsZjO5SZjMdpuaXkJ9pyQT1 4EUbYzCeBxcUtDb6crPamx7SLLYQuWAif5M+8V6R9jJJzFjo2DyEt/decRwTlNHkwX2B OsMqZTgsRNzDTTdkD5eDULiFo45XaHMMBBcL5MDgZ/njlZbO2ofqIT2tMp2haYgyJ77d TtDw== X-Forwarded-Encrypted: i=1; AJvYcCWxmFtf08LYa47Un9OJ6OCq/O3IZzTrvU+RdwIdmhDskqXupQfijB/76HEZsUsX2rYHwtakRT9qjFpg@debbugs.gnu.org X-Gm-Message-State: AOJu0YxDp6MaU3FwXfWINWGc2zJbDYn/loEAOHwFhLX8UeX+jshvFM+0 EmYoSaxskwhyitp4hRRs8h9tzGHcvFV0oDuc67K43QQIioUEtmT3 X-Gm-Gg: ASbGncvo5BjiihSMEeNmQQbgnlr/teRaK7zesRPKJfRpaveqHBAlyVqaRSGFcmsxlME NrRAYkH/qKoCNK5wJIQzV6DNC+/s8K8NWQ3lW3O/3Ddqfzofre4c4V3iD91tgGicSdKCLxW8s/O YuwpTLcRWcO39HlBMfWTejLkrF7p5H9bd8Hn5eEkWjdnNxcbqH7cHCQE3wXfPzcle0XB/3W/oi5 Y5I+OSgdGmQU1NckNYDo7tnHqG9/MK+QYc1h/DtFEME60JE6TgORH8mmHiTD7axIi2rzEV4N9h1 7yj0oRC5tV/D+TXGlv/xMH0vyu9E0c9E+orijhRVA8ANHozVqNLo/9ep9hKbsmv9n3jS X-Google-Smtp-Source: AGHT+IFVo6HZzCz+XfUNfrm1G56C5SLI6FvxloWAUhlIV74fcslJJemuaeuOgcaNOzuCMb6DxPFTGw== X-Received: by 2002:a17:903:182:b0:223:2630:6b82 with SMTP id d9443c01a7336-223f1c6903amr18868265ad.10.1741130194852; Tue, 04 Mar 2025 15:16:34 -0800 (PST) Received: from smtpclient.apple ([2601:646:8f81:6120:c004:4d68:8d79:7ea8]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-223504c5cd2sm101512165ad.143.2025.03.04.15.16.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Mar 2025 15:16:34 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far From: Yuan Fu In-Reply-To: <86wmd5kisa.fsf@gnu.org> Date: Tue, 4 Mar 2025 15:16:23 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <7B3F7821-0477-4020-8FA3-FD1FD56A83DE@gmail.com> References: <86bjujolsv.fsf@gnu.org> <87ikoq60bx.fsf@mail.linkov.net> <8634fumdo0.fsf@gnu.org> <87r03e3smn.fsf@mail.linkov.net> <86wmd5kisa.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3776.700.51) X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 76676-done Cc: 76676-done@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) > On Mar 3, 2025, at 11:37=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >> From: Juri Linkov >> Cc: 76676@debbugs.gnu.org, casouri@gmail.com >> Date: Mon, 03 Mar 2025 19:56:32 +0200 >>=20 >>>>> But in fact, point moves to the first character of 'if' before = that: >>>>>=20 >>>>> if ((0 < scroll_conservatively >>>>>=20 >>>>> Let me know if I can supply more information. >>>>>=20 >>>>> In GNU Emacs 30.1.50 (build 9, i686-pc-mingw32) >>>>=20 >>>> This is already fixed in GNU Emacs 31.0.50. >>>=20 >>> Thanks, good to know. >>>=20 >>>> Should this fix be backported into 30.1.50? >>>=20 >>> Can you point me to the commit(s) which fixed that? If they are = safe, >>> I will backport them. >>=20 >> There are too many commits during the previous 5 months. >> Maybe easier would be to sync whole treesit.c, treesit.el >> and ts-mode files to emacs-30? >=20 > No, that's too many non-trivial changes for my palate. I thought you > knew which changeset on master fixed that, but if you don't, then the > fix will have to wait till Emacs 31. >=20 > Thanks. Yes, to add to that, I made some significant changes to how indentation = works on master which requires changes in c-ts-common.el. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 17 13:59:28 2025 Received: (at 76676) by debbugs.gnu.org; 17 Mar 2025 17:59:29 +0000 Received: from localhost ([127.0.0.1]:60814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuEkK-0001WE-Es for submit@debbugs.gnu.org; Mon, 17 Mar 2025 13:59:28 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:49807) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuEkI-0001VS-1b for 76676@debbugs.gnu.org; Mon, 17 Mar 2025 13:59:26 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0F9792057C; Mon, 17 Mar 2025 17:59:17 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far In-Reply-To: <86bjujolsv.fsf@gnu.org> Organization: LINKOV.NET References: <86bjujolsv.fsf@gnu.org> Date: Mon, 17 Mar 2025 19:56:20 +0200 Message-ID: <87msdjsfqz.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugedtudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopegtrghsohhurhhisehgmhgrihhlrdgtohhmpdhrtghpthhtohepjeeiieejieesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrgh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76676 Cc: Yuan Fu , 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Now type C-M-b. The expected result is that point moves to the > corresponding opening brace, as shown below: > > [...] > > But in fact, point moves to the first character of 'if' before that: > > if ((0 < scroll_conservatively IME half the time C-M-b needs to move to the opening brace, and other half the time to the first character of 'if'. When need to operate on the block enclosed inside braces, then C-M-b is expected to move where it moved traditionally in c-mode. But often need to take advantage of the tree-sitter grammars and to operate directly on its nodes, e.g. select the whole 'if' condition with its body to move to another place. We still need to address this discrepancy between these two modes. So I tried to create a parallel set of commands: one of them using the current sexp/list navigation, and another using any treesit nodes. But the problem that this requires more duplication such as adding treesit-mark-named-thing to work like mark-sexp, etc. Then I realized it should be sufficient to have just one very short command to toggle the current mode. And here it is: (defun treesit-toggle-named-thing () (interactive) (setq-local treesit-sexp-type-regexp (unless treesit-sexp-type-regexp #'treesit-node-named))) For the example above it toggles between moving to the first character of 'if' and moving to the opening brace. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 18 03:30:11 2025 Received: (at 76676) by debbugs.gnu.org; 18 Mar 2025 07:30:11 +0000 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 1tuROr-0005G1-Mj for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:30:11 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:59859) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuROo-0005E3-Np for 76676@debbugs.gnu.org; Tue, 18 Mar 2025 03:30:07 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id AF28C443A7; Tue, 18 Mar 2025 07:29:57 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far In-Reply-To: <87msdjsfqz.fsf@mail.linkov.net> Organization: LINKOV.NET References: <86bjujolsv.fsf@gnu.org> <87msdjsfqz.fsf@mail.linkov.net> Date: Tue, 18 Mar 2025 09:20:59 +0200 Message-ID: <87wmcm249w.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugedukeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeettdeiieegfeehtddvgeekhfelvdeggfevfeevgeelvdffudekkedtledtgfekvdenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopeejieeijeeiseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrgh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76676 Cc: Yuan Fu , 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > (defun treesit-toggle-named-thing () > (interactive) > (setq-local treesit-sexp-type-regexp > (unless treesit-sexp-type-regexp #'treesit-node-named))) > > For the example above it toggles between moving to the > first character of 'if' and moving to the opening brace. Actually, it's better to toggle between the traditional behavior and navigation by the 'sexp' thing: (defun treesit-toggle-sexp-mode () (interactive) (setq-local treesit-sexp-type-regexp (unless treesit-sexp-type-regexp (if (treesit-thing-defined-p 'sexp nil) 'sexp #'treesit-node-named)) forward-sexp-function (if (eq treesit-sexp-type-regexp 'sexp) #'treesit-forward-sexp #'treesit-forward-sexp-list))) The only ts-mode where the 'sexp' thing is well defined is c-ts-mode with (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) All other ts-modes contain desperate attempts to emulate the traditional behavior to navigate symbols with the 'sexp' thing. But symbol navigation is now implemented as the default behavior. So these ts-modes should be fixed based on the pattern in c-ts-mode. Then after toggling to the sexp mode they will navigate all ts nodes except nodes that define boundaries. Here is an example how such fix will look for ruby-ts-mode: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=ruby-ts-mode-sexp-thing.patch diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 1594f301641..39113d381c7 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1167,52 +1167,15 @@ ruby-ts-mode (setq-local treesit-thing-settings `((ruby - (sexp ,(cons (rx - bos - (or - "class" - "singleton_class" - "module" - "method" - "singleton_method" - "array" - "hash" - "parenthesized_statements" - "method_parameters" - "array_pattern" - "hash_pattern" - "if" - "else" - "then" - "unless" - "case" - "case_match" - "when" - "while" - "until" - "for" - "block" - "do_block" - "begin" - "integer" - "identifier" - "self" - "super" - "constant" - "simple_symbol" - "hash_key_symbol" - "symbol_array" - "string" - "string_array" - "heredoc_body" - "regex" - "argument_list" - "interpolation" - "instance_variable" - "global_variable" - ) - eos) - #'ruby-ts--sexp-p)) + (sexp (not (or (and named + ,(rx (or "program" + "body_statement"))) + (and anonymous + ,(rx (or "do" "begin" + "if" "unless" + "def" "end" + "{" "}" "[" "]" + "(" ")" "[" "]" "|")))))) (list ,(cons (rx bos (or --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 18 13:53:12 2025 Received: (at 76676) by debbugs.gnu.org; 18 Mar 2025 17:53:12 +0000 Received: from localhost ([127.0.0.1]:43095 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tub7n-0007pg-Je for submit@debbugs.gnu.org; Tue, 18 Mar 2025 13:53:12 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:44117) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tub7i-0007nW-Bb for 76676@debbugs.gnu.org; Tue, 18 Mar 2025 13:53:09 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 231F543210; Tue, 18 Mar 2025 17:52:57 +0000 (UTC) From: Juri Linkov To: Yuan Fu Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far In-Reply-To: <87wmcm249w.fsf@mail.linkov.net> Organization: LINKOV.NET References: <86bjujolsv.fsf@gnu.org> <87msdjsfqz.fsf@mail.linkov.net> <87wmcm249w.fsf@mail.linkov.net> Date: Tue, 18 Mar 2025 19:49:01 +0200 Message-ID: <87y0x2z0tu.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugeeftdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeettdeiieegfeehtddvgeekhfelvdeggfevfeevgeelvdffudekkedtledtgfekvdenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopeejieeijeeiseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrgh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76676 Cc: Eli Zaretskii , 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > The only ts-mode where the 'sexp' thing is well defined is c-ts-mode with > > (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) > > All other ts-modes contain desperate attempts to emulate the > traditional behavior to navigate symbols with the 'sexp' thing. > But symbol navigation is now implemented as the default behavior. > > So these ts-modes should be fixed based on the pattern in c-ts-mode. > Then after toggling to the sexp mode they will navigate all ts nodes > except nodes that define boundaries. Ok, here is more complete patch with a small improvement in c-ts-mode, and using the same pattern in java/css/ruby-ts-mode: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=treesit-toggle-sexp-mode.patch diff --git a/lisp/treesit.el b/lisp/treesit.el index 46332cb1e4b..f5cd3f2067c 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3310,6 +3317,24 @@ treesit-end-of-thing (when dest (goto-char dest)))) +(defun treesit-toggle-sexp-mode () + "Toggle the mode of navigation for sexp commands." + (interactive) + (when (treesit-thing-defined-p 'list nil) + (setq-local treesit-sexp-type-regexp + (unless treesit-sexp-type-regexp + (if (treesit-thing-defined-p 'sexp nil) + 'sexp + #'treesit-node-named)) + forward-sexp-function + (if treesit-sexp-type-regexp + #'treesit-forward-sexp + #'treesit-forward-sexp-list)) + (message "Toggle to mode where sexp commands navigate %s" + (or (and treesit-sexp-type-regexp + "treesit nodes") + "syntax symbols and treesit lists")))) + (defun treesit-beginning-of-defun (&optional arg) "Move backward to the beginning of a defun. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index fa5f8567b60..285d38e6411 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -1194,7 +1194,11 @@ c-ts-mode--emacs-current-defun-name (defvar c-ts-mode--thing-settings `(;; It's more useful to include semicolons as sexp so ;; that users can move to the end of a statement. - (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) + (sexp (not (or (and named + ,(rx bos (or "translation_unit") eos)) + (and anonymous + ,(rx (or "{" "}" "[" "]" "(" ")" + "," ";")))))) (list ,(regexp-opt '("preproc_params" "preproc_if" diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index c4b2282b574..cd18d6d1e28 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -436,19 +436,12 @@ java-ts-mode (setq-local treesit-thing-settings `((java - (sexp ,(rx (or "annotation" - "parenthesized_expression" - "argument_list" - "identifier" - "modifiers" - "block" - "body" - "literal" - "access" - "reference" - "_type" - "true" - "false"))) + (sexp (not (or (and named + ,(rx bos (or "program") eos)) + (and anonymous + ,(rx (or "{" "}" "[" "]" + "(" ")" "<" ">" + "," ";")))))) (list ,(rx bos (or "inferred_parameters" "parenthesized_expression" "argument_list" diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 1594f301641..e8fb0f62d46 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1167,52 +1167,17 @@ ruby-ts-mode (setq-local treesit-thing-settings `((ruby - (sexp ,(cons (rx - bos - (or - "class" - "singleton_class" - "module" - "method" - "singleton_method" - "array" - "hash" - "parenthesized_statements" - "method_parameters" - "array_pattern" - "hash_pattern" - "if" - "else" - "then" - "unless" - "case" - "case_match" - "when" - "while" - "until" - "for" - "block" - "do_block" - "begin" - "integer" - "identifier" - "self" - "super" - "constant" - "simple_symbol" - "hash_key_symbol" - "symbol_array" - "string" - "string_array" - "heredoc_body" - "regex" - "argument_list" - "interpolation" - "instance_variable" - "global_variable" - ) - eos) - #'ruby-ts--sexp-p)) + (sexp (not (or (and named + ,(rx bos (or "program" + "body_statement" + "then") + eos)) + (and anonymous + ,(rx (or "do" "begin" + "if" "unless" + "def" "end" + "{" "}" "[" "]" + "(" ")" "[" "]" "|")))))) (list ,(cons (rx bos (or diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 02c3618d281..9d063646184 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1781,7 +1781,13 @@ css--extract-index-name res))))))) (defvar css--treesit-thing-settings - `((css (list + `((css (sexp + (not (or (and named + ,(rx bos (or "stylesheet") eos)) + (and anonymous + ,(rx (or "{" "}" "[" "]" "(" ")" + "," ";")))))) + (list ,(rx bos (or "keyframe_block_list" "block" "pseudo_class_arguments" --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 09 14:24:09 2025 Received: (at 76676) by debbugs.gnu.org; 9 Apr 2025 18:24:10 +0000 Received: from localhost ([127.0.0.1]:41950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2a5p-0007tx-Kx for submit@debbugs.gnu.org; Wed, 09 Apr 2025 14:24:09 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35527) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2a5m-0007tO-U4 for 76676@debbugs.gnu.org; Wed, 09 Apr 2025 14:24:07 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id DC6E24430D; Wed, 9 Apr 2025 18:23:53 +0000 (UTC) From: Juri Linkov To: Yuan Fu Subject: Re: bug#76676: 30.1.50; C-M-b in c-ts-mode moves too far In-Reply-To: <87y0x2z0tu.fsf@mail.linkov.net> Organization: LINKOV.NET References: <86bjujolsv.fsf@gnu.org> <87msdjsfqz.fsf@mail.linkov.net> <87wmcm249w.fsf@mail.linkov.net> <87y0x2z0tu.fsf@mail.linkov.net> Date: Wed, 09 Apr 2025 21:22:49 +0300 Message-ID: <87r0215h52.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvtdeijeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopeejieeijeeiseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepvghlihiisehgnhhurdhorhhgpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76676 Cc: Eli Zaretskii , 76676@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> The only ts-mode where the 'sexp' thing is well defined is c-ts-mode with >> >> (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) >> >> All other ts-modes contain desperate attempts to emulate the >> traditional behavior to navigate symbols with the 'sexp' thing. >> But symbol navigation is now implemented as the default behavior. >> >> So these ts-modes should be fixed based on the pattern in c-ts-mode. >> Then after toggling to the sexp mode they will navigate all ts nodes >> except nodes that define boundaries. > > Ok, here is more complete patch with a small improvement in c-ts-mode, > and using the same pattern in java/css/ruby-ts-mode: Now pushed to master. From unknown Tue Jun 17 20:18:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 08 May 2025 11:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator