From unknown Mon Jun 23 04:09:35 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#62951 <62951@debbugs.gnu.org> To: bug#62951 <62951@debbugs.gnu.org> Subject: Status: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Reply-To: bug#62951 <62951@debbugs.gnu.org> Date: Mon, 23 Jun 2025 11:09:35 +0000 retitle 62951 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_T= AIL_SAFE reassign 62951 emacs submitter 62951 Eli Zaretskii severity 62951 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 19 12:40:44 2023 Received: (at submit) by debbugs.gnu.org; 19 Apr 2023 16:40:44 +0000 Received: from localhost ([127.0.0.1]:35674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppArM-0001NL-A5 for submit@debbugs.gnu.org; Wed, 19 Apr 2023 12:40:44 -0400 Received: from lists.gnu.org ([209.51.188.17]:49586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppArJ-0001NC-NR for submit@debbugs.gnu.org; Wed, 19 Apr 2023 12:40:43 -0400 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 1ppArJ-0006lV-Gw for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2023 12:40:41 -0400 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 1ppArJ-0007BR-8P for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2023 12:40:41 -0400 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=xArsqJfri4pK/RfOmiZVMmLaS2rg72d+HwDs3ECSqu4=; b=QkVch72/8thnOv m/L6+4kbS1D9tBMmeYPkdc4U6pPz4dsqWrdH++cj6AFpvRWJyHOBedy1JdnHrZx0FwyXh9pZsmFev 9W7RS6zYsxlKHM/f1eGKlfAmxEEgqKtgxXkF8Shrk37rPtKT7SXIFBRy2TbrfHJWhBOo2ElpZ4zKO L9dAnTe6Iaxc3wXKELumeP8Sb91A1Nysd+6u1xDNGyOMGl9uckQ2PovkF4aifARIXZpL4lVvy1iIY zkGx4Qd4tdEzRqqHs7Q4MOFGhj5N7VbddyibZIl7kbRjH1PWxP0ju/4jfx6dqIi0xbqrK8A4sbEfp 41sNWusOJ1jnJsciY85g==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppArI-0005Wq-Kx for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2023 12:40:41 -0400 Date: Wed, 19 Apr 2023 19:40:52 +0300 Message-Id: <83y1mn7rl7.fsf@gnu.org> From: Eli Zaretskii To: bug-gnu-emacs@gnu.org Subject: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE X-Spam-Score: -2.3 (--) 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: -3.3 (---) To reproduce: emacs -Q C-x C-f src/fns.c RET C-u 3365 M-g g Observe that "if" and "STRINGP" in the body of FOR_EACH_TAIL_SAFE are fontified in font-lock-function-name-face. This is because the FOR_EACH_TAIL_SAFE macro is misparsed by tree-sitter as a declaration. Can we teach c-ts-mode to recognize FOR_EACH_TAIL_SAFE and FOR_EACH_TAIL for what they are, perhaps conditioned on c-ts-mode-emacs-sources-support being non-nil? In GNU Emacs 29.0.90 (build 25, i686-pc-mingw32) of 2023-04-17 built on HOME-C4E4A596F7 Repository revision: 2f59595f5f4e86a791c425a6f9e2c1594d6813e4 Repository branch: emacs-29 Windowing system distributor 'Microsoft Corp.', version 5.1.2600 System Description: Microsoft Windows XP Service Pack 3 (v5.1.0.2600) Configured using: 'configure -C --prefix=/d/usr --with-wide-int --enable-checking=yes,glyphs 'CFLAGS=-O0 -gdwarf-4 -g3'' Configured features: ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON 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: cp1255 Major mode: C/* Minor modes in effect: 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 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 mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date subr-x pp wid-edit descr-text help-mode c-ts-mode c-ts-common treesit cl-seq vc-git diff-mode easy-mmode vc vc-dispatcher bug-reference byte-opt gv bytecomp byte-compile 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 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 make-network-process emacs) Memory information: ((conses 16 100876 13128) (symbols 48 10122 0) (strings 16 31511 2068) (string-bytes 1 995836) (vectors 16 17200) (vector-slots 8 233602 14782) (floats 8 43 173) (intervals 40 2885 151) (buffers 888 16)) From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 21 16:37:30 2023 Received: (at 62951) by debbugs.gnu.org; 21 Apr 2023 20:37:30 +0000 Received: from localhost ([127.0.0.1]:41248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppxVa-0004Lj-0E for submit@debbugs.gnu.org; Fri, 21 Apr 2023 16:37:30 -0400 Received: from mail-pl1-f176.google.com ([209.85.214.176]:51534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppxVW-0004LQ-8V for 62951@debbugs.gnu.org; Fri, 21 Apr 2023 16:37:29 -0400 Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1a6c5acf6ccso21265875ad.3 for <62951@debbugs.gnu.org>; Fri, 21 Apr 2023 13:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682109440; x=1684701440; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=D9WryCw91hUtex4VWdMeqkQiOipcgZPzYfYFuw9yZEg=; b=nJxS9f5L4VtM4IAoetPzh4V7cFSdNuBkz7ogOIDmdEd5VMrE3rRcxIYi3+jgI6MvZw qiQcwJIsqhZ+Fad+ZVkmAcQNU78iCwg6AfL/EKmxI63TBLllw5PfQ6tSytpxzFqltQ4N QsEA0MwE1Jezo94I+PkMglX325FUfGbkqnUBv3hvyzsZ34xM5+VddgTqbFP0K7Osw8xx ZiRRrf42GQv2O8POkpXywFTCwsyfYS9hr/sWROxP54t8msDB+HRkaSMaT7VKWesdoJZm gfkXRBaZyEYSy9rTHlTxx3c7bWhgi3mOPtMZZY5GSlNrYgvZ/0ZMss9x9MrIhHPH0V6W f0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682109440; x=1684701440; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D9WryCw91hUtex4VWdMeqkQiOipcgZPzYfYFuw9yZEg=; b=WtUUDno9toZGAYi3x6ETqUkRWQrzC+SAey6E+5cZiMrn7/I2M6LKKXx/FDJ88dl6CV 1vQi5HD1121cVMAffzWnIOaEF4fRpbhbdO0C1YQvQOMNCYyQIll5V/4MFGJBFFcbOLQL 3jmXvbhvuW8n6PrqxcqU7u/BdLAqubtCXJtUz99Fm75/BWNfiQ6EVm9yk5gY5XfTUa+8 n91KsSdQ9nDJx+V3JwMl29o0RkVIcZlx19INXKp3QJBwVwjE6FCIp6AXXI4w+EJRCy+w el8JlxFgGVVf5E51ORE7J+Z6SwHbTCNaIdU50uVLQVHT/a+Ag3qm4dAnpkkJJUSQGFpT IW0g== X-Gm-Message-State: AAQBX9e1FklUT4wo/v+thdxo/d3/DtJmrJs0V8gv2IUW3HlAjbFoQW7r WZ2UJvr2a0zklL1Shk0x9iM= X-Google-Smtp-Source: AKy350arbq03WRiP6SrCmF6ags0wyeQOo/6lD+QNkuYJjWqolC5CQzT+5uwf2n1uT96fL52c+LzNpw== X-Received: by 2002:a17:902:e892:b0:1a2:8c7e:f310 with SMTP id w18-20020a170902e89200b001a28c7ef310mr8376998plg.35.1682109440111; Fri, 21 Apr 2023 13:37:20 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id b5-20020a170902a9c500b001a6f6638595sm3077647plr.92.2023.04.21.13.37.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2023 13:37:19 -0700 (PDT) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Message-Id: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> Date: Fri, 21 Apr 2023 13:37:08 -0700 To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: 62951@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 (-) Eli Zaretskii writes: > To reproduce: > > emacs -Q > C-x C-f src/fns.c RET > C-u 3365 M-g g > > Observe that "if" and "STRINGP" in the body of FOR_EACH_TAIL_SAFE are > fontified in font-lock-function-name-face. This is because the > FOR_EACH_TAIL_SAFE macro is misparsed by tree-sitter as a declaration. > > Can we teach c-ts-mode to recognize FOR_EACH_TAIL_SAFE and > FOR_EACH_TAIL for what they are, perhaps conditioned on > c-ts-mode-emacs-sources-support being non-nil? I=E2=80=99m aware of this issue, but the truth is there isn=E2=80=99t a = good solution to it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix arbitrary code after it (hard). In this case it=E2=80=99s a if statement, with = macro calls and AND operation in it=E2=80=99s condition, it=E2=80=99s already three = things we need to recognize and somehow handle. It can also be a for loop, a switch case, a function call, a while loop. If we want to fix FOR_EACH_TAIL we would need to handle every possible thing, at that point we might as well have wrote a parser :-) We can probably fix this very particular case, but it=E2=80=99s still = work and overhead, and doesn=E2=80=99t mean much. Yuan From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 22 03:17:44 2023 Received: (at 62951) by debbugs.gnu.org; 22 Apr 2023 07:17:44 +0000 Received: from localhost ([127.0.0.1]:41585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pq7V9-0005np-Vr for submit@debbugs.gnu.org; Sat, 22 Apr 2023 03:17:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pq7V7-0005nR-G9 for 62951@debbugs.gnu.org; Sat, 22 Apr 2023 03:17:43 -0400 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 1pq7V2-0006iM-4K; Sat, 22 Apr 2023 03:17:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=8h2R99nYiL1NiDU1K82mENOASocpawu/VfQ0ziX/A6c=; b=N1hJQc24anejM9AqG/Yw +cSLg5lE85gGOHgndo3w5xANU3vGu0oXIlm+rNMZDZdqj+Ok7VY2X1y1N+Pzo8K9uOW0ELq85BTmw LdwU9R/YwkgvdmSr7djBIT9ygya0Yl9mt63cLhJ09ZIILSh/85f0Xy3WbCHLn6e9uBbOcgKI5Q0fw 2NnqkKFjTc2Sjqz9jnwGkZHpX90+PNzCxMEApINnAeYUcpLAdisJizu15+JO1DAki+8vJ7IjOiB6z NP7u3lMGSWEqNfpr/LHCzoBlbAMWlriH1uj+yYiKqDnwrSojlEZn+555/Zy0cX/q8TNHA4ih9mbED y7wSRuoQniAWrg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pq7V0-0002Mv-EG; Sat, 22 Apr 2023 03:17:34 -0400 Date: Sat, 22 Apr 2023 10:17:51 +0300 Message-Id: <83fs8s2xnk.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> (message from Yuan Fu on Fri, 21 Apr 2023 13:37:08 -0700) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62951 Cc: 62951@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: -3.3 (---) > From: Yuan Fu > Date: Fri, 21 Apr 2023 13:37:08 -0700 > Cc: 62951@debbugs.gnu.org > > > Eli Zaretskii writes: > > > To reproduce: > > > > emacs -Q > > C-x C-f src/fns.c RET > > C-u 3365 M-g g > > > > Observe that "if" and "STRINGP" in the body of FOR_EACH_TAIL_SAFE are > > fontified in font-lock-function-name-face. This is because the > > FOR_EACH_TAIL_SAFE macro is misparsed by tree-sitter as a declaration. > > > > Can we teach c-ts-mode to recognize FOR_EACH_TAIL_SAFE and > > FOR_EACH_TAIL for what they are, perhaps conditioned on > > c-ts-mode-emacs-sources-support being non-nil? > > I’m aware of this issue, but the truth is there isn’t a good solution to > it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix arbitrary > code after it (hard). In this case it’s a if statement, with macro calls > and AND operation in it’s condition, it’s already three things we need > to recognize and somehow handle. It can also be a for loop, a switch > case, a function call, a while loop. If we want to fix FOR_EACH_TAIL we > would need to handle every possible thing, at that point we might as > well have wrote a parser :-) Sorry, I don't understand the difficulties. The body of FOR_EACH_TAIL and a few similar macros we use could be on of the following: . a single simple statement . an 'if' clause . a 'while' loop . a 'do' loop . a 'for' loop . a brace-delimited block (this one already works, AFAICS, so we perhaps need not anything about it) (In practice, only the first 2 and the last one are used, AFAICS.) Doesn't tree-sitter tell us enough to figure out which of the above is in the body? If so, why would we need to write a full parser? > We can probably fix this very particular case, but it’s still work and > overhead, and doesn’t mean much. Please understand: good support for editing Emacs C sources is from my POV imperative for c-ts-mode to gain traction. One of my gripes about CC Mode was insufficient support for our macro system and for various GCC attributes; that improved recently to some extend, but not enough, and at a price of introducing ugly lists of strings that cause trouble when used in file-local variables. We must do better in c-ts-mode! So please make an effort of providing reasonable built-in solutions for these idiosyncrasies of the Emacs C sources, conditioned on the new variable c-ts-mode-emacs-sources-support, at least for those of them that are used widely enough. It is very important. TIA From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 22 20:28:49 2023 Received: (at 62951) by debbugs.gnu.org; 23 Apr 2023 00:28:49 +0000 Received: from localhost ([127.0.0.1]:44335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqNay-0007wD-Hj for submit@debbugs.gnu.org; Sat, 22 Apr 2023 20:28:48 -0400 Received: from mail-pf1-f179.google.com ([209.85.210.179]:62586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqNau-0007vn-0d for 62951@debbugs.gnu.org; Sat, 22 Apr 2023 20:28:47 -0400 Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-63d4595d60fso21083245b3a.0 for <62951@debbugs.gnu.org>; Sat, 22 Apr 2023 17:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682209718; x=1684801718; 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=UqMMf6KdY70TMRKXGdifmvdwKjjo7fY7CB6kXB8wREk=; b=bNvJnThYFSBO5KCNgrFh/94nUIsWWOy4C8K6evzK51h2S4ODaCKeznO1OYKErZUP2j QuIidZePz+Sf6/g8CMwEwcwO1B5c4iMRdXbBNvB11lxvoiKhpdUmj5xvbvvuTTsvtPpD LxT0thRSnM1rX53i4LWNf3kmBSWcqpQ6cMY+M1UEoPUtEL7KZcAe6HkY7dP8sNA85uFu zhwpaMMsWGt+FgfeoIwtpf554Vy0AYIFV1eqmIJHmnQ9Vy+kpF1kTa3c3THSnXDVSzZi pLMrgaZqhfBl1dxCy6GuBKoiTqKLzGzFt+dBt6N6ksdiqgnW0vzgIu5EI+1ERD+idHXB McHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682209718; x=1684801718; 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=UqMMf6KdY70TMRKXGdifmvdwKjjo7fY7CB6kXB8wREk=; b=TQZChq1W8oLIyeJ2jkEWBObXu5ShjI8PZUbtfeg5cgWnMTi6EP9p7oiJ9pHeY4g4ME mnidk8qajjGmk6yreLSTz2vDgKxVO079Hq11aOACh47jOvtKZod3aikmRMjFnoZ83lAq l6QI7X2kauoecsnsL/vU963Pzd9GthwKSg1JNo8qSZo227XJ4AukShiMK+u39BChcLyA 8hE8bXXQG7YjJRpvavIWf38f/ArJF9yI07pwEk664sJU2V0ZPbdK6Dk9f29A+apOT1gQ 1rWmUJF37zIBt1K+3G3jMyW0KA14k3PNWlEy5CcQYKqSLxJhH1bRWHgxmkvcv9QS5EI1 sZRw== X-Gm-Message-State: AAQBX9dJ1Lp0LXi8WQDlEy/SRkhPfTEHP8cMe8hcp0aUhXAO8ETDSgB7 uVyYB3nOSD2oeKVr39gssqi+9SaV7GhmUg== X-Google-Smtp-Source: AKy350a1rmpbuEsfWcLJv4oL2q7j9Tt1s+9Vzu6YsUbIJyVXt344xkLrlyqxv6B3NhI1lUiPi9HaIw== X-Received: by 2002:a17:902:e752:b0:1a6:6bd4:cd8c with SMTP id p18-20020a170902e75200b001a66bd4cd8cmr10696410plf.25.1682209717698; Sat, 22 Apr 2023 17:28:37 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id f2-20020a170902ab8200b001a0448731c2sm4483320plr.47.2023.04.22.17.28.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Apr 2023 17:28:37 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE From: Yuan Fu In-Reply-To: <83fs8s2xnk.fsf@gnu.org> Date: Sat, 22 Apr 2023 17:28:25 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> <83fs8s2xnk.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: 62951@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 (-) > On Apr 22, 2023, at 12:17 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Fri, 21 Apr 2023 13:37:08 -0700 >> Cc: 62951@debbugs.gnu.org >>=20 >>=20 >> Eli Zaretskii writes: >>=20 >>> To reproduce: >>>=20 >>> emacs -Q >>> C-x C-f src/fns.c RET >>> C-u 3365 M-g g >>>=20 >>> Observe that "if" and "STRINGP" in the body of FOR_EACH_TAIL_SAFE = are >>> fontified in font-lock-function-name-face. This is because the >>> FOR_EACH_TAIL_SAFE macro is misparsed by tree-sitter as a = declaration. >>>=20 >>> Can we teach c-ts-mode to recognize FOR_EACH_TAIL_SAFE and >>> FOR_EACH_TAIL for what they are, perhaps conditioned on >>> c-ts-mode-emacs-sources-support being non-nil? >>=20 >> I=E2=80=99m aware of this issue, but the truth is there isn=E2=80=99t = a good solution to >> it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix = arbitrary >> code after it (hard). In this case it=E2=80=99s a if statement, with = macro calls >> and AND operation in it=E2=80=99s condition, it=E2=80=99s already = three things we need >> to recognize and somehow handle. It can also be a for loop, a switch >> case, a function call, a while loop. If we want to fix FOR_EACH_TAIL = we >> would need to handle every possible thing, at that point we might as >> well have wrote a parser :-) >=20 > Sorry, I don't understand the difficulties. The body of FOR_EACH_TAIL > and a few similar macros we use could be on of the following: >=20 > . a single simple statement > . an 'if' clause > . a 'while' loop > . a 'do' loop > . a 'for' loop > . a brace-delimited block (this one already works, AFAICS, so we > perhaps need not anything about it) >=20 > (In practice, only the first 2 and the last one are used, AFAICS.) >=20 > Doesn't tree-sitter tell us enough to figure out which of the above is > in the body? If so, why would we need to write a full parser? Ok, the full parser part is a bit exaggeration :-) But my point is = it=E2=80=99s a lot of dirty code for a subpar result. Take if (NILP (XCDR (tail)) && STRINGP (XCAR (tail))) for example, it=E2=80=99s parsed as a function definition and all the = tokens in the condition are parsed as weird things like macro = declarator, error, function declarator, type, etc. And if the condition = changes to something else, say it has another layer of function call, = it=E2=80=99ll parse differently. >=20 >> We can probably fix this very particular case, but it=E2=80=99s still = work and >> overhead, and doesn=E2=80=99t mean much. >=20 > Please understand: good support for editing Emacs C sources is from my > POV imperative for c-ts-mode to gain traction. One of my gripes about > CC Mode was insufficient support for our macro system and for various > GCC attributes; that improved recently to some extend, but not enough, > and at a price of introducing ugly lists of strings that cause trouble > when used in file-local variables. We must do better in c-ts-mode! >=20 > So please make an effort of providing reasonable built-in solutions > for these idiosyncrasies of the Emacs C sources, conditioned on the > new variable c-ts-mode-emacs-sources-support, at least for those of > them that are used widely enough. It is very important. 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=E2=80=99t 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=E2=80=99s author = isn=E2=80=99t too much different from depending on the grammar = maintained by another individual (ie, me)? Yuan= From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 23 02:24:59 2023 Received: (at 62951) by debbugs.gnu.org; 23 Apr 2023 06:24:59 +0000 Received: from localhost ([127.0.0.1]:44524 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqT9e-0001wd-VL for submit@debbugs.gnu.org; Sun, 23 Apr 2023 02:24:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqT9a-0001wO-6w for 62951@debbugs.gnu.org; Sun, 23 Apr 2023 02:24:57 -0400 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 1pqT9U-0006T1-Pw; Sun, 23 Apr 2023 02:24:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=vpapQpUKxDwDQ7h+po/hBWPPbiPh2SlLGRgrvJ4m1oE=; b=EY341BTjHEbo/5ywIatF P+mwQ6MjDjsl85+Brvp2rgFBZckat2dG3BU0dvpIEadeb70vl39BEqrck87VB6+bvKhre1Wp95o2B hu5u68r7p7++mgX52L9ylzx0zZmVASqrM+umUKjxgjNk4s7C8vP+pABq+zLJhmNx0f+VFiqWcDodb 8lY+Si13MoDTmPwUkyI0fNv4xM3oZj16/+Qj8hoKXyDLd7IIqoVsyiFoJwzXinNCbPYZt7lFIuuGD IpmoGgYr6dKomWE6IDpw69MnxGDZtg4ZSWUvU0mo7XycR7CbiFRZopxhvuq98got4nHikEuW1SgN0 Qyc+y6Fvg/T3UQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqT9U-0002g0-4X; Sun, 23 Apr 2023 02:24:48 -0400 Date: Sun, 23 Apr 2023 09:25:08 +0300 Message-Id: <83sfcryv23.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> (message from Yuan Fu on Sat, 22 Apr 2023 17:28:25 -0700) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> <83fs8s2xnk.fsf@gnu.org> <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62951 Cc: 62951@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: -3.3 (---) > From: Yuan Fu > Date: Sat, 22 Apr 2023 17:28:25 -0700 > Cc: 62951@debbugs.gnu.org > > >> I’m aware of this issue, but the truth is there isn’t a good solution to > >> it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix arbitrary > >> code after it (hard). In this case it’s a if statement, with macro calls > >> and AND operation in it’s condition, it’s already three things we need > >> to recognize and somehow handle. It can also be a for loop, a switch > >> case, a function call, a while loop. If we want to fix FOR_EACH_TAIL we > >> would need to handle every possible thing, at that point we might as > >> well have wrote a parser :-) > > > > Sorry, I don't understand the difficulties. The body of FOR_EACH_TAIL > > and a few similar macros we use could be on of the following: > > > > . a single simple statement > > . an 'if' clause > > . a 'while' loop > > . a 'do' loop > > . a 'for' loop > > . a brace-delimited block (this one already works, AFAICS, so we > > perhaps need not anything about it) > > > > (In practice, only the first 2 and the last one are used, AFAICS.) > > > > Doesn't tree-sitter tell us enough to figure out which of the above is > > in the body? If so, why would we need to write a full parser? > > Ok, the full parser part is a bit exaggeration :-) But my point is it’s a lot of dirty code for a subpar result. Take > > if (NILP (XCDR (tail)) && STRINGP (XCAR (tail))) > > for example, it’s parsed as a function definition and all the tokens in the condition are parsed as weird things like macro declarator, error, function declarator, type, etc. And if the condition changes to something else, say it has another layer of function call, it’ll parse differently. But the top-level construct is 'if', no? Isn't that enough? Also, can we detect the FOR_EACH_TAIL etc. macros themselves, and then treat their body specially? > > Please understand: good support for editing Emacs C sources is from my > > POV imperative for c-ts-mode to gain traction. One of my gripes about > > CC Mode was insufficient support for our macro system and for various > > GCC attributes; that improved recently to some extend, but not enough, > > and at a price of introducing ugly lists of strings that cause trouble > > when used in file-local variables. We must do better in c-ts-mode! > > > > So please make an effort of providing reasonable built-in solutions > > for these idiosyncrasies of the Emacs C sources, conditioned on the > > new variable c-ts-mode-emacs-sources-support, at least for those of > > them that are used widely enough. It is very important. > > What do you think of extending the parser to support these macros instead? (So we fork tree-sitter-c.) This goes against the purpose of using tree-sitter and its grammars. I don't think we should maintain and develop language grammars, especially since the production of the C sources from them needs non-trivial system resources and additional tools. Maybe coming up with a way of extending the C grammar in some more general way, and then submitting the changes to the tree-sitter-c developers for inclusion would be OK. But I very much hope that we could support these macros at a lower cost, by some tailored Lisp. Please give it a try. Even if the result works only for the cases we actually use in our sources, it might be "good enough" for us. From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 23 17:04:11 2023 Received: (at 62951) by debbugs.gnu.org; 23 Apr 2023 21:04:12 +0000 Received: from localhost ([127.0.0.1]:47034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqgsV-0001YV-Ja for submit@debbugs.gnu.org; Sun, 23 Apr 2023 17:04:11 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:46861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqgsU-0001YJ-9z for 62951@debbugs.gnu.org; Sun, 23 Apr 2023 17:04:10 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 3E4C458218A; Sun, 23 Apr 2023 17:04:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 23 Apr 2023 17:04:05 -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= 1682283845; x=1682287445; bh=AfS64jNiaQzX/UgnEJXe2L7o98IEMyKiFqq IUUgQ4qw=; b=M+miK9I5kvkqJL0atwll/CWwIZes1v5rUZsRn5ON5BpgZdjWJ2R mJ0gQwcSGwE80cbfpyHuW2ogfHmIfI7vsLy/q2eUD37+NBzntiqQfBXlgGs6wR2R 0BAOhuThXE11cBbXWp4lU+km0u5S7HrqBZMLEXFoz6GGaCIRe1aEnjiI8UiC7kqn XLRHQncl5Jl1A8Q0EE6gNrJiLVD4MxEA4t4nsKUMrWqa7BO/A9WbWKcRaeFqWTG0 0jaUv2gxy1cr274gs8mVnGUqla+LlS0qqHhe1xthCkMtkcgV8zlm9c2Z+WwdCu2Z MyvzNJ1Rz2WdEGp86Ae4nulvfM32/1XcGbA== 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= 1682283845; x=1682287445; bh=AfS64jNiaQzX/UgnEJXe2L7o98IEMyKiFqq IUUgQ4qw=; b=GTDFKQ2j2pp0rI0egSLJUD0+dwnqg9XVdU5KVpZNQb2WqPOJ3oR fWIR9nVu1n365+mMlCPf4FYAv1UucK8A2Gs57RX7cdsQz/8iVAiCiSIKsbyDT9YC wZY3ufsZc4qkN9ELSHTjeU/1ncTPKMZtVSUQz2i05j6dZsWpP7SqHiyETCpq3RFC kVqOuQuQ5+W8UCcBvEdNmg6JAxpcI55etALNqTR3pkEIGYl7liDMcn6ND8/GzJoV ppFctlG3nm7xp2lx3JDOVPBICcan3VKm6D2fEV66FIO4VsbfGr9GrnIKfH098mh4 hiOA50WfkUrfIuRaQ5j/8o+SBzH43Dm+nxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedtkedgudehjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpeekjeduleevuedthfelhfeiheetudevteeutdfhtdefffejhfeugfffvdet teefvdenucffohhmrghinhepvghlrdhimhenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 23 Apr 2023 17:04:03 -0400 (EDT) Message-ID: <384f8110-eba6-8fb3-ef4e-56fa0721d85d@gutov.dev> Date: Mon, 24 Apr 2023 00:04:02 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Content-Language: en-US To: Yuan Fu , Eli Zaretskii References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> <83fs8s2xnk.fsf@gnu.org> <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> From: Dmitry Gutov In-Reply-To: <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.8 (-) X-Debbugs-Envelope-To: 62951 Cc: 62951@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.8 (--) 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 24 03:02:23 2023 Received: (at 62951) by debbugs.gnu.org; 24 Apr 2023 07:02:23 +0000 Received: from localhost ([127.0.0.1]:47355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqqDP-00022w-Bb for submit@debbugs.gnu.org; Mon, 24 Apr 2023 03:02:23 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:58517) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqqDN-00022j-IP for 62951@debbugs.gnu.org; Mon, 24 Apr 2023 03:02:22 -0400 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1a6862e47b1so46232615ad.0 for <62951@debbugs.gnu.org>; Mon, 24 Apr 2023 00:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682319735; x=1684911735; 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=3r5z72xr+Ur/yOgCf0Zx6xiqCet4mcEtyslqb8dnCg0=; b=o+8HcxV0nNUg+28h39CuKKZ1nhf6er6CQnB5pTycBCPziL7fxb6IIXpqf3v5advrIA RAXvhd3i0BgeDRxjMATa9M9vP5eDtNQQ1MZ901TSusvJDajAfTqFs297CKDkH1HGz+cp qh0QxzWkrsSZbmWE+BvL0plfefK7o8gl79AtdzH3nMR9fOqjKGcWEpsxtdkQDDBXB6xP o4GXjTPM/D1gvH7KsFQ+OdoZPD6l7T7QtFQIOzPl4rqW1m790uVFlFw99q5YHX06DtZj CdZrvOQwHJ0DLaBjqaCuGl4fysrJ1IYk3hLVqzn2F0VsAJEQWECvHmoB9Ntgr81CiYC+ 9OrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682319735; x=1684911735; 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=3r5z72xr+Ur/yOgCf0Zx6xiqCet4mcEtyslqb8dnCg0=; b=XWIfOr7kXRj4hYPk371GmmkdnhH2jnjqENcAjjd6OIByuJH6f63g3jlByalSkC7i0B YT9pWTri9JEHsEcUlXN6M05PjGMI0MY1sT6xqvM0028ENphRqeT55k0pjsQiGrxlxZiX 8u/Tj3JR2PLjjfOSmoQIKECTZiKLJ7+SFr7TH9ZtqsmIlZG2Exk4O4w5u+L9ZhQ/4AzQ B8u7mlzuEKtsr3+h+HQuxlN2Hp4ZAgodqx0bdkZQUqim+Ht/GuFd0KRFRaNK+I7kDkVI TCG+1Jr5T/EN9MITsvObqHjQfAHSevLcMhsmlqWyxAxvyI+IQqwXWMiaxpuSQHSEbh/r J6yg== X-Gm-Message-State: AAQBX9eLphL2CBV3paCoe5zPqeFy+mZXKMK6oBpjo4D2Av0+1giC6YVI fU4Q89sKejZiyCmoDwukBks= X-Google-Smtp-Source: AKy350a/GfqiQLkOvoCI/Jc8U6S/skJcUF9WGKtK/Lrmyh4adZroNuH+jz+Cwu7tCjPeKQ0EM/TkOw== X-Received: by 2002:a17:902:8215:b0:1a5:5e7:a1cc with SMTP id x21-20020a170902821500b001a505e7a1ccmr12088172pln.58.1682319735263; Mon, 24 Apr 2023 00:02:15 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id d3-20020a170902b70300b001a1deff606fsm5981807pls.125.2023.04.24.00.02.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2023 00:02:14 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE From: Yuan Fu In-Reply-To: <83sfcryv23.fsf@gnu.org> Date: Mon, 24 Apr 2023 00:02:03 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> <83fs8s2xnk.fsf@gnu.org> <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> <83sfcryv23.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: 62951@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 (-) > On Apr 22, 2023, at 11:25 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Sat, 22 Apr 2023 17:28:25 -0700 >> Cc: 62951@debbugs.gnu.org >>=20 >>>> I=E2=80=99m aware of this issue, but the truth is there isn=E2=80=99t= a good solution to >>>> it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix = arbitrary >>>> code after it (hard). In this case it=E2=80=99s a if statement, = with macro calls >>>> and AND operation in it=E2=80=99s condition, it=E2=80=99s already = three things we need >>>> to recognize and somehow handle. It can also be a for loop, a = switch >>>> case, a function call, a while loop. If we want to fix = FOR_EACH_TAIL we >>>> would need to handle every possible thing, at that point we might = as >>>> well have wrote a parser :-) >>>=20 >>> Sorry, I don't understand the difficulties. The body of = FOR_EACH_TAIL >>> and a few similar macros we use could be on of the following: >>>=20 >>> . a single simple statement >>> . an 'if' clause >>> . a 'while' loop >>> . a 'do' loop >>> . a 'for' loop >>> . a brace-delimited block (this one already works, AFAICS, so we >>> perhaps need not anything about it) >>>=20 >>> (In practice, only the first 2 and the last one are used, AFAICS.) >>>=20 >>> Doesn't tree-sitter tell us enough to figure out which of the above = is >>> in the body? If so, why would we need to write a full parser? >>=20 >> Ok, the full parser part is a bit exaggeration :-) But my point is = it=E2=80=99s a lot of dirty code for a subpar result. Take >>=20 >> if (NILP (XCDR (tail)) && STRINGP (XCAR (tail))) >>=20 >> for example, it=E2=80=99s parsed as a function definition and all the = tokens in the condition are parsed as weird things like macro = declarator, error, function declarator, type, etc. And if the condition = changes to something else, say it has another layer of function call, = it=E2=80=99ll parse differently. >=20 > But the top-level construct is 'if', no? Isn't that enough? >=20 > Also, can we detect the FOR_EACH_TAIL etc. macros themselves, and then > treat their body specially? >=20 >>> Please understand: good support for editing Emacs C sources is from = my >>> POV imperative for c-ts-mode to gain traction. One of my gripes = about >>> CC Mode was insufficient support for our macro system and for = various >>> GCC attributes; that improved recently to some extend, but not = enough, >>> and at a price of introducing ugly lists of strings that cause = trouble >>> when used in file-local variables. We must do better in c-ts-mode! >>>=20 >>> So please make an effort of providing reasonable built-in solutions >>> for these idiosyncrasies of the Emacs C sources, conditioned on the >>> new variable c-ts-mode-emacs-sources-support, at least for those of >>> them that are used widely enough. It is very important. >>=20 >> What do you think of extending the parser to support these macros = instead? (So we fork tree-sitter-c.) >=20 > This goes against the purpose of using tree-sitter and its grammars. > I don't think we should maintain and develop language grammars, > especially since the production of the C sources from them needs > non-trivial system resources and additional tools. >=20 > Maybe coming up with a way of extending the C grammar in some more > general way, and then submitting the changes to the tree-sitter-c > developers for inclusion would be OK. >=20 > But I very much hope that we could support these macros at a lower > cost, by some tailored Lisp. Please give it a try. Even if the > result works only for the cases we actually use in our sources, it > might be "good enough" for us. Fair enough, I=E2=80=99ll try :-) Yuan= From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 26 18:19:25 2023 Received: (at 62951) by debbugs.gnu.org; 26 Apr 2023 22:19:25 +0000 Received: from localhost ([127.0.0.1]:57131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prnTw-0002xu-Pw for submit@debbugs.gnu.org; Wed, 26 Apr 2023 18:19:25 -0400 Received: from mail-pf1-f178.google.com ([209.85.210.178]:62720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prnTs-0002xe-Nl for 62951@debbugs.gnu.org; Wed, 26 Apr 2023 18:19:22 -0400 Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-64115eef620so604190b3a.1 for <62951@debbugs.gnu.org>; Wed, 26 Apr 2023 15:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682547554; x=1685139554; 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=UUhnrostUiptwuANAsGoG3iyjnCNJmkcDnWfcld/7f0=; b=J+ZhFR27B16lRXhF9vxcv+2Xb/aB1ZP14wYBnvzFZkfXfaxGlDaSOT1NH+HytkBmLu 5zqp7YtiFq56Moopnmk99Y+adXusVWTVtfOnd5HqDJIZdG3lVDy9iI1STua9m/DphszX /I9UonB0+Mj5wvHtAnmihgGDuOOLRa5A44IqcFxnXtSdInwP8DbFpjwgXN8REBxBiDcu foqhRu74BZneTA5UKx4Oq1UQcZga7C8nLGYP3id97P3rxEfomRaJrGgxwKv2AV9WOWHN rD8mw1FvHbQSm20lxIgZ4Scf+9KDCdSDQlKuIv3pqicmsEvd28CpxrK+yJSAxTcq/B6D Vckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682547554; x=1685139554; 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=UUhnrostUiptwuANAsGoG3iyjnCNJmkcDnWfcld/7f0=; b=LTru3HiMbMxEUcy+S0DpN/62ZUs0A/t/fRAdUa0AFgIi7Wzg7wskvp+lsSNI2ScHb8 yLRgLj0dQCF+ngfE0dt/kIjrVRwrz0+kKhVbMIBmD/3ihvrFt2EOqjNKZi1g+C8rmChE SDx4LY5IgzunnVl6Xa7Ysh82vKQr+tbcAfKgndWt71e28RPlRi/Lx63dpBCtVnCQD3lA YhQVLxzeuQ5yaKbvciN4EMWdXbLsg9nYWyr1tZnpoSPjlWR5EcTzASVKhtP4Utj/8G+2 ytQUGIOzfBiVpNeEmRsTC7NL+cQoQyO5hif/1v0J7qpEYWTc5J31+NQVTAJxWrq3eDMG scmA== X-Gm-Message-State: AC+VfDyHwC+F0e62jJkIxLuNsgzje59lcixQwURto7XlNqXTym2BFEWg feKiA8e5GBQW1wqO3BTg8dc= X-Google-Smtp-Source: ACHHUZ5L9Xs4opJdEDRNRtihbklrNzaLrw7FZomkRoLwjEE9a1oFTorHAy4moxTz3QHrYwZMpf4IJg== X-Received: by 2002:a17:903:1c8:b0:1a1:cb18:7f99 with SMTP id e8-20020a17090301c800b001a1cb187f99mr4977240plh.30.1682547554279; Wed, 26 Apr 2023 15:19:14 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id k9-20020a170902694900b0019c32968271sm10339719plt.11.2023.04.26.15.19.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2023 15:19:13 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE From: Yuan Fu In-Reply-To: <384f8110-eba6-8fb3-ef4e-56fa0721d85d@gutov.dev> Date: Wed, 26 Apr 2023 15:19:01 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <90E66143-A3E2-4B76-AC0A-01DC5E841AFE@gmail.com> 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> To: Dmitry Gutov X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: Eli Zaretskii , 62951@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 (-) > On Apr 23, 2023, at 2:04 PM, Dmitry Gutov wrote: >=20 > 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=E2=80=99t 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=E2=80=99s author = isn=E2=80=99t too much different from depending on the grammar = maintained by another individual (ie, me)? >=20 > We had also talked at some point about replacing the actual text that = the parser sees with something else. >=20 > 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. >=20 > 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=E2=80=99t too = easy. Now plus narrowing, and what if the narrowing boundary is in the = middle of a replace region? My idea right now is to use the range feature in tree-sitter. Since the = =E2=80=9Cbody=E2=80=9D 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. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 26 23:15:06 2023 Received: (at 62951) by debbugs.gnu.org; 27 Apr 2023 03:15:06 +0000 Received: from localhost ([127.0.0.1]:57288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prs65-0002zi-VW for submit@debbugs.gnu.org; Wed, 26 Apr 2023 23:15:06 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:50225) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prs64-0002yt-1R for 62951@debbugs.gnu.org; Wed, 26 Apr 2023 23:15:05 -0400 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1a66e7a52d3so60439015ad.0 for <62951@debbugs.gnu.org>; Wed, 26 Apr 2023 20:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682565298; x=1685157298; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=2OQYmPXwJWzFK3zfltXoHitr9TFSo5WL0jLOf+uBiD4=; b=FjQm3KLhT6PjzVtEGiu0PxknkddjxHBsVrSIFDsybHP2CJUIjWwjDBGx5mF7ZvG6pi qcQN6fER5r8nMvGExs+/NKXLlt6elKBkhU5/ecTzW1of9Bu7K2BQnC8p8oXSwVMfiLGm 0XbZodUKK7vYGCTZX7vXkxhvf82CNh98LutkSii8paSmZZo13Q19MOZQTdTUDykSOcrW IKIkV1s0NvSYl4mUTNdQq8Lj61lBUK6EXBwAVegGJQSiK9u07+2ZeZ8l4E5wliVtkG+E 3waAMk9Gol8IREbW4wzmQVtE1yjLsWRW8+MIRf6ML5PVjDuNjKzskvWpk3dmU/Ba4Po2 yKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682565298; x=1685157298; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2OQYmPXwJWzFK3zfltXoHitr9TFSo5WL0jLOf+uBiD4=; b=jJocoXeZWuCIs1aU11GfLNs+fV3pFT/DnnKvvsB5EWBgZkJtQtPzRztbqGIFrqFMI1 cImywZjp9vwKWDFhSXwE5Ve6zsEwJ+JtAaGvIGMPLIAhktTEiTsiTdKdXQEI8bpDgSjt SBJSJK0+Id/qAjfsDST/hTpY8tr5JH3MTVfJgSzE3mxemVgBtwyeuJW/scCJXyrj6tV9 RfYHtuELt0E9belq2d88N4gJDDl6nXsypwRsTiGZPVIBXivsqAjn7MUJHuP+8gDkYRt9 JhSJ6//rY/E1yQTYQW8+QaDNZuJJnKaCYIpb3H37LBQjII1Ib0yD0KT2RR/ZusAiaUMX F6zg== X-Gm-Message-State: AC+VfDy4Sw+LcTs4g7w/AmZ2Qv5MflyGNlsPSwf9A67p1o5YzPifDPn3 zNgTH+UoUuTSoe3iF1WlL2o= X-Google-Smtp-Source: ACHHUZ4of0p+L8vJ61+u9Wr5FkD9MP+sqmebz8x0Zzl+HW6vj0Dkgs0W/wwuZ1GTgDLFFSxOX6RdSQ== X-Received: by 2002:a17:903:244e:b0:19e:6cb9:4c8f with SMTP id l14-20020a170903244e00b0019e6cb94c8fmr54731pls.41.1682565297684; Wed, 26 Apr 2023 20:14:57 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id w14-20020a1709029a8e00b00183c6784704sm10569400plp.291.2023.04.26.20.14.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2023 20:14:57 -0700 (PDT) From: Yuan Fu Message-Id: <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_C19C1CC5-40F6-4BFB-B14A-97E439DD0C7D" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Date: Wed, 26 Apr 2023 20:14:45 -0700 In-Reply-To: <90E66143-A3E2-4B76-AC0A-01DC5E841AFE@gmail.com> To: Dmitry Gutov 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> X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: Eli Zaretskii , 62951@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 (-) --Apple-Mail=_C19C1CC5-40F6-4BFB-B14A-97E439DD0C7D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >=20 > My idea right now is to use the range feature in tree-sitter. Since = the =E2=80=9Cbody=E2=80=9D of FOR_EACH_TAIL is valid C, I can either set = the ranges for the parser so it ignores FOR_EACH_TAIL I end up going this route. > or I can add another parser that only parses the body of = FOR_EACH_TAIL. Ok, here=E2=80=99s the patch. Eli, would you give it a try? This is a = sizable patch so I=E2=80=99m not sure if you want it on emacs-29 or = master. Yuan --Apple-Mail=_C19C1CC5-40F6-4BFB-B14A-97E439DD0C7D Content-Disposition: attachment; filename=for-each-tail-fix.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="for-each-tail-fix.patch" Content-Transfer-Encoding: quoted-printable =46rom=206d9a9a4ce88f996d87fd121aaf6bfa21581fac30=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Wed,=20= 26=20Apr=202023=2020:09:42=20-0700=0ASubject:=20[PATCH]=20Fix=20= FOR_EACH_TAIL=20in=20c-ts-mode=20(bug#62951)=0A=0A*=20= lisp/progmodes/c-ts-mode.el=0A(c-ts-mode--indent-styles):=20New=20indent=20= rule.=0A*=20lisp/progmodes/c-ts-mode.el=20= (c-ts-mode--for-each-tail-body-matcher):=0A= (c-ts-mode--emacs-c-range-query)=0A(c-ts-mode--for-each-tail-ranges)=0A= (c-ts-mode--reverse-ranges)=0A(c-ts-mode--emacs-set-ranges):=20New=20= functions=20and=20variables.=0A(c-ts-mode):=20Create=20a=20emacs-c=20= parser.=20=20More=20setup=20for=20Emacs=20source=0Asupport.=0A=0A*=20= lisp/treesit.el=20(treesit-query-range):=20Ignore=20underscore-prefixed=0A= capture=20names.=0A---=0A=20lisp/progmodes/c-ts-mode.el=20|=2092=20= ++++++++++++++++++++++++++++++++++++-=0A=20lisp/treesit.el=20=20=20=20=20= =20=20=20=20=20=20=20=20|=2017=20+++++--=0A=202=20files=20changed,=20103=20= insertions(+),=206=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/progmodes/c-ts-mode.el=20b/lisp/progmodes/c-ts-mode.el=0Aindex=20= 6100f00e3ba..c4e1ba7a23a=20100644=0A---=20a/lisp/progmodes/c-ts-mode.el=0A= +++=20b/lisp/progmodes/c-ts-mode.el=0A@@=20-357,7=20+357,9=20@@=20= c-ts-mode--indent-styles=0A=20=20=20"Indent=20rules=20supported=20by=20= `c-ts-mode'.=0A=20MODE=20is=20either=20`c'=20or=20`cpp'."=0A=20=20=20= (let=20((common=0A-=20=20=20=20=20=20=20=20=20`(((parent-is=20= "translation_unit")=20column-0=200)=0A+=20=20=20=20=20=20=20=20=20= `((c-ts-mode--for-each-tail-body-matcher=20prev-line=20= c-ts-mode-indent-offset)=0A+=0A+=20=20=20=20=20=20=20=20=20=20=20= ((parent-is=20"translation_unit")=20column-0=200)=0A=20=20=20=20=20=20=20= =20=20=20=20=20((query=20"(ERROR=20(ERROR))=20@indent")=20column-0=200)=0A= =20=20=20=20=20=20=20=20=20=20=20=20((node-is=20")")=20parent=201)=0A=20=20= =20=20=20=20=20=20=20=20=20=20((node-is=20"]")=20parent-bol=200)=0A@@=20= -969,6=20+971,75=20@@=20c-ts-mode--emacs-current-defun-name=0A=20=20=20= (or=20(treesit-add-log-current-defun)=0A=20=20=20=20=20=20=20= (c-ts-mode--defun-name=20(c-ts-mode--emacs-defun-at-point))))=0A=20=0A= +;;;=20FOR_EACH_TAIL=20fix=0A+;;=0A+;;=20FOR_EACH_TAIL=20(and=20= FOR_EACH_TAIL_SAFE)=20followed=20by=20a=20unbracketed=0A+;;=20body=20= will=20mess=20up=20the=20parser,=20which=20parses=20the=20thing=20as=20a=20= function=0A+;;=20declaration.=20=20We=20"fix"=20it=20by=20adding=20a=20= shadow=20parser,=20emacs-c=20(which=0A+;;=20is=20just=20c=20but=20under=20= a=20different=20name).=20=20We=20use=20emacs-c=20to=20find=20each=0A+;;=20= FOR_EACH_TAIL=20with=20a=20unbracketed=20body,=20and=20set=20the=20= ranges=20of=20the=20C=0A+;;=20parser=20so=20that=20it=20skips=20those=20= FOR_EACH_TAIL's.=20=20Note=20that=20we=20only=0A+;;=20ignore=20= FOR_EACH_TAIL's=20with=20a=20unbracketed=20body.=20=20Those=20with=20a=0A= +;;=20bracketed=20body=20parses=20more=20or=20less=20fine.=0A+=0A+(defun=20= c-ts-mode--for-each-tail-body-matcher=20(_n=20_p=20bol=20&rest=20_)=0A+=20= =20"A=20matcher=20that=20matches=20the=20first=20line=20after=20a=20= FOR_EACH_TAIL.=0A+For=20BOL=20see=20`treesit-simple-indent-rules'."=0A+=20= =20(when=20c-ts-mode-emacs-sources-support=0A+=20=20=20=20= (save-excursion=0A+=20=20=20=20=20=20(goto-char=20bol)=0A+=20=20=20=20=20= =20(forward-line=20-1)=0A+=20=20=20=20=20=20(skip-chars-forward=20"=20= \t")=0A+=20=20=20=20=20=20(looking-at=20(rx=20"FOR_EACH_TAIL"=20(?=20(or=20= "_SAFE"=20"_ALIST_VALUE")))))))=0A+=0A+(defvar=20= c-ts-mode--emacs-c-range-query=0A+=20=20(treesit-query-compile=0A+=20=20=20= 'emacs-c=20`(((declaration=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20type:=20(macro_type_specifier=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20name:=20(identifier)=20@_name)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20@for-each-tail)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(:match=20,(rx=20"FOR_EACH_TAIL"=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (?=20(or=20"_SAFE"=20"_ALIST_VALUE")))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20@_name))))=0A+=20=20"Query=20that=20= finds=20the=20FOR_EACH_TAIL=20with=20a=20unbracketed=20body.")=0A+=0A= +(defvar-local=20c-ts-mode--for-each-tail-ranges=20nil=0A+=20=20"Ranges=20= covering=20all=20the=20FOR_EACH_TAIL's=20in=20the=20buffer.")=0A+=0A= +(defun=20c-ts-mode--reverse-ranges=20(ranges=20beg=20end)=0A+=20=20= "Reverse=20RANGES=20and=20return=20the=20new=20ranges=20between=20BEG=20= and=20END.=0A+Positions=20that=20were=20included=20RANGES=20are=20not=20= in=20the=20returned=0A+ranges,=20and=20vice=20versa.=0A+=0A+Return=20nil=20= if=20RANGES=20is=20nil.=20=20This=20way,=20passing=20the=20returned=0A= +ranges=20to=20`treesit-parser-set-included-ranges'=20will=20make=20the=0A= +parser=20parse=20the=20whole=20buffer."=0A+=20=20(if=20(null=20ranges)=0A= +=20=20=20=20=20=20nil=0A+=20=20=20=20(let=20((new-ranges=20nil)=0A+=20=20= =20=20=20=20=20=20=20=20(prev-end=20beg))=0A+=20=20=20=20=20=20(dolist=20= (range=20ranges)=0A+=20=20=20=20=20=20=20=20(push=20(cons=20prev-end=20= (car=20range))=20new-ranges)=0A+=20=20=20=20=20=20=20=20(setq=20prev-end=20= (cdr=20range)))=0A+=20=20=20=20=20=20(push=20(cons=20prev-end=20end)=20= new-ranges)=0A+=20=20=20=20=20=20(nreverse=20new-ranges))))=0A+=0A= +(defun=20c-ts-mode--emacs-set-ranges=20(beg=20end)=0A+=20=20"Set=20= ranges=20for=20the=20C=20parser=20to=20skip=20some=20FOR_EACH_TAIL's.=0A= +BEG=20and=20END=20are=20described=20in=20`treesit-range-rules'."=0A+=20=20= (let*=20((c-parser=20(treesit-parser-create=20'c))=0A+=20=20=20=20=20=20=20= =20=20(old-ranges=20c-ts-mode--for-each-tail-ranges)=0A+=20=20=20=20=20=20= =20=20=20(new-ranges=20(treesit-query-range=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20'emacs-c=20= c-ts-mode--emacs-c-range-query=20beg=20end))=0A+=20=20=20=20=20=20=20=20=20= (set-ranges=20(treesit--clip-ranges=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(treesit--merge-ranges=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20old-ranges=20= new-ranges=20beg=20end)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(point-min)=20(point-max)))=0A+=20=20=20=20=20=20=20=20= =20(reversed-ranges=20(c-ts-mode--reverse-ranges=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20set-ranges=20= (point-min)=20(point-max))))=0A+=20=20=20=20(setq-local=20= c-ts-mode--for-each-tail-ranges=20set-ranges)=0A+=20=20=20=20= (treesit-parser-set-included-ranges=20c-parser=20reversed-ranges)))=0A+=0A= =20;;;=20Modes=0A=20=0A=20(defvar-keymap=20c-ts-base-mode-map=0A@@=20= -1072,6=20+1143,13=20@@=20c-ts-mode=0A=20=20=20:after-hook=20= (c-ts-mode-set-modeline)=0A=20=0A=20=20=20(when=20(treesit-ready-p=20'c)=0A= +=20=20=20=20;;=20If=20Emacs=20source=20support=20is=20enabled,=20make=20= sure=20emacs-c=20parser=20is=0A+=20=20=20=20;;=20after=20c=20parser=20in=20= the=20parser=20list.=20This=20way=20various=20tree-sitter=0A+=20=20=20=20= ;;=20functions=20will=20automatically=20use=20the=20c=20parser=20rather=20= than=20the=0A+=20=20=20=20;;=20emacs-c=20parser.=0A+=20=20=20=20(when=20= c-ts-mode-emacs-sources-support=0A+=20=20=20=20=20=20= (treesit-parser-create=20'emacs-c))=0A+=0A=20=20=20=20=20= (treesit-parser-create=20'c)=0A=20=20=20=20=20;;=20Comments.=0A=20=20=20=20= =20(setq-local=20comment-start=20"/*=20")=0A@@=20-1087,7=20+1165,17=20@@=20= c-ts-mode=0A=20=0A=20=20=20=20=20(when=20c-ts-mode-emacs-sources-support=0A= =20=20=20=20=20=20=20(setq-local=20add-log-current-defun-function=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= #'c-ts-mode--emacs-current-defun-name))))=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20#'c-ts-mode--emacs-current-defun-name)=0A+=0A+=20= =20=20=20=20=20(setq-local=20treesit-range-settings=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(treesit-range-rules=20= 'c-ts-mode--emacs-set-ranges))=0A+=0A+=20=20=20=20=20=20(setq-local=20= treesit-language-at-point-function=20(lambda=20(_pos)=20'c))=0A+=0A+=20=20= =20=20=20=20;;=20Add=20a=20fake=20"emacs-c"=20language=20which=20is=20= just=20C.=20=20Used=20for=0A+=20=20=20=20=20=20;;=20skipping=20= FOR_EACH_TAIL,=20see=20`c-ts-mode--emacs-set-ranges'.=0A+=20=20=20=20=20=20= (setf=20(alist-get=20'emacs-c=20treesit-load-name-override-list)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20'("libtree-sitter-c"=20= "tree_sitter_c")))))=0A=20=0A=20;;;###autoload=0A=20(define-derived-mode=20= c++-ts-mode=20c-ts-base-mode=20"C++"=0Adiff=20--git=20a/lisp/treesit.el=20= b/lisp/treesit.el=0Aindex=20e718ea1a23a..1d4749c8cd2=20100644=0A---=20= a/lisp/treesit.el=0A+++=20b/lisp/treesit.el=0A@@=20-378,13=20+378,16=20= @@=20treesit-query-string=0A=20(defun=20treesit-query-range=20(node=20= query=20&optional=20beg=20end)=0A=20=20=20"Query=20the=20current=20= buffer=20and=20return=20ranges=20of=20captured=20nodes.=0A=20=0A-QUERY,=20= NODE,=20BEG,=20END=20are=20the=20same=20as=20in=0A= -`treesit-query-capture'.=20=20This=20function=20returns=20a=20list=0A= -of=20(START=20.=20END),=20where=20START=20and=20END=20specifics=20the=20= range=20of=20each=0A-captured=20node.=20=20Capture=20names=20don't=20= matter."=0A+QUERY,=20NODE,=20BEG,=20END=20are=20the=20same=20as=20in=20= `treesit-query-capture'.=0A+This=20function=20returns=20a=20list=20of=20= (START=20.=20END),=20where=20START=20and=0A+END=20specifics=20the=20= range=20of=20each=20captured=20node.=20=20Capture=20names=0A+generally=20= don't=20matter,=20but=20names=20that=20starts=20with=20an=20underscore=0A= +are=20ignored."=0A=20=20=20(cl-loop=20for=20capture=0A=20=20=20=20=20=20= =20=20=20=20=20=20in=20(treesit-query-capture=20node=20query=20beg=20= end)=0A+=20=20=20=20=20=20=20=20=20=20=20for=20name=20=3D=20(car=20= capture)=0A=20=20=20=20=20=20=20=20=20=20=20=20for=20node=20=3D=20(cdr=20= capture)=0A+=20=20=20=20=20=20=20=20=20=20=20if=20(not=20= (string-prefix-p=20"_"=20(symbol-name=20name)))=0A=20=20=20=20=20=20=20=20= =20=20=20=20collect=20(cons=20(treesit-node-start=20node)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (treesit-node-end=20node))))=0A=20=0A@@=20-399,6=20+402,9=20@@=20= treesit-range-settings=0A=20range=20to=20the=20range=20spanned=20by=20= captured=20nodes.=20=20QUERY=20must=20be=20a=0A=20compiled=20query.=0A=20= =0A+Capture=20names=20generally=20don't=20matter,=20but=20names=20that=20= starts=20with=0A+an=20underscore=20are=20ignored.=0A+=0A=20QUERY=20can=20= also=20be=20a=20function,=20in=20which=20case=20it=20is=20called=20with=20= 2=0A=20arguments,=20START=20and=20END.=20=20It=20should=20ensure=20= parsers'=20ranges=20are=0A=20correct=20in=20the=20region=20between=20= START=20and=20END.=0A@@=20-418,6=20+424,9=20@@=20treesit-range-rules=0A=20= Each=20QUERY=20is=20a=20tree-sitter=20query=20in=20either=20the=20= string,=0A=20s-expression=20or=20compiled=20form.=0A=20=0A+Capture=20= names=20generally=20don't=20matter,=20but=20names=20that=20starts=20with=0A= +an=20underscore=20are=20ignored.=0A+=0A=20For=20each=20QUERY,=20= :KEYWORD=20and=20VALUE=20pairs=20add=20meta=20information=20to=0A=20it.=20= =20For=20example,=0A=20=0A--=20=0A2.33.1=0A=0A= --Apple-Mail=_C19C1CC5-40F6-4BFB-B14A-97E439DD0C7D-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 27 04:58:06 2023 Received: (at 62951) by debbugs.gnu.org; 27 Apr 2023 08:58:06 +0000 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 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 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) 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 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Apr 2023 04:57:57 -0400 (EDT) Message-ID: <836bfacd-91ce-c138-71d9-3290d7a36e2b@gutov.dev> Date: Thu, 27 Apr 2023 11:57:55 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Content-Language: en-US To: Yuan Fu 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> From: Dmitry Gutov In-Reply-To: <90E66143-A3E2-4B76-AC0A-01DC5E841AFE@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 62951 Cc: Eli Zaretskii , 62951@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.9 (--) 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). From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 27 11:03:07 2023 Received: (at 62951) by debbugs.gnu.org; 27 Apr 2023 15:03:07 +0000 Received: from localhost ([127.0.0.1]:59550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps39G-0000WF-QD for submit@debbugs.gnu.org; Thu, 27 Apr 2023 11:03:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps39E-0000Vj-6D for 62951@debbugs.gnu.org; Thu, 27 Apr 2023 11:03:05 -0400 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 1ps398-0002vn-Ub; Thu, 27 Apr 2023 11:02:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=Vdx8hEYVtNp4Vf48AFlaNgNluPasm53TyAuYJJX6D2U=; b=P4V8tnpbQt2TPLxSmWCL UKQMSqJQC6eBlpU9351VgqHzlDDajInuz/DiQD1SSQox423Ak1ldCZBfc6ib9enhJtwRxo2qDjNPV 7kye0hHrpJ8kJkircJ9z0wsjmk/l6z2M+m7C4x6V3BeIW5/zHiB38hQ8AkB5liSo4cpGf/FrOXf1B VvhKx+Ja3rDLBtvBs7lnp/tf+W9lZhyP15kVLkE0rhE+YTbC8ddHu0CosbeWH8txQ7Yo0jNY9f8NO N4d2ZBG6jBy6/GTuc3GSny5AAwR+rAaZrRC/5bpEN3srN2B53OwwThX+ZP3FxXK6Eth8oPlTxPxBf bGI89/7bBuLthg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps395-00028K-U7; Thu, 27 Apr 2023 11:02:57 -0400 Date: Thu, 27 Apr 2023 18:03:28 +0300 Message-Id: <83jzxxs6yn.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> (message from Yuan Fu on Wed, 26 Apr 2023 20:14:45 -0700) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE 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> <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62951 Cc: dmitry@gutov.dev, 62951@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: -3.3 (---) > From: Yuan Fu > Date: Wed, 26 Apr 2023 20:14:45 -0700 > Cc: Eli Zaretskii , > 62951@debbugs.gnu.org > > Ok, here’s the patch. Eli, would you give it a try? It signals an error when I enable c-ts-mode: c-ts-mode: Cannot load language definition: not-found, ("libtree-sitter-emacs-c" "libtree-sitter-emacs-c.dll"), "No such file or directory" It looks like your "fake emacs-c language" trick somehow misfires? The value of treesit-load-name-override-list is nil, which is not what you intended, AFAICT? The only way I can make this work is by manually customizing treesit-load-name-override-list before loading c-ts-mode. Otherwise, looks quite good; here are some other problems I found: . some uses of FOR_EACH_TAIL are not fontified at all; examples: comp.c, line 2079, fns.c, line 189 . FOR_EACH_LIVE_BUFFER (data.c, line 1430) is not recognized? . FOR_EACH_FRAME (keyboard.c, line 1256) is not recognized? This is much better than before already, so I think you should install this on the emacs-29 branch, once you fix the above problems (assuming they are easily fixable). Thanks! From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 27 15:56:29 2023 Received: (at 62951) by debbugs.gnu.org; 27 Apr 2023 19:56:29 +0000 Received: from localhost ([127.0.0.1]:59863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps7jA-0002yz-Pp for submit@debbugs.gnu.org; Thu, 27 Apr 2023 15:56:29 -0400 Received: from mail-pf1-f171.google.com ([209.85.210.171]:55628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps7j8-0002yl-GL for 62951@debbugs.gnu.org; Thu, 27 Apr 2023 15:56:26 -0400 Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-63b5c4c769aso11099981b3a.3 for <62951@debbugs.gnu.org>; Thu, 27 Apr 2023 12:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682625380; x=1685217380; 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=aG1eIkyH0RmuLRiAJmc0g9+HliRjtKlB5JGZchelrpI=; b=BG9IUQrmTSOyaJ1I+nic1Yw49Cv0yQF4Pth4UgV0HaqcAAIczKnqCZyIAzcdkdkO2x N/lkTGUtEvNhmKvDEy4IENn6AAzIWM7QkLGlemmjdGQPMt0S7CJDwBQAqoBgry0RP3GF TNWD/4mV8Q/KjhqfpkuHuBQfV3zE3Qux3QaJ25xRcYNiQIOn6LbFPWmt29jQWF2plk42 rYeiELgZjyRosw9AwhpOOvqEcrp6Mc/gSiIUnwJzx1A1KjATcC9bmQx2o42xecNSyEmA 3x3yNiejXvpUccHLQgrrF8L4aKSebAj3/56wRu76WE8HSYrWrUmEmz1YN0vH28woRsKX p5Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682625380; x=1685217380; 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=aG1eIkyH0RmuLRiAJmc0g9+HliRjtKlB5JGZchelrpI=; b=OZmg5HWa3FUsneGVSrOthCT5hU/WGc6G33x7tjm06flOp6lBikOed8xEB/KJerj+xb mvktM68ZgkaBgy9A2rAOFVCipDzX/dlSd//KdFwIJfPTCc2od06pyITouZ/03ksuB2z0 7WgrQ4pZWNdzItfPY6D03h//nIUHsXQSy6XlbCHUUdan2oKSpWWlFtj2eVLtNpOK7p/U uWUZb9kGuu8grpmAJgb83Lx7RqpoR6V2c7+CsudGV7AKWZvnu5P4+B0T/2U2+B5GbwK3 9ECmuBuCZMwnkMyKmipvr2yGfjUrAndq4K2Y6jjVdhVhdOQB9cqaW3VX6EfRbKjhSMQv 0lgQ== X-Gm-Message-State: AC+VfDx0uSyBwseIfz02UZRPsBWAzCU8GeSoGUmOPd7x32Ouai2pAbcJ 33rgfapnz4lW444Hx57qyq4= X-Google-Smtp-Source: ACHHUZ78stmdCBQff7SSD1SgtPZLMgjP7J4wb5Um6Chy7xaj7cCuqXEotcqKu83ODcYP6R7niOTxMQ== X-Received: by 2002:a05:6a00:1946:b0:63d:3ae4:7c72 with SMTP id s6-20020a056a00194600b0063d3ae47c72mr3347684pfk.0.1682625380050; Thu, 27 Apr 2023 12:56:20 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id o64-20020a62cd43000000b0063d642dcd12sm14029357pfg.16.2023.04.27.12.56.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2023 12:56:19 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE From: Yuan Fu In-Reply-To: <83jzxxs6yn.fsf@gnu.org> Date: Thu, 27 Apr 2023 12:56:07 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <85A2194C-5C67-4AC2-A265-9C20F03FA5B6@gmail.com> 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> <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> <83jzxxs6yn.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: dmitry@gutov.dev, 62951@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 (-) > On Apr 27, 2023, at 8:03 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Wed, 26 Apr 2023 20:14:45 -0700 >> Cc: Eli Zaretskii , >> 62951@debbugs.gnu.org >>=20 >> Ok, here=E2=80=99s the patch. Eli, would you give it a try? >=20 > It signals an error when I enable c-ts-mode: >=20 > c-ts-mode: Cannot load language definition: not-found, = ("libtree-sitter-emacs-c" "libtree-sitter-emacs-c.dll"), "No such file = or directory" >=20 > It looks like your "fake emacs-c language" trick somehow misfires? > The value of treesit-load-name-override-list is nil, which is not what > you intended, AFAICT? The only way I can make this work is by > manually customizing treesit-load-name-override-list before loading > c-ts-mode. Duh, sorry, dumb mistake. Fixed. >=20 > Otherwise, looks quite good; here are some other problems I found: >=20 > . some uses of FOR_EACH_TAIL are not fontified at all; examples: > comp.c, line 2079, fns.c, line 189 You mean the FOE_EACH_TAIL part isn=E2=80=99t fontified, or the body = isn=E2=80=99t fontified? Because the body are always fontified here. = FOR_EACH_TAIL itself shouldn=E2=80=99t be fontified since it=E2=80=99s = just a macro call and a variable. > . FOR_EACH_LIVE_BUFFER (data.c, line 1430) is not recognized? > . FOR_EACH_FRAME (keyboard.c, line 1256) is not recognized? Didn=E2=80=99t know that they exited :-) Now I have FOR_EACH_TAIL, = FOR_EACH_TAIL_SAFE, FOR_EACH_ALIST_VALUE, FOR_EACH_LIVE_BUFFER, = FOR_EACH_FRAME. >=20 > This is much better than before already, so I think you should install > this on the emacs-29 branch, once you fix the above problems (assuming > they are easily fixable). Cool, I pushed the change. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 28 01:41:29 2023 Received: (at 62951) by debbugs.gnu.org; 28 Apr 2023 05:41:30 +0000 Received: from localhost ([127.0.0.1]:60241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psGrJ-0006BF-HR for submit@debbugs.gnu.org; Fri, 28 Apr 2023 01:41:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psGrG-0006B1-4C for 62951@debbugs.gnu.org; Fri, 28 Apr 2023 01:41:28 -0400 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 1psGrA-0001IE-Nb; Fri, 28 Apr 2023 01:41:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=cIMaIuil4W64HoCDA1TXB84ZHEJYvP36xCYmt5LxD+4=; b=nTm86ER6fhbbKspr8g+z grjYWoF01Tr/kUeJpCd7i6NwhlEuW9PaD2dYutZSXVXJ4zM3uHvjKe7uGaSWPCSdQc29JH1PWUe2W WxKriSTGD1Lo4kuwjYBAwKBEyUw8Metj1BwOrjEK/hAtZDp233XC2z1yOSQ/Nd7MTHFNNX3UyOOo7 xcTi+6ro7fgrbrYQxhdYWLjjDOxzxMb1R86bK9mK5g9uCkZq3Hs8huWi3dpP6lNWm0pPfy591nG9t kLXIzS7tLQgLgxFLRtnvaReSpyFOqaiUBs1urdYizaB4u25k2LQDwmaWKGt2LNFbhkRzHMMJI7ryG dAntPI+1yAJfcg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psGr9-0004bj-JH; Fri, 28 Apr 2023 01:41:19 -0400 Date: Fri, 28 Apr 2023 08:41:53 +0300 Message-Id: <838recsgv2.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <85A2194C-5C67-4AC2-A265-9C20F03FA5B6@gmail.com> (message from Yuan Fu on Thu, 27 Apr 2023 12:56:07 -0700) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE 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> <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> <83jzxxs6yn.fsf@gnu.org> <85A2194C-5C67-4AC2-A265-9C20F03FA5B6@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62951 Cc: dmitry@gutov.dev, 62951@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: -3.3 (---) > From: Yuan Fu > Date: Thu, 27 Apr 2023 12:56:07 -0700 > Cc: dmitry@gutov.dev, > 62951@debbugs.gnu.org > > > c-ts-mode: Cannot load language definition: not-found, ("libtree-sitter-emacs-c" "libtree-sitter-emacs-c.dll"), "No such file or directory" > > > > It looks like your "fake emacs-c language" trick somehow misfires? > > The value of treesit-load-name-override-list is nil, which is not what > > you intended, AFAICT? The only way I can make this work is by > > manually customizing treesit-load-name-override-list before loading > > c-ts-mode. > > Duh, sorry, dumb mistake. Fixed. Thanks. > > Otherwise, looks quite good; here are some other problems I found: > > > > . some uses of FOR_EACH_TAIL are not fontified at all; examples: > > comp.c, line 2079, fns.c, line 189 > > You mean the FOE_EACH_TAIL part isn’t fontified, or the body isn’t fontified? Because the body are always fontified here. FOR_EACH_TAIL itself shouldn’t be fontified since it’s just a macro call and a variable. I mean the macro itself, FOR_EACH_TAIL. If it isn't supposed to be fontified, then why is it fontified at line 856 of comp.c? It's inconsistent. (However, this is a very minor problem, so if fixing it is difficult, we can leave this alone for now.) > > . FOR_EACH_LIVE_BUFFER (data.c, line 1430) is not recognized? > > . FOR_EACH_FRAME (keyboard.c, line 1256) is not recognized? > > Didn’t know that they exited :-) Now I have FOR_EACH_TAIL, FOR_EACH_TAIL_SAFE, FOR_EACH_ALIST_VALUE, FOR_EACH_LIVE_BUFFER, FOR_EACH_FRAME. Great, thanks. > > This is much better than before already, so I think you should install > > this on the emacs-29 branch, once you fix the above problems (assuming > > they are easily fixable). > > Cool, I pushed the change. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 29 18:55:49 2023 Received: (at 62951) by debbugs.gnu.org; 29 Apr 2023 22:55:49 +0000 Received: from localhost ([127.0.0.1]:36814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pstTo-0001K0-Vg for submit@debbugs.gnu.org; Sat, 29 Apr 2023 18:55:49 -0400 Received: from mail-pj1-f45.google.com ([209.85.216.45]:51705) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pstTk-0001Ji-5d for 62951@debbugs.gnu.org; Sat, 29 Apr 2023 18:55:46 -0400 Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-24ded4b33d7so161805a91.3 for <62951@debbugs.gnu.org>; Sat, 29 Apr 2023 15:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682808938; x=1685400938; 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=Ae8j+Pjr/S5r6BaOZYAp2tOsKcCvUZJKXlJRGmN2sFA=; b=QPLJ4bIT6Rg3ogbtyBfgbtoQkqMufWBHLp3FM0C9YMEJXnxlal9vMdi5LOOTkHy8iF XW6p+O/ZlAav9GNwUuR/rT/ZJdjcCv7+NwsFG4IBy7OcNKAN0s3hSm/dHzF+JaUXz/Ub qUGqAqFK/IIqtk/Q0wiUpAUbAbmoB6do2LigU5VXYeOCkoXsDJsyU1mgh1/z7dwLanZg NypyUVBkwtLTgu/HZjEcQ89aqhn3pTio51yzR3XJUU9tfgLU+hYtDv/z2RRAXeyCJBay jVaJvRXzhelO/82lTo/C3xINmAuIaow1z89VUH7ArxavR7npzj8brmWMbY72ECtUHolK VqxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682808938; x=1685400938; 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=Ae8j+Pjr/S5r6BaOZYAp2tOsKcCvUZJKXlJRGmN2sFA=; b=WZOa18WcNCF9Jo2FH5Ev3aDLMk97TvhvKBIcFM50sCueXKDYWQDvAQ+OQ8VFukpaZz MfRYlR904GObiXg0H/Vnw6PXnLw5pWlhtpEqaeSJP874U0whheMNot1rDHtvg6WyHwcW BfG4dh86qd/H+V9FmJqm3NFhdYn2SZ92vEDsSufbNwQtERoHKHTMbN7Q6XKnpS7rxAze pIbAAvUMG1YnsbqGKbJ46lOKG0o2DE195dy8ZxzSPt8Yh1D1Bvi8ndrDiEw7+VqpLV4G v9Teq8Fv6NCiWvjuiuTlYxtP2SN73nIy2t0NrQnWNkj+yVBFRJ++Zw812u6bygd3m6Rm AATg== X-Gm-Message-State: AC+VfDwKATRc/u81I9D/vjcLvKW5dZ9YtMHOpFwoFPG45iJrNcRD5oxP pGLboyOA2r3oeo6dXfupwKk= X-Google-Smtp-Source: ACHHUZ64R8DZGbyXWWiK3LCcbEyoGKRbwzq9CYLbdSG9G37cbw0m3ASplhsoGV4BDpQv++pI3Ar/rw== X-Received: by 2002:a17:90a:4b05:b0:249:7224:41cb with SMTP id g5-20020a17090a4b0500b00249722441cbmr9860723pjh.31.1682808937885; Sat, 29 Apr 2023 15:55:37 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id bj19-20020a17090b089300b002465a7fc0cfsm16683806pjb.44.2023.04.29.15.55.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Apr 2023 15:55:37 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE From: Yuan Fu In-Reply-To: <838recsgv2.fsf@gnu.org> Date: Sat, 29 Apr 2023 15:55:26 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <09F6DE90-EA98-4758-A718-2BC4A12EA846@gmail.com> 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> <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> <83jzxxs6yn.fsf@gnu.org> <85A2194C-5C67-4AC2-A265-9C20F03FA5B6@gmail.com> <838recsgv2.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62951 Cc: Dmitry Gutov , 62951@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 (-) > On Apr 27, 2023, at 10:41 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Thu, 27 Apr 2023 12:56:07 -0700 >> Cc: dmitry@gutov.dev, >> 62951@debbugs.gnu.org >>=20 >>> c-ts-mode: Cannot load language definition: not-found, = ("libtree-sitter-emacs-c" "libtree-sitter-emacs-c.dll"), "No such file = or directory" >>>=20 >>> It looks like your "fake emacs-c language" trick somehow misfires? >>> The value of treesit-load-name-override-list is nil, which is not = what >>> you intended, AFAICT? The only way I can make this work is by >>> manually customizing treesit-load-name-override-list before loading >>> c-ts-mode. >>=20 >> Duh, sorry, dumb mistake. Fixed. >=20 > Thanks. >=20 >>> Otherwise, looks quite good; here are some other problems I found: >>>=20 >>> . some uses of FOR_EACH_TAIL are not fontified at all; examples: >>> comp.c, line 2079, fns.c, line 189 >>=20 >> You mean the FOE_EACH_TAIL part isn=E2=80=99t fontified, or the body = isn=E2=80=99t fontified? Because the body are always fontified here. = FOR_EACH_TAIL itself shouldn=E2=80=99t be fontified since it=E2=80=99s = just a macro call and a variable. >=20 > I mean the macro itself, FOR_EACH_TAIL. If it isn't supposed to be > fontified, then why is it fontified at line 856 of comp.c? It's > inconsistent. (However, this is a very minor problem, so if fixing > it is difficult, we can leave this alone for now.) Ah, I see. FOR_EACH_TAIL=E2=80=99s that has a bracketed body are not = skipped and still have fontification on them. I pushed a change so that = no one has fontification now. Also thanks for the doc fix :-) Yuan= From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 30 01:23:48 2023 Received: (at 62951) by debbugs.gnu.org; 30 Apr 2023 05:23:48 +0000 Received: from localhost ([127.0.0.1]:37055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pszXI-0003tB-BR for submit@debbugs.gnu.org; Sun, 30 Apr 2023 01:23:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pszXE-0003su-5U for 62951@debbugs.gnu.org; Sun, 30 Apr 2023 01:23:46 -0400 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 1pszX8-0008RI-Hn; Sun, 30 Apr 2023 01:23:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=E462ztfaW6rv1GDBNuWB5cabFm9Bj8ZBE8SX6Ky2vss=; b=JpvYQFo4zIg8RI61fwWc /OuU+cdpyl7FqoOipRiysJyNZSoPOFxK9fBxAY9Nv0p25PHOxb/VuxdzTrGVLAt/JMBxUUMUKXhpl oft94ftdcLzvoUxBvEZ9NTDVuX2OGtAt3sNaazJCP6HSBdqUjFba74aiH/QzG7tuVOSsOnmA6V4rS RQWyGOEErzs2A0Bx0VOKwobdi/ArfPCnYtcSLFDJZ6cL8oT/kPifxXFP581nMDNVxc2C/oY8yykhL FbSJO/88vAc8dNzaY1V7gagWtS+UEt+j9D9wRPQcoH+k/Ids4GWgSGpwkTM2opBG+XdJzoxfu74Ni eH8pXhG8YptF9A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pszX7-0005A1-M0; Sun, 30 Apr 2023 01:23:37 -0400 Date: Sun, 30 Apr 2023 08:24:16 +0300 Message-Id: <83mt2qoscf.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <09F6DE90-EA98-4758-A718-2BC4A12EA846@gmail.com> (message from Yuan Fu on Sat, 29 Apr 2023 15:55:26 -0700) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE 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> <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> <83jzxxs6yn.fsf@gnu.org> <85A2194C-5C67-4AC2-A265-9C20F03FA5B6@gmail.com> <838recsgv2.fsf@gnu.org> <09F6DE90-EA98-4758-A718-2BC4A12EA846@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62951 Cc: dmitry@gutov.dev, 62951@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: -3.3 (---) > From: Yuan Fu > Date: Sat, 29 Apr 2023 15:55:26 -0700 > Cc: Dmitry Gutov , > 62951@debbugs.gnu.org > > > I mean the macro itself, FOR_EACH_TAIL. If it isn't supposed to be > > fontified, then why is it fontified at line 856 of comp.c? It's > > inconsistent. (However, this is a very minor problem, so if fixing > > it is difficult, we can leave this alone for now.) > > Ah, I see. FOR_EACH_TAIL’s that has a bracketed body are not skipped and still have fontification on them. I pushed a change so that no one has fontification now. Thanks, looks good now. From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 30 01:25:22 2023 Received: (at control) by debbugs.gnu.org; 30 Apr 2023 05:25:22 +0000 Received: from localhost ([127.0.0.1]:37060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pszYn-0003vm-Ul for submit@debbugs.gnu.org; Sun, 30 Apr 2023 01:25:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pszYm-0003va-Oa for control@debbugs.gnu.org; Sun, 30 Apr 2023 01:25:21 -0400 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 1pszYg-0000IH-Bh for control@debbugs.gnu.org; Sun, 30 Apr 2023 01:25:14 -0400 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=w+yn/SxvR+RaoUnxwAbihyPsCQWgxm/WNdoBH6TvhjY=; b=hDqWFK9usvYp IjkA6QM1aboMgBl8WrOkepCbL2rZzuthC6M6F9Lk3NYrBmpZiB+VyTfQc1Hs+HBqvOXPo5rvi02Xo AqkVbdIzBu/eUgpOuLcA9fnDx3LAVkJnDF6E+zXjXr+xmjcY+/ytAzYkYbcNvelDRYQM4k6Imv2/H N+XAXLKa37HCY4+rtWiFhAUAVJj49ekuOC59MvPEx7CX3j7TKQKKoIKmkLh11xnZScInPl/S4iM3M 7F1zH7cgBA03meO5zJugSZAEburfndnB33SXT+A1I3k1l6bDlnFO6FvgV5bdbVwgQLtphst3bHUiC DDusRYJa/zhIWQDTZEPdlQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pszYe-0005GW-CT for control@debbugs.gnu.org; Sun, 30 Apr 2023 01:25:13 -0400 Date: Sun, 30 Apr 2023 08:25:52 +0300 Message-Id: <83leiaos9r.fsf@gnu.org> From: Eli Zaretskii To: control@debbugs.gnu.org In-Reply-To: <09F6DE90-EA98-4758-A718-2BC4A12EA846@gmail.com> (message from Yuan Fu on Sat, 29 Apr 2023 15:55:26 -0700) Subject: Re: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE 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> <36F36D54-E56C-42C8-B686-448C8BF938EA@gmail.com> <83jzxxs6yn.fsf@gnu.org> <85A2194C-5C67-4AC2-A265-9C20F03FA5B6@gmail.com> <838recsgv2.fsf@gnu.org> <09F6DE90-EA98-4758-A718-2BC4A12EA846@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control 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: -3.3 (---) close 62951 29.1 thanks From unknown Mon Jun 23 04:09:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 28 May 2023 11:24:05 +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