emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 31395511: "Don’t attempt to modify constant strings"


From: Paul Eggert
Subject: Re: 31395511: "Don’t attempt to modify constant strings"
Date: Wed, 3 Jun 2020 17:43:32 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

On 6/3/20 4:48 PM, João Távora wrote:
> I think I'd rather this previous behavior were retained, or at least
> achievable by request.

It's tricky, as make-text-button in emacs-27 (and earlier) modifies its string
argument, which is buggy because string constants are not always unique. For
example:

(defun example-bug ()
  (concat "1. " (make-text-button
                 "example" nil
                 'action (lambda (_) (message "action 1")))
          "2. " (make-text-button
                 "example" nil
                 'action (lambda (_) (message "action 2")))))

If you byte-compile this in emacs-27, both buttons message "action 2" because
there's there's really just one instance of the string constant "example", and
so there's just one button and the second action overwrites the first.

Does SLY always pass mutable strings to make-text-button? I.e., strings built
from 'concat' etc. (not string constants)? If so, I could change
make-string-button to copy its string argument only if it's a constant, and that
should fix the compatibility issue without needing to make any changes to SLY.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]