GNU bug report logs -
#40338
27.0.60; c-fill-paragraph and after-change-functions
Previous Next
Reported by: Yuan Fu <casouri <at> gmail.com>
Date: Tue, 31 Mar 2020 01:28:02 UTC
Severity: normal
Found in version 27.0.60
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#40338: 27.0.60; c-fill-paragraph and after-change-functions
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 40338 <at> debbugs.gnu.org.
--
40338: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=40338
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
> Begin forwarded message:
>
> From: Yuan Fu <casouri <at> gmail.com>
> 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 <npostavs <at> gmail.com>
> Cc: 40338 <at> debbugs.gnu.org
>
>
>
>> On Mar 30, 2020, at 9:56 PM, Noam Postavsky <npostavs <at> gmail.com> wrote:
>>
>> Yuan Fu <casouri <at> gmail.com> 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.
>
> Yuan
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
[Message part 6 (text/plain, inline)]
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
[track.el (application/octet-stream, attachment)]
[test.c (application/octet-stream, attachment)]
[Message part 9 (text/plain, inline)]
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))
This bug report was last modified 5 years and 52 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.