aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2005-03-02 09:12:54 +0000
committerMiles Bader2005-03-02 09:12:54 +0000
commitaad1926a4f348185f2dbdb6ffd1ba86f3d80710c (patch)
tree038b5fbbf53bbf27d50336a016710d196095b19a
parent527d43c2bab3846a92b037c8e3370d12154b3cee (diff)
downloademacs-aad1926a4f348185f2dbdb6ffd1ba86f3d80710c.tar.gz
emacs-aad1926a4f348185f2dbdb6ffd1ba86f3d80710c.zip
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-145
(make-text-button): Default button type if not specified 2005-03-02 Miles Bader <miles@gnu.org> * lisp/button.el (make-text-button): If the user doesn't specify a type, use the default. Rewrite to use `add-text-properties' and plist functions.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/button.el37
2 files changed, 24 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 56097bb2ccc..01fb5a5e6b4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12005-03-02 Miles Bader <miles@gnu.org>
2
3 * button.el (make-text-button): If the user doesn't specify a
4 type, use the default. Rewrite to use `add-text-properties' and
5 plist functions.
6
12005-03-01 Robert J. Chassell <bob@rattlesnake.com> 72005-03-01 Robert J. Chassell <bob@rattlesnake.com>
2 8
3 * textmodes/texinfmt.el: (texinfo-no-refill-regexp): Comment out 9 * textmodes/texinfmt.el: (texinfo-no-refill-regexp): Comment out
diff --git a/lisp/button.el b/lisp/button.el
index 5f9b5094e6c..78008f06db2 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -1,6 +1,6 @@
1;;; button.el --- clickable buttons 1;;; button.el --- clickable buttons
2;; 2;;
3;; Copyright (C) 2001 Free Software Foundation, Inc. 3;; Copyright (C) 2001, 2005 Free Software Foundation, Inc.
4;; 4;;
5;; Author: Miles Bader <miles@gnu.org> 5;; Author: Miles Bader <miles@gnu.org>
6;; Keywords: extensions 6;; Keywords: extensions
@@ -298,24 +298,23 @@ large numbers of buttons can also be somewhat faster using
298`make-text-button'. 298`make-text-button'.
299 299
300Also see `insert-text-button'." 300Also see `insert-text-button'."
301 (let (prop val) 301 (let ((type-entry
302 (while properties 302 (or (plist-member properties 'type)
303 (setq prop (pop properties)) 303 (plist-member properties :type))))
304 (setq val (pop properties)) 304 ;; Disallow setting the `category' property directly.
305 ;; Note that all the following code is basically equivalent to 305 (when (plist-get properties 'category)
306 ;; `button-put', but we can do it much more efficiently since we 306 (error "Button `category' property may not be set directly"))
307 ;; already have BEG and END. 307 (if (null type-entry)
308 (cond ((memq prop '(type :type)) 308 ;; The user didn't specify a `type' property, use the default.
309 ;; We translate a `type' property into a `category' 309 (setq properties (cons 'category (cons 'default-button properties)))
310 ;; property, since that's what's actually used by 310 ;; The user did specify a `type' property. Translate it into a
311 ;; text-properties for inheritance. 311 ;; `category' property, which is what's actually used by
312 (setq prop 'category) 312 ;; text-properties for inheritance.
313 (setq val (button-category-symbol val))) 313 (setcar type-entry 'category)
314 ((eq prop 'category) 314 (setcar (cdr type-entry)
315 ;; Disallow setting the `category' property directly. 315 (button-category-symbol (car (cdr type-entry))))))
316 (error "Button `category' property may not be set directly"))) 316 ;; Now add all the text properties at once
317 ;; Add the property. 317 (add-text-properties beg end properties)
318 (put-text-property beg end prop val)))
319 ;; Return something that can be used to get at the button. 318 ;; Return something that can be used to get at the button.
320 beg) 319 beg)
321 320