all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Paul Nelson <ultrono@gmail.com>, Lars Ingebrigtsen <larsi@gnus.org>
Cc: acm@muc.de, 48100@debbugs.gnu.org
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	[thread overview]
Message-ID: <YI6Z9mINikn2zzhp@ACM> (raw)
In-Reply-To: <CAOA-32PSKEQC8mzO64KGWu-Og+AF6zWTtCgO-gjes5CnvNHaiQ@mail.gmail.com>

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 <cstdio>
> #include <cstdlib>
> #include <cstring>
> #include <climits>
> #include <cfloat>
> #include <vector>
> #include <cmath>
> #include <set>
> #include <list>
> #include <map>
> #include <stack>
> #include <queue>
> #include <iostream>
> #include <sstream>
> #include <fstream>
> #include <algorithm>
> #include <numeric>
> #include <functional>
> #include <cstdio>
> #include <cstdlib>
> #include <cstring>
> #include <climits>
> #include <cfloat>
> #include <vector>
> #include <cmath>
> #include <set>
> #include <list>
> #include <map>
> #include <stack>

> 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 <stack>).

> 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).






  parent reply	other threads:[~2021-05-02 12:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29  8:04 bug#48100: 28.0.50; inserting too many lines into a fresh cpp file breaks the buffer Paul Nelson
2021-05-02  7:58 ` Lars Ingebrigtsen
2021-05-02 12:24 ` Alan Mackenzie [this message]
2021-05-02 13:33   ` Basil L. Contovounesios
2021-05-02 15:01     ` Alan Mackenzie
2021-05-05  3:01       ` Paul Nelson
2021-05-05  9:26         ` Lars Ingebrigtsen
2021-05-05 10:18         ` Alan Mackenzie
2021-05-06 10:26           ` Paul Nelson
2021-05-09  9:33             ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YI6Z9mINikn2zzhp@ACM \
    --to=acm@muc.de \
    --cc=48100@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=ultrono@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.