[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40338: closed (27.0.60; c-fill-paragraph and after-change-functions)

From: GNU bug Tracking System
Subject: bug#40338: closed (27.0.60; c-fill-paragraph and after-change-functions)
Date: Tue, 31 Mar 2020 17:10:02 +0000

Your message dated Tue, 31 Mar 2020 13:09:18 -0400
with message-id <address@hidden>
and subject line Fwd: bug#40338: 27.0.60; c-fill-paragraph and 
has caused the debbugs.gnu.org bug report #40338,
regarding 27.0.60; c-fill-paragraph and after-change-functions
to be marked as done.

(If you believe you have received this mail in error, please contact

40338: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=40338
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 27.0.60; c-fill-paragraph and after-change-functions 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.


Attachment: track.el
Description: Binary data

Attachment: test.c
Description: Binary data

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
save-current-buffer: Args out of range: #<buffer trackbuf>, 421, 422
Configured using:
'configure --with-modules --with-pdumper=yes

Configured features:

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.

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

--- End Message ---
--- Begin Message --- Subject: Fwd: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions Date: Tue, 31 Mar 2020 13:09:18 -0400

Begin forwarded message:

From: Yuan Fu <address@hidden>
Subject: Re: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions
Date: March 31, 2020 at 11:27:23 AM GMT-4
To: Noam Postavsky <address@hidden>

On Mar 30, 2020, at 9:56 PM, Noam Postavsky <address@hidden> wrote:

Yuan Fu <address@hidden> writes:

(defun mytrack-hook (beg end len)
(if (> len 0)
    ;; delete
    (with-current-buffer trackbuf
      (delete-region beg (+ beg len)))
  ;; insert
  (let ((content (buffer-substring beg end)))
    (with-current-buffer trackbuf
      (goto-char beg)
      (insert content)))))

I'm not very familiar with either eglot or cc-mode, but I can say the
problem in your example lies with mytrack-hook: there can be kinds of
changes other than just pure delete or insert (replace, for example).
It can be fixed like this:

(defun mytrack-hook (beg end len)
(when (> len 0)
  ;; Delete old text.
  (with-current-buffer "trackbuf"
    (delete-region beg (+ beg len))))
;; Insert new text.
(let ((content (buffer-substring beg end)))
  (with-current-buffer "trackbuf"
    (goto-char beg)
    (insert content))))

Thank you. Indeed this works. Maybe the problem is not in c-fill-paragraph.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]