From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master f51f963: Fix some side-effecting uses of make-text-button Date: Fri, 05 Jun 2020 09:02:54 -0400 Message-ID: References: <20200604223056.17078.81265@vcs0.savannah.gnu.org> <20200604223058.1850020A26@vcs0.savannah.gnu.org> <87eeqtiy4x.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="74499"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: "Basil L. Contovounesios" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 05 15:03:39 2020 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 1jhC0Z-000JHy-7l for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jun 2020 15:03:39 +0200 Original-Received: from localhost ([::1]:50922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhC0Y-0000lu-82 for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jun 2020 09:03:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhBzw-0008JH-9C for emacs-devel@gnu.org; Fri, 05 Jun 2020 09:03:00 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhBzu-0007kf-Hm for emacs-devel@gnu.org; Fri, 05 Jun 2020 09:02:59 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2470D81177; Fri, 5 Jun 2020 09:02:57 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5BD24805AC; Fri, 5 Jun 2020 09:02:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1591362175; bh=Oclaqzh67dfeJagFt0NMqyAFHYDFtDveYk3nZsY5S/A=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=KsZTWqautL04ULvnLPVeyP1DXwhOiUpmJBJ4iW6FQKqJBU6B8VfnR4gL+iScrWA8n G/z7gtADfqru2ry/y5AWPtJYiTMVTmM8S03mHweIKGPuLtmkgGKwyKHDDWoEz30zKv 9sP3T464Sg8GQOlgypfFTWH5ae2oqwAH/oSeNxlS/QxQ6z6KMWQ0It+9F6rEFR9R6w XXVQQZ3CHkef4qhIJecMh2hoBLUudcPoOExxjnbcpv+cIKZOJm7qC+GkyWOQevhTX/ aWbuJZ8Mqug4CqDOTit56tfhOoxCwq0i/19ghw+WOOXrc6umv1DzH5or3ER0mmWBHP H5+vLnA8sq1hA== Original-Received: from alfajor (unknown [157.52.17.179]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E27601221D9; Fri, 5 Jun 2020 09:02:54 -0400 (EDT) In-Reply-To: <87eeqtiy4x.fsf@tcd.ie> (Basil L. Contovounesios's message of "Fri, 05 Jun 2020 11:51:26 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/05 08:44:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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:251894 Archived-At: > As Paul said, not quite - it has historically modified its first > argument by placing properties on it. If you look at the line preceding > this diff hunk you'll see a call to copy-sequence. > > My reasons for making this particular change are: > 0. Since Emacs 24.4, make-text-button has returned its modified first > argument, so callers can use the value returned by make-text-button > instead of calling it only for its side effects. > 1. This has now been reverted again, but for the last month, > make-text-button returned a modified _copy_ of its argument, which > meant that its side effects could no longer be relied upon. > > Either way, relying on its return value rather than its side effects > seems like the best style to stick with for now. So, IIUC `make-text-button` should ideally work functionally, but for historical reasons it works by side-effect. What's the long term plan? Do we plan to live with the current side-effecting behavior, or do we plan to move to the "pure" functional behavior? If we could detect when a string-button is "used" (i.e. displayed or inserted into a buffer), then we could detect the use of the old side-effecting style (by checking if the string passed as argument had already been displayed/inserted elsewhere) and emit a good warning. >>> @@ -202,7 +202,7 @@ The format has been repaired and the variable modified accordingly. >>> You can save the current value through the customize system by >>> either clicking or hitting return " >>> (make-text-button >>> - "here" nil >>> + (copy-sequence "here") nil >>> 'face '(:weight bold :inherit button) >>> 'mouse-face '(:weight normal :background "gray50" :inherit button) >>> 'follow-link t >> So, here why do we need to `copy-sequence`? > To avoid destructively modifying a string literal by placing properties > on it. Makes sense, Stefan