Mercurial > emacs
comparison lisp/button.el @ 90114:e4694597cbf4
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-21
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0 (patch 129-149)
- Update from CVS
- Merge from gnus--rel--5.10
- (make-text-button): Default button type if not specified
- quick-install-emacs: Use mkdir --verbose only when requested
* miles@gnu.org--gnu-2005/gnus--rel--5.10 (patch 31-33)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 03 Mar 2005 10:35:22 +0000 |
parents | bf0d492ea2d5 3cd3e3cf3529 |
children | f9a65d7ebd29 |
comparison
equal
deleted
inserted
replaced
90113:a50413a4ba8b | 90114:e4694597cbf4 |
---|---|
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 |
7 ;; | 7 ;; |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
296 part of the text instead of being a property of the buffer. Creating | 296 part of the text instead of being a property of the buffer. Creating |
297 large numbers of buttons can also be somewhat faster using | 297 large numbers of buttons can also be somewhat faster using |
298 `make-text-button'. | 298 `make-text-button'. |
299 | 299 |
300 Also see `insert-text-button'." | 300 Also 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 |
322 ;;;###autoload | 321 ;;;###autoload |
323 (defun insert-text-button (label &rest properties) | 322 (defun insert-text-button (label &rest properties) |