Subject: bug#23909: 25.1.50; `button-label' must be called in the buffer where the button is in but not mentioned in document

From: Jiegec <[email-masked]>
Date: Fri, 8 Jul 2016 18:36:42 +0800

I have gone through button.el and found only `button-label’ needs
this change. If I have left out some, please add those as well.

This change should be small enough and I needn’t sign.

diff --git a/lisp/button.el b/lisp/button.el
index cb08b78..62a2d0f 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -244,7 +244,8 @@ button-activate
       (funcall action button))))

 (defun button-label (button)
-  "Return BUTTON's text label."
+  "Return BUTTON's text label.
+Only works when BUTTON is in the current buffer."
   (if (button--area-button-p button)
       (substring-no-properties (button--area-button-string button))
     (buffer-substring-no-properties (button-start button)

> On Jul 7, 2016, at 11:24 PM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Jiajie Chen <[email-masked]>
>> Date: Thu, 07 Jul 2016 18:19:11 +0800
>> 
>> The definition of button-label is:
>> 
>> #+BEGIN_SRC elisp
>> (defun button-label (button)
>>  "Return BUTTON's text label."
>>  (if (button--area-button-p button)
>>      (substring-no-properties (button--area-button-string button))
>>    (buffer-substring-no-properties (button-start button)
>>                                    (button-end button))))
>> #+END_SRC
>> 
>> So when the function is called in a different buffer, it
>> returns a wrong result.
> 
> AFAICT, all of the functions in button.el operate on buttons in the
> current buffer, although only a few mention that explicitly in their
> doc strings.  Patches to mention that in the doc strings are welcome.
> 
> Thanks.
> 
> 
> 
>