]> code.delx.au - gnu-emacs/blobdiff - lisp/button.el
Detect remote uid and gid in tramp-gvfs.el
[gnu-emacs] / lisp / button.el
index c52dcabed08d92414f241171bae53d75fd6a371a..cb08b7881cdf90a614d18a2a2fb258f658c0e31e 100644 (file)
@@ -1,6 +1,6 @@
 ;;; button.el --- clickable buttons
 ;;
-;; Copyright (C) 2001-201 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2016 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <miles@gnu.org>
 ;; Keywords: extensions
@@ -192,7 +192,8 @@ changes to a supertype are not reflected in its subtypes)."
   (cond ((overlayp button)
         (overlay-get button prop))
        ((button--area-button-p button)
-        (get-text-property 0 prop (button--area-button-string button)))
+        (get-text-property (cdr button)
+                           prop (button--area-button-string button)))
        (t ; Must be a text-property button.
         (get-text-property button prop))))
 
@@ -223,10 +224,10 @@ changes to a supertype are not reflected in its subtypes)."
          prop val))))
 
 (defun button-activate (button &optional use-mouse-action)
-  "Call BUTTON's action property.
-If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action
-instead of its normal action; if the button has no mouse-action,
-the normal action is used instead.
+  "Call BUTTON's `action' property.
+If USE-MOUSE-ACTION is non-nil, invoke the button's `mouse-action'
+property instead of `action'; if the button has no `mouse-action',
+the value of `action' is used instead.
 
 The action can either be a marker or a function.  If it's a
 marker then goto it.  Otherwise it it is a function then it is
@@ -257,11 +258,12 @@ header-line) a string."
   "Return t if BUTTON has button-type TYPE, or one of TYPE's subtypes."
   (button-type-subtype-p (button-get button 'type) type))
 
-(defalias 'button--area-button-p 'stringp
+(defun button--area-button-p (b)
   "Return non-nil if BUTTON is an area button.
-Such area buttons are used for buttons in the mode-line and header-line.")
+Such area buttons are used for buttons in the mode-line and header-line."
+  (stringp (car-safe b)))
 
-(defalias 'button--area-button-string 'identity
+(defalias 'button--area-button-string #'car
   "Return area button BUTTON's button-string.")
 \f
 ;; Creating overlay buttons
@@ -427,11 +429,13 @@ instead of starting at the next button."
 (defun push-button (&optional pos use-mouse-action)
   "Perform the action specified by a button at location POS.
 POS may be either a buffer position or a mouse-event.  If
-USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action
-instead of its normal action; if the button has no mouse-action,
-the normal action is used instead.  The action may be either a
-function to call or a marker to display and is invoked using
-`button-activate' (which see).
+USE-MOUSE-ACTION is non-nil, invoke the button's `mouse-action'
+property instead of its `action' property; if the button has no
+`mouse-action', the value of `action' is used instead.
+
+The action in both cases may be either a function to call or a
+marker to display and is invoked using `button-activate' (which
+see).
 
 POS defaults to point, except when `push-button' is invoked
 interactively as the result of a mouse-event, in which case, the
@@ -444,10 +448,10 @@ return t."
       ;; POS is a mouse event; switch to the proper window/buffer
       (let ((posn (event-start pos)))
        (with-current-buffer (window-buffer (posn-window posn))
-         (if (posn-area posn)
-             ;; mode-line or header-line event
-             (button-activate (car (posn-string posn)) t)
-           (push-button (posn-point posn)) t)))
+         (if (posn-string posn)
+             ;; mode-line, header-line, or display string event.
+             (button-activate (posn-string posn) t)
+           (push-button (posn-point posn) t))))
     ;; POS is just normal position
     (let ((button (button-at (or pos (point)))))
       (when button