From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59788: 29.0.60; [PATCH] Make treesit-end-of-defun handle nil node Date: Fri, 02 Dec 2022 21:45:59 +0100 Message-ID: <87h6ydfsag.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26397"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, eliz@gnu.org To: 59788@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 21:47:17 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1CwF-0006ap-MV for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 21:47:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1Cw4-0000bT-UQ; Fri, 02 Dec 2022 15:47:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1Cw3-0000bC-9b for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 15:47:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1Cw3-0007yf-1C; Fri, 02 Dec 2022 15:47:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1Cw2-00017M-Ke; Fri, 02 Dec 2022 15:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: casouri@gmail.com, eliz@gnu.org, bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59788 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: casouri@gmail.com, eliz@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16700139754280 (code B ref -1); Fri, 02 Dec 2022 20:47:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Dec 2022 20:46:15 +0000 Original-Received: from localhost ([127.0.0.1]:48772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1CvG-00016y-NF for submit@debbugs.gnu.org; Fri, 02 Dec 2022 15:46:15 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:34014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1CvA-00016s-P2 for submit@debbugs.gnu.org; Fri, 02 Dec 2022 15:46:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1CvA-0000FS-Fa for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 15:46:08 -0500 Original-Received: from out-82.mta0.migadu.com ([2001:41d0:1004:224b::52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1Cv5-0007o5-Jx for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 15:46:08 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670013960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=e9EVCIhLAhMp3K01lnSaIjeHHdPBGYhmZWmIuxXWlcg=; b=HzEOOs4i+TNruBLwxIUL/UnNneuqOb7qBAGT4hSMrioSpMhsYtowH3SjZLXx+YzsJOn6ZH wLhyHTtzuSM9e/zqfIJdJnO8ke0JKbBQAQliXzaJnOcw25UaLuU4nZXaC6NKE5K94PGO1M Gc/RJCggLN+4kD0KqyVy1blw9d4cc0wYLy0jOVJHuUpJ56QRAgyL+X+rWwEpFU4sUWYZ/4 y5M4Jj+a835ASwXAVAxF81YkzR7xZ8yEMUBkhXxmVnRb/cDVRseVZUQ+dDSDdJ3mDA73nw NQHUMslg/YBE5mtM7vuNIv/QNDAnL8PBrW7cTOmeuBfnO1lqKq28wPMqfdbKIw== X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::52; envelope-from=theo@thornhill.no; helo=out-82.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249785 Archived-At: --=-=-= Content-Type: text/plain Hi Eli, Yuan and others, mark-defun errors when node is missing in the call to goto-char. Repro: emacs -Q find-file xdisp.c M-g M-g 450 RET M-x mark-defun Observe that emacs is erroring. This patch fixes this bug. However, I notice that treesit-beginning-of-defun returns t after it is done. Is there a reason for end-of-defun not to return the same? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-treesit-end-of-defun-handle-nil-node.patch >From 5e85e6e23f6dde43fc6433bed819c6d9f827007c Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 2 Dec 2022 21:40:50 +0100 Subject: [PATCH] Make treesit-end-of-defun handle nil node * lisp/treesit.el (treesit-end-of-defun): Change from 'let*' to 'when-let*'. --- lisp/treesit.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 0de0e283c3..e0949d7328 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1611,9 +1611,9 @@ treesit-end-of-defun "Tree-sitter `end-of-defun' function." ;; Why not simply get the largest node at point: when point is at ;; (point-min), that gives us the root node. - (let* ((node (treesit-search-forward - (treesit-node-at (point)) treesit-defun-type-regexp t t)) - (top (treesit--defun-maybe-top-level node))) + (when-let* ((node (treesit-search-forward + (treesit-node-at (point)) treesit-defun-type-regexp t t)) + (top (treesit--defun-maybe-top-level node))) (goto-char (treesit-node-end top)))) ;;; Activating tree-sitter -- 2.34.1 --=-=-=--