From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Date: Thu, 27 Apr 2023 11:57:55 +0300 Message-ID: <836bfacd-91ce-c138-71d9-3290d7a36e2b@gutov.dev> References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> <83fs8s2xnk.fsf@gnu.org> <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> <384f8110-eba6-8fb3-ef4e-56fa0721d85d@gutov.dev> <90E66143-A3E2-4B76-AC0A-01DC5E841AFE@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34960"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Cc: Eli Zaretskii , 62951@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 27 10:59:24 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 1prxTH-0008s1-Pe for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Apr 2023 10:59:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prxSy-00068I-Je; Thu, 27 Apr 2023 04:59:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prxSw-00067j-UM for bug-gnu-emacs@gnu.org; Thu, 27 Apr 2023 04:59:03 -0400 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 1prxSw-0007FC-Ma for bug-gnu-emacs@gnu.org; Thu, 27 Apr 2023 04:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1prxSw-0007Kv-Bb for bug-gnu-emacs@gnu.org; Thu, 27 Apr 2023 04:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Apr 2023 08:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62951 X-GNU-PR-Package: emacs Original-Received: via spool by 62951-submit@debbugs.gnu.org id=B62951.168258588628137 (code B ref 62951); Thu, 27 Apr 2023 08:59:02 +0000 Original-Received: (at 62951) by debbugs.gnu.org; 27 Apr 2023 08:58:06 +0000 Original-Received: from localhost ([127.0.0.1]:57548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prxS2-0007Jk-2A for submit@debbugs.gnu.org; Thu, 27 Apr 2023 04:58:06 -0400 Original-Received: from new3-smtp.messagingengine.com ([66.111.4.229]:46003) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prxRz-0007JG-V2 for 62951@debbugs.gnu.org; Thu, 27 Apr 2023 04:58:05 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 98ADF582343; Thu, 27 Apr 2023 04:57:58 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 27 Apr 2023 04:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1682585878; x=1682589478; bh=WC7lQMygfOvY564/zxVMIFTAmRD2P1FrJ1f BQ67IEZc=; b=TD46takMCJQv2X5L6392eL4r3n9Uy0xoISO2EYB173FT1yRJhj5 udXdR6OhBlngvmZMj7WP/xUMxYFyFfAfv2EifrL3DiAvX2mbMtdxCvLuDgMoa5EA W30UDeNhcqtilnzMTOA/V88vQRZIvKFsIDKfzQLGoKFlt7KbARfHUfoC9oGm9PKp ktdONda7O4XMX3qAnjiDjuzKAA1nqL8n7Ngo0D/dvU6veeVWlzJ6kg0Qk1knXZfF +9dvyj30gSLEL7a7Y8aZjnJSs79lIuhht0jOLCUtvJ3fVvIzEUi7DTHtOhHWh+R2 MhmE6X+aoXJOp3th9D3z2STIWOcJ2rKZZow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1682585878; x=1682589478; bh=WC7lQMygfOvY564/zxVMIFTAmRD2P1FrJ1f BQ67IEZc=; b=VHV2OsxxtKpNvU87HdDFgwexhgmKQgJrHWvlWJxRabtBQjlzLa9 pC0kaoCk/Tk1O/jG92tHvFlNe82R+k994g9OESoZLUZJipBhZ5OzmCtDN4llojAP tubwWY5ov935IxCXQmMC3p6qwlzI8cjQ81Hbo13UlYdgL2j6FuI/OxQb5XmA1R+s yy69U3HoPiSpUinXcVU5lVQMhZZiUUFniRmOP7Sygc0xOt8Uu4Sr0yC57Sl54SHH nSgLSZGS7edZkPdUItXohJ5ZZOUKI6t+atnozWn7SIFGrarxznMkCN6xAkzf+MWq 0mQGqbzMEeyvx++Rw3nZtPMfa5xjmnTG1yw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeduiedguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepkeejudelveeutdfhlefhieehteduveetuedthfdtfeffjefhuefgffdvteet fedvnecuffhomhgrihhnpegvlhdrihhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Apr 2023 04:57:57 -0400 (EDT) Content-Language: en-US In-Reply-To: <90E66143-A3E2-4B76-AC0A-01DC5E841AFE@gmail.com> 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:260709 Archived-At: On 27/04/2023 01:19, Yuan Fu wrote: > > >> On Apr 23, 2023, at 2:04 PM, Dmitry Gutov wrote: >> >> On 23/04/2023 03:28, Yuan Fu wrote: >>> What do you think of extending the parser to support these macros instead? (So we fork tree-sitter-c.) If we can fix the parser, we don’t need to retrofit hacks onto font-lock, indent, etc, separately, and it truly fixes the problem. The downside is compiling from grammar source to grammar.c needs rust and node tools. But I guess depending on the grammar maintained by tree-sitter’s author isn’t too much different from depending on the grammar maintained by another individual (ie, me)? >> >> We had also talked at some point about replacing the actual text that the parser sees with something else. >> >> If this can be done in a straightforward way (with tracking the subsequent correspondence of "real" text back to the buffer for syntax highlighting), that might be the perfect solution: we'd have a defcustom which would hold a list of macros used in the current codebase in the form of templates, and we'd set a bunch of them in emacs/.dir-locals.el. >> >> I'm not sure how difficult this is to implement and maintain, but it's probably going to be less work to maintain than a fork of the grammar. > > Sounds to me a bit difficult to write. Eg, translating between tree-sitter position and buffer position efficiently isn’t too easy. Now plus narrowing, and what if the narrowing boundary is in the middle of a replace region? When the match isn't full, the replacement wouldn't be performed. Same as with macro name that isn't fully typed out yet. Yeah, it does seem like a lot of work, but the result might be that everybody's macros could be supported. I'm definitely not volunteering, though, so please take this as just a suggestion. > My idea right now is to use the range feature in tree-sitter. Since the “body” of FOR_EACH_TAIL is valid C, I can either set the ranges for the parser so it ignores FOR_EACH_TAIL, or I can add another parser that only parses the body of FOR_EACH_TAIL. Sounds good. Especially for Emacs 29 (maybe).