From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mickey Petersen Newsgroups: gmane.emacs.bugs Subject: bug#61235: 30.0.50; tree-sit: `treesit-node-check' lacks a way to tell if a node belongs to a deleted parser Date: Mon, 06 Feb 2023 12:35:20 +0000 Organization: Mastering Emacs Message-ID: <87o7q7dl4o.fsf@masteringemacs.org> References: <83edr3q8ez.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13513"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e @VERSION@; emacs 30.0.50 Cc: Yuan Fu , 61235@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 06 13:40:06 2023 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 1pP0mz-0003MB-0V for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Feb 2023 13:40:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pP0mZ-0006Xa-8d; Mon, 06 Feb 2023 07:39:39 -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 1pP0m8-0006Sq-BY for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 07:39:16 -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 1pP0ly-0001lO-Ms for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 07:39:06 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pP0ly-00067R-Ho for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 07:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mickey Petersen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Feb 2023 12:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61235 X-GNU-PR-Package: emacs Original-Received: via spool by 61235-submit@debbugs.gnu.org id=B61235.167568713323497 (code B ref 61235); Mon, 06 Feb 2023 12:39:02 +0000 Original-Received: (at 61235) by debbugs.gnu.org; 6 Feb 2023 12:38:53 +0000 Original-Received: from localhost ([127.0.0.1]:47543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP0lg-00066k-3S for submit@debbugs.gnu.org; Mon, 06 Feb 2023 07:38:52 -0500 Original-Received: from mail-vi1eur05on2108.outbound.protection.outlook.com ([40.107.21.108]:26081 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP0le-00066R-9c for 61235@debbugs.gnu.org; Mon, 06 Feb 2023 07:38:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOCJwuDzECu4kB2s7rU3toOcDwLIj5BqWVhYBSOej0GdX39ST2s4NLJrKG5MZsbasWUxspNji6FWA/dY56LRdpIwUdGkPZtE2RiEYJGE1Kj7Y6GLRZFQkJt4rgjAET/3HD6vvRy747K81Ec6lvwXp4/hJBWdA2g0Rht0Hru0Jmjl+IA6MGV7dS29yCqFtjx0+9Fb4fg/rpKM24DV1wXfSLt2zK0bijKg71fbl+ecA9Kf25MGL3cLweYmk5CihULwGLLmNwbesp81ol4LL91Wlmol0Ez0cI22f1x2aFtEg+L0iPHpOt+N91sYaAgFT9vC4khDGEgPmrZKbXU1HEouxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8SDH/8NKfGvG8E9SbwmbACDJI5JLajHe5jDOij5mUv4=; b=cLrCGUR7czBmaGK9eLid/Nq8SdVhjkoXijXFj32LS2jZh7E4QxNAPWj5ivgH9JqpA8ppEc6Dtr6im3R9Pgxobp7IeZ2JypKvkuXYpRyTaFfut97gLTFcdM4pcBKEg+RaQA1bDTsLfKRteFphQSJ/qmXlgzQQv/S5KHYRphHICJyJ9+avKW84PEwjsEBuM5OYKYiT+MeWE3rs8CAUMljXG8ueu9qVjm4YrIX042BhET2y2NR/2+YcVhOQunoEENw2kqP/xllN8af/yUlPW2PeDmujQCWLR85YHJWCJKor8y40BWD+iOaPhVS2ep9fh/oiPmzW6nwn9KURIf8oO6vvyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=debbugs.gnu.org smtp.mailfrom=masteringemacs.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8SDH/8NKfGvG8E9SbwmbACDJI5JLajHe5jDOij5mUv4=; b=ngqtFB+WnCa1Dcj4+l4Btr2H9dolknonICjuW0Rb0zNWb0SqzYCrAG8TqWzGVRVjABVLOYx6SsrvKmpxxCrwPN1DVRe97rg5HCNV3TzovzrGCa6z7sQigKSI/fJkPBHjwhbCn7RZnPRTobUGwchybdJIkzwf5xLVhiK5MMPzIzY= Original-Received: from LO4P123CA0247.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::18) by LO3P265MB2092.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:103::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 12:38:35 +0000 Original-Received: from CWLGBR01FT021.eop-gbr01.prod.protection.outlook.com (2603:10a6:600:1a7:cafe::eb) by LO4P123CA0247.outlook.office365.com (2603:10a6:600:1a7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 12:38:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org;dmarc=pass action=none header.from=masteringemacs.org; Received-SPF: Pass (protection.outlook.com: domain of masteringemacs.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Original-Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT021.mail.protection.outlook.com (10.152.40.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 12:38:35 +0000 Original-Received: by semantical.co.uk (Postfix, from userid 5001) id 173D9114002; Mon, 6 Feb 2023 12:38:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=masteringemacs.org; s=masteringemacs.org; t=1675687115; bh=GwjubfLwWl5n4m2vSVplInNKY9b+oVOSeQJ962oaVjY=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=n98eJqbHBW/0T3FBCn6ZCK+6oH9awWQGmXFjfynuohse6owUGh2cjAUVTjswskCmt ACqXzwFUGpO5/qEUBsJh0Ez61LiHlKgO2Ubwo6iNConjp2XlXMyINpyIFY7xB5HllQ 73SUc8eHdVCIHh8Cze5YuvvjWdKvjjjg5QmYtd80= In-reply-to: <83edr3q8ez.fsf@gnu.org> X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT021:EE_|LO3P265MB2092:EE_ X-MS-Office365-Filtering-Correlation-Id: e039b944-ce63-458c-fb34-08db083f1056 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1aa/v67kpbj991WUxGH9CukWBXXeIJFgan989578Ui33m7CNMzokQbUncOEvP2JZMWhwR9CKzSu7TRdCV24lkzgdIl4KKO9opwoh8jf3JglWBnHTiGyDlkbGZQwUV/dbtl13KiEgbzmQERQ9QxGFixyePpkqE9Eg/pi+hm8OTmGaB1NJB2mGJ6zAwOvXRbPuR6PjiWevz0c+DLsa9LAGJ75LPkijWzrFRX1z7Ef9dzTVjzog/qj9QDQS20vNdHTcXSX817IF1w0VotlC8DpUaYGzimRcvROM6I8obHC1L0vKO+/pEJvnBF3ujr3eNVK//B9zznC+H3+lUMUKHD4ejK3AW6EgyZors12KnpygoO8tnps7U0wPKSomHxR64dsSBU5mR5A+E23FL5X29/CajaeWKUKVG5aiksaipp1hI2j7cgKnrxjGqqGZ+ucHZPjVGnRnAUZG0xL6Cn2WToYGLh79ekrdQf4iEy4FvUq33GHoG2BbpfpiIE61JRTClVhPewZUwF0rH8WLFjH4rmzFj0oo2MrdclePelEEtY1JYOuV/scyAhkX++HU3OaoqgCXZyoZLj/kpBqnxr97YLftd+VfKNCVIeU5iSnE8/k92fnAg60sBD0NgX2eySNuHgsTiRCaVFl9rZSU2VGbvQk6VA0wK2YV/wy3P++u7nd8A0ulxI+/uuj13QH0S5Gl/ZphGky0KHRpKQ14PVfBN0Qyy5f50W4yIpJg5bBJAOQG7O2eYqX8bN6J9+Q3SYGDv OGb5b6RUrG3dDWIYJtm5g7tCHETeLt7Ua5s7KtAWHp+ByB3RbeeZfH0mlfTp2JeINLC X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230025)(136003)(376002)(39830400003)(346002)(396003)(451199018)(46966006)(36840700001)(6266002)(478600001)(36916002)(42186006)(316002)(186003)(2616005)(6666004)(26005)(82310400005)(36756003)(5660300002)(86362001)(40480700001)(7636003)(7596003)(83380400001)(336012)(47076005)(70206006)(4326008)(8676002)(2906002)(70586007)(356005)(8936002)(36860700001)(41300700001)(6862004)(38230200001)(81973001)(43043002)(14776008)(79816003); DIR:OUT; SFP:1102; X-OriginatorOrg: masteringemacs.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 12:38:35.2529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e039b944-ce63-458c-fb34-08db083f1056 X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT021.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO3P265MB2092 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:254954 Archived-At: Eli Zaretskii writes: >> From: Yuan Fu >> Date: Sun, 5 Feb 2023 20:24:27 -0800 >> Cc: 61235@debbugs.gnu.org, >> Eli Zaretskii >> >> Mickey Petersen writes: >> >> > There's no way to tell if a node belongs to a now-deleted >> > parser. Checking if it is `missing' or `outdated' returns nil; there >> > is no way to ascertain this state except by catching an error if you >> > try to get its node text, type, etc. >> >> That sounds reasonable. I can add treesit-parser-live-p, and add >> a "live" PROPERTY to treesit-node-check. > > I'm not sure I understand the need. AFAIU, a parser is deleted only > if we call treesit-parser-delete; are we saying that a Lisp program > doesn't know that it deleted a parser? What exactly is the practical > situation where this problem happens, and why? > > Frankly, I don't think we should at this stage add APIs without a very > good reason. We should instead collect experience, both from users > and from Lisp programs, and analyze them before deciding whether more > APIs are necessary. > Because node references are retained even after a parser is deleted. Retrieving a node; somehow deleting the parser (maybe you closed the buffer, or you were doing some off-hand parsing); and then doing _anything_ with the aforementioned node yields an error for which there is no way to test for. This is particularly the case when you mix and match parsers in the same buffer. >> +DEFUN ("treesit-parser-live-p", >> + Ftreesit_parser_live_p, Streesit_parser_live_p, 1, 1, 0, >> + doc: /* Check whether PARSER is not deleted and its buffer is live. */) >> + (Lisp_Object parser) >> +{ >> + treesit_check_parser (parser); >> + if (XTS_PARSER (parser)->deleted) >> + return Qnil; >> + else if (NILP (Fbuffer_live_p (XTS_PARSER (parser)->buffer))) >> + return Qnil; >> + else >> + return Qt; >> +} > > Doesn't treesit_check_parser signal an error if the parser was > deleted? If so, how will the above be useful, if someone wants to > avoid errors?