Received: (at 68993) by debbugs.gnu.org; 17 Apr 2024 06:55:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 17 02:55:52 2024 Received: from localhost ([127.0.0.1]:45589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rwzCy-0003r9-0Z for submit <at> debbugs.gnu.org; Wed, 17 Apr 2024 02:55:52 -0400 Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]:36255) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rwzCu-0003qb-UQ for 68993 <at> debbugs.gnu.org; Wed, 17 Apr 2024 02:55:50 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 4A45B240005; Wed, 17 Apr 2024 06:55:27 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattias.engdegard@HIDDEN> Subject: Re: bug#68993: treesitter support for forward-sexp-default-function In-Reply-To: <0624B4F8-AFDC-473C-B4F6-C3E974B30F11@HIDDEN> ("Mattias =?iso-8859-1?Q?Engdeg=E5rd=22's?= message of "Tue, 16 Apr 2024 12:15:28 +0200") Organization: LINKOV.NET References: <0624B4F8-AFDC-473C-B4F6-C3E974B30F11@HIDDEN> Date: Wed, 17 Apr 2024 09:54:55 +0300 Message-ID: <86wmowa37k.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org, Yuan Fu <casouri@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) > Looks like 568c174135 broke lisp-tests and thingatpt-tests: Thanks, should be fixed now.
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 16 Apr 2024 10:15:55 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 16 06:15:55 2024 Received: from localhost ([127.0.0.1]:42991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rwfr0-0004Uh-Qh for submit <at> debbugs.gnu.org; Tue, 16 Apr 2024 06:15:55 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:42207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mattias.engdegard@HIDDEN>) id 1rwfqu-0004Fy-OX for 68993 <at> debbugs.gnu.org; Tue, 16 Apr 2024 06:15:52 -0400 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-518a3e0d2e4so2582901e87.0 for <68993 <at> debbugs.gnu.org>; Tue, 16 Apr 2024 03:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713262530; x=1713867330; darn=debbugs.gnu.org; h=to:cc:date:message-id:subject:mime-version:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=+hzDStDnb78E5Bk6IlmiNDAxXefvkULa6Ysf1530hUE=; b=jKMG6k48qD0pYKIvrjl5trHR5KFnd4gpSh6A5bRZoWwuEziV0iBiIKCIQgzQ4pa0b/ qWraBaqOsJwh51pq/LaWdzIbxnRq6VpQcO2p9zk2xIyjUYR4CwftesyW+3d/uG64xdWH eJF/+bfA1MqCPX2NUP1KCITjU+BP+WifPqSRlZdmClmElHBhq+bDSCTnemcVxDFuW8kP XAomzSTPzanXBIUdDkcdRfR5mp1e5RAVeDQEto76h0oysu6rdAlsfqIOjSHjftYfxzVi 6OWjZs6F2xG+8TfnSyZAZGVienYaa1zQJ/pQnak18H5dRu8+fe4kCUFESjsuJh92ecGs qEIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713262530; x=1713867330; h=to:cc:date:message-id:subject:mime-version:from:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+hzDStDnb78E5Bk6IlmiNDAxXefvkULa6Ysf1530hUE=; b=UlvIC35U0p1ZCm1SRgHygD+oOSYn3jhgr8tT4OZXf+n6kRozhLZsYPE5q7X96bb2nh 9pSel27tOv7qIGJqvyd3yizbn4ThoDqVCUTCsiLR8a0lbpB9mpaRiKoknzX9x+o/ucWf /HVwJQgNk/yUgxFePhnF997LxxHP8I+35hIYopLL+zFRknyWtMp0T53qYIu1D6244B5s yUnX55IIxR7+EpS0V+PXOcwkBlKHm4bgiuHdBsc1JzjLAvn1kozcMgHA5rHmkbARml5L KdCfjeKTUs5RYq1tJxUXK/PzokVsNPGIHEwAHfz6BKLz0mMpVKaEvWofGOkmuKeUFR1u jRng== X-Forwarded-Encrypted: i=1; AJvYcCUr3lZjWzb5+hDx/4F3QQ09VCIDgayUruKzRogvYO7zaGYGIUVnCtRZ3Ky2Yv9oRj+bQEgmFa4hE6AuqmdjxA5gBeorl2c= X-Gm-Message-State: AOJu0YxlEgaKp0HG/OZyuWw9Z4srU3bh1M8fA1BIAIZyBsu4tCgiKhEt 9zUEBm484AgVrstPl2gdGsjNXD0gJsd5GUuPjPrx/I+vpqt3nbU9 X-Google-Smtp-Source: AGHT+IFn3IFlUweXPB4Ku5W5CHdCs2YDdoBSaP/X5MipwxopJSMBdiccCWZaxuUa098ChO2wKZ0RTA== X-Received: by 2002:a05:6512:2385:b0:513:d1d9:9eda with SMTP id c5-20020a056512238500b00513d1d99edamr675702lfv.27.1713262530138; Tue, 16 Apr 2024 03:15:30 -0700 (PDT) Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id y23-20020a196417000000b00515d4bcc650sm1561141lfb.117.2024.04.16.03.15.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Apr 2024 03:15:29 -0700 (PDT) From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= <mattias.engdegard@HIDDEN> Content-Type: multipart/mixed; boundary="Apple-Mail=_89EDD90E-CB1E-4456-A855-3857BE070169" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Subject: bug#68993: treesitter support for forward-sexp-default-function Message-Id: <0624B4F8-AFDC-473C-B4F6-C3E974B30F11@HIDDEN> Date: Tue, 16 Apr 2024 12:15:28 +0200 To: Juri Linkov <juri@HIDDEN> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org, Yuan Fu <casouri@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --Apple-Mail=_89EDD90E-CB1E-4456-A855-3857BE070169 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Looks like 568c174135 broke lisp-tests and thingatpt-tests: --Apple-Mail=_89EDD90E-CB1E-4456-A855-3857BE070169 Content-Disposition: attachment; filename=lisp-tests.log Content-Type: application/octet-stream; x-unix-mode=0644; name="lisp-tests.log" Content-Transfer-Encoding: 7bit GEN lisp/emacs-lisp/lisp-tests.log Running 37 tests (2024-04-16 12:12:01+0200, selector `(not (or (tag :unstable) (tag :nativecomp)))') passed 1/37 backward-up-list-basic (0.000521 sec) passed 2/37 core-elisp-tests-1-defvar-in-let (0.000078 sec) Mark set passed 3/37 core-elisp-tests-2-window-configurations (0.000078 sec) passed 4/37 core-elisp-tests-3-backquote (0.000045 sec) passed 5/37 end-of-defun-twice (0.000316 sec) passed 6/37 lisp-backward-sexp-1-empty-parens (0.000057 sec) passed 7/37 lisp-backward-sexp-1-eobp (0.000056 sec) passed 8/37 lisp-backward-sexp-1-error-mismatch (0.000046 sec) passed 9/37 lisp-backward-sexp-2-bobp (0.000045 sec) passed 10/37 lisp-backward-sexp-2-bobp-and-subsequent (0.000046 sec) passed 11/37 lisp-delete-pair-parens (1.005549 sec) passed 12/37 lisp-delete-pair-quotation-marks (1.005471 sec) passed 13/37 lisp-delete-pair-quotes-in-text-mode (0.000220 sec) passed 14/37 lisp-delete-pair-quotes-text-mode-syntax-table (1.005522 sec) passed 15/37 lisp-fill-paragraph-colon (0.001064 sec) passed 16/37 lisp-forward-sexp-1-empty-parens (0.000099 sec) passed 17/37 lisp-forward-sexp-1-eobp (0.000085 sec) passed 18/37 lisp-forward-sexp-1-error-mismatch (0.000086 sec) passed 19/37 lisp-forward-sexp-2-eobp (0.000085 sec) passed 20/37 lisp-forward-sexp-2-eobp-and-subsequent (0.000097 sec) passed 21/37 lisp-forward-sexp-elisp-inside-symbol (0.000240 sec) passed 22/37 lisp-forward-sexp-elisp-quoted-symbol (0.000221 sec) passed 23/37 lisp-forward-sexp-emacs-lisp-quote-char (0.000209 sec) passed 24/37 lisp-forward-sexp-emacs-lisp-semi-char-error (0.000213 sec) passed 25/37 lisp-forward-sexp-python-triple-quoted-string (0.000601 sec) passed 26/37 lisp-forward-sexp-python-triple-quotes-string (0.000365 sec) passed 27/37 mark-defun-arg-region-active (0.000385 sec) Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set passed 28/37 mark-defun-bob (0.000846 sec) Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set passed 29/37 mark-defun-neg-arg-region-inactive (0.057865 sec) passed 30/37 mark-defun-no-arg-region-active (0.000312 sec) Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set Mark set passed 31/37 mark-defun-no-arg-region-inactive (0.000903 sec) Mark set Mark set Mark set Mark set Mark set Mark set passed 32/37 mark-defun-pos-arg-region-inactive (0.000503 sec) passed 33/37 up-list-basic (0.000085 sec) Test up-list-cross-string backtrace: signal(ert-test-failed (((should (eql (point) (posof instruction))) ert-fail(((should (eql (point) (posof instruction))) :form (eql 24 2 lisp-run-up-list-test(#f(compiled-function () #<bytecode 0x51b5696be #f(compiled-function () #<bytecode 0x515baeca3b92b8a>)() #f(compiled-function () #<bytecode 0x18e9853ee4bdb3eb>)() handler-bind-1(#f(compiled-function () #<bytecode 0x18e9853ee4bdb3eb ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name up-list-cross-string :documentation n ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp)))) ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq command-line() normal-top-level() Test up-list-cross-string condition: (ert-test-failed ((should (eql (point) (posof instruction))) :form (eql 24 21) :value nil)) FAILED 34/37 up-list-cross-string (0.000112 sec) at ../../emacs/test/lisp/emacs-lisp/lisp-tests.el:291 passed 35/37 up-list-no-cross-string (0.000155 sec) Test up-list-out-of-string backtrace: signal(ert-test-failed (((should (eql (point) (posof instruction))) ert-fail(((should (eql (point) (posof instruction))) :form (eql 23 1 lisp-run-up-list-test(#f(compiled-function () #<bytecode 0x51b5696be #f(compiled-function () #<bytecode -0x1189b0e3987319ce>)() #f(compiled-function () #<bytecode 0x18e9853ee4bdb3eb>)() handler-bind-1(#f(compiled-function () #<bytecode 0x18e9853ee4bdb3eb ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name up-list-out-of-string :documentation ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp)))) ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq command-line() normal-top-level() Test up-list-out-of-string condition: (ert-test-failed ((should (eql (point) (posof instruction))) :form (eql 23 18) :value nil)) FAILED 36/37 up-list-out-of-string (0.000155 sec) at ../../emacs/test/lisp/emacs-lisp/lisp-tests.el:285 passed 37/37 up-list-with-forward-sexp-function (0.000164 sec) Ran 37 tests, 35 results as expected, 2 unexpected (2024-04-16 12:12:04+0200, 3.502098 sec) 2 unexpected results: FAILED up-list-cross-string FAILED up-list-out-of-string --Apple-Mail=_89EDD90E-CB1E-4456-A855-3857BE070169 Content-Disposition: attachment; filename=thingatpt-tests.log Content-Type: application/octet-stream; x-unix-mode=0644; name="thingatpt-tests.log" Content-Transfer-Encoding: 7bit GEN lisp/thingatpt-tests.log Running 13 tests (2024-04-16 12:13:44+0200, selector `(not (or (tag :unstable) (tag :nativecomp)))') passed 1/13 test-numbers-decimal (0.000164 sec) passed 2/13 test-numbers-hex-c (0.000162 sec) passed 3/13 test-numbers-hex-lisp (0.000140 sec) passed 4/13 test-numbers-none (0.000057 sec) passed 5/13 test-symbol-thing-1 (0.000108 sec) passed 6/13 test-symbol-thing-2 (0.000067 sec) passed 7/13 test-symbol-thing-3 (0.000055 sec) passed 8/13 test-symbol-thing-4 (0.000053 sec) Test thing-at-point-bounds-of-list-at-point backtrace: signal(ert-test-failed (((should (equal (list-at-point) (cl-second t ert-fail(((should (equal (list-at-point) (cl-second test))) :form (e #f(compiled-function () #<bytecode 0xe6420b0d408fe48>)() #f(compiled-function () #<bytecode 0x3b8a42f521d079f>)() handler-bind-1(#f(compiled-function () #<bytecode 0x3b8a42f521d079f> ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name thing-at-point-bounds-of-list-at-poin ert-run-or-rerun-test(#s(ert--stats :selector (not ...) :tests [... ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp)))) ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq command-line() normal-top-level() Test thing-at-point-bounds-of-list-at-point condition: (ert-test-failed ((should (equal (list-at-point) (cl-second test))) :form (equal nil (a "b" c)) :value nil :explanation (different-types nil (a "b" c)))) FAILED 9/13 thing-at-point-bounds-of-list-at-point (0.000358 sec) at ../../emacs/test/lisp/thingatpt-tests.el:128 passed 10/13 thing-at-point-looking-at (0.000125 sec) passed 11/13 thing-at-point-looking-at-overlapping-matches (0.000123 sec) passed 12/13 thing-at-point-tests (0.034991 sec) passed 13/13 thing-at-point-url-in-comment (0.081406 sec) Ran 13 tests, 12 results as expected, 1 unexpected (2024-04-16 12:13:44+0200, 0.341416 sec) 1 unexpected results: FAILED thing-at-point-bounds-of-list-at-point --Apple-Mail=_89EDD90E-CB1E-4456-A855-3857BE070169--
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Juri Linkov <juri@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 14 Apr 2024 16:24:01 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 14 12:24:01 2024 Received: from localhost ([127.0.0.1]:36033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rw2e8-0008Sn-RK for submit <at> debbugs.gnu.org; Sun, 14 Apr 2024 12:24:01 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:48331) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rw2e6-0008RU-EN; Sun, 14 Apr 2024 12:23:59 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 474EA240002; Sun, 14 Apr 2024 16:23:40 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#68993: treesitter support for forward-sexp-default-function In-Reply-To: <5BB812B1-6A9F-4F9D-89C5-A4A1A191409C@HIDDEN> (Yuan Fu's message of "Fri, 12 Apr 2024 21:32:13 -0700") Organization: LINKOV.NET References: <5BB812B1-6A9F-4F9D-89C5-A4A1A191409C@HIDDEN> Date: Sun, 14 Apr 2024 19:23:25 +0300 Message-ID: <865xwjapde.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) close 68993 30.0.50 thanks >>> My suggestion would be for both treesit-forward-sentence and -sexp to >>> use “text” for their heuristic. If someone wants more customized >>> behavior, they can always write a custom forward-sentence/sexp function. >> >> Thanks for the suggestion. So here is the patch that implements this: > > LGTM Thanks, so now pushed and closed.
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 10 Apr 2024 18:10:53 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 10 14:10:53 2024 Received: from localhost ([127.0.0.1]:54349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rucPJ-0002sT-GF for submit <at> debbugs.gnu.org; Wed, 10 Apr 2024 14:10:52 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:35927) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rucPG-0002rx-NI for 68993 <at> debbugs.gnu.org; Wed, 10 Apr 2024 14:10:47 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id ACA0DC0003; Wed, 10 Apr 2024 18:10:29 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#68993: treesitter support for forward-sexp-default-function In-Reply-To: <12153B04-8B7E-43D4-8EC4-8931021F1965@HIDDEN> (Yuan Fu's message of "Sun, 11 Feb 2024 17:28:03 -0800") Organization: LINKOV.NET References: <86y1bv6jsm.fsf@HIDDEN> <86a5o86wl5.fsf@HIDDEN> <12153B04-8B7E-43D4-8EC4-8931021F1965@HIDDEN> Date: Wed, 10 Apr 2024 21:03:07 +0300 Message-ID: <86seztf5to.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > My suggestion would be for both treesit-forward-sentence and -sexp to > use “text” for their heuristic. If someone wants more customized > behavior, they can always write a custom forward-sentence/sexp function. Thanks for the suggestion. So here is the patch that implements this: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=treesit-forward-sexp-text.patch diff --git a/lisp/treesit.el b/lisp/treesit.el index 1443162f79c..62d797513fc 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2145,7 +2145,10 @@ treesit-forward-sexp (interactive "^p") (let ((arg (or arg 1)) (pred (or treesit-sexp-type-regexp 'sexp))) - (or (if (> arg 0) + (or (when (treesit-node-match-p (treesit-node-at (point)) 'text t) + (funcall #'forward-sexp-default-function arg) + t) + (if (> arg 0) (treesit-end-of-thing pred (abs arg) 'restricted) (treesit-beginning-of-thing pred (abs arg) 'restricted)) ;; If we couldn't move, we should signal an error and report diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index c57b1357f63..4c0f720b1a0 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -45,7 +45,12 @@ parens-require-spaces :type 'boolean :group 'lisp) -(defvar forward-sexp-function nil +(defun forward-sexp-default-function (&optional arg) + "Default function for `forward-sexp-function'." + (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) + (if (< arg 0) (backward-prefix-chars))) + +(defvar forward-sexp-function #'forward-sexp-default-function ;; FIXME: ;; - for some uses, we may want a "sexp-only" version, which only ;; jumps over a well-formed sexp, rather than some dwimish thing @@ -74,10 +79,9 @@ forward-sexp "No next sexp" "No previous sexp")))) (or arg (setq arg 1)) - (if forward-sexp-function - (funcall forward-sexp-function arg) - (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) - (if (< arg 0) (backward-prefix-chars))))) + (funcall (or forward-sexp-function + #'forward-sexp-default-function) + arg))) (defun backward-sexp (&optional arg interactive) "Move backward across one balanced expression (sexp). --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 12 Feb 2024 18:44:40 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 12 13:44:40 2024 Received: from localhost ([127.0.0.1]:48961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rZbIG-00012F-8q for submit <at> debbugs.gnu.org; Mon, 12 Feb 2024 13:44:40 -0500 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]:32831) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rZbID-00011T-2H for 68993 <at> debbugs.gnu.org; Mon, 12 Feb 2024 13:44:39 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 96F6DFF805; Mon, 12 Feb 2024 18:44:12 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#68993: treesitter support for forward-sexp-default-function In-Reply-To: <89817820-6928-43AD-B4BB-0AB48B1808FB@HIDDEN> (Yuan Fu's message of "Sun, 11 Feb 2024 17:42:34 -0800") Organization: LINKOV.NET References: <86y1bv6jsm.fsf@HIDDEN> <89817820-6928-43AD-B4BB-0AB48B1808FB@HIDDEN> Date: Mon, 12 Feb 2024 20:41:46 +0200 Message-ID: <86o7clv82d.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) >> The problem is that e.g. Ruby parser to such text: >> >> hash[:key] >> >> produces such syntax tree: >> >> (element_reference object: (identifier) [ (simple_symbol) ]) >> >> so when point is on [ then 'C-M-f' can't move to ]. >> >> This is fixed now by the third patch: >> @@ -1170,7 +1170,20 @@ ruby-ts-mode >> + (comment ,(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")))))))) > > IIUC, this doesn’t look like a good idea: you don’t want to mark > something that’s not comment as comment. In the future, other packages > will start using these thing definitions, and I’m sure you don’t want > them consider regular code as comments. > > For the specific problem you described, maybe the change made in #68899 can help? bug#68899 can't help because it only fixes 'C-M-f' to move point to the end of the current symbol. Whereas for the problem above we need a predicate that will instruct 'treesit-forward-sexp' to fall back to 'forward-sexp-default-function'. Clearly neither the name 'text' nor 'comment' would be suitable for such usage. Maybe it's possible to find a different name?
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 12 Feb 2024 01:43:11 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 11 20:43:11 2024 Received: from localhost ([127.0.0.1]:40174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rZLLj-0007XP-8j for submit <at> debbugs.gnu.org; Sun, 11 Feb 2024 20:43:11 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:45497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1rZLLg-0007X1-Ri for 68993 <at> debbugs.gnu.org; Sun, 11 Feb 2024 20:43:09 -0500 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5dbcfa0eb5dso2603600a12.3 for <68993 <at> debbugs.gnu.org>; Sun, 11 Feb 2024 17:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707702166; x=1708306966; 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=cVApWHj9VPTxFK6EtiWYkYGDqYGfsIh8KrB111NF+Ug=; b=XslPIXzO6UWPR0oK1lzku+V5Wl+3U4Z9ZFgwYJBay5eWOetxb1sNejJbTsFbFko0an kP52ILO94s552r1EeKD+Mxvcug2bkvAK06JBz/4OVVliz82qXWF9zXrXrzr0hudTRa0E 6YXQSSlSNcDLQJqCiGOupcLTLGzbixoiUbAsFXFZOku8rYCrz3rMwbydHvG4/4Jf1xI3 1GhnlRB8VR0rFa8yOyRlPT6jQDuLueMoOkPg0hvgTlq5puQHWFX/iz1T+THcqAe3oX5W FMqkIl8+TeP1zJ2ThpbC1Yn/sT8gpIOimH2X5qZSNT0mmr0OfsOeqYgW/DWIGvWhRvPf x4aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707702166; x=1708306966; 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=cVApWHj9VPTxFK6EtiWYkYGDqYGfsIh8KrB111NF+Ug=; b=qf/BCvSO6HftFZqEGrJAlcTw0vYhLjn4MJv8Xq3FLqQTIofFpGKVStuoP92W13icS5 eL5xBcLU6fCp93RyQq0RxC3NGECRhiVw61v4BF8PiEGRrHinZFOfzeKmz+de43EPVwIB 9GrC+SawA5lBasUMixvPPt6Nn583cKs8hQ57v5BgGLylHcVeTMH9jQfAapkroDrKh8dn aok9H7vu517OhMPM/J+VHbZST1XSrs/AbCszUuQYhjUsDiv8j2iI/KqiEasSLo2hFsKi 3FMZUaV5QhEH13GzD9qhVhibaWlZbgQ+KTY8QmcgLpzw1wMgYA5RWSphP5Ms1nS5f1bh hK8g== X-Gm-Message-State: AOJu0YzcyyTs5hFWkvCKQem+uBuannkF227l0Rxev02T6VlsErIJVEtQ AwP7u2XCsN+0Wtc8CNgL5KsqKYnfwW1+KWnD/ORBifXYrLxT1auU X-Google-Smtp-Source: AGHT+IFUMFqmp0XmRAGsK6zkmB+fddcZZrSRkG3B9t6vhLx2pOetds9VuQdL70f+gHn53Bhpme8t5w== X-Received: by 2002:aa7:888e:0:b0:6e0:91c4:be1c with SMTP id z14-20020aa7888e000000b006e091c4be1cmr6357719pfe.9.1707702166382; Sun, 11 Feb 2024 17:42:46 -0800 (PST) Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id o17-20020a637e51000000b005cd78f13608sm5664783pgn.13.2024.02.11.17.42.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2024 17:42:45 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#68993: treesitter support for forward-sexp-default-function From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <86y1bv6jsm.fsf@HIDDEN> Date: Sun, 11 Feb 2024 17:42:34 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <89817820-6928-43AD-B4BB-0AB48B1808FB@HIDDEN> References: <86y1bv6jsm.fsf@HIDDEN> To: Juri Linkov <juri@HIDDEN> X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Feb 8, 2024, at 9:38 AM, Juri Linkov <juri@HIDDEN> wrote: >=20 > 'treesit-forward-sentence' supports the node type 'text', > and for matching nodes it uses the fallback to > 'forward-sentence-default-function'. >=20 > This patch does exactly the same for 'treesit-forward-sexp': > for nodes that match a new node type 'comment', > it uses the fallback to the new function > 'forward-sexp-default-function'. >=20 > diff --git a/lisp/treesit.el b/lisp/treesit.el > index 82b2f97b4a5..284c4915f3a 100644 > --- a/lisp/treesit.el > +++ b/lisp/treesit.el > @@ -2137,7 +2137,10 @@ treesit-forward-sexp > (interactive "^p") > (let ((arg (or arg 1)) > (pred (or treesit-sexp-type-regexp 'sexp))) > - (or (if (> arg 0) > + (or (when (treesit-node-match-p (treesit-node-at (point)) = 'comment t) > + (funcall #'forward-sexp-default-function arg) > + t) > + (if (> arg 0) > (treesit-end-of-thing pred (abs arg) 'restricted) > (treesit-beginning-of-thing pred (abs arg) 'restricted)) > ;; If we couldn't move, we should signal an error and report > diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el > index 4b722b4e9a7..d3c3bf55de3 100644 > --- a/lisp/emacs-lisp/lisp.el > +++ b/lisp/emacs-lisp/lisp.el > @@ -45,7 +45,12 @@ parens-require-spaces > :type 'boolean > :group 'lisp) >=20 > -(defvar forward-sexp-function nil > +(defun forward-sexp-default-function (&optional arg) > + "Default function for `forward-sexp-function'." > + (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) > + (if (< arg 0) (backward-prefix-chars))) > + > +(defvar forward-sexp-function #'forward-sexp-default-function > ;; FIXME: > ;; - for some uses, we may want a "sexp-only" version, which only > ;; jumps over a well-formed sexp, rather than some dwimish thing > @@ -74,10 +79,7 @@ forward-sexp > "No next sexp" > "No previous sexp")))) > (or arg (setq arg 1)) > - (if forward-sexp-function > - (funcall forward-sexp-function arg) > - (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) > - (if (< arg 0) (backward-prefix-chars))))) > + (funcall forward-sexp-function arg))) >=20 > (defun backward-sexp (&optional arg interactive) > "Move backward across one balanced expression (sexp). >=20 > Maybe the node type 'comment' is not the best name, > but it was intended to allow using the default function > to be able to move with 'M-C-f' in the comments and strings > there tree-sitter has no information. >=20 > It makes sense to support the default movement with 'M-C-f' > in the comments and strings of all ts modes. The second patch > shows how this could be achieved by adding the default > 'comment' match to 'treesit-thing-settings' of all modes. > Or maybe this should be customizable? I think treesit-thing-settings is something we want to left for major = mode=E2=80=99s to set. They=E2=80=99ll need to define other =E2=80=9Cthing= s=E2=80=9D in treesit-thing-settings anyway. Sure, it=E2=80=99s nice if = we can set a few definitions automatically, but I don=E2=80=99t think = the gain is worth that much; OTOH, it=E2=80=99s nice to have clear = boundaries, and minimizes the possibility of confusion. >=20 > diff --git a/lisp/treesit.el b/lisp/treesit.el > index 82b2f97b4a5..284c4915f3a 100644 > --- a/lisp/treesit.el > +++ b/lisp/treesit.el > @@ -3054,6 +3057,18 @@ treesit-major-mode-setup > (setq-local outline-search-function #'treesit-outline-search > outline-level #'treesit-outline-level)) >=20 > + (dolist (parser (treesit-parser-list)) > + (let ((language (treesit-parser-language parser)) > + (comment (regexp-opt '("comment" "string" = "string_content")))) > + (unless (treesit-thing-defined-p 'comment language) > + (if-let ((l (alist-get language treesit-thing-settings))) > + (progn > + (setf (alist-get 'comment l) (list comment)) > + (setf (alist-get language treesit-thing-settings) l)) > + (setq-local treesit-thing-settings > + (append `((,language (comment ,comment))) > + treesit-thing-settings)))))) > + > ;; Remove existing local parsers. > (dolist (ov (overlays-in (point-min) (point-max))) > (when-let ((parser (overlay-get ov 'treesit-parser))) >=20 > The third patch demonstrates how it's possible to close bug#67036 > that was impossible to fix without more general changes in treesit.el. >=20 > The problem is that e.g. Ruby parser to such text: >=20 > hash[:key] >=20 > produces such syntax tree: >=20 > (element_reference object: (identifier) [ (simple_symbol) ]) >=20 > so when point is on [ then 'M-C-f' can't move to ]. >=20 > This is fixed now by the third patch: >=20 > diff --git a/lisp/progmodes/ruby-ts-mode.el = b/lisp/progmodes/ruby-ts-mode.el > index 598eaa461ff..4d0ae2e9303 100644 > --- a/lisp/progmodes/ruby-ts-mode.el > +++ b/lisp/progmodes/ruby-ts-mode.el > @@ -1170,7 +1170,20 @@ ruby-ts-mode > "global_variable" > ) > eol) > - #'ruby-ts--sexp-p))))) > + #'ruby-ts--sexp-p)) > + (comment ,(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")))))))) >=20 > ;; AFAIK, Ruby can not nest methods > (setq-local treesit-defun-prefer-top-level nil) IIUC, this doesn=E2=80=99t look like a good idea: you don=E2=80=99t want = to mark something that=E2=80=99s not comment as comment. In the future, = other packages will start using these thing definitions, and I=E2=80=99m = sure you don=E2=80=99t want them consider regular code as comments. For the specific problem you described, maybe the change made in #68899 = can help? Yuan=
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 12 Feb 2024 01:28:42 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 11 20:28:42 2024 Received: from localhost ([127.0.0.1]:39062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rZL7h-0006qL-OR for submit <at> debbugs.gnu.org; Sun, 11 Feb 2024 20:28:42 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:48186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1rZL7e-0006pj-7v for 68993 <at> debbugs.gnu.org; Sun, 11 Feb 2024 20:28:39 -0500 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5d81b08d6f2so2131429a12.0 for <68993 <at> debbugs.gnu.org>; Sun, 11 Feb 2024 17:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707701296; x=1708306096; 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=V6hR1PPryX0Aj8lCOQ87tHuNZtozxg0zCmQN850w+Ec=; b=LZOGFKHMLKViEWL/I9YEOo8PRRvpjAxk8Fnw8CCTXhxkfS+Ruo/YmTQeK7tRuF31X9 j5LEpMgbSn+C1R59oqi+ODsGnwCTK8pcd0A0qkp+F7xI00WgK+/dBWoAbhBL/bE3YYSC 0q4dYf2Pw//x8CyGzWIlOZOGKgWT3OhpoLEv7sLfTQA0240LSyVDa56WYvA1G163iGBm 2/fGEG5TVRXpYG8RdS5WwJag8CENmXTTFKnLOyIguS2AnBvXLE07c0p+J7Of83c8LMOQ yYOhoKg7rxVi6TDabiTXnoIkCjy9AkPNC8DW/xi0k3Ra6t7alb5E6F4/IMx3whLayv2n LXoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707701296; x=1708306096; 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=V6hR1PPryX0Aj8lCOQ87tHuNZtozxg0zCmQN850w+Ec=; b=Jqmk1ncCAxXBmlSW9xQJSUqkIggVJbOvYLKmViYktkdLf2keJ3g7qBRXpUu2oeJstL Pp/zaRVBFN4lpm3VYArHZkHsys7pCcDFqRIDdFunuMQM4K/0QDCfGTYF68jbiCiOStAk xWBcgQX3PgZ70EGhTgUOYLFsy/Ei2+FYMvHL1qLNHmAJatm0M32ZggELW7XIANKGkBkh d/PUstX5vdMynvoNtkuDt97kHvYyvlnCMiTHGt8Vf+ocdq0zfQcTfJhk3jZYrkNwxOfP befu9wpjORCtKhjyAhM1if3H5cdHt4E0BY4zya1aDzeAT3/s3O3BtxlSDS2ZX6G2N5wl PPDg== X-Gm-Message-State: AOJu0YxEsDcXbaY3llOTqQvazLBX7JPj+0NfsRblKzZzk0h2BJdTcxtw 3/TzXF1O6/jCjO2uUBxP+2CY1LCNmnJU1FKQPQFChb+SvySXbm0EPBX/LGqb X-Google-Smtp-Source: AGHT+IFAyuh730tzSC0e+dxwkMBAuazk3n5g2so3NAbVM0bE6O8uxKhHeFvU9OGRQqGglFWmb982Ww== X-Received: by 2002:a05:6a20:2d1e:b0:1a0:56c9:609d with SMTP id g30-20020a056a202d1e00b001a056c9609dmr931591pzl.25.1707701295741; Sun, 11 Feb 2024 17:28:15 -0800 (PST) Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id z5-20020aa79e45000000b006dd6c439996sm4271102pfq.161.2024.02.11.17.28.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2024 17:28:15 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#68993: treesitter support for forward-sexp-default-function From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <86a5o86wl5.fsf@HIDDEN> Date: Sun, 11 Feb 2024 17:28:03 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <12153B04-8B7E-43D4-8EC4-8931021F1965@HIDDEN> References: <86y1bv6jsm.fsf@HIDDEN> <86a5o86wl5.fsf@HIDDEN> To: Juri Linkov <juri@HIDDEN> X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Feb 10, 2024, at 9:46 AM, Juri Linkov <juri@HIDDEN> wrote: >=20 > Hi Yuan, >=20 > Do you think 'comment' is a suitable name for 'treesit-forward-sexp'? > I'm unsure even if 'text' is a good name for = 'treesit-forward-sentence'. > But at least these two should be consistent with each another. >=20 > Maybe better to add the prefix 'default-' to both? > This will hint that the default function is used. >=20 > Then 'treesit-forward-sentence' will support types > 'sentence' and 'default-sentence'. > And 'treesit-forward-sexp' will support types > 'sexp' and 'default-sexp'. First there=E2=80=99s the =E2=80=9Ctext=E2=80=9D definition, then = treesit-forward-sentence uses it as a heuristic to get better results in = comments and strings, rather than the other way around. So for me it = doesn=E2=80=99t make much sense to say if =E2=80=9Ctext=E2=80=9D is good = or bad name for treesit-forward-sentence=E2=80=94it=E2=80=99s not for = treesit-forward-sentence to start with. My suggestion would be for both treesit-forward-sentence and -sexp to = use =E2=80=9Ctext=E2=80=9D for their heuristic. If someone wants more = customized behavior, they can always write a custom = forward-sentence/sexp function. Yuan=
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at 68993) by debbugs.gnu.org; 10 Feb 2024 17:49:41 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 10 12:49:41 2024 Received: from localhost ([127.0.0.1]:57738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rYrTx-0006P0-8x for submit <at> debbugs.gnu.org; Sat, 10 Feb 2024 12:49:41 -0500 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]:53363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rYrTu-0006OZ-Tn for 68993 <at> debbugs.gnu.org; Sat, 10 Feb 2024 12:49:39 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id D8E9DFF803; Sat, 10 Feb 2024 17:49:15 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#68993: treesitter support for forward-sexp-default-function In-Reply-To: <86y1bv6jsm.fsf@HIDDEN> (Juri Linkov's message of "Thu, 08 Feb 2024 19:38:17 +0200") Organization: LINKOV.NET References: <86y1bv6jsm.fsf@HIDDEN> Date: Sat, 10 Feb 2024 19:46:46 +0200 Message-ID: <86a5o86wl5.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68993 Cc: 68993 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Hi Yuan, Do you think 'comment' is a suitable name for 'treesit-forward-sexp'? I'm unsure even if 'text' is a good name for 'treesit-forward-sentence'. But at least these two should be consistent with each another. Maybe better to add the prefix 'default-' to both? This will hint that the default function is used. Then 'treesit-forward-sentence' will support types 'sentence' and 'default-sentence'. And 'treesit-forward-sexp' will support types 'sexp' and 'default-sexp'. > @@ -2137,7 +2137,10 @@ treesit-forward-sexp > (interactive "^p") > (let ((arg (or arg 1)) > (pred (or treesit-sexp-type-regexp 'sexp))) > - (or (if (> arg 0) > + (or (when (treesit-node-match-p (treesit-node-at (point)) 'comment t) > + (funcall #'forward-sexp-default-function arg) > + t) > + (if (> arg 0) > (treesit-end-of-thing pred (abs arg) 'restricted) > (treesit-beginning-of-thing pred (abs arg) 'restricted)) > ;; If we couldn't move, we should signal an error and report
bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 8 Feb 2024 17:41:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 08 12:41:10 2024 Received: from localhost ([127.0.0.1]:33557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rY8Ob-0004Go-LN for submit <at> debbugs.gnu.org; Thu, 08 Feb 2024 12:41:10 -0500 Received: from lists.gnu.org ([2001:470:142::17]:33500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rY8OV-0004Fu-Vm for submit <at> debbugs.gnu.org; Thu, 08 Feb 2024 12:41:08 -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 <juri@HIDDEN>) id 1rY8OB-0002D8-P9 for bug-gnu-emacs@HIDDEN; Thu, 08 Feb 2024 12:40:43 -0500 Received: from relay6-d.mail.gandi.net ([2001:4b98:dc4:8::226]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1rY8O8-0000Hd-TG for bug-gnu-emacs@HIDDEN; Thu, 08 Feb 2024 12:40:43 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id AC334C0002 for <bug-gnu-emacs@HIDDEN>; Thu, 8 Feb 2024 17:40:36 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: treesitter support for forward-sexp-default-function Organization: LINKOV.NET X-Debbugs-Cc: Yuan Fu <casouri@HIDDEN> Date: Thu, 08 Feb 2024 19:38:17 +0200 Message-ID: <86y1bv6jsm.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: juri@HIDDEN Received-SPF: pass client-ip=2001:4b98:dc4:8::226; envelope-from=juri@HIDDEN; helo=relay6-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.4 (/) --=-=-= Content-Type: text/plain 'treesit-forward-sentence' supports the node type 'text', and for matching nodes it uses the fallback to 'forward-sentence-default-function'. This patch does exactly the same for 'treesit-forward-sexp': for nodes that match a new node type 'comment', it uses the fallback to the new function 'forward-sexp-default-function'. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=forward-sexp-default-function.patch diff --git a/lisp/treesit.el b/lisp/treesit.el index 82b2f97b4a5..284c4915f3a 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2137,7 +2137,10 @@ treesit-forward-sexp (interactive "^p") (let ((arg (or arg 1)) (pred (or treesit-sexp-type-regexp 'sexp))) - (or (if (> arg 0) + (or (when (treesit-node-match-p (treesit-node-at (point)) 'comment t) + (funcall #'forward-sexp-default-function arg) + t) + (if (> arg 0) (treesit-end-of-thing pred (abs arg) 'restricted) (treesit-beginning-of-thing pred (abs arg) 'restricted)) ;; If we couldn't move, we should signal an error and report diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 4b722b4e9a7..d3c3bf55de3 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -45,7 +45,12 @@ parens-require-spaces :type 'boolean :group 'lisp) -(defvar forward-sexp-function nil +(defun forward-sexp-default-function (&optional arg) + "Default function for `forward-sexp-function'." + (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) + (if (< arg 0) (backward-prefix-chars))) + +(defvar forward-sexp-function #'forward-sexp-default-function ;; FIXME: ;; - for some uses, we may want a "sexp-only" version, which only ;; jumps over a well-formed sexp, rather than some dwimish thing @@ -74,10 +79,7 @@ forward-sexp "No next sexp" "No previous sexp")))) (or arg (setq arg 1)) - (if forward-sexp-function - (funcall forward-sexp-function arg) - (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) - (if (< arg 0) (backward-prefix-chars))))) + (funcall forward-sexp-function arg))) (defun backward-sexp (&optional arg interactive) "Move backward across one balanced expression (sexp). --=-=-= Content-Type: text/plain Maybe the node type 'comment' is not the best name, but it was intended to allow using the default function to be able to move with 'M-C-f' in the comments and strings there tree-sitter has no information. It makes sense to support the default movement with 'M-C-f' in the comments and strings of all ts modes. The second patch shows how this could be achieved by adding the default 'comment' match to 'treesit-thing-settings' of all modes. Or maybe this should be customizable? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=treesit-major-mode-setup.patch diff --git a/lisp/treesit.el b/lisp/treesit.el index 82b2f97b4a5..284c4915f3a 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3054,6 +3057,18 @@ treesit-major-mode-setup (setq-local outline-search-function #'treesit-outline-search outline-level #'treesit-outline-level)) + (dolist (parser (treesit-parser-list)) + (let ((language (treesit-parser-language parser)) + (comment (regexp-opt '("comment" "string" "string_content")))) + (unless (treesit-thing-defined-p 'comment language) + (if-let ((l (alist-get language treesit-thing-settings))) + (progn + (setf (alist-get 'comment l) (list comment)) + (setf (alist-get language treesit-thing-settings) l)) + (setq-local treesit-thing-settings + (append `((,language (comment ,comment))) + treesit-thing-settings)))))) + ;; Remove existing local parsers. (dolist (ov (overlays-in (point-min) (point-max))) (when-let ((parser (overlay-get ov 'treesit-parser))) --=-=-= Content-Type: text/plain The third patch demonstrates how it's possible to close bug#67036 that was impossible to fix without more general changes in treesit.el. The problem is that e.g. Ruby parser to such text: hash[:key] produces such syntax tree: (element_reference object: (identifier) [ (simple_symbol) ]) so when point is on [ then 'M-C-f' can't move to ]. This is fixed now by the third patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=ruby-ts-mode.patch diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 598eaa461ff..4d0ae2e9303 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1170,7 +1170,20 @@ ruby-ts-mode "global_variable" ) eol) - #'ruby-ts--sexp-p))))) + #'ruby-ts--sexp-p)) + (comment ,(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) --=-=-=--
Juri Linkov <juri@HIDDEN>
:casouri@HIDDEN, bug-gnu-emacs@HIDDEN
.
Full text available.casouri@HIDDEN, bug-gnu-emacs@HIDDEN
:bug#68993
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.