From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 30 21:27:40 2020 Received: (at submit) by debbugs.gnu.org; 31 Mar 2020 01:27:40 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 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 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 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) 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) From: Yuan Fu Content-Type: multipart/mixed; boundary="Apple-Mail=_FEFD736B-5B9F-4619-B707-5BDA7630E196" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: 27.0.60; c-fill-paragraph and after-change-functions Message-Id: Date: Mon, 30 Mar 2020 21:27:33 -0400 To: Bug Report Emacs 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-Received-From: 2607:f8b0:4864:20::831 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --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-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 30 21:57:06 2020 Received: (at 40338) by debbugs.gnu.org; 31 Mar 2020 01:57:06 +0000 Received: from localhost ([127.0.0.1]:35323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ69J-0001MQ-WF for submit@debbugs.gnu.org; Mon, 30 Mar 2020 21:57:06 -0400 Received: from mail-qt1-f170.google.com ([209.85.160.170]:44599) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ69H-0001Lq-Tn for 40338@debbugs.gnu.org; Mon, 30 Mar 2020 21:57:04 -0400 Received: by mail-qt1-f170.google.com with SMTP id x16so17060672qts.11 for <40338@debbugs.gnu.org>; Mon, 30 Mar 2020 18:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ph7qcv/Xp2V2RWCUqJ8l2YFm5W/NobjeBqor/zZJj3U=; b=WB9Hogoec9oRaE8ib1CI/KNLY7PJiNjtNlQchpVXaxJpfGcGY1OX9K0f3/0bWmILQ0 cp8fN0vyWERJ2Gn0DtpLZlv8KiPCojQ6xBWS/o2wc4hWG+uX3853hywkgr/phpFhmtgk wvX4R5S/WHvvtDff/E1gyMcfFZhQgmPF92EHTIej6LLUjw3ioZCqGoCFwp+tlq5XxV5N tY7KWAODslqf2Q1Id8qFKageZCqYP5h7PWCu3b/JGm0xfejBusQEDBHqwdvfAIyI+gMa CutVMJEg186a3ia0Q4F62q2//c+zFT9Jnxwh513fbOMm/MFrbVMf4oAmjxb9KYhcAT34 qM6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ph7qcv/Xp2V2RWCUqJ8l2YFm5W/NobjeBqor/zZJj3U=; b=r7UqDiiMnH0UpG96Q6UUZXxCTmALYmKD3mkObSjAqKjC1vChOaHSe9Jp9AbtXopOTl Hl4D3rPHJ5KbmlZVMoQKwHeYT6K2dveKuX+6Vsm/UH19OHCX7oE/o2lDvtZ4R8RtTTVb JKvybMzgu3fxjkdzgZZBZJfbXUtWeZc6iY2wIpkx0XTrtsakKekGgfREiiMAFM3D58ja MPcLarRHxHJg1go4ttjzcHQcTCz2WRUNI7XyoQCpbMqG5goGAWwt8nzhTnIosEi181b6 pUmOYaYyUronY/0F+2tSPcE4KxRABkjaGW1RaYjkZNQJFdN/AQ/WikiXrIW3h/g3st7O 0pXw== X-Gm-Message-State: ANhLgQ2Nv87MLuWKdvcXVCjK781jMczyrHJV6t42bvJPnp965eFBavyI Pbp76p0vrV3gZ6aWR+MDEFrfTTjo X-Google-Smtp-Source: ADFU+vsKagviEyXXe5L4eb77ANHrYuXMBXU4z9+h11CWYHTKmAbfAfFhX5bJQ/qp/CkAjG5VzyGe6Q== X-Received: by 2002:ac8:304d:: with SMTP id g13mr2979331qte.221.1585619818228; Mon, 30 Mar 2020 18:56:58 -0700 (PDT) Received: from minid (cbl-45-2-119-47.yyz.frontiernetworks.ca. [45.2.119.47]) by smtp.gmail.com with ESMTPSA id t53sm12757988qth.70.2020.03.30.18.56.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Mar 2020 18:56:57 -0700 (PDT) From: Noam Postavsky To: Yuan Fu Subject: Re: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions References: Date: Mon, 30 Mar 2020 21:56:56 -0400 In-Reply-To: (Yuan Fu's message of "Mon, 30 Mar 2020 21:27:33 -0400") Message-ID: <87lfnhi8wn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40338 Cc: 40338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Yuan Fu 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)))) From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 31 11:27:33 2020 Received: (at 40338) by debbugs.gnu.org; 31 Mar 2020 15:27:33 +0000 Received: from localhost ([127.0.0.1]:36819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJInd-0007Tp-3q for submit@debbugs.gnu.org; Tue, 31 Mar 2020 11:27:33 -0400 Received: from mail-qk1-f177.google.com ([209.85.222.177]:34613) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJIna-0007Ta-UV for 40338@debbugs.gnu.org; Tue, 31 Mar 2020 11:27:31 -0400 Received: by mail-qk1-f177.google.com with SMTP id i6so23417693qke.1 for <40338@debbugs.gnu.org>; Tue, 31 Mar 2020 08:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=qxAcQq32MREBmL9lmxizXxR4L0rBMFThO7Uj3b8cwWg=; b=eOVN7ZoNaIS65VxducDCg4jSmAMDRaBWaMaHhJXTTwftGTZv0YszqI0Wx0FZPVSPbG 4kMNs2J89abLlriilZklNu1IkfTiQnH37aMZjdguVu9pSAfzQu3gf6f13VbPMFCBf0J5 5UoYAZ9ePCfU6VI01VLb93MYmjAulIo7LOqpx799DK2PvVNQnINlpydUMG3Hv4cr4CPV 6CtYQGmgh02Ok8psIuM0sjez7Qn5owc1VT8pRHSum+EoldGODKhmcHyaO1lH3BlS94wB tYS6QzA90ssqm9zCyonpIBhksSiu3Az4kA3rZJiuesanYLH2Lp9oVSjfnyt3sy4P7z1X 3a+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=qxAcQq32MREBmL9lmxizXxR4L0rBMFThO7Uj3b8cwWg=; b=JHoq4+C8eAgFCimK53+m3ex5rSvVPC8meW/GaobyjVa0iJUBG4EO8PuZYUKNb6xim/ JYUZI056hdihV5KFF9QPZmsIid2bEkae7imZE2MnzgMM8spzLgH5bCeYmE+fV0iRx0K8 UDsHGwlqrEKMFWetQ1erPmwF095younO21BeZPnKRD1OsjlNgZJIgLp+SxGAuSU0l4bT /0+EI887sFFstZine0tSZbArLQVwTQA57I/dtjds6mXd3CjtfBVp42Di30GePRjSVxQe kYgeDRqccfnMafdCXfW/o6uOQ20IxnI3eEMQaLNKDVtEaOid7Vp9nNK8ISpEGVoZq/Tu 9Ihw== X-Gm-Message-State: ANhLgQ2+uXLpFM4/wKqvFpQqxjAYMH1OEtddzlZIDKKODfNghgIM10jh jMHZvzf1GpXp1JitliaZfVo= X-Google-Smtp-Source: ADFU+vu5fc61J0FaGl0E2I/5hrmFySmr194xz+qq5OmIjrg+ADiYh1avsYJcuMc9VSym/euRnwj1Hw== X-Received: by 2002:a37:80c7:: with SMTP id b190mr5400078qkd.255.1585668445314; Tue, 31 Mar 2020 08:27:25 -0700 (PDT) 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 145sm2722562qke.126.2020.03.31.08.27.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2020 08:27:24 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions From: Yuan Fu In-Reply-To: <87lfnhi8wn.fsf@gmail.com> Date: Tue, 31 Mar 2020 11:27:23 -0400 Content-Transfer-Encoding: 7bit Message-Id: <67980875-3F21-489B-9182-D33F3570BF64@gmail.com> References: <87lfnhi8wn.fsf@gmail.com> To: Noam Postavsky X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40338 Cc: 40338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Mar 30, 2020, at 9:56 PM, Noam Postavsky wrote: > > Yuan Fu 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 From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 31 13:09:27 2020 Received: (at 40338-done) by debbugs.gnu.org; 31 Mar 2020 17:09:27 +0000 Received: from localhost ([127.0.0.1]:36936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJKOF-0003wA-8W for submit@debbugs.gnu.org; Tue, 31 Mar 2020 13:09:27 -0400 Received: from mail-qk1-f172.google.com ([209.85.222.172]:34041) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJKOE-0003vx-Fa for 40338-done@debbugs.gnu.org; Tue, 31 Mar 2020 13:09:26 -0400 Received: by mail-qk1-f172.google.com with SMTP id i6so23839264qke.1 for <40338-done@debbugs.gnu.org>; Tue, 31 Mar 2020 10:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:message-id:references:to:date; bh=sNOqMucD1REwehrLzZL3zl4P+LJX2Oz1DRILVttXvr4=; b=cIrClUHE0l3lKVuzRUDn10uFS9h5ahtiTSLzIgtf52JnMd/jJoUeFEgfDf9i05GtkC q5ye6ka8SvbwlVPK+r334OmXWTFPVah+y1zpXWHBnnmD8sf2Zc8VwKenbNQ2Mv+LhsOx Szi30lOaWcRmaB/JiIa1aUipjsDqRPiYbFsz2agSM+jFpSyiTcHbaZ/yIPlEbqDo3CF6 DEeKpf2wOsE8bUQuuZYY2hYx0KzWzM55tuAX/fbDCr4omPvJMQME6kF+6xgKFsUHuyAj yhiqXuzm9IxbpAMDhqIFhSNleG0HFeXQVmT+3RQTVe7gSgwNlQUg4h51fwDj4T/BsZ+J bpcw== 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:references :to:date; bh=sNOqMucD1REwehrLzZL3zl4P+LJX2Oz1DRILVttXvr4=; b=oMc5Mu3gvKNg6Fw881rnIMxq8s2yMdvZl8DbfA/rDhMk8zbaEYTuqeMnwW/ROkJnLd SlkpZ/ox8wxm/sEK5Z31TpA/YpNM+k92ci4foJtiAqkP9I7KIbjx7m8Hvn2VbolfDKIe TuQd1UXk04jV/UB2VALsuG2dFqbOV3GseN5MdwMJpgxrlqnUbf8E+aawHXiRAxIvKdrl leJ4Fj1QGfI8Ue3GT9jr8BHeeRZVKyFnX6SNS4Z/gHbH/nMPGsSgOc5RMxF3zdHEkqPF iq4mUioUWTRMBB6d89h+jA6pSgzZ8DfvuBrkoOmtAUXLaJKg1xRmsWRDBJKHPfQ8u8Ze yVWQ== X-Gm-Message-State: ANhLgQ1dysCgngbkY5w3GpdvfDM8WinutdNqNCEwT/9ET7tOyApSc1ke 0WK9sc4u7mVZ8Q17UyRSbyV1fT3QHU4MQGRG X-Google-Smtp-Source: ADFU+vv0VJeFMVeM/r78kgZK/miuIZ/0OUZWMY5NAeiS0G3elPVEh8iZxDcv28l0Dq05LSXB1m9yOg== X-Received: by 2002:a05:620a:a86:: with SMTP id v6mr5816186qkg.156.1585674560673; Tue, 31 Mar 2020 10:09:20 -0700 (PDT) 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 p38sm14326100qtf.50.2020.03.31.10.09.19 for <40338-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2020 10:09:19 -0700 (PDT) From: Yuan Fu Content-Type: multipart/alternative; boundary="Apple-Mail=_49B6E92D-A289-4C14-ADA0-2113C689BC71" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Fwd: bug#40338: 27.0.60; c-fill-paragraph and after-change-functions Message-Id: References: <67980875-3F21-489B-9182-D33F3570BF64@gmail.com> To: 40338-done@debbugs.gnu.org Date: Tue, 31 Mar 2020 13:09:18 -0400 X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40338-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_49B6E92D-A289-4C14-ADA0-2113C689BC71 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > Begin forwarded message: >=20 > From: Yuan Fu > 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 > Cc: 40338@debbugs.gnu.org >=20 >=20 >=20 >> On Mar 30, 2020, at 9:56 PM, Noam Postavsky = wrote: >>=20 >> Yuan Fu writes: >>=20 >>> (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))))) >>=20 >> 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: >>=20 >> (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)))) >>=20 >=20 > Thank you. Indeed this works. Maybe the problem is not in = c-fill-paragraph.=20 >=20 > Yuan --Apple-Mail=_49B6E92D-A289-4C14-ADA0-2113C689BC71 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

Begin forwarded message:

From: = Yuan Fu <casouri@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@gmail.com>



On Mar 30, 2020, at 9:56 = PM, Noam Postavsky <npostavs@gmail.com> wrote:

Yuan Fu <casouri@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

= --Apple-Mail=_49B6E92D-A289-4C14-ADA0-2113C689BC71-- From unknown Thu Jun 19 16:23:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 29 Apr 2020 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator