1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
|
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/syntax
@node Syntax Tables, Abbrevs, Searching and Matching, Top
@c @chapter Syntax Tables
@chapter $B9=J8%F!<%V%k(B
@c @cindex parsing
@c @cindex syntax table
@c @cindex text parsing
@cindex $B9=J82r@O(B
@cindex $B9=J8%F!<%V%k(B
@cindex $B%F%-%9%H$N2r@O(B
@c A @dfn{syntax table} specifies the syntactic textual function of each
@c character. This information is used by the @dfn{parsing functions}, the
@c complex movement commands, and others to determine where words, symbols,
@c and other syntactic constructs begin and end. The current syntax table
@c controls the meaning of the word motion functions (@pxref{Word Motion})
@c and the list motion functions (@pxref{List Motion}), as well as the
@c functions in this chapter.
@dfn{$B9=J8%F!<%V%k(B}$B!J(Bsyntax table$B!K$O!"(B
$B3FJ8;z$N9=J8E*$J%F%-%9%H>e$N5!G=$r;XDj$7$^$9!#(B
$B$3$N>pJs$O!"(B@dfn{$B9=J82r@O4X?t(B}$B$dJ#;($J0\F0$r9T$&%3%^%s%I$J$I$,(B
$BC18l$d%7%s%\%k$J$I$N9=J8MWAG$,$I$3$G;O$^$j$I$3$G=*$k$+$rD4$Y$k$?$a$K;H$$$^$9!#(B
$B8=:_$N9=J8%F!<%V%k$,!"K\>O$N4X?t$K2C$($F!"(B
$BC18lC10L$N0\F04X?t!J(B@pxref{Word Motion}$B!K!"(B
$B%j%9%HC10L$N0\F04X?t!J(B@pxref{List Motion}$B!K$N0UL#$r@)8f$7$^$9!#(B
@menu
* Basics: Syntax Basics. Basic concepts of syntax tables.
* Desc: Syntax Descriptors. How characters are classified.
* Syntax Table Functions:: How to create, examine and alter syntax tables.
* Syntax Properties:: Overriding syntax with text properties.
* Motion and Syntax:: Moving over characters with certain syntaxes.
* Parsing Expressions:: Parsing balanced expressions
using the syntax table.
* Standard Syntax Tables:: Syntax tables used by various major modes.
* Syntax Table Internals:: How syntax table information is stored.
* Categories:: Another way of classifying character syntax.
@end menu
@node Syntax Basics
@c @section Syntax Table Concepts
@section $B9=J8%F!<%V%k$N35G0(B
@ifinfo
@c A @dfn{syntax table} provides Emacs with the information that
@c determines the syntactic use of each character in a buffer. This
@c information is used by the parsing commands, the complex movement
@c commands, and others to determine where words, symbols, and other
@c syntactic constructs begin and end. The current syntax table controls
@c the meaning of the word motion functions (@pxref{Word Motion}) and the
@c list motion functions (@pxref{List Motion}) as well as the functions in
@c this chapter.
@dfn{$B9=J8%F!<%V%k(B}$B!J(Bsyntax table$B!K$O!"(B
$B%P%C%U%!Fb$N3FJ8;z$N9=J8>e$NMQES$K4X$9$k>pJs$r(BEmacs$B$KM?$($^$9!#(B
$B$3$N>pJs$O!"(B@dfn{$B9=J82r@O4X?t(B}$B$dJ#;($J0\F0$r9T$&%3%^%s%I$J$I$,(B
$BC18l$d%7%s%\%k$J$I$N9=J8MWAG$,$I$3$G;O$^$j$I$3$G=*$k$+$rD4$Y$k$?$a$K;H$$$^$9!#(B
$B8=:_$N9=J8%F!<%V%k$,!"K\>O$N4X?t$K2C$($F!"(B
$BC18lC10L$N0\F04X?t!J(B@pxref{Word Motion}$B!K!"(B
$B%j%9%HC10L$N0\F04X?t!J(B@pxref{List Motion}$B!K$N0UL#$r@)8f$7$^$9!#(B
@end ifinfo
@c A syntax table is a char-table (@pxref{Char-Tables}). The element at
@c index @var{c} describes the character with code @var{c}. The element's
@c value should be a list that encodes the syntax of the character in
@c question.
$B9=J8%F!<%V%k$OJ8;z%F!<%V%k!J(B@pxref{Char-Tables}$B!K$G$9!#(B
@var{c}$B$GE:;zIU$1$i$l$kMWAG$O!"%3!<%I$,(B@var{c}$B$G$"$kJ8;z$K$D$$$F5-=R$7$^$9!#(B
$BMWAG$NCM$O!"Ev3:J8;z$N9=J8>e$N5!G=$rId9f2=$7$?%j%9%H$G$9!#(B
@c Syntax tables are used only for moving across text, not for the Emacs
@c Lisp reader. Emacs Lisp uses built-in syntactic rules when reading Lisp
@c expressions, and these rules cannot be changed. (Some Lisp systems
@c provide ways to redefine the read syntax, but we decided to leave this
@c feature out of Emacs Lisp for simplicity.)
$B9=J8%F!<%V%k$O!"%F%-%9%HFb$rF0$-2s$k$?$a$K$N$_;H$o$l!"(B
Emacs$B$N(BLisp$B%j!<%@$O$3$l$r;H$$$^$;$s!#(B
Emacs Lisp$B$,(BLisp$B<0$rFI$`$H$-$K$O!"AH$_9~$_$N9=J85,B'$r;H$$$^$9!#(B
$B!JF~NO9=J8$r:FDj5A$9$kJ}K!$rM?$($k(BLisp$B%7%9%F%`$b$"$k$,!"(B
$BC1=c$G$"$k$h$&$K(BEacs Lisp$B$G$O$3$N5!G=$r>J$/$3$H$K$7$?!#!K(B
@c Each buffer has its own major mode, and each major mode has its own
@c idea of the syntactic class of various characters. For example, in Lisp
@c mode, the character @samp{;} begins a comment, but in C mode, it
@c terminates a statement. To support these variations, Emacs makes the
@c choice of syntax table local to each buffer. Typically, each major
@c mode has its own syntax table and installs that table in each buffer
@c that uses that mode. Changing this table alters the syntax in all
@c those buffers as well as in any buffers subsequently put in that mode.
@c Occasionally several similar modes share one syntax table.
@c @xref{Example Major Modes}, for an example of how to set up a syntax
@c table.
$B3F%P%C%U%!$K$OFH<+$N%a%8%c!<%b!<%I$,$"$j!"(B
$B3F%a%8%c!<%b!<%I$O$5$^$6$^$JJ8;z$N9=J8%/%i%9$rFH<+$K07$$$^$9!#(B
$B$?$H$($P!"(Blisp$B%b!<%I$G$OJ8;z(B@samp{;}$B$O%3%a%s%H$r;O$a$^$9$,!"(B
C$B%b!<%I$G$OJ8$r=*$i$;$^$9!#(B
$B$3$N$h$&$JB?MM@-$r07$&$?$a$K!"(B
Emacs$B$O3F%P%C%U%!$4$H$K%m!<%+%k$J9=J8%F!<%V%k$rA*$S$^$9!#(B
$BE57?E*$K$O!"3F%a%8%c!<%b!<%I$KFH<+$N9=J8%F!<%V%k$,$"$j!"(B
$B$=$N%b!<%I$r;H$C$F$$$k%P%C%U%!$KEv3:9=J8%F!<%V%k$r%$%s%9%H!<%k$7$^$9!#(B
$B$3$N9=J8%F!<%V%k$rJQ99$9$k$H!"(B
$BF1$8%b!<%I$N%P%C%U%!$@$1$G$J$/>-Mh$=$N%b!<%I$K$J$C$?%P%C%U%!$G$b(B
$B9=J8$rJQ99$7$F$7$^$$$^$9!#(B
$BN`;w$7$?%b!<%I$G$O(B1$B$D$N9=J8%F!<%V%k$r6&M-$9$k$3$H$,$"$j$^$9!#(B
$B9=J8%F!<%V%k$N@_DjJ}K!$NNc$K$D$$$F$O!"(B@xref{Example Major Modes}$B!#(B
@c A syntax table can inherit the data for some characters from the
@c standard syntax table, while specifying other characters itself. The
@c ``inherit'' syntax class means ``inherit this character's syntax from
@c the standard syntax table.'' Just changing the standard syntax for a
@c characters affects all syntax tables which inherit from it.
$B9=J8%F!<%V%k$G$O!"I8=`$N9=J8%F!<%V%k$+$iJ8;z$N%G!<%?$r7Q>5$7!"(B
$B0lJ}$G$=$NB>$NJ8;z$KFH<+$N;XDj$r9T$($^$9!#(B
$B9=J8%/%i%9$N!X7Q>5!Y$H$O!"(B
$B!XI8=`$N9=J8%F!<%V%k$+$iEv3:J8;z$N9=J8$r0z$-7Q$0!Y$3$H$G$9!#(B
$B$"$kJ8;z$KBP$7$FI8=`$N9=J8$rJQ99$9$k$H!"(B
$B$=$l$r7Q>5$9$k$9$Y$F$N9=J8%F!<%V%k$K1F6A$7$^$9!#(B
@defun syntax-table-p object
@c This function returns @code{t} if @var{object} is a syntax table.
$B$3$N4X?t$O!"(B@var{object}$B$,9=J8%F!<%V%k$J$i$P(B@code{t}$B$rJV$9!#(B
@end defun
@node Syntax Descriptors
@c @section Syntax Descriptors
@section $B9=J85-=R;R(B
@c @cindex syntax classes
@cindex $B9=J8%/%i%9(B
@c This section describes the syntax classes and flags that denote the
@c syntax of a character, and how they are represented as a @dfn{syntax
@c descriptor}, which is a Lisp string that you pass to
@c @code{modify-syntax-entry} to specify the syntax you want.
$BK\@a$G$O!"J8;z$N9=J8$r;XDj$9$k9=J8%/%i%9$H9=J8%U%i%0!"(B
$B$=$l$i$r(B@dfn{$B9=J85-=R;R(B}$B!J(Bsyntax descriptor$B!K$H$7$F$I$N$h$&$K(B
$BI=8=$9$k$+$K$D$$$F=R$Y$^$9!#(B
$B9=J85-=R;R$O(BLisp$BJ8;zNs$G$"$j!"(B
$BK>$_$N9=J8$r;XDj$9$k$?$a$K(B@code{modify-syntax-entry}$B$KEO$7$^$9!#(B
@c The syntax table specifies a syntax class for each character. There
@c is no necessary relationship between the class of a character in one
@c syntax table and its class in any other table.
$B9=J8%F!<%V%k$O!"3FJ8;z$N9=J8%/%i%9$r;XDj$7$^$9!#(B
$B$"$k9=J8%F!<%V%k$G$NJ8;z$N%/%i%9$H(B
$BB>$N9=J8%F!<%V%k$G$NEv3:J8;z$N%/%i%9$H$N$"$$$@$K$O$J$s$N4X78$bI,MW$"$j$^$;$s!#(B
@c Each class is designated by a mnemonic character, which serves as the
@c name of the class when you need to specify a class. Usually the
@c designator character is one that is frequently in that class; however,
@c its meaning as a designator is unvarying and independent of what syntax
@c that character currently has.
$B3F%/%i%9$O%K!<%b%K%C%/J8;z!J;XDj;R!K$G6hJL$7$^$9!#(B
$B%K!<%b%K%C%/J8;z$O!"(B
$B%/%i%9$r;XDj$9$kI,MW$,$"$k$H$-$K%/%i%9L>$H$7$FF/$-$^$9!#(B
$BDL>o!";XDj;R$NJ8;z$OEv3:%/%i%9$K$h$/8=$l$k$b$N$G$9!#(B
$B$7$+$7$J$,$i!";XDj;R$H$7$F$N0UL#$OITJQ$G!"$=$NJ8;z$N8=:_$N9=J8$H$OFHN)$G$9!#(B
@c @cindex syntax descriptor
@cindex $B9=J85-=R;R(B
@c A syntax descriptor is a Lisp string that specifies a syntax class, a
@c matching character (used only for the parenthesis classes) and flags.
@c The first character is the designator for a syntax class. The second
@c character is the character to match; if it is unused, put a space there.
@c Then come the characters for any desired flags. If no matching
@c character or flags are needed, one character is sufficient.
$B9=J85-=R;R$O!"9=J8%/%i%9!"!J3g8L$N%/%i%9$N>l9g$K$N$_;H$o$l$k!K(B
$BD`$j9g$&J8;z!"%U%i%0$r;XDj$9$k(BLisp$BJ8;zNs$G$9!#(B
$B:G=i$NJ8;z$O!"9=J8%/%i%9$r;XDj$9$kJ8;z!J;XDj;R!K$G$9!#(B
2$BHVL\$NJ8;z$O$=$NJ8;z$KD`$j9g$&J8;z$G$9$,!";HMQ$7$J$$>l9g$K$O6uGr$G$9!#(B
$B$=$N$"$H$KK>$_$N%U%i%0$,B3$-$^$9!#(B
$BD`$j9g$&J8;z$d%U%i%0$,I,MW$J$1$l$P!"J8;z(B1$B$D$@$1$G==J,$G$9!#(B
@c For example, the syntax descriptor for the character @samp{*} in C
@c mode is @samp{@w{. 23}} (i.e., punctuation, matching character slot
@c unused, second character of a comment-starter, first character of an
@c comment-ender), and the entry for @samp{/} is @samp{@w{. 14}} (i.e.,
@c punctuation, matching character slot unused, first character of a
@c comment-starter, second character of a comment-ender).
$B$?$H$($P!"(BC$B%b!<%I$K$*$1$kJ8;z(B@samp{*}$B$N9=J85-=R;R$O(B
@samp{@w{. 23}}$B!J6gFIE@!"D`$j9g$&J8;z$J$7!"(B
$B%3%a%s%H3+;O$N(B2$BHVL\$NJ8;z!"%3%a%s%H=*N;$N:G=i$NJ8;z!K$G$"$j!"(B
@samp{/}$B$O(B@samp{@w{. 14}}$B!J6gFIE@!"D`$j9g$&J8;z$J$7!"(B
$B%3%a%s%H3+;O$N:G=i$NJ8;z!"%3%a%s%H=*N;$N(B2$BHVL\$NJ8;z!K$G$9!#(B
@menu
* Syntax Class Table:: Table of syntax classes.
* Syntax Flags:: Additional flags each character can have.
@end menu
@node Syntax Class Table
@c @subsection Table of Syntax Classes
@subsection $B9=J8%/%i%90lMw(B
@c Here is a table of syntax classes, the characters that stand for them,
@c their meanings, and examples of their use.
$B0J2<$N0lMw$O!"9=J8%/%i%9!"$=$N%/%i%9$rI=$9J8;z!J;XDj;R!K!"(B
$B$=$N%/%i%9$N0UL#!"$=$N;HMQNc$G$9!#(B
@c @deffn {Syntax class} @w{whitespace character}
@deffn {$B9=J8%/%i%9(B} @w{$BGrJ8;z!J(Bwhitespace character$B!K(B}
@c @dfn{Whitespace characters} (designated by @w{@samp{@ }} or @samp{-})
@c separate symbols and words from each other. Typically, whitespace
@c characters have no other syntactic significance, and multiple whitespace
@c characters are syntactically equivalent to a single one. Space, tab,
@c newline and formfeed are classified as whitespace in almost all major
@c modes.
@dfn{$BGrJ8;z(B}$B!J(B@w{@samp{@ }}$B$+(B@samp{-}$B$G;XDj!K$O!"(B
$B%7%s%\%k$dC18l$r8_$$$K6h@Z$k!#(B
$BE57?E*$K$O!"GrJ8;z$K$OB>$N9=J8>e$N0UL#$O$J$/!"(B
$BJ#?t8D$NGrJ8;z$O(B1$B$D$NGrJ8;z$H9=J8E*$K$OEy2A$G$"$k!#(B
$B$[$H$s$I$9$Y$F$N%a%8%c!<%b!<%I$G$O!"(B
$B6uGr!"%?%V!"2~9T!"%Z!<%8Aw$j$OGrJ8;z$G$"$k!#(B
@end deffn
@c @deffn {Syntax class} @w{word constituent}
@deffn {$B9=J8%/%i%9(B} @w{$BC18l9=@.J8;z!J(Bword constituent$B!K(B}
@c @dfn{Word constituents} (designated by @samp{w}) are parts of normal
@c English words and are typically used in variable and command names in
@c programs. All upper- and lower-case letters, and the digits, are typically
@c word constituents.
@dfn{$BC18l9=@.J8;z(B}$B!J(B@samp{w}$B$G;XDj!K$OIaDL$N1QC18l$N0lItJ,$G$"$j!"(B
$BE57?E*$K$O!"%W%m%0%i%`$NJQ?t$d%3%^%s%IL>$K;H$o$l$k!#(B
$B$9$Y$F$NBg1QJ8;z!">.1QJ8;z!"?t;zJ8;z$O!"E57?E*$K$OC18l9=@.J8;z$G$"$k!#(B
@end deffn
@c @deffn {Syntax class} @w{symbol constituent}
@deffn {$B9=J8%/%i%9(B} @w{$B%7%s%\%k9=@.J8;z!J(Bsymbol constituent$B!K(B}
@c @dfn{Symbol constituents} (designated by @samp{_}) are the extra
@c characters that are used in variable and command names along with word
@c constituents. For example, the symbol constituents class is used in
@c Lisp mode to indicate that certain characters may be part of symbol
@c names even though they are not part of English words. These characters
@c are @samp{$&*+-_<>}. In standard C, the only non-word-constituent
@c character that is valid in symbols is underscore (@samp{_}).
@dfn{$B%7%s%\%k9=@.J8;z(B}$B!J(B@samp{_}$B$G;XDj!K$O!"(B
$BC18l9=@.J8;z$K2C$($F!"JQ?t$d%3%^%s%IL>$K;H$o$l$kDI2C$NJ8;z$G$"$k!#(B
$B$?$H$($P!"1QC18l$N0lItJ,$G$O$J$$$,%7%s%\%kL>$K;H$($kFCDj$NJ8;z$r;XDj(B
$B$9$k$?$a$K!"(BLisp$B%b!<%I$G$O%7%s%\%k9=@.J8;z%/%i%9$r;H$&!#(B
$B$3$N$h$&$JJ8;z$O(B@samp{$&*+-_<>}$B$G$"$k!#(B
$BI8=`$N(BC$B$G$O!"C18l9=@.J8;z$G$J$/$F%7%s%\%k$K;H$($kM#0l$NJ8;z$O(B
$B2<@~!J(B@samp{_}$B!K$G$"$k!#(B
@end deffn
@c @deffn {Syntax class} @w{punctuation character}
@deffn {$B9=J8%/%i%9(B} @w{$B6gFIE@J8;z!J(Bpunctuation character$B!K(B}
@c @dfn{Punctuation characters} (designated by @samp{.}) are those
@c characters that are used as punctuation in English, or are used in some
@c way in a programming language to separate symbols from one another.
@c Most programming language modes, including Emacs Lisp mode, have no
@c characters in this class since the few characters that are not symbol or
@c word constituents all have other uses.
@dfn{$B6gFIE@J8;z(B}$B!J(B@samp{.}$B$G;XDj!K$O!"(B
$B1QJ8$N6gFIE@$H$7$F;H$o$l$?$j!"(B
$B%W%m%0%i%`8@8l$G%7%s%\%k$r6h@Z$k$?$a$K;H$o$l$kJ8;z$G$"$k!#(B
emacs-lisp$B%b!<%I$r4^$`$[$H$s$I$N%W%m%0%i%`8@8l8~$1%b!<%I$G$O!"(B
$B%7%s%\%k9=@.J8;z$G$bC18l9=@.J8;z$G$b$J$$>/?t$NJ8;z$K$OJL$NMQES$,$"$k$?$a!"(B
$B$3$N%/%i%9$NJ8;z$O$J$$!#(B
@end deffn
@c @deffn {Syntax class} @w{open parenthesis character}
@deffn {$B9=J8%/%i%9(B} @w{$B3+$-3g8LJ8;z!J(Bopen parenthesis character$B!K(B}
@c @deffnx {Syntax class} @w{close parenthesis character}
@deffnx {$B9=J8%/%i%9(B} @w{$BJD$83g8LJ8;z!J(Bclose parenthesis character$B!K(B}
@c @cindex parenthesis syntax
@cindex $B3g8L$N9=J8(B
@c Open and close @dfn{parenthesis characters} are characters used in
@c dissimilar pairs to surround sentences or expressions. Such a grouping
@c is begun with an open parenthesis character and terminated with a close.
@c Each open parenthesis character matches a particular close parenthesis
@c character, and vice versa. Normally, Emacs indicates momentarily the
@c matching open parenthesis when you insert a close parenthesis.
@c @xref{Blinking}.
$B3+$-!?JD$8(B@dfn{$B3g8LJ8;z(B}$B$O!"J8$d<0$r0O$`Aj0[$J$kBP$H$7$F;H$o$l$kJ8;z$G$"$k!#(B
$B$=$N$h$&$J%0%k!<%W2=$O!"3+$-3g8LJ8;z$G;O$^$jJD$83g8LJ8;z$G=*$k!#(B
$B3F3+$-3g8LJ8;z$OFCDj$NJD$83g8LJ8;z$KBP1~$7!"$=$N5U$b$$$($k!#(B
Emacs$B$O!"DL>o!"JD$83g8LJ8;z$rA^F~$9$k$H(B
$BBP1~$9$k3+$-3g8LJ8;z$rC;;~4V;X$7<($9!#(B
@pxref{Blinking}$B!#(B
@c The class of open parentheses is designated by @samp{(}, and that of
@c close parentheses by @samp{)}.
$B3+$-3g8LJ8;z%/%i%9$O(B@samp{(}$B$G;XDj$7!"(B
$BJD$83g8LJ8;z%/%i%9$O(B@samp{)}$B$G;XDj$9$k!#(B
@c In English text, and in C code, the parenthesis pairs are @samp{()},
@c @samp{[]}, and @samp{@{@}}. In Emacs Lisp, the delimiters for lists and
@c vectors (@samp{()} and @samp{[]}) are classified as parenthesis
@c characters.
$B1QJ88~$1$N%F%-%9%H!J(Btext$B!K%b!<%I$H(BC$B%b!<%I$G$O!"(B
$B3g8L$NBP$O!"(B@samp{()}$B!"(B@samp{[]}$B!"(B@samp{@{@}}$B$G$"$k!#(B
Emacs Lisp$B$G$O!"%j%9%H$H%Y%/%H%k$N6h@Z$j!J(B@samp{()}$B$H(B@samp{[]}$B!K$O!"(B
$B3g8LJ8;z$H$7$F%/%i%9J,$1$5$l$k!#(B
@end deffn
@c @deffn {Syntax class} @w{string quote}
@deffn {$B9=J8%/%i%9(B} @w{$BJ8;zNs%/%)!<%H!J(Bstring quote$B!K(B}
@c @dfn{String quote characters} (designated by @samp{"}) are used in
@c many languages, including Lisp and C, to delimit string constants. The
@c same string quote character appears at the beginning and the end of a
@c string. Such quoted strings do not nest.
@dfn{$BJ8;zNs%/%)!<%HJ8;z(B}$B!J(B@samp{"}$B$G;XDj!K$O!"(B
Lisp$B$d(BC$B$r4^$`B?$/$N8@8l$GJ8;zNsDj?t$r6h@Z$k$?$a$K;H$o$l$k!#(B
$BF1$8J8;zNs%/%)!<%HJ8;z$,J8;zNs$N:G=i$H:G8e$K8=$l$k!#(B
@c The parsing facilities of Emacs consider a string as a single token.
@c The usual syntactic meanings of the characters in the string are
@c suppressed.
Emacs$B$N9=J82r@O5!G=$G$O!"J8;zNs$r(B1$B$D$N;z6g$H$_$J$9!#(B
$BJ8;zNsFb$NJ8;z$NIaDL$N9=J8E*$J0UL#$OM^@)$5$l$k!#(B
@c The Lisp modes have two string quote characters: double-quote (@samp{"})
@c and vertical bar (@samp{|}). @samp{|} is not used in Emacs Lisp, but it
@c is used in Common Lisp. C also has two string quote characters:
@c double-quote for strings, and single-quote (@samp{'}) for character
@c constants.
lisp$B8~$1$N%b!<%I$K$OJ8;zNs%/%)!<%HJ8;z$,(B2$B$D!"(B
$B%@%V%k%/%)!<%H!J(B@samp{"}$B!K$H=DK@!J(B@samp{|}$B!K$,$"$k!#(B
@samp{|}$B$O(BEmacs Lisp$B$G$O;H$o$J$$$,(BCommon Lisp$B$G;H$&!#(B
C$B$K$b(B2$B$D$NJ8;zNs%/%)!<%HJ8;z!"(B
$BJ8;zNsMQ$N%@%V%k%/%)!<%H$HJ8;zDj?tMQ$N%7%s%0%k%/%)!<%H!J(B@samp{'}$B!K$,$"$k!#(B
@c English text has no string quote characters because English is not a
@c programming language. Although quotation marks are used in English,
@c we do not want them to turn off the usual syntactic properties of
@c other characters in the quotation.
$B1QJ8$O%W%m%0%i%`8@8l$G$O$J$$$N$G!"1QJ8$K$OJ8;zNs%/%)!<%HJ8;z$O$J$$!#(B
$B1QJ8$G$b0zMQId$OMQ$$$k$,!"$=$NFbB&$NJ8;z$NIaDL$N9=J8E*$JB0@-$r(B
$BM^@)$7$?$/$J$$$N$G$"$k!#(B
@end deffn
@c @deffn {Syntax class} @w{escape}
@deffn {$B9=J8%/%i%9(B} @w{$B%(%9%1!<%W!J(Bescape$B!K(B}
@c An @dfn{escape character} (designated by @samp{\}) starts an escape
@c sequence such as is used in C string and character constants. The
@c character @samp{\} belongs to this class in both C and Lisp. (In C, it
@c is used thus only inside strings, but it turns out to cause no trouble
@c to treat it this way throughout C code.)
@dfn{$B%(%9%1!<%WJ8;z(B}$B!J(B@samp{\}$B$G;XDj!K$O!"(B
C$B$NJ8;zNs$dJ8;zDj?t$G;H$o$l$k$h$&$J%(%9%1!<%W%7!<%1%s%9$r3+;O$9$k!#(B
C$B$H(BLisp$B$G$O!"J8;z(B@samp{\}$B$O$3$N%/%i%9$KB0$9$k!#(B
$B!J(BC$B$G$O$3$NJ8;z$OJ8;zNs$NFbB&$@$1$G;H$o$l$k$,!"(B
C$B%b!<%I$G$D$M$K$3$N$h$&$K07$C$F$bLdBj$J$$$3$H$,$o$+$C$?!#!K(B
@c Characters in this class count as part of words if
@c @code{words-include-escapes} is non-@code{nil}. @xref{Word Motion}.
@code{words-include-escapes}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B$3$N%/%i%9$NJ8;z$OC18l$N0lItJ,$H2r<a$5$l$k!#(B
@pxref{Word Motion}$B!#(B
@end deffn
@c @deffn {Syntax class} @w{character quote}
@deffn {$B9=J8%/%i%9(B} @w{$BJ8;z%/%)!<%H!J(Bcharacter quote$B!K(B}
@c A @dfn{character quote character} (designated by @samp{/}) quotes the
@c following character so that it loses its normal syntactic meaning. This
@c differs from an escape character in that only the character immediately
@c following is ever affected.
@dfn{$BJ8;z%/%)!<%HJ8;z(B}$B!J(B@samp{/}$B$G;XDj!K$O!"(B
$B8eB3$N(B1$BJ8;z$r%/%)!<%H$7!"DL>o$N9=J8>e$N0UL#$rM^@)$9$k!#(B
$BD>8e$N(B1$BJ8;z$N$_$K1F6A$9$k$H$$$&E@$G!"%(%9%1!<%WJ8;z$H0[$J$k!#(B
@c Characters in this class count as part of words if
@c @code{words-include-escapes} is non-@code{nil}. @xref{Word Motion}.
@code{words-include-escapes}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B$3$N%/%i%9$NJ8;z$OC18l$N0lItJ,$H2r<a$5$l$k!#(B
@pxref{Word Motion}$B!#(B
@c This class is used for backslash in @TeX{} mode.
$B$3$N%/%i%9$O!"(B@TeX{}$B%b!<%I$N%P%C%/%9%i%C%7%e$K;H$o$l$k!#(B
@end deffn
@c @deffn {Syntax class} @w{paired delimiter}
@deffn {$B9=J8%/%i%9(B} @w{$BBP$K$J$C$?6h@Z$j!J(Bpaired delimiter$B!K(B}
@c @dfn{Paired delimiter characters} (designated by @samp{$}) are like
@c string quote characters except that the syntactic properties of the
@c characters between the delimiters are not suppressed. Only @TeX{} mode
@c uses a paired delimiter presently---the @samp{$} that both enters and
@c leaves math mode.
@dfn{$BBP$K$J$C$?6h@Z$jJ8;z(B}$B!J(B@samp{$}$B!K$OJ8;zNs%/%)!<%HJ8;z$HF1MM$G$"$k$,!"(B
$B6h@Z$jJ8;z$N$"$$$@$K$"$kJ8;z$N9=J8>e$NB0@-$rM^@)$7$J$$E@$,0[$J$k!#(B
$B8=:_!"BP$K$J$C$?6h@Z$j$O(B@TeX{}$B%b!<%I$N$_$G;H$$!"(B
$B?t3X%b!<%I$K=PF~$j$9$k(B@samp{$}$B$G$"$k!#(B
@end deffn
@c @deffn {Syntax class} @w{expression prefix}
@deffn {$B9=J8%/%i%9(B} @w{$B<0A0CV;R!J(Bexpression prefix$B!K(B}
@c An @dfn{expression prefix operator} (designated by @samp{'}) is used for
@c syntactic operators that are considered as part of an expression if they
@c appear next to one. In Lisp modes, these characters include the
@c apostrophe, @samp{'} (used for quoting), the comma, @samp{,} (used in
@c macros), and @samp{#} (used in the read syntax for certain data types).
@dfn{$B<0A0CV1i;;;R(B}$B!J(B@samp{'}$B!K$O!"<0$N$^$($K8=$l$k$H(B
$B<0$N0lIt$G$"$k$H$_$J$5$l$k9=J8>e$N1i;;;R$K;H$o$l$k!#(B
lisp$B8~$1$N%b!<%I$G$O!"!J%/%)!<%H$9$k!K%"%]%9%H%m%U(B@samp{'}$B!"(B
$B!J%^%/%m$G;H$&!K%3%s%^(B@samp{,}$B!"(B
$B!J$"$k<o$N%G!<%?$NF~NO9=J8$K;H$o$l$k!K(B@samp{#}$B$NJ8;z$,$=$&$G$"$k!#(B
@end deffn
@c @deffn {Syntax class} @w{comment starter}
@c @deffnx {Syntax class} @w{comment ender}
@c @cindex comment syntax
@deffn {$B9=J8%/%i%9(B} @w{$B%3%a%s%H3+;O!J(Bcomment starter$B!K(B}
@deffnx {$B9=J8%/%i%9(B} @w{$B%3%a%s%H=*N;!J(Bcomment ender$B!K(B}
@cindex $B%3%a%s%H$N9=J8(B
@c The @dfn{comment starter} and @dfn{comment ender} characters are used in
@c various languages to delimit comments. These classes are designated
@c by @samp{<} and @samp{>}, respectively.
@dfn{$B%3%a%s%H3+;O(B}$BJ8;z$H(B@dfn{$B%3%a%s%H=*N;(B}$BJ8;z$O!"(B
$B$5$^$6$^$J8@8l$G%3%a%s%H$r6h@Z$k$?$a$KMQ$$$i$l$k!#(B
$B$3$l$i$N%/%i%9$O!"$=$l$>$l!"(B@samp{<}$B$H(B@samp{>}$B$G;XDj$9$k!#(B
@c English text has no comment characters. In Lisp, the semicolon
@c (@samp{;}) starts a comment and a newline or formfeed ends one.
$B1QJ8$K$O%3%a%s%HJ8;z$O$J$$!#(B
Lisp$B$G$O!"%;%_%3%m%s!J(B@samp{;}$B!K$G%3%a%s%H$,;O$^$j!"(B
$B2~9T$+%Z!<%8Aw$j$G=*$k!#(B
@end deffn
@c @deffn {Syntax class} @w{inherit}
@deffn {$B9=J8%/%i%9(B} @w{$B7Q>5!J(Binherit$B!K(B}
@c This syntax class does not specify a particular syntax. It says to look
@c in the standard syntax table to find the syntax of this character. The
@c designator for this syntax code is @samp{@@}.
$B$3$N9=J8%/%i%9$OFCDj$N9=J8$r;XDj$7$J$$!#(B
$BI8=`$N9=J8%F!<%V%k$GEv3:J8;z$N9=J8$rC5$9;XDj$G$"$k!#(B
$B$3$N9=J8%/%i%9$O(B@samp{@@}$B$G;XDj$9$k!#(B
@end deffn
@c @deffn {Syntax class} @w{generic comment delimiter}
@deffn {$B9=J8%/%i%9(B} @w{$BHFMQ%3%a%s%H6h@Z$j!J(Bgeneric comment delimiter$B!K(B}
@c A @dfn{generic comment delimiter} character starts or ends a special
@c kind of comment. @emph{Any} generic comment delimiter matches
@c @emph{any} generic comment delimiter, but they cannot match a comment
@c starter or comment ender; generic comment delimiters can only match each
@c other.
@dfn{$BHFMQ%3%a%s%H6h@Z$j(B}$BJ8;z$O!"FCJL$J<oN`$N%3%a%s%H$r(B
$B;O$a$F=*$($kJ8;z$G$"$k!#(B
@emph{$BG$0U$N(B}$BHFMQ%3%a%s%H6h@Z$jJ8;z$O(B
@emph{$BG$0U$N(B}$BHFMQ%3%a%s%H6h@Z$jJ8;z$KBP1~$9$k$,!"(B
$BIaDL$N%3%a%s%H3+;OJ8;z!?%3%a%s%H=*N;J8;z$K$OBP1~$7$J$$!#(B
$BHFMQ%3%a%s%H6h@Z$jJ8;zF1;N$N$_$GBP1~$9$k!#(B
@c This syntax class is primarily meant for use with the
@c @code{syntax-table} text property (@pxref{Syntax Properties}). You can
@c mark any range of characters as forming a comment, by giving the first
@c and last characters of the range @code{syntax-table} properties
@c identifying them as generic comment delimiters.
$B$3$N9=J8%/%i%9$O!"<g$K%F%-%9%HB0@-(B@code{syntax-table}
$B!J(B@pxref{Syntax Properties}$B!K$G;H$&$3$H$r0U?^$7$?$b$N$G$"$k!#(B
$BG$0U$NHO0O$NJ8;z$,%3%a%s%H$r7A@.$9$k$H0u$rIU$1$k$K$O!"(B
$B$=$NHO0O$N@hF,$HKvHx$NJ8;z$K$=$l$i$,HFMQ%3%a%s%H6h@Z$j$G$"$k$3$H$r(B
$B<1JL$9$kB0@-(B@code{syntax-table}$B$rM?$($k!#(B
@end deffn
@c @deffn {Syntax class} @w{generic string delimiter}
@deffn {$B9=J8%/%i%9(B} @w{$BHFMQJ8;zNs6h@Z$j!J(Bgeneric string delimiter$B!K(B}
@c A @dfn{generic string delimiter} character starts or ends a string.
@c This class differs from the string quote class in that @emph{any}
@c generic string delimiter can match any other generic string delimiter;
@c but they do not match ordinary string quote characters.
@dfn{$BHFMQJ8;zNs6h@Z$j(B}$BJ8;z$O!"J8;zNs$r;O$a$F=*$($k!#(B
$B$3$N%/%i%9$OJ8;zNs%/%)!<%H%/%i%9$H0[$J$j!"(B
$BHFMQJ8;zNs6h@Z$j$OB>$NHFMQJ8;zNs6h@Z$j$KBP1~$7!"(B
$BIaDL$NJ8;zNs%/%)!<%HJ8;z$K$OBP1~$7$J$$!#(B
@c This syntax class is primarily meant for use with the
@c @code{syntax-table} text property (@pxref{Syntax Properties}). You can
@c mark any range of characters as forming a string constant, by giving the
@c first and last characters of the range @code{syntax-table} properties
@c identifying them as generic string delimiters.
$B$3$N9=J8%/%i%9$O!"<g$K%F%-%9%HB0@-(B@code{syntax-table}
$B!J(B@pxref{Syntax Properties}$B!K$G;H$&$3$H$r0U?^$7$?$b$N$G$"$k!#(B
$BG$0U$NHO0O$NJ8;z$,J8;zNsDj?t$r7A@.$9$k$H0u$rIU$1$k$K$O!"(B
$B$=$NHO0O$N@hF,$HKvHx$NJ8;z$K$=$l$i$,HFMQJ8;zNs6h@Z$j$G$"$k$3$H$r(B
$B<1JL$9$kB0@-(B@code{syntax-table}$B$rM?$($k!#(B
@end deffn
@node Syntax Flags
@c @subsection Syntax Flags
@subsection $B9=J8%U%i%0(B
@c @cindex syntax flags
@cindex $B9=J8%U%i%0(B
@c In addition to the classes, entries for characters in a syntax table
@c can specify flags. There are six possible flags, represented by the
@c characters @samp{1}, @samp{2}, @samp{3}, @samp{4}, @samp{b} and
@c @samp{p}.
$B9=J8%F!<%V%k$N3FJ8;z$K$O!"9=J8%/%i%9$K2C$($F!"%U%i%0$b;XDj$G$-$^$9!#(B
$BJ8;z(B@samp{1}$B!"(B@samp{2}$B!"(B@samp{3}$B!"(B@samp{4}$B!"(B@samp{b}$B!"(B@samp{p}$B$G(B
$BI=8=$5$l$k(B6$B$D$N2DG=$J%U%i%0$,$"$j$^$9!#(B
@c All the flags except @samp{p} are used to describe multi-character
@c comment delimiters. The digit flags indicate that a character can
@c @emph{also} be part of a comment sequence, in addition to the syntactic
@c properties associated with its character class. The flags are
@c independent of the class and each other for the sake of characters such
@c as @samp{*} in C mode, which is a punctuation character, @emph{and} the
@c second character of a start-of-comment sequence (@samp{/*}), @emph{and}
@c the first character of an end-of-comment sequence (@samp{*/}).
@samp{p}$B$r=|$/$9$Y$F$N%U%i%0$O!"J#?t$NJ8;z$+$i@.$k%3%a%s%H6h@Z$j$N5-=R$K(B
$B;H$$$^$9!#(B
$B?t;z%U%i%0$O!"Ev3:J8;z$N%/%i%9$GI=$5$l$k9=J8>e$NB0@-$K(B@emph{$B2C$($F(B}$B!"(B
$B%3%a%s%HNs$N0lItJ,$G$b$"$k$3$H$r<($7$^$9!#(B
$B%U%i%0$O%/%i%9$dB>$N%U%i%0$H$OFHN)$G$"$j!"(B
C$B%b!<%I$N(B@samp{*}$B$N$h$&$JJ8;z$N$?$a$K$"$j$^$9!#(B
C$B%b!<%I$N(B@samp{*}$B$O!"6gFIE@J8;z$G$"$k(B@emph{$B$H$H$b$K(B}$B!"(B
$B%3%a%s%H3+;ONs$N(B2$BHVL\$NJ8;z(B@samp{/*}@emph{$B$G$b(B}$B$"$j!"(B
$B%3%a%s%H=*N;Ns$N:G=i$NJ8;z(B@samp{*/}@emph{$B$G$b(B}$B$"$j$^$9!#(B
@c Here is a table of the possible flags for a character @var{c},
@c and what they mean:
$BJ8;z(B@var{c}$B$KBP$7$F2DG=$J%U%i%0$H$=$l$i$N0UL#$r0J2<$K<($7$^$9!#(B
@itemize @bullet
@item
@c @samp{1} means @var{c} is the start of a two-character comment-start
@c sequence.
@samp{1}$B$O!"(B@var{c}$B$,(B2$BJ8;z$N%3%a%s%H3+;ONs$r;O$a$k$3$H$r0UL#$9$k!#(B
@item
@c @samp{2} means @var{c} is the second character of such a sequence.
@samp{2}$B$O!"(B@var{c}$B$,$=$N$h$&$JNs$N(B2$BHVL\$NJ8;z$G$"$k$3$H$r0UL#$9$k!#(B
@item
@c @samp{3} means @var{c} is the start of a two-character comment-end
@c sequence.
@samp{3}$B$O!"(B@var{c}$B$,(B2$BJ8;z$N%3%a%s%H=*N;Ns$r;O$a$k$3$H$r0UL#$9$k!#(B
@item
@c @samp{4} means @var{c} is the second character of such a sequence.
@samp{4}$B$O!"(B@var{c}$B$,$=$N$h$&$JNs$N(B2$BHVL\$NJ8;z$G$"$k$3$H$r0UL#$9$k!#(B
@item
@c @c Emacs 19 feature
@c @samp{b} means that @var{c} as a comment delimiter belongs to the
@c alternative ``b'' comment style.
@samp{b}$B$O!"%3%a%s%H6h@Z$j$H$7$F$N(B@var{c}$B$,(B
$B$b$&(B1$B$D$N!X(Bb$B!Y7A<0$N%3%a%s%H$KB0$9$k$3$H$r0UL#$9$k!#(B
@c Emacs supports two comment styles simultaneously in any one syntax
@c table. This is for the sake of C++. Each style of comment syntax has
@c its own comment-start sequence and its own comment-end sequence. Each
@c comment must stick to one style or the other; thus, if it starts with
@c the comment-start sequence of style ``b'', it must also end with the
@c comment-end sequence of style ``b''.
Emacs$B$G$O!"G$0U$N(B1$B$D$N9=J8%F!<%V%k$G(B2$B$D$N7A<0$N%3%a%s%H$rF1;~$K07$($k!#(B
$B$3$l$O(BC++$B$N$?$a$G$"$k!#(B
$B%3%a%s%H9=J8$N3F7A<0$K$O!"FH<+$N3+;ONs$HFH<+$N=*N;Ns$,$"$k!#(B
$B3F%3%a%s%H$O$I$A$i$+(B1$B$D$N7A<0$G$"$kI,MW$,$"$k!#(B
$B$7$?$,$C$F!"!X(Bb$B!Y7A<0$N%3%a%s%H3+;ONs$G;O$^$k$b$N$O!"(B
$B!X(Bb$B!Y7A<0$N%3%a%s%H=*N;Ns$G=*$kI,MW$,$"$k!#(B
@c The two comment-start sequences must begin with the same character; only
@c the second character may differ. Mark the second character of the
@c ``b''-style comment-start sequence with the @samp{b} flag.
2$B$D$N%3%a%s%H3+;ONs$OF1$8J8;z$G;O$^$kI,MW$,$"$j!"(B2$BJ8;zL\$N$_$,0[$J$k!#(B
$B!X(Bb$B!Y7A<0$N%3%a%s%H3+;ONs$N(B2$BHVL\$NJ8;z$K%U%i%0(B@samp{b}$B$rIU$1$k!#(B
@c A comment-end sequence (one or two characters) applies to the ``b''
@c style if its first character has the @samp{b} flag set; otherwise, it
@c applies to the ``a'' style.
$B!J(B1$BJ8;z$+(B2$BJ8;z$N!K%3%a%s%H=*N;Ns$O!"(B
$B$=$N:G=i$NJ8;z$K%U%i%0(B@samp{b}$B$,IU$$$F$$$k$H!X(Bb$B!Y7A<0$KE,MQ$9$k!#(B
$B$5$b$J$1$l$P!X(Ba$B!Y7A<0$KE,MQ$9$k!#(B
@c The appropriate comment syntax settings for C++ are as follows:
C++$B8~$1$NE,@Z$J%3%a%s%H9=J8$N@_Dj$O$D$.$N$H$*$j$G$"$k!#(B
@table @asis
@item @samp{/}
@samp{124b}
@item @samp{*}
@samp{23}
@item newline
@samp{>b}
@end table
@c This defines four comment-delimiting sequences:
$B$3$l$O(B4$B$D$N%3%a%s%H6h@Z$jNs$rDj5A$9$k!#(B
@table @asis
@item @samp{/*}
@c This is a comment-start sequence for ``a'' style because the
@c second character, @samp{*}, does not have the @samp{b} flag.
2$BJ8;zL\$N(B@samp{*}$B$K$O%U%i%0(B@samp{b}$B$,$J$$$N$G!"(B
$B$3$l$O!X(Ba$B!Y7A<0$N%3%a%s%H3+;ONs$G$"$k!#(B
@item @samp{//}
@c This is a comment-start sequence for ``b'' style because the second
@c character, @samp{/}, does have the @samp{b} flag.
2$BJ8;zL\$N(B@samp{/}$B$K$O%U%i%0(B@samp{b}$B$,$"$k$N$G!"(B
$B$3$l$O!X(Bb$B!Y7A<0$N%3%a%s%H3+;ONs$G$"$k!#(B
@item @samp{*/}
@c This is a comment-end sequence for ``a'' style because the first
@c character, @samp{*}, does not have the @samp{b} flag.
2$BJ8;zL\$N(B@samp{*}$B$K$O%U%i%0(B@samp{b}$B$,$J$$$N$G!"(B
$B$3$l$O!X(Ba$B!Y7A<0$N%3%a%s%H=*N;Ns$G$"$k!#(B
@item newline
@c This is a comment-end sequence for ``b'' style, because the newline
@c character has the @samp{b} flag.
$B2~9T$K$O%U%i%0(B@samp{b}$B$,$"$k$N$G!"(B
$B$3$l$O!X(Bb$B!Y7A<0$N%3%a%s%H=*N;Ns$G$"$k!#(B
@end table
@item
@c @c Emacs 19 feature
@c @samp{p} identifies an additional ``prefix character'' for Lisp syntax.
@c These characters are treated as whitespace when they appear between
@c expressions. When they appear within an expression, they are handled
@c according to their usual syntax codes.
@samp{p}$B$O!"(BLisp$B9=J88~$1$NDI2C$N!XA0CVJ8;z!Y$r<($9!#(B
$B$3$l$i$NJ8;z$O<0$N$"$$$@$K8=$l$k$H$-$K$OGrJ8;z$H$7$F07$&!#(B
$B<0$NFbB&$K8=$l$k$H!"$=$l$i$NDL>o$N9=J8%3!<%I$K=>$C$F07$o$l$k!#(B
@c The function @code{backward-prefix-chars} moves back over these
@c characters, as well as over characters whose primary syntax class is
@c prefix (@samp{'}). @xref{Motion and Syntax}.
$B4X?t(B@code{backward-prefix-chars}$B$O8eJ}$X8~$1$F0\F0$9$k$H$-$K$O!"(B
$B9=J8%/%i%9$,<0A0CV;R!J(B@samp{'}$B!K$G$"$kJ8;z$K2C$($F(B
$B$3$l$i$NJ8;z$bHt$S1[$9!#(B
@pxref{Motion and Syntax}$B!#(B
@end itemize
@node Syntax Table Functions
@c @section Syntax Table Functions
@section $B9=J8%F!<%V%k8~$14X?t(B
@c In this section we describe functions for creating, accessing and
@c altering syntax tables.
$BK\@a$G$O!"9=J8%F!<%V%k$r:n@.!?;2>H!?JQ99$9$k$?$a$N4X?t$K$D$$$F=R$Y$^$9!#(B
@defun make-syntax-table
@c This function creates a new syntax table. It inherits the syntax for
@c letters and control characters from the standard syntax table. For
@c other characters, the syntax is copied from the standard syntax table.
$B$3$N4X?t$O!"?7$?$J9=J8%F!<%V%k$r:n@.$9$k!#(B
$B1QJ8;z$d%3%s%H%m!<%kJ8;z$N9=J8$OI8=`$N9=J8%F!<%V%k$+$i7Q>5$9$k!#(B
$BB>$NJ8;z$N9=J8$OI8=`$N9=J8%F!<%V%k$+$i%3%T!<$9$k!#(B
@c Most major mode syntax tables are created in this way.
$B$[$H$s$I$N%a%8%c!<%b!<%I$N9=J8%F!<%V%k$O$3$N$h$&$K:n@.$9$k!#(B
@end defun
@defun copy-syntax-table &optional table
@c This function constructs a copy of @var{table} and returns it. If
@c @var{table} is not supplied (or is @code{nil}), it returns a copy of the
@c current syntax table. Otherwise, an error is signaled if @var{table} is
@c not a syntax table.
$B$3$N4X?t$O!"9=J8%F!<%V%k(B@var{table}$B$N%3%T!<$r:n@.$7$=$l$rJV$9!#(B
@var{table}$B$r;XDj$7$J$$$H!J$"$k$$$O(B@code{nil}$B!K!"(B
$B8=:_$N9=J8%F!<%V%k$N%3%T!<$rJV$9!#(B
@var{table}$B$,9=J8%F!<%V%k$G$J$$$H%(%i!<$rDLCN$9$k!#(B
@end defun
@c @deffn Command modify-syntax-entry char syntax-descriptor &optional table
@deffn $B%3%^%s%I(B modify-syntax-entry char syntax-descriptor &optional table
@c This function sets the syntax entry for @var{char} according to
@c @var{syntax-descriptor}. The syntax is changed only for @var{table},
@c which defaults to the current buffer's syntax table, and not in any
@c other syntax table. The argument @var{syntax-descriptor} specifies the
@c desired syntax; this is a string beginning with a class designator
@c character, and optionally containing a matching character and flags as
@c well. @xref{Syntax Descriptors}.
$B$3$N4X?t$O!"J8;z(B@var{char}$B$N9=J8;XDj$r(B
$B9=J85-=R;R(B@var{syntax-descriptor}$B$H$9$k!#(B
$B9=J8%F!<%V%k(B@var{table}$B$K$*$$$F$N$_9=J8$rJQ99$7!"(B
$BB>$N9=J8%F!<%V%k$OJQ99$7$J$$!#(B
@var{table}$B$N%G%U%)%k%H$O%+%l%s%H%P%C%U%!$N9=J8%F!<%V%k$G$"$k!#(B
@var{syntax-descriptor}$B$GK>$_$N9=J8$r;XDj$9$k!#(B
$B$3$l$O!"%/%i%9;XDj;R$G;O$^$j!"(B
$BI,MW$K1~$8$FD`$j9g$&J8;z$H%U%i%0$r4^$`J8;zNs$G$"$k!#(B
@pxref{Syntax Descriptors}$B!#(B
@c This function always returns @code{nil}. The old syntax information in
@c the table for this character is discarded.
$B$3$N4X?t$O$D$M$K(B@code{nil}$B$rJV$9!#(B
$BEv3:9=J8%F!<%V%k$K$*$1$k$3$NJ8;z$KBP$9$k8E$$9=J8>pJs$OGK4~$5$l$k!#(B
@c An error is signaled if the first character of the syntax descriptor is not
@c one of the twelve syntax class designator characters. An error is also
@c signaled if @var{char} is not a character.
$B9=J85-=R;R$N:G=i$NJ8;z$,(B12$B8D$N9=J8%/%i%9;XDj;R$N(B1$B$D$G$J$$$H%(%i!<$rDLCN$9$k!#(B
@var{char}$B$,J8;z$G$J$/$F$b%(%i!<$rDLCN$9$k!#(B
@example
@group
@c @exdent @r{Examples:}
@exdent @r{$B!ZNc![(B}
@c ;; @r{Put the space character in class whitespace.}
;; @r{$B6uGrJ8;z$r%/%i%9GrJ8;z$K$9$k(B}
(modify-syntax-entry ?\ " ")
@result{} nil
@end group
@group
@c ;; @r{Make @samp{$} an open parenthesis character,}
@c ;; @r{with @samp{^} as its matching close.}
;; @r{@samp{$}$B$r3+$-3g8LJ8;z$K$9$k(B}
;; @r{$BBP1~$9$kJD$8$kJ8;z$O(B@samp{^}$B$G$"$k(B}
(modify-syntax-entry ?$ "(^")
@result{} nil
@end group
@group
@c ;; @r{Make @samp{^} a close parenthesis character,}
@c ;; @r{with @samp{$} as its matching open.}
;; @r{@samp{^}$B$rJD$83g8LJ8;z$K$9$k(B}
;; @r{$BBP1~$9$k3+$/J8;z$O(B{$}$B$G$"$k(B}
(modify-syntax-entry ?^ ")$")
@result{} nil
@end group
@group
@c ;; @r{Make @samp{/} a punctuation character,}
@c ;; @r{the first character of a start-comment sequence,}
@c ;; @r{and the second character of an end-comment sequence.}
@c ;; @r{This is used in C mode.}
;; @r{@samp{/}$B$r6gFIE@J8;z$K$9$k(B}
;; @r{$B%3%a%s%H3+;ONs$N:G=i$NJ8;z!"$*$h$S!"(B}
;; @r{$B%3%a%s%H=*N;Ns$N(B2$BHVL\$NJ8;z$K$b$9$k(B}
;; @r{$B$3$l$O(BC$B%b!<%I$GMQ$$$i$l$k(B}
(modify-syntax-entry ?/ ". 14")
@result{} nil
@end group
@end example
@end deffn
@defun char-syntax character
@c This function returns the syntax class of @var{character}, represented
@c by its mnemonic designator character. This returns @emph{only} the
@c class, not any matching parenthesis or flags.
$B$3$N4X?t$O!"J8;z(B@var{character}$B$N9=J8%/%i%9$r;XDj;R$GI=$7$?$b$N$GJV$9!#(B
$B$3$l$O9=J8%/%i%9(B@emph{$B$N$_(B}$B$rJV$7!"D`$j9g$&J8;z$d9=J8%U%i%0$OJV$5$J$$!#(B
@c An error is signaled if @var{char} is not a character.
@var{char}$B$,J8;z$G$J$$$H%(%i!<$rDLCN$9$k!#(B
@c The following examples apply to C mode. The first example shows that
@c the syntax class of space is whitespace (represented by a space). The
@c second example shows that the syntax of @samp{/} is punctuation. This
@c does not show the fact that it is also part of comment-start and -end
@c sequences. The third example shows that open parenthesis is in the class
@c of open parentheses. This does not show the fact that it has a matching
@c character, @samp{)}.
$B$D$.$NNc$O(BC$B%b!<%I$K$"$F$O$^$k!#(B
$B:G=i$NNc$O!"6uGr$N9=J8%/%i%9$,!J6uGr$GI=8=$5$l$k!KGrJ8;z$G$"$k$3$H$r<($9!#(B
2$BHVL\$NNc$O!"(B@samp{/}$B$N9=J8$,6gFIE@$G$"$k$3$H$r<($9!#(B
$B$3$l$O!"$3$NJ8;z$,%3%a%s%H3+;O!?=*N;$N0lItJ,$G$b$"$k$3$H$O<($5$J$$!#(B
3$BHVL\$NNc$O!"3+$-3g8L$O3+$-3g8L%/%i%9$G$"$k$3$H$r<($9!#(B
$B$3$l$O!"$3$NJ8;z$KD`$j9g$&J8;z$,(B@samp{)}$B$G$"$k$3$H$O<($5$J$$!#(B
@example
@group
(string (char-syntax ?\ ))
@result{} " "
@end group
@group
(string (char-syntax ?/))
@result{} "."
@end group
@group
(string (char-syntax ?\())
@result{} "("
@end group
@end example
@c We use @code{string} to make it easier to see the character returned by
@c @code{char-syntax}.
$B$3$3$G$O!"(B@code{char-syntax}$B$,JV$9J8;z$r(B
$B8+$d$9$/$9$k$?$a$K(B@code{string}$B$rMQ$$$?!#(B
@end defun
@defun set-syntax-table table
@c This function makes @var{table} the syntax table for the current buffer.
@c It returns @var{table}.
$B$3$N4X?t$O!"(B@var{table}$B$r%+%l%s%H%P%C%U%!$N9=J8%F!<%V%k$K$9$k!#(B
@var{table}$B$rJV$9!#(B
@end defun
@defun syntax-table
@c This function returns the current syntax table, which is the table for
@c the current buffer.
$B$3$N4X?t$O!"8=:_$N9=J8%F!<%V%k!"$D$^$j!"(B
$B%+%l%s%H%P%C%U%!$N9=J8%F!<%V%k$rJV$9!#(B
@end defun
@node Syntax Properties
@c @section Syntax Properties
@section $B9=J8B0@-(B
@c @kindex syntax-table @r{(text property)}
@kindex syntax-table @r{$B!J%F%-%9%HB0@-!K(B}
@c When the syntax table is not flexible enough to specify the syntax of a
@c language, you can use @code{syntax-table} text properties to override
@c the syntax table for specific character occurrences in the buffer.
@c @xref{Text Properties}.
$B8@8l$N9=J8$r;XDj$9$k$K==J,$J$[$I9=J8%F!<%V%k$K=@Fp@-$,$J$$$H$-$K$O!"(B
$B%P%C%U%!Fb$NFCDj$NJ8;z$N=P8=$KBP$7$F9=J8%F!<%V%k$KM%@h$9$k(B
$B%F%-%9%HB0@-(B@code{syntax-table}$B$r;XDj$G$-$^$9!#(B
@xref{Text Properties}$B!#(B
@c The valid values of @code{syntax-table} text property are:
$B%F%-%9%HB0@-(B@code{syntax-table}$B$N@5$7$$CM$O$D$.$N$H$*$j$G$9!#(B
@table @asis
@item @var{syntax-table}
@c If the property value is a syntax table, that table is used instead of
@c the current buffer's syntax table to determine the syntax for this
@c occurrence of the character.
$BB0@-CM$,9=J8%F!<%V%k$G$"$k$H!"(B
$BJ8;z$N$3$N=P8=$KBP$9$k9=J8$rH=Dj$9$k$?$a$K(B
$B%+%l%s%H%P%C%U%!$N9=J8%F!<%V%k$N$+$o$j$K$3$N%F!<%V%k$rMQ$$$k!#(B
@item @code{(@var{syntax-code} . @var{matching-char})}
@c A cons cell of this format specifies the syntax for this
@c occurrence of the character.
$B$3$N7A$N%3%s%9%;%k$O!"J8;z$N$3$N=P8=$N9=J8$r;XDj$9$k!#(B
@item @code{nil}
@c If the property is @code{nil}, the character's syntax is determined from
@c the current syntax table in the usual way.
$BB0@-$,(B@code{nil}$B$G$"$k$H!"DL>o$I$*$j!"(B
$B8=:_$N9=J8%F!<%V%k$+$iJ8;z$N9=J8$rH=Dj$9$k!#(B
@end table
@defvar parse-sexp-lookup-properties
@tindex parse-sexp-lookup-properties
@c If this is non-@code{nil}, the syntax scanning functions pay attention
@c to syntax text properties. Otherwise they use only the current syntax
@c table.
$B$3$l$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B9=J8$r2r@O$9$k4X?t$O!"%F%-%9%HB0@-$K$h$k9=J8;XDj$KCm0U$rJ'$&!#(B
$B$5$b$J$1$l$P!"8=:_$N9=J8%F!<%V%k$N$_$rMQ$$$k!#(B
@end defvar
@node Motion and Syntax
@c @section Motion and Syntax
@section $B0\F0$H9=J8(B
@c This section describes functions for moving across characters that
@c have certain syntax classes.
$BK\@a$G$O!"FCDj$N9=J8%/%i%9$r;}$DJ8;z$r1[$($F0\F0$9$k$?$a$N(B
$B4X?t$K$D$$$F=R$Y$^$9!#(B
@defun skip-syntax-forward syntaxes &optional limit
@c This function moves point forward across characters having syntax classes
@c mentioned in @var{syntaxes}. It stops when it encounters the end of
@c the buffer, or position @var{limit} (if specified), or a character it is
@c not supposed to skip.
@c The return value is the distance traveled, which is a nonnegative
@c integer.
$B$3$N4X?t$O!"(B@var{syntaxes}$B$G;XDj$5$l$k9=J8%/%i%9$r;}$DJ8;z$r1[$($F(B
$B%]%$%s%H$rA0J}$X8~$1$F0\F0$9$k!#(B
$B%P%C%U%!$NKvHx!"!J;XDj$5$l$F$$$l$P!K(B@var{limit}$B$N0LCV!"(B
$BHt$S1[$5$J$$J8;z$N$$$:$l$+$K=P2q$&$HDd;_$9$k!#(B
$BLa$jCM$O0\F05wN%$G$"$jHsIi@0?t$G$"$k!#(B
@end defun
@defun skip-syntax-backward syntaxes &optional limit
@c This function moves point backward across characters whose syntax
@c classes are mentioned in @var{syntaxes}. It stops when it encounters
@c the beginning of the buffer, or position @var{limit} (if specified), or a
@c character it is not supposed to skip.
$B$3$N4X?t$O!"(B@var{syntaxes}$B$G;XDj$5$l$k9=J8%/%i%9$G$"$kJ8;z$r1[$($F(B
$B%]%$%s%H$r8eJ}$X8~$1$F0\F0$9$k!#(B
$B%P%C%U%!$N@hF,!"!J;XDj$5$l$F$$$l$P!K(B@var{limit}$B$N0LCV!"(B
$BHt$S1[$5$J$$J8;z$N$$$:$l$+$K=P2q$&$HDd;_$9$k!#(B
@c The return value indicates the distance traveled. It is an integer that
@c is zero or less.
$BLa$jCM$O0\F05wN%$G$"$k!#(B
$B$=$l$O%<%m$+Ii$N@0?t$G$"$k!#(B
@end defun
@defun backward-prefix-chars
@c This function moves point backward over any number of characters with
@c expression prefix syntax. This includes both characters in the
@c expression prefix syntax class, and characters with the @samp{p} flag.
$B$3$N4X?t$O!"<0A0CV;R9=J8$NJ8;z$rHt$S1[$($F%]%$%s%H$r8eJ}$X8~$1$F0\F0$9$k!#(B
$B<0A0CV;R%/%i%9$d%U%i%0(B@samp{p}$B$r;}$DJ8;z$rHt$S1[$9!#(B
@end defun
@node Parsing Expressions
@c @section Parsing Balanced Expressions
@section $BD`$j9g$C$?<0$N2r@O(B
@c Here are several functions for parsing and scanning balanced
@c expressions, also known as @dfn{sexps}, in which parentheses match in
@c pairs. The syntax table controls the interpretation of characters, so
@c these functions can be used for Lisp expressions when in Lisp mode and
@c for C expressions when in C mode. @xref{List Motion}, for convenient
@c higher-level functions for moving over balanced expressions.
$B$3$3$G$O!"3g8L$,BP$K$J$C$F$$$k(B@dfn{S$B<0(B}$B!J(Bsexp$B!K$H$b8F$P$l$k(B
$BD`$j9g$C$?<0$r2r@O$7$?$jAv::$9$k4X?t$K$D$$$F=R$Y$^$9!#(B
$B9=J8%F!<%V%k$GJ8;z$N2r<a$r@)8f$9$k$3$H$G!"(B
Lisp$B%b!<%I$G$O(BLisp$B$N<0$KBP$7$F!"(BC$B%b!<%I$G$O(BC$B$N<0$KBP$7$F(B
$B$3$l$i$N4X?t$rMQ$$$k$3$H$,$G$-$^$9!#(B
$BD`$j9g$C$?<0$rHt$S1[$($F0\F0$9$k$?$a$NJXMx$J>e0L%l%Y%k$N4X?t$K$D$$$F$O!"(B
@xref{List Motion}$B!#(B
@defun parse-partial-sexp start limit &optional target-depth stop-before state stop-comment
@c This function parses a sexp in the current buffer starting at
@c @var{start}, not scanning past @var{limit}. It stops at position
@c @var{limit} or when certain criteria described below are met, and sets
@c point to the location where parsing stops. It returns a value
@c describing the status of the parse at the point where it stops.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N(B@var{start}$B$+$i;O$^$k(BS$B<0$r2r@O$9$k$,!"(B
@var{limit}$B$r1[$($F$OAv::$7$J$$!#(B
$B0LCV(B@var{limit}$B$G;_$^$k$+!"(B
$B0J2<$K=R$Y$k>r7o$,K~$?$5$l$k$H2r@O$rDd;_$7!"Ev3:2U=j$K%]%$%s%H$rCV$/!#(B
$B%]%$%s%H$rCV$$$?2U=j$G$N2r@O>u67$rI=$9CM$rJV$9!#(B
@c If @var{state} is @code{nil}, @var{start} is assumed to be at the top
@c level of parenthesis structure, such as the beginning of a function
@c definition. Alternatively, you might wish to resume parsing in the
@c middle of the structure. To do this, you must provide a @var{state}
@c argument that describes the initial status of parsing.
@var{state}$B$,(B@code{nil}$B$G$"$k$H!"(B
$B0LCV(B@var{start}$B$O!"4X?tDj5A$N@hF,$N$h$&$J(B
$B3g8L$N9=B$$N%H%C%W%l%Y%k$G$"$k$H2>Dj$9$k!#(B
$B$"$k$$$O!"9=B$$NESCf$+$i2r@O$r:F3+$7$?$$>l9g$b$"$k!#(B
$B$=$l$K$O!"2r@O$N=i4|>uBV$r0z?t(B@var{state}$B$K;XDj$9$kI,MW$,$"$k!#(B
@c @cindex parenthesis depth
@cindex $B3g8L$N?<$5(B
@c If the third argument @var{target-depth} is non-@code{nil}, parsing
@c stops if the depth in parentheses becomes equal to @var{target-depth}.
@c The depth starts at 0, or at whatever is given in @var{state}.
3$BHVL\$N0z?t(B@var{target-depth}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B3g8L$N?<$5$,(B@var{target-depth}$B$KEy$7$/$J$k$H2r@O$rDd;_$9$k!#(B
$B?<$5$O(B0$B!"$"$k$$$O!"(B@var{state}$B$G;XDj$5$l$?CM$+$i;O$^$k!#(B
@c If the fourth argument @var{stop-before} is non-@code{nil}, parsing
@c stops when it comes to any character that starts a sexp. If
@c @var{stop-comment} is non-@code{nil}, parsing stops when it comes to the
@c start of a comment. If @var{stop-comment} is the symbol
@c @code{syntax-table}, parsing stops after the start of a comment or a
@c string, or the end of a comment or a string, whichever comes first.
4$BHVL\$N0z?t(B@var{stop-before}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
S$B<0$r;O$a$kJ8;z$K=P2q$&$H2r@O$rDd;_$9$k!#(B
@var{stop-comment}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%3%a%s%H$N;O$^$j$K=P2q$&$H2r@O$rDd;_$9$k!#(B
@var{stop-comment}$B$,%7%s%\%k(B@code{syntax-table}$B$G$"$k$H!"(B
$B%3%a%s%H$dJ8;zNs$N;O$^$j!"%3%a%s%H$dJ8;zNs$N=*$j$N$$$:$l$+$K(B
$B=P2q$C$?$"$H$G2r@O$rDd;_$9$k!#(B
@c @cindex parse state
@cindex $B2r@O>uBV(B
@c The fifth argument @var{state} is a nine-element list of the same form
@c as the value of this function, described below. (It is OK to omit the
@c last element of the nine.) The return value of one call may be used to
@c initialize the state of the parse on another call to
@c @code{parse-partial-sexp}.
5$BHVL\$N0z?t(B@var{state}$B$O(B9$BMWAG$N%j%9%H$G$"$j!"(B
$B0J2<$K=R$Y$k$h$&$K$3$N4X?t$NCM$HF1$87A$G$"$k!#(B
$B!J(B9$BHVL\$N:G8e$NMWAG$O>J$$$F$b$h$$!#!K(B
@code{parse-partial-sexp}$B$N8F$S=P$7$NLa$jCM$r!"(B
$BJL$N(B@code{parse-partial-sexp}$B$N8F$S=P$7$N2r@O>uBV$N=i4|CM$K;H$C$F$h$$!#(B
@c The result is a list of nine elements describing the final state of
@c the parse:
$B7k2L$O!"2r@O$N:G=*>uBV$r5-=R$7$?(B9$BMWAG$N%j%9%H$G$"$k!#(B
@enumerate 0
@item
@c The depth in parentheses, counting from 0.
0$B$+$i?t$($?3g8L$N?<$5!#(B
@item
@c @cindex innermost containing parentheses
@cindex $B$b$C$H$bFbB&$N3g8L<0(B
@c The character position of the start of the innermost parenthetical
@c grouping containing the stopping point; @code{nil} if none.
$B%]%$%s%H$rDd;_$7$?2U=j$r4^$`$b$C$H$bFbB&$N3g8L<0$N3+;O0LCV!#(B
$B$J$1$l$P(B@code{nil}$B!#(B
@item
@c @cindex previous complete subexpression
@cindex $B$^$($N40A4$JItJ,<0(B
@c The character position of the start of the last complete subexpression
@c terminated; @code{nil} if none.
$BJD$8$F$$$k:G8e$N40A4$JItJ,<0$N3+;O0LCV!#(B
$B$J$1$l$P(B@code{nil}$B!#(B
@item
@c @cindex inside string
@cindex $BJ8;zNs$NFbB&(B
@c Non-@code{nil} if inside a string. More precisely, this is the
@c character that will terminate the string, or @code{t} if a generic
@c string delimiter character should terminate it.
$BJ8;zNs$NFbB&$G$"$k$H(B@code{nil}$B0J30$G$"$k!#(B
$B$h$j@53N$K$O!"$3$l$OJ8;zNs$r=*$($kJ8;z$G$"$k!#(B
$B$"$k$$$O!"HFMQJ8;zNs6h@Z$jJ8;z$G=*$($k$H$-$K$O(B@code{t}$B$G$"$k!#(B
@item
@c @cindex inside comment
@cindex $B%3%a%s%H$NFbB&(B
@c @code{t} if inside a comment (of either style).
$B!J$I$A$i$+$N7A<0$N!K%3%a%s%H$NFbB&$G$"$k$H(B@code{t}$B$G$"$k!#(B
@item
@c @cindex quote character
@cindex $B%/%)!<%HJ8;z(B
@c @code{t} if point is just after a quote character.
$B%]%$%s%H$,%/%)!<%HJ8;z$ND>8e$G$"$k$H(B@code{t}$B$G$"$k!#(B
@item
@c The minimum parenthesis depth encountered during this scan.
$B$3$N2r@OCf$K=P2q$C$?:G>.$N3g8L$N?<$5!#(B
@item
@c What kind of comment is active: @code{nil} for a comment of style ``a'',
@c @code{t} for a comment of style ``b'', and @code{syntax-table} for
@c a comment that should be ended by a generic comment delimiter character.
$B$I$N7A<0$N%3%a%s%H$,3h@-$G$"$k$+$rI=$9!#(B
$B!X(Ba$B!Y7A<0$G$"$k$H(B@code{nil}$B!"(B
$B!X(Bb$B!Y7A<0$G$"$k$H(B@code{t}$B!"(B
$BHFMQ%3%a%s%H6h@Z$jJ8;z$G=*$k%3%a%s%H$N>l9g$K$O(B@code{syntax-table}$B$G$"$k!#(B
@item
@c The string or comment start position. While inside a comment, this is
@c the position where the comment began; while inside a string, this is the
@c position where the string began. When outside of strings and comments,
@c this element is @code{nil}.
$BJ8;zNs$d%3%a%s%H$N3+;O0LCV!#(B
$B%3%a%s%H$NFbB&$G$"$k$H$-$K$O$3$l$O%3%a%s%H$N3+;O0LCV$G$"$j!"(B
$BJ8;zNs$NFbB&$G$"$k$H$-$K$O$3$l$OJ8;zNs$N3+;O0LCV$G$"$k!#(B
$BJ8;zNs$d%3%a%s%H$N30B&$G$O!"$3$NMWAG$O(B@code{nil}$B$G$"$k!#(B
@end enumerate
@c Elements 0, 3, 4, 5 and 7 are significant in the argument @var{state}.
$B0z?t(B@var{state}$B$G$O!"MWAG(B0$B!"(B3$B!"(B4$B!"(B5$B!"(B7$B$O=EMW$G$"$k!#(B
@c @cindex indenting with parentheses
@cindex $B3g8L$K$h$k;z2<$2(B
@c This function is most often used to compute indentation for languages
@c that have nested parentheses.
$B$3$N4X?t$O!"F~$l;R$K$"$C$?3g8L$r;}$D8@8l8~$1$K(B
$B;z2<$2$r7W;;$9$k$?$a$K$7$P$7$PMQ$$$i$l$k!#(B
@end defun
@defun scan-lists from count depth
@c This function scans forward @var{count} balanced parenthetical groupings
@c from position @var{from}. It returns the position where the scan stops.
@c If @var{count} is negative, the scan moves backwards.
$B$3$N4X?t$O!"0LCV(B@var{from}$B$+$iA0J}$X8~$1$F(B@var{count}$B8D$N(B
$BD`$j9g$C$?3g8L$N%0%k!<%W$rAv::$9$k!#(B
$BAv::$rDd;_$7$?0LCV$rJV$9!#(B
@var{count}$B$,Ii$G$"$k$H!"8eJ}$X8~$1$FAv::$9$k!#(B
@c If @var{depth} is nonzero, parenthesis depth counting begins from that
@c value. The only candidates for stopping are places where the depth in
@c parentheses becomes zero; @code{scan-lists} counts @var{count} such
@c places and then stops. Thus, a positive value for @var{depth} means go
@c out @var{depth} levels of parenthesis.
@var{depth}$B$,(B0$B0J30$G$"$k$H!"3g8L$N?<$5$r$=$NCM$+$i?t$(;O$a$k!#(B
$BDd;_2U=j$N8uJd0LCV$O!"3g8L$N?<$5$,(B0$B$K$J$k2U=j$G$"$k!#(B
@code{scan-lists}$B$O!"$=$N$h$&$J2U=j$r(B@var{count}$B2s?t$($F$+$iDd;_$9$k!#(B
$B$7$?$,$C$F!"(B@var{depth}$B$K@5$NCM$r;XDj$9$k$H!"(B
$B3g8L$N%l%Y%k$r(B@var{depth}$B%l%Y%k$@$1H4$1$k$3$H$r0UL#$9$k!#(B
@c Scanning ignores comments if @code{parse-sexp-ignore-comments} is
@c non-@code{nil}.
@code{parse-sexp-ignore-comments}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%3%a%s%H$rL5;k$7$FAv::$9$k!#(B
@c If the scan reaches the beginning or end of the buffer (or its
@c accessible portion), and the depth is not zero, an error is signaled.
@c If the depth is zero but the count is not used up, @code{nil} is
@c returned.
$BAv::$,%P%C%U%!!J$"$k$$$O$=$N;2>H2DG=ItJ,!K$N@hF,$dKvHx$KC#$7!"(B
$B?<$5$,(B0$B$G$J$$$H!"%(%i!<$rDLCN$9$k!#(B
$B?<$5$O(B0$B$G$"$k$,;XDj8D?t$@$1?t$($F$J$$>l9g$K$O!"(B@code{nil}$B$rJV$9!#(B
@end defun
@defun scan-sexps from count
@c This function scans forward @var{count} sexps from position @var{from}.
@c It returns the position where the scan stops. If @var{count} is
@c negative, the scan moves backwards.
$B$3$N4X?t$O!"0LCV(B@var{from}$B$+$iA0J}$X8~$1$F(B@var{count}$B8D$N(BS$B<0$rAv::$9$k!#(B
$BAv::$r=*$($?0LCV$rJV$9!#(B
@var{count}$B$,Ii$G$"$k$H!"8eJ}$X8~$1$F0\F0$9$k!#(B
@c Scanning ignores comments if @code{parse-sexp-ignore-comments} is
@c non-@code{nil}.
@code{parse-sexp-ignore-comments}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%3%a%s%H$rL5;k$7$FAv::$9$k!#(B
@c If the scan reaches the beginning or end of (the accessible part of) the
@c buffer while in the middle of a parenthetical grouping, an error is
@c signaled. If it reaches the beginning or end between groupings but
@c before count is used up, @code{nil} is returned.
$BAv::$,3g8L$K$h$k%0%k!<%W$NESCf$G(B
$B%P%C%U%!!J$"$k$$$O$=$N;2>H2DG=ItJ,!K$N@hF,$dKvHx$KC#$9$k$H!"(B
$B%(%i!<$rDLCN$9$k!#(B
$B;XDj8D?t$@$1?t$($k$^$($K3g8L$K$h$k%0%k!<%W$N$"$$$@$G(B
$B@hF,$dKvHx$KC#$7$?>l9g$O(B@code{nil}$B$rJV$9!#(B
@end defun
@defvar parse-sexp-ignore-comments
@c @cindex skipping comments
@cindex $B%3%a%s%H$rHt$S1[$($k(B
@c If the value is non-@code{nil}, then comments are treated as
@c whitespace by the functions in this section and by @code{forward-sexp}.
$BCM$,(B@code{nil}$B0J30$G$"$k$H!"(B
$BK\@a$N4X?t$d(B@code{forward-sexp}$B$O!"%3%a%s%H$rGrJ8;z$H$7$F07$&!#(B
@c In older Emacs versions, this feature worked only when the comment
@c terminator is something like @samp{*/}, and appears only to end a
@c comment. In languages where newlines terminate comments, it was
@c necessary make this variable @code{nil}, since not every newline is the
@c end of a comment. This limitation no longer exists.
Emacs$B$N8E$$HG$G$O!"%3%a%s%H$N=*N;$,(B@samp{*/}$B$N$h$&$J7A$G$"$j!"$+$D!"(B
$B%3%a%s%H$N=*N;$H;W$($k>l9g$K$N$_!"$3$N5!G=$OF0:n$7$?!#(B
$B2~9T$G%3%a%s%H$r=*$($k8@8l$G$O!"2~9T$9$Y$F$,%3%a%s%H$N=*$j$G$O$J$$$?$a$K!"(B
$B$3$NJQ?t$r(B@code{nil}$B$K$9$kI,MW$,$"$C$?!#(B
$B$3$N$h$&$J@)8B;v9`$O$9$G$K$J$$!#(B
@end defvar
@c You can use @code{forward-comment} to move forward or backward over
@c one comment or several comments.
@code{forward-comment}$B$r;H$&$H!"(B
1$B$D$N%3%a%s%H$dJ#?t$N%3%a%s%H$rHt$S1[$($FA08e$K0\F0$G$-$^$9!#(B
@defun forward-comment count
@c This function moves point forward across @var{count} comments (backward,
@c if @var{count} is negative). If it finds anything other than a comment
@c or whitespace, it stops, leaving point at the place where it stopped.
@c It also stops after satisfying @var{count}.
$B$3$N4X?t$O!"%]%$%s%H$rA0J}$X8~$1$F!J(B@var{count}$B$,Ii$J$i$P8eJ}$X8~$1$F!K(B
@var{count}$B8D$N%3%a%s%H$rHt$S1[$($F0\F0$9$k!#(B
$B%3%a%s%H$+GrJ8;z0J30$N$b$N$K=P2q$&$HDd;_$7!"Ev3:2U=j$K%]%$%s%H$rCV$/!#(B
@var{count}$B8D$@$1?t$($?$"$H$K$b$b$A$m$sDd;_$9$k!#(B
@end defun
@c To move forward over all comments and whitespace following point, use
@c @code{(forward-comment (buffer-size))}. @code{(buffer-size)} is a good
@c argument to use, because the number of comments in the buffer cannot
@c exceed that many.
$B%]%$%s%H$KB3$/$9$Y$F$N%3%a%s%H$HGrJ8;z$rHt$S1[$($k$K$O!"(B
@code{(forward-comment (buffer-size))}$B$r;H$$$^$9!#(B
$B%P%C%U%!Fb$N%3%a%s%H$N8D?t$O(B@code{(buffer-size)}$B$r1[$($k$O$:$,$J$$$N$G!"(B
$B0z?t$K;H$&$K$O(B@code{(buffer-size)}$B$O$h$$$b$N$G$9!#(B
@node Standard Syntax Tables
@c @section Some Standard Syntax Tables
@section $BI8=`E*$J9=J8%F!<%V%k(B
@c Most of the major modes in Emacs have their own syntax tables. Here
@c are several of them:
Emacs$B$N$[$H$s$I$N%a%8%c!<%b!<%I$K$O$=$lFH<+$N9=J8%F!<%V%k$,$"$j$^$9!#(B
$B$=$l$i$N$$$/$D$+$r$D$.$K<($7$^$9!#(B
@defun standard-syntax-table
@c This function returns the standard syntax table, which is the syntax
@c table used in Fundamental mode.
$B$3$N4X?t$O!"4pK\!J(Bfundamental$B!K%b!<%I$G;HMQ$9$k9=J8%F!<%V%k$G$"$k(B
$BI8=`$N9=J8%F!<%V%k$rJV$9!#(B
@end defun
@defvar text-mode-syntax-table
@c The value of this variable is the syntax table used in Text mode.
$B$3$NJQ?t$NCM$O!"%F%-%9%H!J(Btext$B!K%b!<%I$G;HMQ$9$k9=J8%F!<%V%k$G$"$k!#(B
@end defvar
@defvar c-mode-syntax-table
@c The value of this variable is the syntax table for C-mode buffers.
$B$3$NJQ?t$NCM$O!"(BC$B%b!<%I$N%P%C%U%!8~$1$N9=J8%F!<%V%k$G$"$k!#(B
@end defvar
@defvar emacs-lisp-mode-syntax-table
@c The value of this variable is the syntax table used in Emacs Lisp mode
@c by editing commands. (It has no effect on the Lisp @code{read}
@c function.)
$B$3$NJQ?t$NCM$O!"JT=8%3%^%s%I$,(Bemacs-lisp$B%b!<%I$G;HMQ$9$k9=J8%F!<%V%k$G$"$k!#(B
$B!J$3$l$O(BLisp$B$N4X?t(B@code{read}$B$K$O$J$s$N8z2L$b$J$$!#!K(B
@end defvar
@node Syntax Table Internals
@c @section Syntax Table Internals
@section $B9=J8%F!<%V%k$NFbIt(B
@c @cindex syntax table internals
@cindex $B9=J8%F!<%V%k$NFbIt(B
@c Lisp programs don't usually work with the elements directly; the
@c Lisp-level syntax table functions usually work with syntax descriptors
@c (@pxref{Syntax Descriptors}). Nonetheless, here we document the
@c internal format.
Lisp$B%W%m%0%i%`$G$OIaDL$O9=J8%F!<%V%k$NMWAG$rD>@\$K$OA`:n$7$^$;$s!#(B
Lisp$B%l%Y%k$N9=J8%F!<%V%k4X?t$O!"(B
$BIaDL$O9=J85-=R;R!J(B@pxref{Syntax Descriptors}$B!K$rA`:n$7$^$9!#(B
$B$G$9$,!"FbIt7A<0$rL@J82=$7$F$*$-$^$9!#(B
@c Each element of a syntax table is a cons cell of the form
@c @code{(@var{syntax-code} . @var{matching-char})}. The @sc{car},
@c @var{syntax-code}, is an integer that encodes the syntax class, and any
@c flags. The @sc{cdr}, @var{matching-char}, is non-@code{nil} if
@c a character to match was specified.
$B9=J8%F!<%V%k$N3FMWAG$O!"(B@code{(@var{syntax-code} . @var{matching-char})}$B$N(B
$B7A$N%3%s%9%;%k$G$9!#(B
@sc{car}$B$N(B@var{syntax-code}$B$O!"9=J8%/%i%9$H9=J8%U%i%0$rId9f2=$9$k@0?t$G$9!#(B
$BD`$j9g$&J8;z$r;XDj$7$F$"$k$H!"(B
@sc{cdr}$B$N(B@var{matching-char}$B$O(B@code{nil}$B0J30$G$9!#(B
@c This table gives the value of @var{syntax-code} which corresponds
@c to each syntactic type.
$B$D$.$NI=$O!"3F9=J8%/%i%9$KBP1~$9$k(B@var{syntax-code}$B$NCM$G$9!#(B
@c = $BF|K\8l$N%3%i%`$N@hF,$K$OA43Q%9%Z!<%9$,$"$k!*(B
@multitable @columnfractions .05 .3 .3 .3
@item
@tab
@c @i{Integer} @i{Class}
@i{$B@0?t(B} @i{$B%/%i%9(B}
@tab
@c @i{Integer} @i{Class}
@i{$B@0?t(B} @i{$B%/%i%9(B}
@tab
@c @i{Integer} @i{Class}
@i{$B@0?t(B} @i{$B%/%i%9(B}
@item
@tab
0 @ @ whitespace
@tab
5 @ @ close parenthesis
@tab
10 @ @ character quote
@item
@tab
$B!!(B@ @ $BGrJ8;z(B
@tab
$B!!(B@ @ $BJD$83g8L(B
@tab
$B!!(B@ @ $BJ8;z%/%)!<%H(B
@item
@tab
1 @ @ punctuation
@tab
6 @ @ expression prefix
@tab
11 @ @ comment-start
@item
@tab
$B!!(B@ @ $B6gFIE@(B
@tab
$B!!(B@ @ $B<0A0CV;R(B
@tab
$B!!(B@ @ $B%3%a%s%H3+;O(B
@item
@tab
2 @ @ word
@tab
7 @ @ string quote
@tab
12 @ @ comment-end
@item
@tab
$B!!(B@ @ $BC18l(B
@tab
$B!!(B@ @ $BJ8;zNs%/%)!<%H(B
@tab
$B!!(B@ @ $B%3%a%s%H=*N;(B
@item
@tab
3 @ @ symbol
@tab
8 @ @ paired delimiter
@tab
13 @ @ inherit
@item
@tab
$B!!(B@ @ $B%7%s%\%k(B
@tab
$B!!(B@ @ $BBP$K$J$C$?6h@Z$j(B
@tab
$B!!(B@ @ $B7Q>5(B
@item
@tab
4 @ @ open parenthesis
@tab
9 @ @ escape
@tab
14 @ @ comment-fence
@item
@tab
$B!!(B@ @ $B3+$-3g8L(B
@tab
$B!!(B@ @ $B%(%9%1!<%W(B
@tab
$B!!(B@ @ $B%3%a%s%H6h@Z$j(B
@item
@tab
15 @ string-fence
@ifinfo
@tab
@tab
@end ifinfo
@item
@tab
$B!!(B@ @ $BJ8;zNs6h@Z$j(B
@ifinfo
@tab
@tab
@end ifinfo
@end multitable
@c For example, the usual syntax value for @samp{(} is @code{(4 . 41)}.
@c (41 is the character code for @samp{)}.)
$B$?$H$($P!"(B@samp{(}$B$NIaDL$N9=J8CM$O!"(B@code{(4 . 41)}$B$G$9!#(B
$B!J(B41$B$O(B@samp{)}$B$NJ8;z%3!<%I!#!K(B
@c The flags are encoded in higher order bits, starting 16 bits from the
@c least significant bit. This table gives the power of two which
@c corresponds to each syntax flag.
$B%U%i%0$O!":G2<0L%S%C%H$+$i(B16$BHVL\$N%S%C%H$+$i;O$^$k>e0L%S%C%H$KId9f2=$7$^$9!#(B
$B$D$.$NI=$O!"3F9=J8%U%i%0$H$=$l$KBP1~$9$k(B2$B$N6R$G$9!#(B
@multitable @columnfractions .05 .3 .3 .3
@item
@tab
@c @i{Prefix} @i{Flag}
@i{$B%U%i%0(B} @i{2$B$N6R(B}
@tab
@c @i{Prefix} @i{Flag}
@i{$B%U%i%0(B} @i{2$B$N6R(B}
@tab
@c @i{Prefix} @i{Flag}
@i{$B%U%i%0(B} @i{2$B$N6R(B}
@item
@tab
@samp{1} @ @ @code{(lsh 1 16)}
@tab
@samp{3} @ @ @code{(lsh 1 18)}
@tab
@samp{p} @ @ @code{(lsh 1 20)}
@item
@tab
@samp{2} @ @ @code{(lsh 1 17)}
@tab
@samp{4} @ @ @code{(lsh 1 19)}
@tab
@samp{b} @ @ @code{(lsh 1 21)}
@end multitable
@node Categories
@c @section Categories
@section $B%+%F%4%j(B
@c @cindex categories of characters
@cindex $BJ8;z$N%+%F%4%j(B
@cindex $B%+%F%4%j!"J8;z(B
@c @dfn{Categories} provide an alternate way of classifying characters
@c syntactically. You can define several categories as needed, then
@c independently assign each character to one or more categories. Unlike
@c syntax classes, categories are not mutually exclusive; it is normal for
@c one character to belong to several categories.
@dfn{$B%+%F%4%j(B}$B!J(Bcategory$B!K$O!"J8;z$r9=J8E*$KJ,N`$9$kJL$NJ}K!$G$9!#(B
$BI,MW$K1~$8$FJ#?t$N%+%F%4%j$rDj5A$G$-$F!"(B
$B$=$&$9$k$H3FJ8;z$K(B1$B$D$+J#?t$N%+%F%4%j$rFHN)$K@_Dj$G$-$^$9!#(B
$B9=J8%/%i%9$H0[$J$j!"%+%F%4%j$O8_$$$KGSB>E*$G$O$"$j$^$;$s!#(B
1$B$D$NJ8;z$,J#?t$N%+%F%4%j$KB0$9$k$3$H$OIaDL$K$"$j$^$9!#(B
@c Each buffer has a @dfn{category table} which records which categories
@c are defined and also which characters belong to each category. Each
@c category table defines its own categories, but normally these are
@c initialized by copying from the standard categories table, so that the
@c standard categories are available in all modes.
$B3F%P%C%U%!$K$O(B@dfn{$B%+%F%4%j%F!<%V%k(B}$B!J(Bcategory table$B!K$,$"$j!"(B
$B$I$N%+%F%4%j$,Dj5A:Q$_$G$I$NJ8;z$,$I$N%+%F%4%j$KB0$9$k$+$r5-O?$7$F$$$^$9!#(B
$B3F%+%F%4%j%F!<%V%k$O$=$lFH<+$N%+%F%4%j72$rDj5A$7$^$9$,!"(B
$B$=$l$i$OI8=`$N%+%F%4%j%F!<%V%k$r%3%T!<$7$FIaDL$O=i4|2=$5$l$^$9!#(B
$B$=$N$?$a!"$9$Y$F$N%b!<%I$GI8=`$N%+%F%4%j$r;H$($^$9!#(B
@c Each category has a name, which is an @sc{ASCII} printing character in
@c the range @w{@samp{ }} to @samp{~}. You specify the name of a category
@c when you define it with @code{define-category}.
$B3F%+%F%4%j$K$OL>A0$,$"$j!"$=$l$O(B@w{@samp{ }}$B$+$i(B@samp{~}$B$^$G$N(B
$BHO0O$N(B@sc{ASCII}$B0u;zJ8;z$G$9!#(B
@code{define-category}$B$G%+%F%4%j$rDj5A$9$k$H$-$K$=$NL>A0$r;XDj$7$^$9!#(B
@c The category table is actually a char-table (@pxref{Char-Tables}).
@c The element of the category table at index @var{c} is a @dfn{category
@c set}---a bool-vector---that indicates which categories character @var{c}
@c belongs to. In this category set, if the element at index @var{cat} is
@c @code{t}, that means category @var{cat} is a member of the set, and that
@c character @var{c} belongs to category @var{cat}.
$B%+%F%4%j%F!<%V%k$O<B:]$K$OJ8;z%F!<%V%k!J(B@pxref{Char-Tables}$B!K$G$9!#(B
$B%+%F%4%j%F!<%V%k$NE:;z(B@var{c}$B$NMWAG$O!"(B
@dfn{$B%+%F%4%j=89g(B}$B!J(Bcategory set$B!K$G$9!#(B
$B$3$l$O%V!<%k%Y%/%H%k$G$"$j!"J8;z(B@var{c}$B$,B0$9$k%+%F%4%j72$rI=$7$^$9!#(B
$B$3$N%+%F%4%j=89g$K$*$$$F!"E:;z(B@var{cat}$B$NMWAG$,(B@code{t}$B$G$"$k$H!"(B
@var{cat}$B$O=89g$NMWAG$G$"$k$3$H$r0UL#$7!"(B
$BEv3:J8;z(B@var{c}$B$O%+%F%4%j(B@var{cat}$B$KB0$9$k$3$H$r0UL#$7$^$9!#(B
@defun define-category char docstring &optional table
@c This function defines a new category, with name @var{char} and
@c documentation @var{docstring}.
$B$3$N4X?t$O!"L>A0$r(B@var{char}$B!"@bL@J8;zNs$r(B@var{docstring}$B$H$7$F(B
$B?7$?$J%+%F%4%j$rDj5A$9$k!#(B
@c The new category is defined for category table @var{table}, which
@c defaults to the current buffer's category table.
$B?7$?$J%+%F%4%j$O!"%+%F%4%j%F!<%V%k(B@var{table}$B$KBP$7$FDj5A$5$l$k!#(B
@var{table}$B$N%G%U%)%k%H$O!"%+%l%s%H%P%C%U%!$N%+%F%4%j%F!<%V%k$G$"$k!#(B
@end defun
@defun category-docstring category &optional table
@c This function returns the documentation string of category @var{category}
@c in category table @var{table}.
$B$3$N4X?t$O!"%+%F%4%j%F!<%V%k(B@var{table}$B$N%+%F%4%j(B@var{category}$B$N(B
$B@bL@J8;zNs$rJV$9!#(B
@example
(category-docstring ?a)
@result{} "ASCII"
(category-docstring ?l)
@result{} "Latin"
@end example
@end defun
@defun get-unused-category table
@c This function returns a category name (a character) which is not
@c currently defined in @var{table}. If all possible categories are in use
@c in @var{table}, it returns @code{nil}.
$B$3$N4X?t$O!"%+%F%4%j%F!<%V%k(B@var{table}$B$G8=:_Dj5A$5$l$F$$$J$$(B
$B?7$?$J%+%F%4%jL>!JJ8;z!K$rJV$9!#(B
@var{table}$B$K$*$$$F2DG=$J$9$Y$F$N%+%F%4%j$,;HMQ:Q$_$G$"$k$H(B@code{nil}$B$rJV$9!#(B
@end defun
@defun category-table
@c This function returns the current buffer's category table.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N%+%F%4%j%F!<%V%k$rJV$9!#(B
@end defun
@defun category-table-p object
@c This function returns @code{t} if @var{object} is a category table,
@c otherwise @code{nil}.
$B$3$N4X?t$O!"(B@var{object}$B$,%+%F%4%j%F!<%V%k$G$"$k$H(B@code{t}$B$rJV$7!"(B
$B$5$b$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@end defun
@defun standard-category-table
@c This function returns the standard category table.
$B$3$N4X?t$O!"I8=`$N%+%F%4%j%F!<%V%k$rJV$9!#(B
@end defun
@defun copy-category-table &optional table
@c This function constructs a copy of @var{table} and returns it. If
@c @var{table} is not supplied (or is @code{nil}), it returns a copy of the
@c current category table. Otherwise, an error is signaled if @var{table}
@c is not a category table.
$B$3$N4X?t$O!"%+%F%4%j%F!<%V%k(B@var{table}$B$N%3%T!<$r:n@.$7$=$l$rJV$9!#(B
@var{table}$B$r;XDj$7$J$$!J$"$k$$$O(B@code{nil}$B!K$H!"(B
$B8=:_$N%+%F%4%j%F!<%V%k$N%3%T!<$rJV$9!#(B
@var{table}$B$,%+%F%4%j%F!<%V%k$G$J$$$H%(%i!<$rDLCN$9$k!#(B
@end defun
@defun set-category-table table
@c This function makes @var{table} the category table for the current
@c buffer. It returns @var{table}.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N%+%F%4%j%F!<%V%k$r(B@var{table}$B$H$9$k!#(B
@var{table}$B$rJV$9!#(B
@end defun
@defun make-category-set categories
@c This function returns a new category set---a bool-vector---whose initial
@c contents are the categories listed in the string @var{categories}. The
@c elements of @var{categories} should be category names; the new category
@c set has @code{t} for each of those categories, and @code{nil} for all
@c other categories.
$B$3$N4X?t$O!"?7$?$J%+%F%4%j=89g!"$D$^$j!"(B
$BJ8;zNs(B@var{categories}$B$K;XDj$7$?%+%F%4%j$G(B
$BFbMF$r=i4|2=$7$?%V!<%k%Y%/%H%k$rJV$9!#(B
@var{categories}$B$NMWAG$O%+%F%4%jL>$G$"$k$3$H!#(B
$B?7$?$J%+%F%4%j=89g$G$O!"(B@var{categories}$B$N3F%+%F%4%j$KBP$7$F$O(B@code{t}$B$r(B
$B$=$l0J30$N%+%F%4%j$KBP$7$F$O(B@code{nil}$B$r@_Dj$9$k!#(B
@example
(make-category-set "al")
@result{} #&128"\0\0\0\0\0\0\0\0\0\0\0\0\2\20\0\0"
@end example
@end defun
@defun char-category-set char
@c This function returns the category set for character @var{char}. This
@c is the bool-vector which records which categories the character
@c @var{char} belongs to. The function @code{char-category-set} does not
@c allocate storage, because it returns the same bool-vector that exists in
@c the category table.
$B$3$N4X?t$O!"J8;z(B@var{char}$B$KBP$9$k%+%F%4%j=89g$rJV$9!#(B
$B$3$l$O!"J8;z(B@var{char}$B$,B0$9$k%+%F%4%j72$r5-O?$7$?%V!<%k%Y%/%H%k$G$"$k!#(B
$B4X?t(B@code{char-category-set}$B$O!"%+%F%4%j%F!<%V%k$K(B
$BB8:_$9$kF1$8%V!<%k%Y%/%H%k$rJV$9$?$a!"?7$?$JNN0h$r3d$jIU$1$J$$!#(B
@example
(char-category-set ?a)
@result{} #&128"\0\0\0\0\0\0\0\0\0\0\0\0\2\20\0\0"
@end example
@end defun
@defun category-set-mnemonics category-set
@c This function converts the category set @var{category-set} into a string
@c containing the names of all the categories that are members of the set.
$B$3$N4X?t$O!"%+%F%4%j=89g(B@var{category-set}$B$r(B
$B$3$N=89g$KB0$9$k$9$Y$F$N%+%F%4%j$NL>A0$+$i$J$kJ8;zNs$KJQ49$9$k!#(B
@example
(category-set-mnemonics (char-category-set ?a))
@result{} "al"
@end example
@end defun
@defun modify-category-entry character category &optional table reset
@c This function modifies the category set of @var{character} in category
@c table @var{table} (which defaults to the current buffer's category
@c table).
$B$3$N4X?t$O!"%+%F%4%j%F!<%V%k(B@var{table}$B!J%G%U%)%k%H$O%+%l%s%H%P%C%U%!$N(B
$B%+%F%4%j%F!<%V%k!KFb$NJ8;z(B@var{character}$B$N%+%F%4%j=89g$rJQ99$9$k!#(B
@c Normally, it modifies the category set by adding @var{category} to it.
@c But if @var{reset} is non-@code{nil}, then it deletes @var{category}
@c instead.
$BIaDL!"%+%F%4%j=89g$K(B@var{category}$B$rDI2C$7$FJQ99$9$k!#(B
$B$7$+$7!"(B@var{reset}$B$,(B@code{nil}$B0J30$G$"$k$H(B@var{category}$B$r:o=|$9$k!#(B
@end defun
|