summaryrefslogtreecommitdiff
path: root/lisp/button.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-06-10 14:17:32 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-06-10 14:17:32 +0000
commit7ba88a4da7722c2877e064e13d8e357bb55a00cf (patch)
treee016f3e3ae3902414aa21f1fa90f3c3db22fcb4d /lisp/button.el
parentbcf209a0c8da55d7ef2a1432e3e075814d52fb22 (diff)
downloademacs-7ba88a4da7722c2877e064e13d8e357bb55a00cf.tar.gz
(make-text-button): Allow `start' to be a string.
Diffstat (limited to 'lisp/button.el')
-rw-r--r--lisp/button.el26
1 files changed, 16 insertions, 10 deletions
diff --git a/lisp/button.el b/lisp/button.el
index 1be68acbc87..6a558af445a 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -293,10 +293,15 @@ part of the text instead of being a property of the buffer. Creating
large numbers of buttons can also be somewhat faster using
`make-text-button'.
+BEG can also be a string, in which case it is made into a button.
+
Also see `insert-text-button'."
- (let ((type-entry
+ (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"))
@@ -308,15 +313,16 @@ Also see `insert-text-button'."
;; text-properties for inheritance.
(setcar type-entry 'category)
(setcar (cdr type-entry)
- (button-category-symbol (car (cdr type-entry))))))
- ;; Now add all the text properties at once
- (add-text-properties beg end
- ;; Each button should have a non-eq `button'
- ;; property so that next-single-property-change can
- ;; detect boundaries reliably.
- (cons 'button (cons (list t) properties)))
- ;; Return something that can be used to get at the button.
- beg)
+ (button-category-symbol (car (cdr type-entry)))))
+ ;; Now add all the text properties at once
+ (add-text-properties beg end
+ ;; Each button should have a non-eq `button'
+ ;; property so that next-single-property-change can
+ ;; detect boundaries reliably.
+ (cons 'button (cons (list t) properties))
+ object)
+ ;; Return something that can be used to get at the button.
+ beg))
(defun insert-text-button (label &rest properties)
"Insert a button with the label LABEL.