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.devel Subject: Re: Distinguish between regional undo and undo to the beginning in undo-equiv-table Date: Wed, 3 Mar 2021 10:42:12 -0500 Message-ID: <60DCC8C7-CCA4-4113-88BE-B81A395C494D@gmail.com> References: <195AF8D0-1BFD-419D-88A1-69EA1FEED4D6@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_BABEF2DE-A05B-4EAB-9B57-872128B9E602" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29633"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 03 16:43:20 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lHTeh-0007cO-Uw for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Mar 2021 16:43:20 +0100 Original-Received: from localhost ([::1]:51428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHTeg-0002pM-I3 for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Mar 2021 10:43:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHTdi-0002OI-JI for emacs-devel@gnu.org; Wed, 03 Mar 2021 10:42:18 -0500 Original-Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]:36214) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHTdh-0003a1-7C for emacs-devel@gnu.org; Wed, 03 Mar 2021 10:42:18 -0500 Original-Received: by mail-qk1-x731.google.com with SMTP id n79so12764790qke.3 for ; Wed, 03 Mar 2021 07:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=jAToxZfzl9QgXTDt3nwwYsWwe/6hTRZcY0r/Jf3V4to=; b=sz+yUJYCary0iWX1hOfN8areyCg3TOwcbggwymhu2wsFVrRl302RySkUwT5KFX2FVG 3XsRhZnHayXNevlMwMuXXlFthu9duOLxYzz+EGPdnH1lHeaJF0VjEUhhG+TWG9cGf+5a xUDCJ+dFbgqCgHvw+ekKiY1TLtMjnI1fJ8nCZE3KVYICrOJ9lksRyMzfNlfO9fT1lSrC Sgn2kLg0ww4kXP+3vLhNQnskVxjaP3v5F+9AShySi7O5cv5HugHOMRp4PcQFmbQ8qk+Y lZCXFDP1s4iXdArdvSKO+sku7VafnzEzOZ08e44ztI+qIEMHuM/KvTzhK1X+PLTLWsSu 6O+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=jAToxZfzl9QgXTDt3nwwYsWwe/6hTRZcY0r/Jf3V4to=; b=ieh8rYC/zCtY8eIbsDAjahaZtamrhnAVIKGKCF4uM3KrlfKWJFWT8ibtD1salWf9Fe OCOduNawBovf4H5thlC3GBwKNQRk+46EfOS2NxciNLE86PgWL+ZwzS3UcQqIrd0SdUBz uWQhVfhTwy/Y96T2m9HdMBCnpGjlw5Ln0+kTI2DWlKytbeJCOQsQSeL2keC/JyguPJtt 1ZKrR2o9oCoHzSSFfn1I8+PL3UFO/05vpwOo31lcmTdM7lhLoNKVWgdFiD8xC2LhVDNK CDmDMRWIVZFaCaK7TxnqKKBEurd3QqOsuYk0lKqcmE7+lbf+Vtm0GRtSsqlapxfoR9HB GPDQ== X-Gm-Message-State: AOAM532LVJs/lkh7yAAZ1lM7N25Iilbf8ALszs8MXKHSZTwZeUPNx0w8 dHXA82G2wfI/91PA2Fpaei8COeEGDUg= X-Google-Smtp-Source: ABdhPJyHHoHXpW6wlm4m4K0OfPcU2/1K414pfLOT9T0tjbtBIWsM7mSm2w2j/5ztafwviUWKXOQbgQ== X-Received: by 2002:a37:94f:: with SMTP id 76mr18336271qkj.222.1614786136083; Wed, 03 Mar 2021 07:42:16 -0800 (PST) Original-Received: from ?IPv6:2601:98a:4200:9210:f034:d410:c287:1f5b? ([2601:98a:4200:9210:f034:d410:c287:1f5b]) by smtp.gmail.com with ESMTPSA id a34sm15824407qtc.97.2021.03.03.07.42.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 07:42:15 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::731; envelope-from=casouri@gmail.com; helo=mail-qk1-x731.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:265887 Archived-At: --Apple-Mail=_BABEF2DE-A05B-4EAB-9B57-872128B9E602 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Mar 2, 2021, at 6:50 PM, Stefan Monnier = wrote: >=20 >> That means my package that constructs an undo tree from = buffer-undo-list >> cannot distinguish the two and thus cannot work incorrectly. Is it ok = to map >> one type of undo to something other than t? >=20 > I think so, yes. It might require a few tweaks in simple.el but = nothing > major (if at all). >=20 Here is a patch, I mapped undo-in-region records to 'undo-in-region. I = also fixed a bug in undo-make-selective-list: before this change, if you = undo-in-region, break the undo chain, then undo-in-region again with = undo-only, ulist would be set to t and it breaks at (setq undo-elt (car = ulist)). Yuan --Apple-Mail=_BABEF2DE-A05B-4EAB-9B57-872128B9E602 Content-Disposition: attachment; filename=undo-in-region.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="undo-in-region.patch" Content-Transfer-Encoding: quoted-printable =46rom=208c4d50409a7ad88eb85d51e79b04f3587cd36976=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Wed,=20= 3=20Mar=202021=2009:50:15=20-0500=0ASubject:=20[PATCH]=20Map=20redo=20= records=20for=20undo-in-region=20to=20'undo-in-region=0A=0A*=20= lisp/simple.el=20(undo-equiv-table):=20Add=20explaination=20for=0A= undo-in-region=20and=20undo=20to=20the=20beginning=20of=20undo=20list.=0A= (undo):=20If=20equiv=20is=20'undo-in-region=20or=20t,=20set=20to=20= pending-undo-list=20to=0At.=20If=20the=20redo=20is=20undo-in-region,=20= map=20buffer-undo-list=20to=0A'undo-in-region=20instead=20of=20t.=0A= (undo-make-selective-list):=20Only=20continue=20when=20ulist=20is=20not=20= t=20or=0Aundo-in-region.=0A---=0A=20lisp/simple.el=20|=2020=20= +++++++++++---------=0A=201=20file=20changed,=2011=20insertions(+),=209=20= deletions(-)=0A=0Adiff=20--git=20a/lisp/simple.el=20b/lisp/simple.el=0A= index=20f8050091d5..05bf4b8784=20100644=0A---=20a/lisp/simple.el=0A+++=20= b/lisp/simple.el=0A@@=20-2824,8=20+2824,9=20@@=20'advertised-undo=0A=20=0A= =20(defconst=20undo-equiv-table=20(make-hash-table=20:test=20'eq=20= :weakness=20t)=0A=20=20=20"Table=20mapping=20redo=20records=20to=20the=20= corresponding=20undo=20one.=0A-A=20redo=20record=20for=20undo-in-region=20= maps=20to=20t.=0A-A=20redo=20record=20for=20ordinary=20undo=20maps=20to=20= the=20following=20(earlier)=20undo.")=0A+A=20redo=20record=20for=20= undo-in-region=20maps=20to=20'undo-in-region.=0A+A=20redo=20record=20for=20= ordinary=20undo=20maps=20to=20the=20following=20(earlier)=20undo.=0A+An=20= undo=20record=20that=20undoes=20to=20the=20beginning=20of=20the=20undo=20= list=20maps=20to=20t.")=0A=20=0A=20(defvar=20undo-in-region=20nil=0A=20=20= =20"Non-nil=20if=20`pending-undo-list'=20is=20not=20just=20a=20tail=20of=20= `buffer-undo-list'.")=0A@@=20-2901,7=20+2902,7=20@@=20undo=0A=20=09;;=20= undo-redo-undo-redo-...=20so=20skip=20to=20the=20very=20last=20equiv.=0A=20= =09(while=20(let=20((next=20(gethash=20equiv=20undo-equiv-table)))=0A=20=09= =09=20(if=20next=20(setq=20equiv=20next))))=0A-=09(setq=20= pending-undo-list=20equiv)))=0A+=09(setq=20pending-undo-list=20(if=20= (consp=20equiv)=20equiv=20t))))=0A=20=20=20=20=20(undo-more=0A=20=20=20=20= =20=20(if=20(numberp=20arg)=0A=20=09=20(prefix-numeric-value=20arg)=0A@@=20= -2917,11=20+2918,12=20@@=20undo=0A=20=20=20=20=20=20=20(while=20(eq=20= (car=20list)=20nil)=0A=20=09(setq=20list=20(cdr=20list)))=0A=20=20=20=20=20= =20=20(puthash=20list=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= Prevent=20identity=20mapping.=20=20This=20can=20happen=20if=0A-=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20;;=20consecutive=20nils=20are=20= erroneously=20in=20undo=20list.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(if=20(or=20undo-in-region=20(eq=20list=20pending-undo-list))=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20t=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20pending-undo-list)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(cond=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(undo-in-region=20'undo-in-region)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20;;=20Prevent=20identity=20mapping.=20=20This=20= can=20happen=20if=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= consecutive=20nils=20are=20erroneously=20in=20undo=20list.=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20((eq=20list=20pending-undo-list)=20= t)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20= pending-undo-list))=0A=20=09=20=20=20=20=20=20=20undo-equiv-table))=0A=20= =20=20=20=20;;=20Don't=20specify=20a=20position=20in=20the=20undo=20= record=20for=20the=20undo=20command.=0A=20=20=20=20=20;;=20Instead,=20= undoing=20this=20should=20move=20point=20to=20where=20the=20change=20is.=0A= @@=20-3234,7=20+3236,7=20@@=20undo-make-selective-list=0A=20=20=20=20=20=20= =20=20=20undo-elt)=0A=20=20=20=20=20(while=20ulist=0A=20=20=20=20=20=20=20= (when=20undo-no-redo=0A-=20=20=20=20=20=20=20=20(while=20(gethash=20= ulist=20undo-equiv-table)=0A+=20=20=20=20=20=20=20=20(while=20(consp=20= (gethash=20ulist=20undo-equiv-table))=0A=20=20=20=20=20=20=20=20=20=20=20= (setq=20ulist=20(gethash=20ulist=20undo-equiv-table))))=0A=20=20=20=20=20= =20=20(setq=20undo-elt=20(car=20ulist))=0A=20=20=20=20=20=20=20(cond=0A= --=20=0A2.24.3=20(Apple=20Git-128)=0A=0A= --Apple-Mail=_BABEF2DE-A05B-4EAB-9B57-872128B9E602 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_BABEF2DE-A05B-4EAB-9B57-872128B9E602--