Mercurial > hg > xemacs-beta
comparison man/lispref/symbols.texi @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 3ecd8885ac67 |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
376 @section Symbol Properties | 376 @section Symbol Properties |
377 @cindex property list, symbol | 377 @cindex property list, symbol |
378 @cindex plist, symbol | 378 @cindex plist, symbol |
379 | 379 |
380 A @dfn{property list} (@dfn{plist} for short) is a list of paired | 380 A @dfn{property list} (@dfn{plist} for short) is a list of paired |
381 elements stored in the property list cell of a symbol. Each of the | 381 elements, often stored in the property list cell of a symbol. Each of |
382 pairs associates a property name (usually a symbol) with a property or | 382 the pairs associates a property name (usually a symbol) with a property |
383 value. Property lists are generally used to record information about a | 383 or value. Property lists are generally used to record information about |
384 symbol, such as its documentation as a variable, the name of the file | 384 a symbol, such as its documentation as a variable, the name of the file |
385 where it was defined, or perhaps even the grammatical class of the | 385 where it was defined, or perhaps even the grammatical class of the |
386 symbol (representing a word) in a language-understanding system. | 386 symbol (representing a word) in a language-understanding system. |
387 | 387 |
388 Many objects other than symbols can have property lists associated | 388 Some objects which are not symbols also have property lists associated |
389 with them, and XEmacs provides a full complement of functions for | 389 with them, and XEmacs provides a full complement of functions for |
390 working with property lists. @xref{Property Lists}. | 390 working with property lists. @xref{Property Lists}. |
391 | 391 |
392 The property names and values in a property list can be any Lisp | 392 The property names and values in a property list can be any Lisp |
393 objects, but the names are usually symbols. They are compared using | 393 objects, but the names are usually symbols. They are compared using |
403 names, and the other two elements are the corresponding values. | 403 names, and the other two elements are the corresponding values. |
404 | 404 |
405 @menu | 405 @menu |
406 * Plists and Alists:: Comparison of the advantages of property | 406 * Plists and Alists:: Comparison of the advantages of property |
407 lists and association lists. | 407 lists and association lists. |
408 * Symbol Plists:: Functions to access symbols' property lists. | 408 * Object Plists:: Functions to access objects' property lists. |
409 * Other Plists:: Accessing property lists stored elsewhere. | 409 * Other Plists:: Accessing property lists stored elsewhere. |
410 @end menu | 410 @end menu |
411 | 411 |
412 @node Plists and Alists | 412 @node Plists and Alists |
413 @subsection Property Lists and Association Lists | 413 @subsection Property Lists and Association Lists |
439 unique, such as by including the name of the library in the property | 439 unique, such as by including the name of the library in the property |
440 name.) An association list may be used like a stack where associations | 440 name.) An association list may be used like a stack where associations |
441 are pushed on the front of the list and later discarded; this is not | 441 are pushed on the front of the list and later discarded; this is not |
442 possible with a property list. | 442 possible with a property list. |
443 | 443 |
444 @node Symbol Plists | 444 @node Object Plists |
445 @subsection Property List Functions for Symbols | 445 @subsection Property List Functions for Objects |
446 | |
447 Once upon a time, only symbols had property lists. Now, several other | |
448 object types, including strings, extents, faces and glyphs also have | |
449 property lists. | |
446 | 450 |
447 @defun symbol-plist symbol | 451 @defun symbol-plist symbol |
448 This function returns the property list of @var{symbol}. | 452 This function returns the property list of @var{symbol}. |
453 @end defun | |
454 | |
455 @defun object-plist object | |
456 This function returns the property list of @var{object}. If | |
457 @var{object} is a symbol, this is identical to @code{symbol-plist}. | |
449 @end defun | 458 @end defun |
450 | 459 |
451 @defun setplist symbol plist | 460 @defun setplist symbol plist |
452 This function sets @var{symbol}'s property list to @var{plist}. | 461 This function sets @var{symbol}'s property list to @var{plist}. |
453 Normally, @var{plist} should be a well-formed property list, but this is | 462 Normally, @var{plist} should be a well-formed property list, but this is |
461 @end smallexample | 470 @end smallexample |
462 | 471 |
463 For symbols in special obarrays, which are not used for ordinary | 472 For symbols in special obarrays, which are not used for ordinary |
464 purposes, it may make sense to use the property list cell in a | 473 purposes, it may make sense to use the property list cell in a |
465 nonstandard fashion; in fact, the abbrev mechanism does so | 474 nonstandard fashion; in fact, the abbrev mechanism does so |
466 (@pxref{Abbrevs}). | 475 (@pxref{Abbrevs}). But generally, its use is discouraged. Use |
467 @end defun | 476 @code{put} instead. @code{setplist} can only be used with symbols, not |
468 | 477 other object types. |
469 @defun get symbol property | 478 @end defun |
479 | |
480 @defun get object property &optional default | |
470 This function finds the value of the property named @var{property} in | 481 This function finds the value of the property named @var{property} in |
471 @var{symbol}'s property list. If there is no such property, @code{nil} | 482 @var{object}'s property list. If there is no such property, |
472 is returned. Thus, there is no distinction between a value of | 483 @code{default} (which itself defaults to @code{nil}) is returned. |
473 @code{nil} and the absence of the property. | 484 |
474 | 485 @var{property} is compared with the existing properties using @code{eq}, |
475 The name @var{property} is compared with the existing property names | 486 so any object is a legitimate property. |
476 using @code{eq}, so any object is a legitimate property. | |
477 | 487 |
478 See @code{put} for an example. | 488 See @code{put} for an example. |
479 @end defun | 489 @end defun |
480 | 490 |
481 @defun put symbol property value | 491 @defun put object property value |
482 This function puts @var{value} onto @var{symbol}'s property list under | 492 This function puts @var{value} onto @var{object}'s property list under |
483 the property name @var{property}, replacing any previous property value. | 493 the property name @var{property}, replacing any previous property value. |
484 The @code{put} function returns @var{value}. | 494 The @code{put} function returns @var{value}. |
485 | 495 |
486 @smallexample | 496 @smallexample |
487 (put 'fly 'verb 'transitive) | 497 (put 'fly 'verb 'transitive) |
488 @result{}'transitive | 498 @result{}'transitive |
489 (put 'fly 'noun '(a buzzing little bug)) | 499 (put 'fly 'noun '(a buzzing little bug)) |
490 @result{} (a buzzing little bug) | 500 @result{} (a buzzing little bug) |
491 (get 'fly 'verb) | 501 (get 'fly 'verb) |
492 @result{} transitive | 502 @result{} transitive |
493 (symbol-plist 'fly) | 503 (object-plist 'fly) |
494 @result{} (verb transitive noun (a buzzing little bug)) | 504 @result{} (verb transitive noun (a buzzing little bug)) |
495 @end smallexample | 505 @end smallexample |
496 @end defun | 506 @end defun |
497 | 507 |
508 @defun remprop object property | |
509 This function removes the entry for @var{property} from the property | |
510 list of @var{object}. It returns @code{t} if the property was | |
511 indeed found and removed, or @code{nil} if there was no such property. | |
512 (This function was probably omitted from Emacs originally because, | |
513 since @code{get} did not allow a @var{default}, it was very difficult | |
514 to distinguish between a missing property and a property whose value | |
515 was @code{nil}; thus, setting a property to @code{nil} was close | |
516 enough to @code{remprop} for most purposes.) | |
517 @end defun | |
518 | |
498 @node Other Plists | 519 @node Other Plists |
499 @subsection Property Lists Outside Symbols | 520 @subsection Property Lists Not Associated with Objects |
500 | 521 |
501 These functions are useful for manipulating property lists | 522 These functions are useful for manipulating property lists |
502 that are stored in places other than symbols: | 523 that are stored in places other than symbols: |
503 | 524 |
504 @defun getf plist property &optional default | 525 @defun getf plist property &optional default |