Mercurial > emacs
comparison lispref/syntax.texi @ 54114:f309c4cf39a2
(Syntax Table Functions): Clarify and correct descriptions of
make-syntax-table and copy-syntax-table.
(Motion and Syntax): Clarify SYNTAXES argument to skip-syntax-forward.
(Parsing Expressions): Mention that the return value of parse-partial-sexp
is currently a list of ten rather than nine elements.
(Categories): Various corrections and clarifications.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Sat, 21 Feb 2004 16:44:20 +0000 |
parents | b3ba32bd740f |
children | 69dcc9afcf6f |
comparison
equal
deleted
inserted
replaced
54113:a045d0873ac4 | 54114:f309c4cf39a2 |
---|---|
395 @section Syntax Table Functions | 395 @section Syntax Table Functions |
396 | 396 |
397 In this section we describe functions for creating, accessing and | 397 In this section we describe functions for creating, accessing and |
398 altering syntax tables. | 398 altering syntax tables. |
399 | 399 |
400 @defun make-syntax-table | 400 @defun make-syntax-table &optional table |
401 This function creates a new syntax table. It inherits the syntax for | 401 This function creates a new syntax table, with all values initialized |
402 letters and control characters from the standard syntax table. For | 402 to @code{nil}. If @var{table} is non-@code{nil}, it becomes the |
403 other characters, the syntax is copied from the standard syntax table. | 403 parent of the new syntax table, otherwise the standard syntax table is |
404 the parent. Like all char-tables, a syntax table inherits from its | |
405 parent. Thus the original syntax of all characters in the returned | |
406 syntax table is determined by the parent. @xref{Char-Tables}. | |
404 | 407 |
405 Most major mode syntax tables are created in this way. | 408 Most major mode syntax tables are created in this way. |
406 @end defun | 409 @end defun |
407 | 410 |
408 @defun copy-syntax-table &optional table | 411 @defun copy-syntax-table &optional table |
409 This function constructs a copy of @var{table} and returns it. If | 412 This function constructs a copy of @var{table} and returns it. If |
410 @var{table} is not supplied (or is @code{nil}), it returns a copy of the | 413 @var{table} is not supplied (or is @code{nil}), it returns a copy of the |
411 current syntax table. Otherwise, an error is signaled if @var{table} is | 414 standard syntax table. Otherwise, an error is signaled if @var{table} is |
412 not a syntax table. | 415 not a syntax table. |
413 @end defun | 416 @end defun |
414 | 417 |
415 @deffn Command modify-syntax-entry char syntax-descriptor &optional table | 418 @deffn Command modify-syntax-entry char syntax-descriptor &optional table |
416 This function sets the syntax entry for @var{char} according to | 419 This function sets the syntax entry for @var{char} according to |
423 | 426 |
424 This function always returns @code{nil}. The old syntax information in | 427 This function always returns @code{nil}. The old syntax information in |
425 the table for this character is discarded. | 428 the table for this character is discarded. |
426 | 429 |
427 An error is signaled if the first character of the syntax descriptor is not | 430 An error is signaled if the first character of the syntax descriptor is not |
428 one of the twelve syntax class designator characters. An error is also | 431 one of the seventeen syntax class designator characters. An error is also |
429 signaled if @var{char} is not a character. | 432 signaled if @var{char} is not a character. |
430 | 433 |
431 @example | 434 @example |
432 @group | 435 @group |
433 @exdent @r{Examples:} | 436 @exdent @r{Examples:} |
557 | 560 |
558 This section describes functions for moving across characters that | 561 This section describes functions for moving across characters that |
559 have certain syntax classes. | 562 have certain syntax classes. |
560 | 563 |
561 @defun skip-syntax-forward syntaxes &optional limit | 564 @defun skip-syntax-forward syntaxes &optional limit |
562 This function moves point forward across characters having syntax classes | 565 This function moves point forward across characters having syntax |
563 mentioned in @var{syntaxes}. It stops when it encounters the end of | 566 classes mentioned in @var{syntaxes} (a string of syntax code |
564 the buffer, or position @var{limit} (if specified), or a character it is | 567 characters). It stops when it encounters the end of the buffer, or |
565 not supposed to skip. | 568 position @var{limit} (if specified), or a character it is not supposed |
569 to skip. | |
566 | 570 |
567 If @var{syntaxes} starts with @samp{^}, then the function skips | 571 If @var{syntaxes} starts with @samp{^}, then the function skips |
568 characters whose syntax is @emph{not} in @var{syntaxes}. | 572 characters whose syntax is @emph{not} in @var{syntaxes}. |
569 | 573 |
570 The return value is the distance traveled, which is a nonnegative | 574 The return value is the distance traveled, which is a nonnegative |
695 | 699 |
696 @item | 700 @item |
697 The minimum parenthesis depth encountered during this scan. | 701 The minimum parenthesis depth encountered during this scan. |
698 | 702 |
699 @item | 703 @item |
700 What kind of comment is active: @code{nil} for a comment of style ``a'', | 704 What kind of comment is active: @code{nil} for a comment of style |
701 @code{t} for a comment of style ``b'', and @code{syntax-table} for | 705 ``a'' or when not inside a comment, @code{t} for a comment of style |
702 a comment that should be ended by a generic comment delimiter character. | 706 ``b'', and @code{syntax-table} for a comment that should be ended by a |
707 generic comment delimiter character. | |
703 | 708 |
704 @item | 709 @item |
705 The string or comment start position. While inside a comment, this is | 710 The string or comment start position. While inside a comment, this is |
706 the position where the comment began; while inside a string, this is the | 711 the position where the comment began; while inside a string, this is the |
707 position where the string began. When outside of strings and comments, | 712 position where the string began. When outside of strings and comments, |
708 this element is @code{nil}. | 713 this element is @code{nil}. |
709 @end enumerate | 714 @end enumerate |
710 | 715 |
711 Elements 0, 3, 4, 5 and 7 are significant in the argument @var{state}. | 716 Elements 0, 3, 4, 5 and 7 are significant in the argument @var{state}. |
717 | |
718 Actually, the return value is currently a list of ten, rather than | |
719 nine, elements and @var{state} is allowed to be a list of ten elements | |
720 as well. However, the meaning of the tenth element is subject to | |
721 change and only the first eight elements of @var{state} need to be | |
722 specified. | |
712 | 723 |
713 @cindex indenting with parentheses | 724 @cindex indenting with parentheses |
714 This function is most often used to compute indentation for languages | 725 This function is most often used to compute indentation for languages |
715 that have nested parentheses. | 726 that have nested parentheses. |
716 @end defun | 727 @end defun |
755 non-@acronym{ASCII} characters as symbol constituents regardless | 766 non-@acronym{ASCII} characters as symbol constituents regardless |
756 of what the syntax table says about them. (However, text properties | 767 of what the syntax table says about them. (However, text properties |
757 can still override the syntax.) | 768 can still override the syntax.) |
758 @end defvar | 769 @end defvar |
759 | 770 |
760 @defvar parse-sexp-ignore-comments | 771 @defopt parse-sexp-ignore-comments |
761 @cindex skipping comments | 772 @cindex skipping comments |
762 If the value is non-@code{nil}, then comments are treated as | 773 If the value is non-@code{nil}, then comments are treated as |
763 whitespace by the functions in this section and by @code{forward-sexp}. | 774 whitespace by the functions in this section and by @code{forward-sexp}. |
764 @end defvar | 775 @end defopt |
765 | 776 |
766 @vindex parse-sexp-lookup-properties | 777 @vindex parse-sexp-lookup-properties |
767 The behaviour of @code{parse-partial-sexp} is also affected by | 778 The behaviour of @code{parse-partial-sexp} is also affected by |
768 @code{parse-sexp-lookup-properties} (@pxref{Syntax Properties}). | 779 @code{parse-sexp-lookup-properties} (@pxref{Syntax Properties}). |
769 | 780 |
949 set}---a bool-vector---that indicates which categories character @var{c} | 960 set}---a bool-vector---that indicates which categories character @var{c} |
950 belongs to. In this category set, if the element at index @var{cat} is | 961 belongs to. In this category set, if the element at index @var{cat} is |
951 @code{t}, that means category @var{cat} is a member of the set, and that | 962 @code{t}, that means category @var{cat} is a member of the set, and that |
952 character @var{c} belongs to category @var{cat}. | 963 character @var{c} belongs to category @var{cat}. |
953 | 964 |
965 For the next three functions, the optional argument @var{table} | |
966 defaults to the current buffer's category table. | |
967 | |
954 @defun define-category char docstring &optional table | 968 @defun define-category char docstring &optional table |
955 This function defines a new category, with name @var{char} and | 969 This function defines a new category, with name @var{char} and |
956 documentation @var{docstring}. | 970 documentation @var{docstring}, for the category table @var{table}, |
957 | |
958 The new category is defined for category table @var{table}, which | |
959 defaults to the current buffer's category table. | |
960 @end defun | 971 @end defun |
961 | 972 |
962 @defun category-docstring category &optional table | 973 @defun category-docstring category &optional table |
963 This function returns the documentation string of category @var{category} | 974 This function returns the documentation string of category @var{category} |
964 in category table @var{table}. | 975 in category table @var{table}. |
969 (category-docstring ?l) | 980 (category-docstring ?l) |
970 @result{} "Latin" | 981 @result{} "Latin" |
971 @end example | 982 @end example |
972 @end defun | 983 @end defun |
973 | 984 |
974 @defun get-unused-category table | 985 @defun get-unused-category &optional table |
975 This function returns a category name (a character) which is not | 986 This function returns a category name (a character) which is not |
976 currently defined in @var{table}. If all possible categories are in use | 987 currently defined in @var{table}. If all possible categories are in use |
977 in @var{table}, it returns @code{nil}. | 988 in @var{table}, it returns @code{nil}. |
978 @end defun | 989 @end defun |
979 | 990 |
991 @end defun | 1002 @end defun |
992 | 1003 |
993 @defun copy-category-table &optional table | 1004 @defun copy-category-table &optional table |
994 This function constructs a copy of @var{table} and returns it. If | 1005 This function constructs a copy of @var{table} and returns it. If |
995 @var{table} is not supplied (or is @code{nil}), it returns a copy of the | 1006 @var{table} is not supplied (or is @code{nil}), it returns a copy of the |
996 current category table. Otherwise, an error is signaled if @var{table} | 1007 standard category table. Otherwise, an error is signaled if @var{table} |
997 is not a category table. | 1008 is not a category table. |
998 @end defun | 1009 @end defun |
999 | 1010 |
1000 @defun set-category-table table | 1011 @defun set-category-table table |
1001 This function makes @var{table} the category table for the current | 1012 This function makes @var{table} the category table for the current |
1021 @result{} #&128"\0\0\0\0\0\0\0\0\0\0\0\0\2\20\0\0" | 1032 @result{} #&128"\0\0\0\0\0\0\0\0\0\0\0\0\2\20\0\0" |
1022 @end example | 1033 @end example |
1023 @end defun | 1034 @end defun |
1024 | 1035 |
1025 @defun char-category-set char | 1036 @defun char-category-set char |
1026 This function returns the category set for character @var{char}. This | 1037 This function returns the category set for character @var{char} in the |
1027 is the bool-vector which records which categories the character | 1038 current buffer's category table. This is the bool-vector which |
1028 @var{char} belongs to. The function @code{char-category-set} does not | 1039 records which categories the character @var{char} belongs to. The |
1029 allocate storage, because it returns the same bool-vector that exists in | 1040 function @code{char-category-set} does not allocate storage, because |
1030 the category table. | 1041 it returns the same bool-vector that exists in the category table. |
1031 | 1042 |
1032 @example | 1043 @example |
1033 (char-category-set ?a) | 1044 (char-category-set ?a) |
1034 @result{} #&128"\0\0\0\0\0\0\0\0\0\0\0\0\2\20\0\0" | 1045 @result{} #&128"\0\0\0\0\0\0\0\0\0\0\0\0\2\20\0\0" |
1035 @end example | 1046 @end example |
1054 Normally, it modifies the category set by adding @var{category} to it. | 1065 Normally, it modifies the category set by adding @var{category} to it. |
1055 But if @var{reset} is non-@code{nil}, then it deletes @var{category} | 1066 But if @var{reset} is non-@code{nil}, then it deletes @var{category} |
1056 instead. | 1067 instead. |
1057 @end defun | 1068 @end defun |
1058 | 1069 |
1059 @deffn Command describe-categories | 1070 @deffn Command describe-categories &optional buffer-or-name |
1060 This function describes the category specifications in the current | 1071 This function describes the category specifications in the current |
1061 category table. The descriptions are inserted in a buffer, which is | 1072 category table. It inserts the descriptions in a buffer, and then |
1062 then displayed. | 1073 displays that buffer. If @var{buffer-or-name} is non-@code{nil}, it |
1074 describes the category table of that buffer instead. | |
1063 @end deffn | 1075 @end deffn |
1064 | 1076 |
1065 @ignore | 1077 @ignore |
1066 arch-tag: 4d914e96-0283-445c-9233-75d33662908c | 1078 arch-tag: 4d914e96-0283-445c-9233-75d33662908c |
1067 @end ignore | 1079 @end ignore |