From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: CC Mode troubles and Emacs 29 Date: Wed, 11 Jan 2023 09:36:25 +0800 Message-ID: <87zgapg8di.fsf@yahoo.com> References: <874jt0hw7p.fsf.ref@yahoo.com> <874jt0hw7p.fsf@yahoo.com> <838ribq48f.fsf@gnu.org> <87zgarhl7j.fsf@yahoo.com> <83zgarodeh.fsf@gnu.org> <87v8lfgpwf.fsf@yahoo.com> <83k01uo8db.fsf@gnu.org> <56368889cb296ad26b5e@heytings.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25482"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , acm@muc.de, emacs-devel@gnu.org To: Gregory Heytings Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 11 02:37:39 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFQ3e-0006Cu-Qm for ged-emacs-devel@m.gmane-mx.org; Wed, 11 Jan 2023 02:37:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFQ2m-00085b-F0; Tue, 10 Jan 2023 20:36:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFQ2k-000858-NN for emacs-devel@gnu.org; Tue, 10 Jan 2023 20:36:42 -0500 Original-Received: from sonic317-33.consmr.mail.ne1.yahoo.com ([66.163.184.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFQ2i-0001nP-K9 for emacs-devel@gnu.org; Tue, 10 Jan 2023 20:36:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1673400997; bh=7L9UOzlgz9LXuLGKFsTV914jqt78LX7moH/cqVtWCEQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=qgEtHj/BDm4kB5HNEvYSo74NH49GrMDVsx/mDRb+yPP7QGBV61RMvE/9beNqIL8VaopTPWsNqIh3CFvQ1ij3Im+dZQCNX3Zm6wCPasJxcbiS7h5StW3udv4Z82zDGoyz2YCeUzz25+PKxrfkMIS18tx6BsoC8rRWwg0/zgOFJ4NHK40LFis5yQqIQWyQBQhziSj0hPcjtua4tCznlrGby0QupV9ZzTLPuxVTTQ8hFCYntWrknlz+1gnuwWS0u35fC8g7G4wVSa8E1qV68I4LZdBWT2UAS3CP/L6BNzNLM7EaUt4T0Iy0Iwqmhy1ppO3zbi7KN5OtjCmoPeFvsap51g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1673400997; bh=r9R3+9W/dYNh/sj43mw2+3MwVdzW926xEmGPzqwcBCF=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=A4nVJFDsotLhkPSh7H0obtmgti0fPurOpT7bR5UEFulaPQR3w2zaOKht9vowss/7Fo8AW+Nxoah7SKWmTXOYruzxyt9u0Nu6Om7c0TUopaHr/KFnLtj5RyQgKQdcel4a3WMZA0dwZovO1Thz7OyYVeU4MSa96XywC9E9BNX83VxHHt90QWflBoVFORdTyRIbHkcJV0BpoX5FqJ/CsHs9yPSs/pxDLRBxrgZFcwVzAteCdzTI0318Lu8d8OXrGwHAWAfOsv7fEsGGRVxLPx/Mt74uMpMJrzFhDlqFMwi3JUUNFoATq36DL+qDG6UuOfvAUNv0/2k/gM2TFixLSs/GDw== X-YMail-OSG: xCBiwwQVM1nYjNCN0QS0wvBs4PSYyqQu6PO2kvQWsSaNq9GQrzTYpmNzwcEPoHf KDnR8FTvGS_.n2ZwP0PC2PIfynVtw.fm4Lzz4sTDkUQfWyGh9EqwMcKGdQ2Wlq2oPtOtLtBi_lDP _aqkUcIIkWkiUkHgHro6VetAVidq_cbk3FpxUBwIAF186LUtC0.KKGnzX7HI5Yn55qFBd84oY8fR HY9GFcbf_KYnNdEIZowg__OF9yViW.oM92pxb8FOAzuhR5iKT1qwuLo5RWG2vCz84TMliN5AJhbG FM40ZQqDY3l7TXuuOPfK7rQSSXK45Qa46edMP8oGBSnVwytsQKA_2g3eyyR_sRg4kmsMiWAozHHZ 2Jkn10EMaE.vUKIGarhyd8s9TAxfjnJxnYgyQLPBgVQ2mEBxlrLD8Kp3_wdPONwseA8XEDIIdvpV g0qeCagk7o8Xwpw12BqsMwbXpjqM192lzoccFJ_2K7uwdVxWuF8faB9bYTYb3FNfKk9VhsNfIk6W FfY2BdGamZsnRRElypukQSYPWQ5vkOGaCBX84JiLk1Yn4vT8j5WqWMhwVG4tUUGoaU8M1tmwlr8Z vfh1v91l477pKSf3hfDCTRMrpgeZOkq8vLryx2TlKgZJ1EnNB6CTXYFSm4iFgnb3qFEXK5fkm2.g zwroqeANme8BTrUskE__X7JZQquhH3GWC.6WsvXyUxZHCTM7qRxo_CmM6ODjhcAimw8loliEhFrJ .bEz2Ip4Tp3Hw6bz6caOJ_ZFQiXJw3fdKNuxhbHR_k1wAQ91eVGyiqZrgGDktS_rD_.2di7vLMKs MiI4lezHfdcgDFFTGnPcdqu6jq2JDouKtlLRCKhK2z X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Wed, 11 Jan 2023 01:36:37 +0000 Original-Received: by hermes--production-sg3-5ff5bbd69d-px9nq (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID a912945922f29e482f1794d9c12aad98; Wed, 11 Jan 2023 01:36:33 +0000 (UTC) In-Reply-To: <56368889cb296ad26b5e@heytings.org> (Gregory Heytings's message of "Tue, 10 Jan 2023 14:13:27 +0000") X-Mailer: WebService/1.1.20982 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.184.44; envelope-from=luangruo@yahoo.com; helo=sonic317-33.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302323 Archived-At: Gregory Heytings writes: > It's indeed exaggerated, AFAIU. Basically, it's an effect of the > c-fontify-new-found-type function, which was added to CC Mode in Oct > 2021 because of this thread: It's not exaggerated at all. After 20 minutes to an hour of work, C Mode must be turned on and off again. > https://lists.gnu.org/archive/html/emacs-devel/2021-06/msg00174.html. Yes, because of the long ensuing thread from there on, C Mode is now much more annoying to work with than it was in Emacs 28. Previously, CC Mode fontification was missing some types. Judge for yourself what is better: missing types, or randomly adding types? > A simple recipe is this: > > emacs -Q > C-x C-f foo.c > > and type: > > int main () { int foo; foo = 1; } > typedef foo SPC > > Now 'foo' in 'foo = 1' is fontified in green, because CC Mode > considers that 'foo' is a type. If you now realize that 'foo' is a > typo, and that what you actually meant is 'foobar', and correct that > typo with DEL bar, 'foo' in 'foo = 1' does not loose its type > fontification. And if you do that often enough, in the end the buffer > is "filled with green splotches". Note that this can easily be fixed > with C-u C-x x f C-x x f. Or re-enabling C Mode. Both of which are annoying things that weren't necessary in Emacs 28. And that's not the only situation under which incorrect recognition of types occurs. Sometimes, CC Mode will recognize a random identifier in an incompletely entered statement as a type. Most of that was fixed in November, but there's one or two which have not been fixed that I haven't been able to reproduce consistently. > It's actually a nice example of the inherent limits of a fontification > that is not based on an actual parser. It worked in Emacs 28, 27, and since before that, because it really is not vital for CC Mode to proactively look for types. AFAIU tree-sitter has the same problem: it does not understand typedefs previously encountered in a buffer, so in the following piece of code: IV_reset_1603 (regRange, regBlock, t2busProbe) long regBlock; Handle t2busProbe; { register *BP, *DP; /* ... */ } it cannot know whether or not `regRange' is a typedef name or an identifier. (This is a big problem with parsing the C language in general.) Or in the following Java code: import org.gnu.emacs.EmacsActivity; where whether or not `EmacsActivity' is a type name is ambiguous: it could have as well been part of a package name. Java is particularly nasty because the only way to know what `EmacsActivity' is is by looking at the file system. Yet the CC Mode type discovery happens to work very well in Java, resulting in consistently fontified blocks of import statements. Besides, Alan says he already has a fix, so I would hardly call it an inherent limit of anything. In the meantime, the so-called ``fontification based on an actual parser'' does not even understand traditional C code. Last I checked, it also had problems indenting the Motif WM hints structure that people copy everywhere.