From: Yuan Fu <casouri@gmail.com>
To: 40338@debbugs.gnu.org
Subject: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions
Date: Mon, 30 Mar 2020 21:27:33 -0400 [thread overview]
Message-ID: <A1AE86DE-CBAD-4347-88D0-FB08E9B422B8@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 876 bytes --]
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
[-- Attachment #2: track.el --]
[-- Type: application/octet-stream, Size: 511 bytes --]
(defun mytrack ()
(let ((content (buffer-string)))
(with-current-buffer (get-buffer-create "trackbuf")
(erase-buffer)
(insert content))
(add-hook 'after-change-functions #'mytrack-hook nil t)))
(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)))))
[-- Attachment #3: test.c --]
[-- Type: application/octet-stream, Size: 696 bytes --]
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include "dep.h"
// Writes data to the given channel
// This is a blocking call i.e., the function only returns on a successful completion of send
// In case the channel is full, the function waits till the channel has space to write the new data
// Returns SUCCESS for successfully writing data to the channel,
// CLOSED_ERROR if the channel is closed, and
// GEN_ERROR on encountering any other generic error of any sort
int add(int x, int y) {
return x + y;
}
int main() {
char arr[4];
arr[0] = 'a';
arr[1] = 'b';
arr[2] = 'c';
arr[3] = 'd';
int x = 1;
int y = -1;
int z = 0;
int j = add(z, y);
return 0;
}
[-- Attachment #4: Type: text/plain, Size: 3311 bytes --]
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))
next reply other threads:[~2020-03-31 1:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 1:27 Yuan Fu [this message]
2020-03-31 1:56 ` bug#40338: 27.0.60; c-fill-paragraph and after-change-functions Noam Postavsky
2020-03-31 15:27 ` Yuan Fu
2020-03-31 17:09 ` bug#40338: Fwd: " Yuan Fu
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=A1AE86DE-CBAD-4347-88D0-FB08E9B422B8@gmail.com \
--to=casouri@gmail.com \
--cc=40338@debbugs.gnu.org \
/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.