From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem Date: Wed, 28 Jun 2023 17:17:14 -0700 Message-ID: <14493480-9226-4AB1-A313-E4E2D61AB0BD@gmail.com> References: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16085"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 64329@debbugs.gnu.org To: Troy Brown Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 29 02:18:37 2023 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 1qEfMr-000415-0Z for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Jun 2023 02:18:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEfMO-00028v-Mb; Wed, 28 Jun 2023 20:18:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEfMI-00028h-JD for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 20:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEfMI-0003RJ-Ak for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 20:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qEfMH-0001P5-NN for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 20:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Jun 2023 00:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64329 X-GNU-PR-Package: emacs Original-Received: via spool by 64329-submit@debbugs.gnu.org id=B64329.16879978595363 (code B ref 64329); Thu, 29 Jun 2023 00:18:01 +0000 Original-Received: (at 64329) by debbugs.gnu.org; 29 Jun 2023 00:17:39 +0000 Original-Received: from localhost ([127.0.0.1]:51867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEfLu-0001OR-Ne for submit@debbugs.gnu.org; Wed, 28 Jun 2023 20:17:39 -0400 Original-Received: from mail-pf1-f178.google.com ([209.85.210.178]:44255) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEfLp-0001O9-EX for 64329@debbugs.gnu.org; Wed, 28 Jun 2023 20:17:37 -0400 Original-Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-666e3b15370so113196b3a.0 for <64329@debbugs.gnu.org>; Wed, 28 Jun 2023 17:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687997847; x=1690589847; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=l5lOTss/DI067AEiaIKUMZBoR9yfh3nUtOA7uH2PGRo=; b=JhFKnbPchOINUZem6AlUOeLqivEjFwaWtinbpRKt1ZlD9SbPEaba7AuzsfxhPHnd5r gIJmN3zDA0Hq3JPV67Cw9uhA8ZFdURsJybtCne4JV7DNrwRYnQmwGQqrA3HjdUOXd67n L1xdPhsckFY3s02FLAyy7sO55qqAutjusLQT4//GJS0QQ2n/hEBBvGs5YPmv56b9TRWp 70gATAGOeMtGDYtubbLUQ++yoXbW39G9pLYrXFJBZnPufSAnw2fwVJaghzf/stfhHaYz ux73PIqKwwPlOXp7t4s+RN3NC3EHQcfoYZ6gdDKYhdVqQMnr9wRxWMb0iiHvJDaOBAWw Rgrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687997847; x=1690589847; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l5lOTss/DI067AEiaIKUMZBoR9yfh3nUtOA7uH2PGRo=; b=UsHkH/pUjSSoqUaW23lqnAulvzOEyK3Hg2z4h7AECJFinT+u6xv7OlWuIYgrTHdcAD BMktWzWCglqoQPVDzBI+tCeS8deE2o8bFl8n3JP0mylI627cLnuokm5C780LefN6P3H4 XvWd2t/zIJNvkR/DfRs710X9nZGnwMBw+UkOkraJBn7SkaiIN9/Cpdh+GbheiiTByy3a /BQnSfq2YG2+Hn3iZ0ifvGxZqYWc5wYo6pqGAXf/ggUSGIGCUWax676H9jxHORLkwHG4 AxZwYo+zFJCCQTmh4Mcme9J0AoUB2OK6Y9H6anb8GCvQyrcdFdYychUfQmBNoAF44EXo O8Zw== X-Gm-Message-State: AC+VfDwcE0cY9KZQEemyRuiEWoz6qCxHTzwRbUJOE7kBnqfIfD0nAjkK WGgZmIeln0i/4EPKHK/KPCo= X-Google-Smtp-Source: ACHHUZ61Cs+JNe7rSsyCJ2Hn+MjqRimZ/A+E6WWPus8mByjtG0QA7z6LK+HcyrUYUtGgNz3rezybcw== X-Received: by 2002:a05:6a20:8f26:b0:12a:40d7:3fcf with SMTP id b38-20020a056a208f2600b0012a40d73fcfmr6177092pzk.24.1687997847165; Wed, 28 Jun 2023 17:17:27 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id j18-20020a62e912000000b00660d80087a8sm7454639pfh.187.2023.06.28.17.17.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2023 17:17:25 -0700 (PDT) In-Reply-To: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> X-Mailer: Apple Mail (2.3731.600.7) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264246 Archived-At: --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 28, 2023, at 2:23 PM, Yuan Fu wrote: >=20 >=20 >=20 >> On Jun 28, 2023, at 9:46 AM, Troy Brown = wrote: >>=20 >> I've noticed this problem on multiple tree-sitter major modes = including >> c-ts-mode, c++-ts-mode, java-ts-mode, bash-ts-mode. I haven't tried >> others, but I suspect those might also suffer from this problem. >>=20 >> The issue occurs when attempting to fill the paragraph of a comment >> block. The following comment block can be used as an example to >> reproduce the problem and happens with "emacs -Q" (assuming >> corresponding tree-sitter libraries are available). >>=20 >> --8<---------------cut here---------------start------------->8--- >> // The quick brown fox jumps over the >> // lazy dog. >> // The quick brown fox jumps over the lazy dog. >> --8<---------------cut here---------------end--------------->8--- >>=20 >> Switch to one of the tree-sitter modes (e.g., M-x java-ts-mode). = Move >> point to the first line of the comment block above and then execute = the >> fill-paragraph command (i.e., M-q). >>=20 >> The text which is wrapped onto the first line of the comment block = will >> be highlighted incorrectly. The results appear as if the comment >> delimiter was removed, fontification occurred, then the text was = moved >> to the first line of the comment block and never refontified with the >> comment face. >=20 > Thank you very much! It=E2=80=99s funny that how long this went under = the radar, presumably because we always use block comment. >=20 > The culprit is the subst-char-in-region function used by the filling = function. It has a branch: >=20 > if (xxx) > { > replace_range (pos, pos + 1, string, ...); > } > else > { > for (i =3D 0; i < len; i++) *p++ =3D tostr[i]; > } >=20 > I overlooked the else branch and thought subst-char-in-region always = calls replace_range. replace_range notifies tree-sitter of the change it = makes; but when subst-char-in-region manually replaces the text in the = else branch, those edits are not notified to tree-sitter. Prompted by this, I went over all the functions that calls = signal_after_change again, and found two other editfns.c functions that = are missing calls to treesit_record_change. Please see the attached = patches that follows the previous one. Sorry for the overlook. I believe = I=E2=80=99ve found all places that needs to call treesit_record_change = now. > Please see the attached patch. Eli, is it more preferable to add a = subroutine in insdel.c that does what "for (i =3D 0; i < len; i++) *p++ = =3D tostr[I];=E2=80=9D does, plus calling treesit_record_change, and = make subst-char-in-region call that subroutine? (This way editfns.c = don=E2=80=99t need to include treesit.h and call treesit_record_change = itself.) Since now there are three functions in editfns.c that needs to call = treesit_record_change, we might as well just include treesit.h and call = treesit_record_change directly. Yuan --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC Content-Disposition: attachment; filename=add-two-other-missing-calls.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="add-two-other-missing-calls.patch" Content-Transfer-Encoding: quoted-printable =46rom=20a09bfd309ffbb4e33df3c1a850193dc20b93af1c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Wed,=20= 28=20Jun=202023=2017:03:19=20-0700=0ASubject:=20[PATCH=201/2]=20Add=20= missing=20calls=20to=20treesit_record_change=20in=20editfns.c=0A=0AThese=20= should=20be=20all=20that=20are=20missing.=20=20See=20the=20next=20commit=20= for=20detail.=0A=0A*=20src/editfns.c=20(Ftranslate_region_internal):=0A= (Ftranspose_regions):=20Call=20treesit_record_change.=0A---=0A=20= src/editfns.c=20|=2016=20++++++++++++++++=0A=201=20file=20changed,=2016=20= insertions(+)=0A=0Adiff=20--git=20a/src/editfns.c=20b/src/editfns.c=0A= index=200cbeefb3262..a1e48daf6c6=20100644=0A---=20a/src/editfns.c=0A+++=20= b/src/editfns.c=0A@@=20-2603,6=20+2603,15=20@@=20DEFUN=20= ("translate-region-internal",=20Ftranslate_region_internal,=0A=20=09=09=20= =20=20=20*p++=20=3D=20*str++;=0A=20=09=09=20=20signal_after_change=20= (pos,=201,=201);=0A=20=09=09=20=20update_compositions=20(pos,=20pos=20+=20= 1,=20CHECK_BORDER);=0A+=0A+#ifdef=20HAVE_TREE_SITTER=0A+=09=09=20=20/*=20= In=20the=20previous=20branch,=20replace_range()=20notifies=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20changes=20to=20= tree-sitter,=20but=20in=20this=20branch,=20we=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20modified=20buffer=20content=20= manually,=20so=20we=20need=20to=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20notify=20tree-sitter=20manually.=20=20*/=0A+=09=09= =20=20treesit_record_change=20(pos_byte,=20pos_byte=20+=20len,=0A+=09=09=09= =09=09=20pos_byte=20+=20len);=0A+#endif=0A=20=09=09}=0A=20=09=20=20=20=20= =20=20characters_changed++;=0A=20=09=20=20=20=20}=0A@@=20-4776,6=20= +4785,13=20@@=20DEFUN=20("transpose-regions",=20Ftranspose_regions,=20= Stranspose_regions,=204,=205,=0A=20=20=20=20=20=20=20= adjust_markers_bytepos=20(start1,=20start1_byte,=20end2,=20end2_byte,=20= 0);=0A=20=20=20=20=20}=0A=20=0A+#ifdef=20HAVE_TREE_SITTER=0A+=20=20/*=20= I=20don't=20think=20it's=20common=20to=20transpose=20two=20far-apart=20= regions,=20so=0A+=20=20=20=20=20amalgamating=20the=20edit=20into=20one=20= should=20be=20fine.=20=20This=20is=20what=20the=0A+=20=20=20=20=20= signal_after_change=20below=20does,=20too.=20=20*/=0A+=20=20= treesit_record_change=20(start1_byte,=20end2_byte,=20end2_byte);=0A= +#endif=0A+=0A=20=20=20signal_after_change=20(start1,=20end2=20-=20= start1,=20end2=20-=20start1);=0A=20=20=20return=20Qnil;=0A=20}=0A--=20=0A= 2.33.1=0A=0A=0A=46rom=2094758fb0e11ce4dd763cd50990828879f9c41b19=20Mon=20= Sep=2017=2000:00:00=202001=0AFrom:=20Yuan=20Fu=20=0A= Date:=20Wed,=2028=20Jun=202023=2017:05:29=20-0700=0ASubject:=20[PATCH=20= 2/2]=20;=20*=20admin/notes/tree-sitter/treesit_record_change:=0A=20= Update.=0A=0A---=0A=20admin/notes/tree-sitter/treesit_record_change=20|=20= 180=20+++++++++++++++++-=0A=201=20file=20changed,=20174=20insertions(+),=20= 6=20deletions(-)=0A=0Adiff=20--git=20= a/admin/notes/tree-sitter/treesit_record_change=20= b/admin/notes/tree-sitter/treesit_record_change=0Aindex=20= 0dc6491e2d1..e80df4adfa7=20100644=0A---=20= a/admin/notes/tree-sitter/treesit_record_change=0A+++=20= b/admin/notes/tree-sitter/treesit_record_change=0A@@=20-3,10=20+3,10=20= @@=20NOTES=20ON=20TREESIT_RECORD_CHANGE=0A=20It=20is=20vital=20that=20= Emacs=20informs=20tree-sitter=20of=20every=20change=20made=20to=20the=0A=20= buffer,=20lest=20tree-sitter's=20parse=20tree=20would=20be=20= corrupted/out=20of=20sync.=0A=20=0A-All=20buffer=20changes=20in=20Emacs=20= are=20made=20through=20functions=20in=20insdel.c=0A-(and=20= casefiddle.c),=20I=20augmented=20functions=20in=20those=20files=20with=20= calls=20to=0A-treesit_record_change.=20=20Below=20is=20a=20manifest=20of=20= all=20the=20relevant=0A-functions=20in=20insdel.c=20as=20of=20Emacs=20= 29:=0A+Almost=20all=20buffer=20changes=20in=20Emacs=20are=20made=20= through=20functions=20in=0A+insdel.c=20(see=20below=20for=20exceptions),=20= I=20augmented=20functions=20in=20insdel.c=0A+with=20calls=20to=20= treesit_record_change.=20=20Below=20is=20a=20manifest=20of=20all=20the=0A= +relevant=20functions=20in=20insdel.c=20as=20of=20Emacs=2029:=0A=20=0A=20= Function=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20Calls=0A=20= ----------------------------------------------------------------------=0A= @@=20-43,8=20+43,176=20@@=20insert_from_buffer=20but=20not=20= insert_from_buffer_1.=20=20I=20also=20left=20a=0A=20reminder=20comment.=0A= =20=0A=20=0A-As=20for=20casefiddle.c,=20do_casify_unibyte_region=20and=0A= +EXCEPTIONS=0A+=0A+=0A+There=20are=20a=20couple=20of=20functions=20that=20= replaces=20characters=20in-place=0A+rather=20than=20insert/delete.=20= They=20are=20in=20casefiddle.c=20and=20editfns.c.=0A+=0A+In=20= casefiddle.c,=20do_casify_unibyte_region=20and=0A=20= do_casify_multibyte_region=20modifies=20buffer,=20but=20they=20are=20= static=0A=20functions=20and=20are=20called=20by=20casify_region,=20which=20= calls=0A=20treesit_record_change.=20=20Other=20higher-level=20functions=20= calls=0A-casify_region=20to=20do=20the=20work.=0A\=20No=20newline=20at=20= end=20of=20file=0A+casify_region=20to=20do=20the=20work.=0A+=0A+In=20= editfns.c,=20subst-char-in-region=20and=20translate-region-internal=20= might=0A+replace=20characters=20in-place,=20I=20made=20them=20to=20call=0A= +treesit_record_change.=20=20transpose-regions=20uses=20memcpy=20to=20= move=20text=0A+around,=20it=20calls=20treesit_record_change=20too.=0A+=0A= +I=20found=20these=20exceptions=20by=20grepping=20for=20= signal_after_change=20and=0A+checking=20each=20caller=20manually.=20=20= Below=20is=20all=20the=20result=20as=20of=20Emacs=2029=0A+and=20some=20= comment=20for=20each=20one.=20=20Readers=20can=20use=0A+=0A= +(highlight-regexp=20"^[^[:space:]]+?\\.c:[[:digit:]]+:[^z-a]+?$"=20= 'highlight)=0A+=0A+to=20make=20things=20easier=20to=20read.=0A+=0A+grep=20= [...]=20--color=3Dauto=20-i=20--directories=3Dskip=20-nH=20--null=20-e=20= signal_after_change=20*.c=0A+=0A+callproc.c:789:=20=20=20=20=20=20=20=20=20= =20=20=20=20calling=20prepare_to_modify_buffer=20and=20= signal_after_change.=0A+callproc.c:793:=20=20=20=20=20=20=20=20=20=20=20=20= =20is=20one=20call=20to=20signal_after_change=20in=20each=20of=20the=0A= +callproc.c:800:=20=20=20=20=20=20=20=20=20=20=20=20=20= signal_after_change=20hasn't.=20=20A=20continue=20statement=0A= +callproc.c:804:=20=20=20=20=20=20=20=20=20=20=20=20=20again,=20and=20= this=20time=20signal_after_change=20gets=20called,=0A+=0A+Not=20code.=0A= +=0A+callproc.c:820:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= signal_after_change=20(PT=20-=20nread,=200,=20nread);=0A+callproc.c:863:=20= =20=20=20=20=20=20=20=20=20=20=20=20=20signal_after_change=20(PT=20-=20= process_coding.produced_char,=0A+=0A+Both=20are=20called=20in=20= call-process.=20=20I=20don=E2=80=99t=20think=20we=E2=80=99ll=20ever=20= use=0A+tree-sitter=20in=20call-process=E2=80=99s=20stdio=20buffer,=20= right?=20=20I=20didn=E2=80=99t=20check=0A+line-by-line,=20but=20it=20= seems=20to=20only=20use=20insert_1_both=20and=20del_range_2.=0A+=0A= +casefiddle.c:558:=20=20=20=20=20=20signal_after_change=20(start,=20end=20= -=20start=20-=20added,=20end=20-=20start);=0A+=0A+Called=20in=20= casify-region,=20calls=20treesit_record_change.=0A+=0A+decompress.c:195:=20= =20=20=20=20=20signal_after_change=20(data->orig,=20data->start=20-=20= data->orig,=0A+=0A+Called=20in=20unwind_decompress,=20uses=20= del_range_2,=20insdel=20function.=0A+=0A+decompress.c:334:=20=20= signal_after_change=20(istart,=20iend=20-=20istart,=20= unwind_data.nbytes);=0A+=0A+Called=20in=20zlib-decompress-region,=20uses=20= del_range_2,=20insdel=20function.=0A+=0A+editfns.c:2139:=20=20=20=20=20=20= signal_after_change=20(BEGV,=20size_a,=20ZV=20-=20BEGV);=0A+=0A+Called=20= in=20replace-buffer-contents,=20which=20calls=20del_range=20and=0A= +Finsert_buffer_substring,=20both=20are=20ok.=0A+=0A+editfns.c:2416:=20=20= =20=20=20=20signal_after_change=20(changed,=0A+=0A+Called=20in=20= subst-char-in-region,=20which=20either=20calls=20replace_range=20(a=0A= +insdel=20function)=20or=20modifies=20buffer=20content=20by=20itself=20= (need=20to=20call=0A+treesit_record_change).=0A+=0A+editfns.c:2544:=09=20= =20=20=20=20=20/*=20Reload=20as=20signal_after_change=20in=20last=20= iteration=20may=20GC.=20=20*/=0A+=0A+Not=20code.=0A+=0A+editfns.c:2604:=09= =09=20=20signal_after_change=20(pos,=201,=201);=0A+=0A+Called=20in=20= translate-region-internal,=20which=20has=20three=20cases:=0A+=0A+if=20= (nc=20!=3D=20oc=20&&=20nc=20>=3D=200)=20{=0A+=20=20if=20(len=20!=3D=20= str_len)=20{=0A+=09replace_range()=0A+=20=20}=20else=20{=0A+=09while=20= (str_len--=20>=200)=0A+=09=20=20*p++=20=3D=20*str++;=0A+=20=20}=0A+}=0A= +else=20if=20(nc=20<=200)=20{=0A+=20=20replace_range()=0A+}=0A+=0A= +replace_range=20is=20ok,=20but=20in=20the=20case=20where=20it=20= manually=20modifies=20buffer=0A+content,=20it=20needs=20to=20call=20= treesit_record_change.=0A+=0A+editfns.c:4779:=20=20signal_after_change=20= (start1,=20end2=20-=20start1,=20end2=20-=20start1);=0A+=0A+Called=20in=20= transpose-regions.=20=20It=20just=20uses=20memcpy=E2=80=99s=20and=20= doesn=E2=80=99t=20use=0A+insdel=20functions;=20needs=20to=20call=20= treesit_record_change.=0A+=0A+fileio.c:4825:=20=20=20=20=20=20= signal_after_change=20(PT,=200,=20inserted);=0A+=0A+Called=20in=20= insert_file_contents.=20=20Uses=20insert_1_both=20(very=20first=20in=20= the=0A+function);=20del_range_1=20and=20del_range_byte=20(the=20= optimized=20way=20to=0A+implement=20replace=20when=20decoding=20isn=E2=80=99= t=20needed);=20del_range_byte=20and=0A+insert_from_buffer=20(the=20= optimized=20way=20used=20when=20decoding=20is=20needed);=0A= +decode_coding_gap=20or=20insert_from_gap_1=20(I=E2=80=99m=20not=20sure=20= the=20condition=20for=0A+this,=20but=20anyway=20it=E2=80=99s=20safe).=20=20= The=20function=20also=20calls=20memcpy=20and=0A+memmove,=20but=20they=20= are=20irrelevant:=20memcpy=20is=20used=20for=20decoding,=20and=0A= +memmove=20is=20moving=20stuff=20inside=20the=20gap=20for=20= decode_coding_gap.=0A+=0A+I=E2=80=99d=20love=20someone=20to=20verify=20= this=20function,=20since=20it=E2=80=99s=20so=20complicated=0A+and=20= large,=20but=20from=20what=20I=20can=20tell=20it=E2=80=99s=20safe.=0A+=0A= +fns.c:3998:=20=20signal_after_change=20(XFIXNAT=20(beg),=200,=20= inserted_chars);=0A+=0A+Called=20in=20base64-decode-region,=20uses=20= insert_1_both=20and=20del_range_both,=0A+safe.=0A+=0A+insdel.c:681:=20=20= =20=20=20=20signal_after_change=20(opoint,=200,=20len);=0A+insdel.c:696:=20= =20=20=20=20=20signal_after_change=20(opoint,=200,=20len);=0A= +insdel.c:741:=20=20=20=20=20=20signal_after_change=20(opoint,=200,=20= len);=0A+insdel.c:757:=20=20=20=20=20=20signal_after_change=20(opoint,=20= 0,=20len);=0A+insdel.c:976:=20=20signal_after_change=20(opoint,=200,=20= PT=20-=20opoint);=0A+insdel.c:996:=20=20signal_after_change=20(opoint,=20= 0,=20PT=20-=20opoint);=0A+insdel.c:1187:=20=20signal_after_change=20= (opoint,=200,=20PT=20-=20opoint);=0A+insdel.c:1412:=20=20=20= signal_after_change.=20=20*/=0A+insdel.c:1585:=20=20=20=20=20=20= signal_after_change=20(from,=20nchars_del,=20GPT=20-=20from);=0A= +insdel.c:1600:=20=20=20prepare_to_modify_buffer=20and=20never=20call=20= signal_after_change.=0A+insdel.c:1603:=20=20=20region=20once.=20=20Apart=20= from=20signal_after_change,=20any=20caller=20of=20this=0A+insdel.c:1747:=20= =20signal_after_change=20(from,=20to=20-=20from,=200);=0A+insdel.c:1789:=20= =20signal_after_change=20(from,=20to=20-=20from,=200);=0A+insdel.c:1833:=20= =20signal_after_change=20(from,=20to=20-=20from,=200);=0A= +insdel.c:2223:signal_after_change=20(ptrdiff_t=20charpos,=20ptrdiff_t=20= lendel,=20ptrdiff_t=20lenins)=0A+insdel.c:2396:=20=20signal_after_change=20= (begpos,=20endpos=20-=20begpos=20-=20change,=20endpos=20-=20begpos);=0A+=0A= +I=E2=80=99ve=20checked=20all=20insdel=20functions.=20=20We=20can=20= assume=20insdel=20functions=20are=0A+all=20safe.=0A+=0A+json.c:790:=20=20= signal_after_change=20(PT,=200,=20inserted);=0A+=0A+Called=20in=20= json-insert,=20calls=20either=20decode_coding_gap=20or=0A= +insert_from_gap_1,=20both=20are=20safe.=20Calls=20memmove=20but=20= it=E2=80=99s=20for=0A+decode_coding_gap.=0A+=0A+keymap.c:2873:=09=20=20=20= =20/*=20Insert=20calls=20signal_after_change=20which=20may=20GC.=20=20*/=0A= +=0A+Not=20code.=0A+=0A+print.c:219:=20=20=20=20=20=20= signal_after_change=20(PT=20-=20print_buffer.pos,=200,=20= print_buffer.pos);=0A+=0A+Called=20in=20print_finish,=20calls=20= copy_text=20and=20insert_1_both,=20safe.=0A+=0A+process.c:6365:=09=20= process=20buffer=20is=20changed=20in=20the=20signal_after_change=20= above.=0A+search.c:2763:=20=20=20=20=20(see=20signal_before_change=20and=20= signal_after_change).=20=20Try=20to=20error=0A+=0A+Not=20code.=0A+=0A= +search.c:2777:=20=20signal_after_change=20(sub_start,=20sub_end=20-=20= sub_start,=20SCHARS=20(newtext));=0A+=0A+Called=20in=20replace_match.=20=20= Calls=20replace_range,=20upcase-region,=0A+upcase-initials-region=20= (both=20calls=20casify_region=20in=20the=20end),=20safe.=0A+Calls=20= memcpy=20but=20it=E2=80=99s=20for=20string=20manipulation.=0A+=0A= +textprop.c:1261:=09=09signal_after_change=20(XFIXNUM=20(start),=20= XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1272:=09=09= signal_after_change=20(XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20= XFIXNUM=20(start),=0A+textprop.c:1283:=09=20=20=20=20signal_after_change=20= (XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A= +textprop.c:1458:=20=20=20=20signal_after_change=20(XFIXNUM=20(start),=20= XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1652:=09=09= signal_after_change=20(XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20= XFIXNUM=20(start),=0A+textprop.c:1661:=09=09signal_after_change=20= (XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A= +textprop.c:1672:=09=20=20=20=20signal_after_change=20(XFIXNUM=20= (start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1750:=20= =20=20=20=20before=20changes=20are=20made=20and=20signal_after_change=20= when=20we=20are=20done.=0A+textprop.c:1752:=20=20=20=20=20and=20call=20= signal_after_change=20before=20returning=20if=20MODIFIED.=20*/=0A= +textprop.c:1764:=09=09=20=20=20=20signal_after_change=20(XFIXNUM=20= (start),=0A+textprop.c:1778:=09=09signal_after_change=20(XFIXNUM=20= (start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1791:=09= =09signal_after_change=20(XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20= XFIXNUM=20(start),=0A+textprop.c:1810:=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20signal_after_change=20(XFIXNUM=20(start),=0A+=0A+We=20= don=E2=80=99t=20care=20about=20text=20property=20changes.=0A+=0A+Grep=20= finished=20with=2051=20matches=20found=20at=20Wed=20Jun=2028=2015:12:23=0A= --=20=0A2.33.1=0A=0A= --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC--