Mercurial > emacs
comparison doc/lispref/sequences.texi @ 98704:92d4fd43578c
(Char-Tables): `map-char-table' can now call its argument FUNCTION with
a cons cell as KEY.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Tue, 14 Oct 2008 11:39:16 +0000 |
parents | 107ccd98fa12 |
children | 43065c518c41 |
comparison
equal
deleted
inserted
replaced
98703:e96bc3be41f0 | 98704:92d4fd43578c |
---|---|
656 name. @xref{Splitting Characters}, for a description of generic characters. | 656 name. @xref{Splitting Characters}, for a description of generic characters. |
657 @end table | 657 @end table |
658 @end defun | 658 @end defun |
659 | 659 |
660 @defun map-char-table function char-table | 660 @defun map-char-table function char-table |
661 This function calls @var{function} for each element of @var{char-table}. | 661 This function calls the specified @var{function} for each element of |
662 @var{char-table} that has a non-@code{nil} value. | |
662 @var{function} is called with two arguments, a key and a value. The key | 663 @var{function} is called with two arguments, a key and a value. The key |
663 is a possible @var{range} argument for @code{char-table-range}---either | 664 is a possible @var{range} argument for @code{char-table-range}---either |
664 a valid character or a generic character---and the value is | 665 a valid character or a cons cell @code{(@var{from} . @var{to})}, |
665 @code{(char-table-range @var{char-table} @var{key})}. | 666 specifying a range of characters that share the same value. The value is |
667 what @code{(char-table-range @var{char-table} @var{key})} returns. | |
666 | 668 |
667 Overall, the key-value pairs passed to @var{function} describe all the | 669 Overall, the key-value pairs passed to @var{function} describe all the |
668 values stored in @var{char-table}. | 670 values stored in @var{char-table}. |
669 | 671 |
670 The return value is always @code{nil}; to make this function useful, | 672 The return value is always @code{nil}; to make calls to |
671 @var{function} should have side effects. For example, | 673 @code{map-char-table} useful, @var{function} should have side effects. |
672 here is how to examine each element of the syntax table: | 674 For example, here is how to examine the elements of the syntax table: |
673 | 675 |
674 @example | 676 @example |
675 (let (accumulator) | 677 (let (accumulator) |
676 (map-char-table | 678 (map-char-table |
677 #'(lambda (key value) | 679 #'(lambda (key value) |
678 (setq accumulator | 680 (setq accumulator |
679 (cons (list key value) accumulator))) | 681 (cons (list |
680 (syntax-table)) | 682 (if (consp key) |
681 accumulator) | 683 (list (car key) (cdr key)) |
684 key) | |
685 value) | |
686 accumulator))) | |
687 (syntax-table)) | |
688 accumulator) | |
682 @result{} | 689 @result{} |
683 ((475008 nil) (474880 nil) (474752 nil) (474624 nil) | 690 (((2597602 4194303) (2)) ((2597523 2597601) (3)) |
684 ... (5 (3)) (4 (3)) (3 (3)) (2 (3)) (1 (3)) (0 (3))) | 691 ... (65379 (5 . 65378)) (65378 (4 . 65379)) (65377 (1)) |
692 ... (12 (0)) (11 (3)) (10 (12)) (9 (0)) ((0 8) (3))) | |
685 @end example | 693 @end example |
686 @end defun | 694 @end defun |
687 | 695 |
688 @node Bool-Vectors | 696 @node Bool-Vectors |
689 @section Bool-vectors | 697 @section Bool-vectors |