Subject: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions

From: Yuan Fu <[email-masked]>
Date: Mon, 30 Mar 2020 21:27:33 -0400

Background: I use eglot with c-mode and every time I use c-fill-paragraph, eglot breaks—it reports a syntax error when there isn’t. It seems that eglot’s image of the buffer’s content (or what it thinks is in the buffer) is corrupted. I can fix this by revert-buffer. I have a feeling that this has something to do with after-change-functions because that’s the only way eglot gets updated with buffer changes. So I setup an experiment. It goes like this:

Open track.el and eval-buffer; then go to test.c and M-: (mytrack); then open the tracking buffer “trackbuf” in another window. Now if you edit in test.c, the change should be reflected in trackbuf. Now try M-q. Both buffer ends up in a corrupted state. 

I tried to look at c-fill-paragraph but it’s too complicated. I hope someone with more expertise in c-mode could give some insight.

Yuan

In GNU Emacs 27.0.60 (build 1, x86_64-apple-darwin19.3.0, NS appkit-1894.30 Version 10.15.3 (Build 19D76))
of 2020-02-25 built on missSilver
Repository revision: f27187f963e9e36435b508e29256e048799e0ff2
Repository branch: emacs-27
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.4

Recent messages:
Wrote /Users/yuan/Desktop/test.c
C-= is undefined
scroll-up-command: End of buffer
Mark set [3 times]
Saving file /Users/yuan/Desktop/track.el...
Wrote /Users/yuan/Desktop/track.el
mytrack-hook
(mytrack-hook)
save-current-buffer: Args out of range: #<buffer trackbuf>, 421, 422
Undo
(mytrack-hook)
Configured using:
'configure --with-modules --with-pdumper=yes
--oldincludedir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2/'

Configured features:
RSVG GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS XIM
NS MODULES THREADS PDUMPER LCMS2

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_CN.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C/*l

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search seq byte-opt gv
bytecomp byte-compile cconv 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 cc-mode
cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic 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 charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue cocoa ns
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 70716 8607)
(symbols 48 8390 1)
(strings 32 21585 1417)
(string-bytes 1 808085)
(vectors 16 12103)
(vector-slots 8 152019 12686)
(floats 8 25 62)
(intervals 56 999 22)
(buffers 1000 16))