From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: master f51f963: Fix some side-effecting uses of make-text-button Date: Fri, 05 Jun 2020 11:51:26 +0100 Message-ID: <87eeqtiy4x.fsf@tcd.ie> References: <20200604223056.17078.81265@vcs0.savannah.gnu.org> <20200604223058.1850020A26@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="25048"; 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: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 05 12:52:06 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 1jh9xF-0006OP-Q5 for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jun 2020 12:52:05 +0200 Original-Received: from localhost ([::1]:50104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh9xE-0001yW-SV for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jun 2020 06:52:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh9wi-0001Ls-2o for emacs-devel@gnu.org; Fri, 05 Jun 2020 06:51:32 -0400 Original-Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:45304) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jh9wg-00046X-U5 for emacs-devel@gnu.org; Fri, 05 Jun 2020 06:51:31 -0400 Original-Received: by mail-wr1-x430.google.com with SMTP id c3so9240308wru.12 for ; Fri, 05 Jun 2020 03:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=JxnEpkeMmr7nGSStfV9Q0fMXdTEU+z3yNgp7Du3DSIY=; b=2F7N0yHBJ8hEcLLFGqOYU8bPwRZajFFbB5RJ/37KQt/821pStembQh1lp17d5kxM99 9Jz51ogY/9jZQ/+7bqClde1HZBG+WkoNSe8J6/7puDyHlM4x7y1C7Uqco9XMvo0PWz3/ p25uf3RZD13bjaLlM+xNfxpoQUoiX8lirY9w8mOc5I1oW7Qgdupf/ns/8Zdk+qSetrUU 4SrqQdmUnRTQNJ8+IB4P29i8lNnZLpRyu1B1nQc/gLGxP6C6r4wmhKW+oz0kMsnDKoei F+JLtKXFDOnviah+a8z/IlHs/lPN/mizCXV8Hhf33Jb2KFU+rffOz9mK+CrJGNy7vJY1 CkUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=JxnEpkeMmr7nGSStfV9Q0fMXdTEU+z3yNgp7Du3DSIY=; b=X77ICQW7SexJn+2h6TPhC6Mx9QXPNfGOc4t/K2/M9/b4IrxOewk2jzM047G6/cjwaH u+VaGL2Z2NrfaelgiiEhWkVaPWOnq92ZkoJdrf5XTBNErz08qmZnKkvKvPVVOqefBN+V VHrtpwsEaPbzY8SDV3FLfOm7sB45wtp6SHQzvupm6oUBZhySo5gBvoGAmZcvyl/Vszn5 Sec9oFDxD0Y0kTRJg+9EQvUu/YqOKc7BRn+ta75Ia4dK5M+r+cTdODoMNbNXQYoAwvop ZXV0u4zeUw8MmWoBANegsnJPKYXaNg4lVROcY+97eLUb1/Gvk+CUbcVUkXmPmCW1XfHO HCLw== X-Gm-Message-State: AOAM533rVpziuKe4WZai6TE42dilCj4CCp6uI8UfTyQY7mzwaLwq3dz1 uCdD438J1qI4VrW61aG0AebUdQ== X-Google-Smtp-Source: ABdhPJy7lljILjn0BZhrI7IsTcfOhSZ2NyxsAuyYP7rLom6jhvIQLHzPoNauFGltl307mnsuuNIdiA== X-Received: by 2002:adf:97cb:: with SMTP id t11mr8934531wrb.314.1591354288557; Fri, 05 Jun 2020 03:51:28 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id w3sm11630908wmg.44.2020.06.05.03.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 03:51:27 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Thu, 04 Jun 2020 18:44:10 -0400") Received-SPF: none client-ip=2a00:1450:4864:20::430; envelope-from=contovob@tcd.ie; helo=mail-wr1-x430.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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:251888 Archived-At: Stefan Monnier writes: >> (make-text-button name nil >> 'type 'apropos-library >> 'face 'apropos-symbol >> - 'apropos-symbol name) >> - name))) >> + 'apropos-symbol name)))) > > So, IIUC we consider `make-text-button` to be functional rather than > side-effecting, right? 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. >> @@ -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. -- Basil