bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23909: 25.1.50; `button-label' must be called in the buffer where th


From: Jiegec
Subject: bug#23909: 25.1.50; `button-label' must be called in the buffer where the button is in but not mentioned in document
Date: Fri, 8 Jul 2016 22:01:40 +0800

Sorry I wasn’t aware that a button can be just represented by a position.

I think insert-button, insert-text-button, push-button, forward-button and 
backward-button 
do not need this change. Their names and documentations implies that.

diff --git a/lisp/button.el b/lisp/button.el
index cb08b78..b0a99d3 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -172,7 +172,8 @@ button-type-subtype-p
 ;; Button properties and other attributes

 (defun button-start (button)
-  "Return the position at which BUTTON starts."
+  "Return the position at which BUTTON starts.
+Only works when BUTTON is in the current buffer."
   (if (overlayp button)
       (overlay-start button)
     ;; Must be a text-property button.
@@ -180,7 +181,8 @@ button-start
        (point-min))))

 (defun button-end (button)
-  "Return the position at which BUTTON ends."
+  "Return the position at which BUTTON ends.
+Only works when BUTTON is in the current buffer."
   (if (overlayp button)
       (overlay-end button)
     ;; Must be a text-property button.
@@ -188,7 +190,8 @@ button-end
        (point-max))))

 (defun button-get (button prop)
-  "Get the property of button BUTTON named PROP."
+  "Get the property of button BUTTON named PROP.
+Only works when BUTTON is in the current buffer."
   (cond ((overlayp button)
         (overlay-get button prop))
        ((button--area-button-p button)
@@ -198,7 +201,8 @@ button-get
         (get-text-property button prop))))

 (defun button-put (button prop val)
-  "Set BUTTON's PROP property to VAL."
+  "Set BUTTON's PROP property to VAL.
+Only works when BUTTON is in the current buffer."
   ;; Treat some properties specially.
   (cond ((memq prop '(type :type))
         ;; We translate a `type' property a `category' property, since
@@ -233,7 +237,9 @@ button-activate
 marker then goto it.  Otherwise it it is a function then it is
 called with BUTTON as only argument.  BUTTON is either an
 overlay, a buffer position, or (for buttons in the mode-line or
-header-line) a string."
+header-line) a string.
+
+Only works when BUTTON is in the current buffer."
   (let ((action (or (and use-mouse-action (button-get button 'mouse-action))
                    (button-get button 'action))))
     (if (markerp action)
@@ -244,7 +250,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)
d

> On Jul 8, 2016, at 9:48 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Jiegec <jiegec@qq.com>
>> Date: Fri, 8 Jul 2016 18:36:42 +0800
>> Cc: 23909@debbugs.gnu.org
>> 
>> 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.
> 
> Are we talking about the same issue?  I see these functions work on
> the current buffer without telling that in their doc strings:
> 
>  button-start, button-end, button-get, button-put, button-activate,
>  insert-button, insert-text-button, push-button, forward-button, and
>  backward-button
> 
> Thanks.
> 
> 
> 
> 








reply via email to

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