From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#48100: 28.0.50; inserting too many lines into a fresh cpp file breaks the buffer Date: Sun, 2 May 2021 12:24:22 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17970"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 48100@debbugs.gnu.org To: Paul Nelson , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 02 14:26:25 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldBB3-0004aY-G0 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 14:26:25 +0200 Original-Received: from localhost ([::1]:33148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldBB2-0008H4-It for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 08:26:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldB9k-0008Fm-IM for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 08:25:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldB9i-0006sV-9g for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 08:25:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ldB9i-0006gU-62 for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 08:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 May 2021 12:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48100 X-GNU-PR-Package: emacs Original-Received: via spool by 48100-submit@debbugs.gnu.org id=B48100.161995827125680 (code B ref 48100); Sun, 02 May 2021 12:25:02 +0000 Original-Received: (at 48100) by debbugs.gnu.org; 2 May 2021 12:24:31 +0000 Original-Received: from localhost ([127.0.0.1]:42530 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldB9D-0006g8-EI for submit@debbugs.gnu.org; Sun, 02 May 2021 08:24:31 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:37352 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ldB9B-0006g2-M6 for 48100@debbugs.gnu.org; Sun, 02 May 2021 08:24:30 -0400 Original-Received: (qmail 67784 invoked by uid 3782); 2 May 2021 12:24:23 -0000 Original-Received: from acm.muc.de (p4fe153df.dip0.t-ipconnect.de [79.225.83.223]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 02 May 2021 14:24:22 +0200 Original-Received: (qmail 19040 invoked by uid 1000); 2 May 2021 12:24:22 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205426 Archived-At: Hello, Paul and Lars. On Thu, Apr 29, 2021 at 10:04:36 +0200, Paul Nelson wrote: > Inserting a sufficiently large chunk of text into a fresh cpp file > breaks syntax highlighting and causes the buffer to enter a > semi-permanent broken state. Moreover, the offending function > "c-guess-basic-syntax" seems to break edebug instrumentation. Thanks for taking the trouble to report these bugs. > In more detail: > Start from emacs -Q. Insert sufficiently many lines of C++ code in a > temporary buffer. A slightly contrived example: > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > Copy these lines to the kill ring. Create a new file "test.cpp", and > paste what was copied. I'm assuming here that by "paste" you mean type C-y. > The first error is that syntax highlighting stops after a certain > number of lines (in the above example, just before the final line). I can't reproduce this, that's on GNU/Linux, neither in a tty nor in X-Windows. However, it looks like on your machine Emacs is fontifying one single 500-byte chunk (which is rounded up to the next EOL) and then neglecting the rest of the lines input (i.e. the final line with ). > The same problem arises if such lines are inserted via abbrev-mode. > This is the intended use case. > No problem if such lines are copy/pasted in small enough chunks. > The problem *appears* to go away if one cuts and then pastes the > offending lines, but the buffer remains in a broken state. For > instance, attempting to insert a couple newlines followed by > int main( > gives the following error: > Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) > c-guess-basic-syntax() > c-indent-line() > indent-according-to-mode() > c-electric-paren(nil) > funcall-interactively(c-electric-paren nil) > command-execute(c-electric-paren) I can't reproduce that either, I'm afraid. At least, not yet. > Incidentally, "C-u C-M-x" applied to c-guess-basic-syntax gives a long and > complicated backtrace that starts with: > Debugger entered--Lisp error: (invalid-read-syntax "Expected" "lambda") > edebug-syntax-error("Expected" "lambda") That, I can reproduce. After a bit of experimentation, it would appear that this is due to the lack of an edebug-spec for the macro c-save-buffer-state. To confirm this in the most basic manner, type M-: (def-edebug-spec c-save-buffer-state let*) , after which C-u C-M-x works on c-guess-basic-syntax. More practically, this situation can be worked around with M-x load-library RET cc-mode RET , which loads cc-defs.elc, which contains the pertinent edebug-spec. I don't understand how that edebug-spec in cc-defs.elc is not loaded anyway, given the you're already using CC Mode. Perhaps that will become clearer in the next few days. > In GNU Emacs 28.0.50 (build 2, x86_64-apple-darwin19.6.0, NS appkit-1894.60 > Version 10.15.7 (Build 19H524)) > of 2021-04-26 built on Pauls-MBP-2 > Repository revision: 9d34fd8b33c55768190d41239931120e3fc9717f > Repository branch: master > Windowing system distributor 'Apple', version 10.3.1894 > System Description: Mac OS X 10.15.7 > Configured using: > 'configure --with-native-compilation' [ .... ] -- Alan Mackenzie (Nuremberg, Germany).