From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71370: 30.0.50; Please un-obsolete buffer-substring as a generalized variable Date: Sat, 22 Jun 2024 00:52:43 +0200 Message-ID: <87ed8pnc1w.fsf@web.de> References: <87iky4zedz.fsf@web.de> <545868c6-1a14-4a3f-9939-da2477c0a902@alphapapa.net> <871q4reij4.fsf@web.de> <87le2z7h37.fsf@localhost> Reply-To: Michael Heerdegen Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21924"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Adam Porter , 71370@debbugs.gnu.org, Ihor Radchenko To: Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 22 00:53:33 2024 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 1sKn8N-0005TJ-S6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jun 2024 00:53:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKn7x-0004pR-2K; Fri, 21 Jun 2024 18:53:05 -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 1sKn7u-0004ox-Tw for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 18:53:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKn7u-0003rQ-MA for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 18:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sKn7t-0007yW-QP for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 18:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jun 2024 22:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71370 X-GNU-PR-Package: emacs Original-Received: via spool by 71370-submit@debbugs.gnu.org id=B71370.171901032830590 (code B ref 71370); Fri, 21 Jun 2024 22:53:01 +0000 Original-Received: (at 71370) by debbugs.gnu.org; 21 Jun 2024 22:52:08 +0000 Original-Received: from localhost ([127.0.0.1]:43992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKn72-0007xJ-2J for submit@debbugs.gnu.org; Fri, 21 Jun 2024 18:52:08 -0400 Original-Received: from mout.web.de ([217.72.192.78]:42025) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKn6z-0007wg-NA for 71370@debbugs.gnu.org; Fri, 21 Jun 2024 18:52:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1719010313; x=1719615113; i=michael_heerdegen@web.de; bh=91Z6g7kDcMGJ46CjBQuwhUdK14dVpa5sKPUMfk7XLMw=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=qm/y7TdQ6K2WOd+zDCWbMpfNBjD27Pcim/nxal+b4lhntBpAfYy/sJjxyW8cmPu3 fM6mNRaPVJb8ehEnVPTeLH9UtWpSkvwRnelMO54igldufHIYDD26FYhmWsGWD0SFl tf0uLLG3ZlDUbtvmkN3QO9s7Abup7QZKWIFOFP71v+CWNcEFGVxYzLMxHWiKyz4/q GnTj/NhjJ8nQwVbi616hL1DXYb91Aa1nfv5/Y5fOh+TJgf/hxhGxh8MCn9vvWBWm8 qG8UKOJGZj15mWB6Z5STaJcviKPd0atqYgDws8Wkg1My0jjZq3QZUypktFJFih84B /XxbINYELBSNnkuVrQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([84.59.210.113]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MhFhg-1spCFW3YwM-00kkyJ; Sat, 22 Jun 2024 00:51:52 +0200 In-Reply-To: (Andrea Corallo's message of "Fri, 21 Jun 2024 04:55:06 -0400") X-Provags-ID: V03:K1:k23SwkFLpL1dnAukO+umejk/PN6NfbvgbuwqJBc4+I2eWY9du5M Kir0ct+zn5k4HuJDrytjjGqphaHvZTf9K9AWZJhjbynJypYnbWB7lTkiX2vwpjsB87H+biQ AaRVtBzVen9T4rAkFiYX7ueqc0jx1PAcGArhf7fUoDT4drmV0vmCgsbaeorWDu9WZw4t4CZ PAu/6KblaNMdZKhkz9U2w== UI-OutboundReport: notjunk:1;M01:P0:lIYAjzAHE5E=;dei91eqLXxvO7OGabx/69Ftac3z WZ+eZvzckTxVZ21lUs5QUSu0lDPOI5+gxELHS83efgDbGftIGCTMZKXcbJh+/V466oP8Je5Eg DKNlEA2FMSu6ulFrdghLX5EuOOYLEYUaXvkKcmS9RzxtOfYuF+6S94zr70toHRO3tfeQFtOxt 9JtaHsAn8v7I6Czj5oWKVxH3VHzNgdoWeGv0Q2m5HwuIoEdmAlE5whPiB0QwiIhpgEN5qO+3a EnWk0wvgf4WrzzYQqNjk/zDk+0FWu6msLRcy6YY5H4LcJ2SUzsm+gE1J+gNBISx4Uhp/BmRBo hJJwyzZz9yL+bmTKpNND40vlHl6Kpz7fdSH5CTTUhheCwvR2iIrqjg8e6HFXijARNO4xPx1Tc ZvgDWzX9hMkyhUfqN2cLar+N8yl0Zwd+vPr/9lScbmVnVaHdIVWp4bSGj1alA/Xdhbj+NCEWj 25dOS06us/TQkw4ASLDqalYxPN0DT3VH2H5zgMdY2oCBpDkKkDTC6IRP9zBrQwc7nJ8meWTf0 uUTIkNtPwORqTP9IzpOVk1I8t9Pw/HxJUKm3gpg+UIRJwNVHW9euV/69CApyAnc4PkKJj1WSM uW10zA7K4vgidMNUOJnzFYkSoXgB8pBulVnhN8YlCZKdbVF0v0rPnDkI4z/jCNx8MFWbRhlk5 jKSJ26HL4yYZbSIhCXN/nFsHQ33KNk7A7IZYHexr8hBrTVvFQM8XRTa4e9e3PxcDlHiTV7eK3 12cEUC/BvO2QKBQES3KIklHEHQMkAWXYaMsOfrEZxGqUdVTyKH5VWd/OqUdErdBQxisoKIdS 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:287645 Archived-At: Andrea Corallo writes: > [...] > Interesting, I took the time to apply your methodology to all GV > obsoleted by the same commit and this is the result: > > | GV | file occurrences | > | | in github | > |------------------------------+------------------| > [... I picked the lines with 100+ matches ...] > | buffer-string | 142 | > | buffer-substring | 512 | > | current-buffer | 234 | > [...] > While some of them are rarely/not used some others looks quite popular. > This is an indication that the popular ones are probably a good > abstraction or they are just convenient. More of the latter I would say. Nonetheless that's one aspect that counts. But especially `buffer-substring' doesn't convince me as a gv because semantics are very doubtful: - You say (setf (buffer-substring START END) STRING). The first thing that is not crystal clear is the question whether STRING will be added, or will replace, existing text. - The END argument is either redundant, or, if text is replaced (which is what the current implementation does), it is unclear what happens if STRING has a length different from (- END START). The current implementation doesn't even fulfill the most _basic_ assumption about places: if STRING has a different length, after (setf (buffer-substring START END) STRING), (buffer-substring START END) will _not_ be equal to STRING. This is very bad, conceptually. - For this reason resetting the place to the old "value" will not always restore the old situation. - With `cl-letf' the generalized variable gets even more doubtful: if you edit the buffer contents inside the scope of the binding, reverting a `buffer-substring' gv binding will give surprising results, especially if START and END were specified as integers then pointing to unrelated positions. These were exactly the kind of problems why those place expressions had been obsoleted. Adding a little helper function with clear semantics really looks more appropriate in this case in my opinion, even if you have to remember one more name. Michael.