From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions Date: Mon, 30 Mar 2020 21:27:33 -0400 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="103319"; mail-complaints-to="usenet@ciao.gmane.io" To: 40338@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 31 03:28:17 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJ5hR-000Qmz-4d for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Mar 2020 03:28:17 +0200 Original-Received: from localhost ([::1]:59090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ5hQ-0002dn-4b for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Mar 2020 21:28:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46538) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ5hH-0002bn-R6 for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:28:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJ5hD-000484-Ek for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:28:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJ5hD-00047I-B3 for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:28:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jJ5hC-0006yd-8D for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 31 Mar 2020 01:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 40338 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Bug Report Emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.158561806026789 (code B ref -1); Tue, 31 Mar 2020 01:28:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Mar 2020 01:27:40 +0000 Original-Received: from localhost ([127.0.0.1]:35306 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ5gq-0006y0-3C for submit@debbugs.gnu.org; Mon, 30 Mar 2020 21:27:40 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:36857) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ5gp-0006xt-2q for submit@debbugs.gnu.org; Mon, 30 Mar 2020 21:27:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46463) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ5gn-0002Xb-PP for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:27:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJ5gm-0003p3-DY for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:27:37 -0400 Original-Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:32920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJ5gm-0003oS-34 for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 21:27:36 -0400 Original-Received: by mail-qt1-x831.google.com with SMTP id c14so17060528qtp.0 for ; Mon, 30 Mar 2020 18:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:message-id:date:to; bh=QZKD3NHfBmf4STos6fPd73h9EbbGnp5AUSydaw0c/Xs=; b=EDYxCZ47/uVlnvfgHK7eniCVNGmsIbXATDZ0hmo2iy8hE4RbvsSmvpDirw+siUR6Vi 25EItdy6b/qPaRjitrO2a5wxyAO1LFKoOSCsAG9oUcogX+OZO3Zuoy75Ml4ax5vG7BBf BZvsyiH+qYG04zSuCoBcUGP0kM1EQ6XHZsCF60TfHyfu2Z1eDpapYqFh5yqZw4RoPO7T +6vtuel5laZwX9Oay5wUJUgjPi0tf6UQ/tgjVAllhZyCw0X4crGusd23YtbyAJ2UrsJs G2wBN6ydP4o/sipm8wkk6972vEcGJ5/fEKvJbSd/Tdwfl72tdGdWr2CDIGazozzn9DLl pZAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=QZKD3NHfBmf4STos6fPd73h9EbbGnp5AUSydaw0c/Xs=; b=f1N9vSrWOPYTm+bwhO5rH6oJEddQVy9zOoVe+7adoH90Jr9gcrKcAVQgJwzMyLFNsp 4cYCPFY/zKA+23ljF/I8sIqI9jIpvUeElugbyTQRioCb9v4h4AHN+zvd/lgOPkhHiwoE 9fglusKFd8pEUTj6493dqrME8nP23U2AMDuD8qQjwIqYNAmKAb4yVG7m1HcaEtRPWeBy 4lXZI1p8gp0riH95AUC2KmXbP26C//EXNUz28UO5VnLrOEuoyeNJkvZgCk2r8AMrSkRu yT9zEXPXzOcS8T9t+qrTAqBQ0IduPDX5qnhaPBX3oDOGoi9XbF6g2HYCtVTClm159BtE JsMA== X-Gm-Message-State: ANhLgQ1l5MOPbpirSldshtIeFKNp1rO0j9WR8+Je6cg1wflpNKTDNSaQ 0fa+r+7JRM9th0Qu3Ju05e+n+xK8+n4urQ== X-Google-Smtp-Source: ADFU+vvgM+gCdSIbX2l/W1K17dydfldvbM8KbemIVowI+dg8mmZzmnD6L7fC+/74ykaH04VSzU8sAA== X-Received: by 2002:ac8:3386:: with SMTP id c6mr2958869qtb.236.1585618054731; Mon, 30 Mar 2020 18:27:34 -0700 (PDT) Original-Received: from [192.168.1.5] (c-174-60-229-153.hsd1.pa.comcast.net. [174.60.229.153]) by smtp.gmail.com with ESMTPSA id v5sm1723750qka.106.2020.03.30.18.27.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2020 18:27:34 -0700 (PDT) X-Mailer: Apple Mail (2.3608.80.23.2.2) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177898 Archived-At: --Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Background: I use eglot with c-mode and every time I use = c-fill-paragraph, eglot breaks=E2=80=94it reports a syntax error when = there isn=E2=80=99t. It seems that eglot=E2=80=99s image of the = buffer=E2=80=99s 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=E2=80=99s = 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 =E2=80=9Ctrackbuf=E2=80=9D 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.=20 I tried to look at c-fill-paragraph but it=E2=80=99s too complicated. I = hope someone with more expertise in c-mode could give some insight. Yuan --Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196 Content-Disposition: attachment; filename=track.el Content-Type: application/octet-stream; x-unix-mode=0700; name="track.el" Content-Transfer-Encoding: 7bit (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))))) --Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196 Content-Disposition: attachment; filename=test.c Content-Type: application/octet-stream; x-unix-mode=0700; name="test.c" Content-Transfer-Encoding: 7bit #include #include #include #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; } --Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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-=3D 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: #, 421, 422 Undo (mytrack-hook) Configured using: 'configure --with-modules --with-pdumper=3Dyes = --oldincludedir=3D/Applications/Xcode.app/Contents/Developer/Platforms/Mac= OSX.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)) --Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196--