From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Keeping replace-buffer-contents runtime in bounds Date: Sun, 24 Feb 2019 11:11:51 +0100 Message-ID: <87y365a42g.fsf@gnu.org> References: <87r2c7ze9n.fsf@gnu.org> <83imxil8h6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="59655"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 24 11:12:43 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gxqm3-000FQj-Mf for ged-emacs-devel@m.gmane.org; Sun, 24 Feb 2019 11:12:43 +0100 Original-Received: from localhost ([127.0.0.1]:48606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxqm2-00088D-Mc for ged-emacs-devel@m.gmane.org; Sun, 24 Feb 2019 05:12:42 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxqlM-000883-VD for emacs-devel@gnu.org; Sun, 24 Feb 2019 05:12:01 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxqlM-0005sf-IN for emacs-devel@gnu.org; Sun, 24 Feb 2019 05:12:00 -0500 Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:34929) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1gxqlJ-0002dg-1i; Sun, 24 Feb 2019 05:11:58 -0500 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 3C10F21FEE; Sun, 24 Feb 2019 05:11:55 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 24 Feb 2019 05:11:55 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrudeggddufeculddtuddrgedtledrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefvrghsshhi lhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecukfhppeelfedrvdefiedrud dvledrhedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhorhhnodhmvghsmhhtphgr uhhthhhpvghrshhonhgrlhhithihqdekieejfeekjeekgedqieefhedvleekqdhtshguhh eppehgnhhurdhorhhgsehfrghsthhmrghilhdrfhhmnecuvehluhhsthgvrhfuihiivgep td X-ME-Proxy: Original-Received: from thinkpad-t440p (p5dec8134.dip0.t-ipconnect.de [93.236.129.52]) by mail.messagingengine.com (Postfix) with ESMTPA id 1FE5EE40C1; Sun, 24 Feb 2019 05:11:53 -0500 (EST) In-Reply-To: <83imxil8h6.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 17 Feb 2019 17:50:45 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233560 Archived-At: Eli Zaretskii writes: >> In the end I settled for a maximum number of seconds one can define >> by setting a new variable replace-buffer-contents-max-secs, so that >> you can define what's still acceptable in the respective use-case. >> (Actually, if you set that to 1.5 or so, it may still run for 2 or >> more seconds because the EARLY_ABORT expression isn't tested at >> regular intervals or rather it is, but the intervals don't take >> equally long.) >> >> If that number of seconds is over, compareseq returns early and >> replace-buffer-contents falls back to plain delete and insert. > > The gotcha about aborting after more than the time-out value should be > mentioned in the doc string. > > Thanks for working on this. My only other comment is that maybe we > should allow passing the time-out value via the function's arguments, > not via a global variable. It seems to me the time-out will be used > in more use cases than MAX-COSTS, and in any case treating these two > differently API-wise sounds strangely inconsistent. I've done that and landed it in master. The downside of having the MAX-* arguments instead of global variables is that now we have a json-pretty-print-max-secs global variable because somewhere a user has to specify how long he is willing to wait. But I guess the JSON scenario is pretty unique in the size and diffs of the replaced text, so that's allright from my POV. I also changed the return value of replace-buffer-contents so that now t means the non-destructive replacement worked as advertised, and nil means we fell back to delete-region and insert-buffer-substring. Using t for success just seemed more natural for me. Bye, Tassilo