]> git.eshelyaron.com Git - emacs.git/commitdiff
make-text-button no longer modifies its string arg
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jun 2020 19:05:10 +0000 (12:05 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jun 2020 19:07:30 +0000 (12:07 -0700)
* etc/NEWS: Mention this.
* lisp/apropos.el (apropos-library-button):
* lisp/ibuf-ext.el (ibuffer-old-saved-filters-warning):
There’s no longer a need copy make-text-button’s string arg.
* lisp/button.el (make-text-button): Return a copy of a string arg.
Delay making the copy until after error-checking.

etc/NEWS
lisp/apropos.el
lisp/button.el
lisp/ibuf-ext.el

index 27e511047e6a4ba6532efe7320e67250672968a9..edad5b37d6c274cd56d47850eea216d846f6611d 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -476,6 +476,11 @@ are 'eq'.  To compare contents, use 'compare-window-configurations'
 instead.  This change helps fix a bug in 'sxhash-equal', which returned
 incorrect hashes for window configurations and some other objects.
 
+** When its first argument is a string, 'make-text-button' no longer
+modifies the string's text properties; instead, it uses and returns
+a copy of the string.  This helps avoid trouble when strings are
+shared or constants.
+
 ---
 ** The obsolete function 'thread-alive-p' has been removed.
 
index 22866cd2cc87470fa5a5ed845b2266eefe3bc215..2566d44dfcf29d08083c6b64d2b644536e32eb39 100644 (file)
@@ -661,7 +661,7 @@ Return list of symbols and documentation found."
 (defun apropos-library-button (sym)
   (if (null sym)
       "<nothing>"
-    (let ((name (copy-sequence (symbol-name sym))))
+    (let ((name (symbol-name sym)))
       (make-text-button name nil
                         'type 'apropos-library
                         'face 'apropos-symbol
index 3a6a6de774c8d612cbf00bbc614ceb3594bc6496..d9c36a0375c8d6e210e73bd6aa981905f0560ab8 100644 (file)
@@ -341,15 +341,14 @@ If the property `button-data' is present, it will later be used
 as the argument for the `action' callback function instead of the
 default argument, which is the button itself.
 
-BEG can also be a string, in which case it is made into a button.
+BEG can also be a string, in which case a copy of it is made into
+a button and returned.
 
 Also see `insert-text-button'."
   (let ((object nil)
         (type-entry
         (or (plist-member properties 'type)
             (plist-member properties :type))))
-    (when (stringp beg)
-      (setq object beg beg 0 end (length object)))
     ;; Disallow setting the `category' property directly.
     (when (plist-get properties 'category)
       (error "Button `category' property may not be set directly"))
@@ -362,6 +361,10 @@ Also see `insert-text-button'."
       (setcar type-entry 'category)
       (setcar (cdr type-entry)
               (button-category-symbol (cadr type-entry))))
+    (when (stringp beg)
+      (setq object (copy-sequence beg))
+      (setq beg 0)
+      (setq end (length object)))
     ;; Now add all the text properties at once.
     (add-text-properties beg end
                          ;; Each button should have a non-eq `button'
index c39000b4886cb93296358df5515cc39828808d11..bfb9787a96d2a5e9106e2dbe8492207dc6152138 100644 (file)
@@ -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
-           (copy-sequence "here") nil
+           "here" nil
            'face '(:weight bold :inherit button)
            'mouse-face '(:weight normal :background "gray50" :inherit button)
            'follow-link t