diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-06-06 12:05:10 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-06-06 12:07:30 -0700 |
commit | 7ac79872aed63110c0d26c1e62e1838d6101c9bd (patch) | |
tree | dce387320ac1e58ba78d17a1df2ae9d9b22e4e51 /lisp/button.el | |
parent | 8bcc781bc762b4082cfd678b88938e3d03465d91 (diff) | |
download | emacs-7ac79872aed63110c0d26c1e62e1838d6101c9bd.tar.gz emacs-7ac79872aed63110c0d26c1e62e1838d6101c9bd.tar.bz2 emacs-7ac79872aed63110c0d26c1e62e1838d6101c9bd.zip |
make-text-button no longer modifies its string arg
* 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.
Diffstat (limited to 'lisp/button.el')
-rw-r--r-- | lisp/button.el | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/button.el b/lisp/button.el index 3a6a6de774c..d9c36a0375c 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -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' |