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 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529
|
@c =============================================================
@c = $B85(B $BK](B $BLu(B: $B@VCS1QIW!wEE5$DL?.Bg3X(B
@c = $B2CI.=$@5(B: $BBgLZFXM:!wBgDM(B.$BC^GHBg3X(B = 1998/11/25
@c = 20.4$B2~D{(B: $BBgLZFXM:!wBgDM(B.$BC^GHBg3X(B = 1999/09/12
@c =============================================================
@c This is part of the Emacs manual.
@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Programs, Building, Text, Top
@c @chapter Editing Programs
@chapter $B%W%m%0%i%`$NJT=8(B
@c @cindex Lisp editing
@c @cindex C editing
@c @cindex program editing
@cindex Lisp$B$NJT=8(B
@cindex C$B$NJT=8(B
@cindex $B%W%m%0%i%`$NJT=8(B
@c Emacs has many commands designed to understand the syntax of programming
@c languages such as Lisp and C. These commands can
Emacs$B$K$O!"(BLisp$B$d(BC$B$H$$$C$?%W%m%0%i%`8@8l$N9=J8$r(B
$BM}2r$9$k$h$&$K@_7W$5$l$?%3%^%s%I$,?tB?$/$"$j$^$9!#(B
$B0J2<$N$3$H$r9T$($^$9!#(B
@itemize @bullet
@item
@c Move over or kill balanced expressions or @dfn{sexps} (@pxref{Lists}).
$BD`$j9g$C$?<0$d(B@dfn{S$B<0(B}$B!J(B@pxref{Lists}$B!K$r2#CG$7$?$j$=$l$i$r%-%k$9$k!#(B
@item
@c Move over or mark top-level expressions---@dfn{defuns}, in Lisp;
@c functions, in C (@pxref{Defuns}).
$B%H%C%W%l%Y%k$N<0!"$D$^$j!"(BLisp$B$N(B@dfn{defun}$B$d(BC$B$N4X?t!J(B@pxref{Defuns}$B!K$r(B
$B2#CG$7$?$j$=$l$i$K%^!<%/$r@_Dj$9$k!#(B
@item
@c Show how parentheses balance (@pxref{Matching}).
$B3g8L$NBP1~6q9g$rI=<($9$k!J(B@pxref{Matching}$B!K!#(B
@item
@c Insert, kill or align comments (@pxref{Comments}).
$B%3%a%s%H$NA^F~!?%-%k!?@0Ns!J(B@pxref{Comments}$B!K!#(B
@item
@c Follow the usual indentation conventions of the language
@c (@pxref{Program Indent}).
$B;HMQ8@8l$N47MQE*$J;z2<$2$rF'=1$9$k!J(B@pxref{Program Indent}$B!K!#(B
@end itemize
@c The commands for words, sentences and paragraphs are very useful in
@c editing code even though their canonical application is for editing
@c human language text. Most symbols contain words (@pxref{Words});
@c sentences can be found in strings and comments (@pxref{Sentences}).
@c Paragraphs per se don't exist in code, but the paragraph commands are
@c useful anyway, because programming language major modes define
@c paragraphs to begin and end at blank lines (@pxref{Paragraphs}).
@c Judicious use of blank lines to make the program clearer will also
@c provide useful chunks of text for the paragraph commands to work
@c on.
$BC18l!?J8!?CJMn$r07$&%3%^%s%I$O!"(B
$B<+A38@8l$N%F%-%9%H$rJT=8$9$k$N$,K\Mh$NL\E*$G$9$,!"(B
$B%3!<%I$rJT=8$9$k>l9g$K$b$*$*$$$KLrN)$A$^$9!#(B
$B$J$<$J$i!"$?$$$F$$$N%7%s%\%k$OC18l$G$9$7!J(B@pxref{Words}$B!K!"(B
$BJ8$OJ8;zNs$d%3%a%s%H$NCf$K$b4^$^$l$k$+$i$G$9!J(B@pxref{Sentences}$B!K!#(B
$BCJMn$OK\<AE*$K$O%3!<%I$NCf$K$OB8:_$7$^$;$s$,!"(B
$B%W%m%0%i%`8@8l8~$1$N%a%8%c!<%b!<%I$G$O!"(B
$BCJMn$O6u9T$G;O$^$j6u9T$G=*$o$k$HDj5A$9$k$N$G!"(B
$BCJMn%3%^%s%I$bLrN)$A$^$9!J(B@pxref{Paragraphs}$B!K!#(B
$B6u9T$r$&$^$/;H$C$F%W%m%0%i%`$,@0A3$H8+$($k$h$&$K$9$k$H!"(B
$BCJMn%3%^%s%I$b$&$^$/F/$-$^$9!#(B
@c The selective display feature is useful for looking at the overall
@c structure of a function (@pxref{Selective Display}). This feature causes
@c only the lines that are indented less than a specified amount to appear
@c on the screen.
$BA*BrE*I=<(5!G=$O!"4X?t$NA4BN9=@.$rD/$a$k$N$KJXMx$G$9(B
$B!J(B@pxref{Selective Display}$B!K!#(B
$B$3$N5!G=$O!";XDjI}0JFb$N;z2<$2I}$N9T$@$1$rI=<($7$^$9!#(B
@menu
* Program Modes:: Major modes for editing programs.
* Lists:: Expressions with balanced parentheses.
* List Commands:: The commands for working with list and sexps.
* Defuns:: Each program is made up of separate functions.
There are editing commands to operate on them.
* Program Indent:: Adjusting indentation to show the nesting.
* Matching:: Insertion of a close-delimiter flashes matching open.
* Comments:: Inserting, killing, and aligning comments.
* Balanced Editing:: Inserting two matching parentheses at once, etc.
* Symbol Completion:: Completion on symbol names of your program or language.
* Which Function:: Which Function mode shows which function you are in.
* Documentation:: Getting documentation of functions you plan to call.
* Change Log:: Maintaining a change history for your program.
* Tags:: Go direct to any function in your program in one
command. Tags remembers which file it is in.
* Emerge:: A convenient way of merging two versions of a program.
* C Modes:: Special commands of C, C++, Objective-C,
Java, and Pike modes.
* Fortran:: Fortran mode and its special features.
* Asm Mode:: Asm mode and its special features.
@end menu
@node Program Modes
@c @section Major Modes for Programming Languages
@section $B%W%m%0%i%`8@8l8~$1%a%8%c!<%b!<%I(B
@c @cindex modes for programming languages
@cindex $B%W%m%0%i%`8@8l8~$1%b!<%I(B
@c @cindex Perl mode
@c @cindex Icon mode
@c @cindex Awk mode
@c @cindex Makefile mode
@c @cindex Tcl mode
@c @cindex CPerl mode
@cindex Perl$B%b!<%I(B
@cindex Icon$B%b!<%I(B
@cindex Awk$B%b!<%I(B
@cindex Makefile$B%b!<%I(B
@cindex Tcl$B%b!<%I(B
@cindex CPerl$B%b!<%I(B
@c Emacs also has major modes for the programming languages Lisp, Scheme
@c (a variant of Lisp), Awk, C, C++, Fortran, Icon, Java, Objective-C,
@c Pascal, Perl, Pike, CORBA IDL, and Tcl. There is also a major mode for
@c makefiles, called Makefile mode. An second alternative mode for Perl is
@c called CPerl mode.
Emacs$B$K$O!"(BLisp$B!"(BScheme$B!J(BLisp$B$NJ}8@$N(B1$B$D!K!"(BAwk$B!"(BC$B!"(BC++$B!"(BFortran$B!"(B
Icon$B!"(BJava$B!"(BObjective-C$B!"(BPascal$B!"(BPerl$B!"(BPike$B!"(BCORBA IDL$B!"(B
Tcl$B$H$$$C$?3F<o%W%m%0%i%`8@8l8~$1$N%a%8%c!<%b!<%I$,$"$j$^$9!#(B
makefile$BMQ$N%a%8%c!<%b!<%I!"(Bmakefile$B%b!<%I$b$"$j$^$9!#(B
Perl$B8~$1$NJL$N%b!<%I$H$7$F!"(Bcperl$B%b!<%I$b$"$j$^$9!#(B
@c Ideally, a major mode should be implemented for each programming
@c language that you might want to edit with Emacs; but often the mode for
@c one language can serve for other syntactically similar languages. The
@c language modes that exist are those that someone decided to take the
@c trouble to write.
$BM}A[E*$K$O!"(BEmacs$B$GJT=8$9$k2DG=@-$N$"$k$9$Y$F$N%W%m%0%i%`8@8l$KBP$7$F!"(B
$B$=$l$>$l$N%a%8%c!<%b!<%I$r<BAu$9$Y$-$G$9!#(B
$B$7$+$7!"$"$k8@8l8~$1$N%b!<%I$,!"9=J8E*$KN`;w$7$?B>$N8@8l$K$b(B
$B;H$($k$3$H$,$h$/$"$j$^$9!#(B
$B4{B8$N8@8l%b!<%I72$O!"C/$+$,$o$6$o$6=q$3$&$H7h?4$7$?$b$N$G$9!#(B
@c There are several forms of Lisp mode, which differ in the way they
@c interface to Lisp execution. @xref{Executing Lisp}.
Lisp$B%b!<%I$K$O$$$/$D$+JQ<o$,$"$j$^$9$,!"(B
Lisp$B$r<B9T$9$k:]$N%$%s%?!<%U%'%$%9J}K!$,0[$J$j$^$9!#(B
@xref{Executing Lisp}$B!#(B
@c Each of the programming language major modes defines the @key{TAB} key
@c to run an indentation function that knows the indentation conventions of
@c that language and updates the current line's indentation accordingly.
@c For example, in C mode @key{TAB} is bound to @code{c-indent-line}.
@c @kbd{C-j} is normally defined to do @key{RET} followed by @key{TAB};
@c thus, it too indents in a mode-specific fashion.
$B3F%W%m%0%i%`8@8l8~$1%a%8%c!<%b!<%I$G$O!"(B
$B$=$N8@8l$N47MQE*$J;z2<$2J}K!$rM}2r$7(B
$B8=:_9T$r$=$N$h$&$K;z2<$2$9$k4X?t$r<B9T$9$k$h$&$K(B
@key{TAB}$B%-!<$rDj5A$7$^$9!#(B
$B$?$H$($P!"(BC$B%b!<%I$G$O!"(B@key{TAB}$B$O(B@code{c-indent-line}$B$K%P%$%s%I$5$l$F$$$^$9!#(B
$B$^$?!"(B@kbd{C-j}$B$O!"(B@key{RET}$B$KB3$1$F(B@key{TAB}$B$r<B9T$9$k$h$&$K(B
$BDj5A$5$l$F$$$^$9!#(B
$B$D$^$j!"%b!<%I$K8GM-$N;z2<$2$b9T$$$^$9!#(B
@c @kindex DEL @r{(programming modes)}
@kindex DEL @r{$B!J%W%m%0%i%_%s%0%b!<%I!K(B}
@findex backward-delete-char-untabify
@c In most programming languages, indentation is likely to vary from line to
@c line. So the major modes for those languages rebind @key{DEL} to treat a
@c tab as if it were the equivalent number of spaces (using the command
@c @code{backward-delete-char-untabify}). This makes it possible to rub out
@c indentation one column at a time without worrying whether it is made up of
@c spaces or tabs. Use @kbd{C-b C-d} to delete a tab character before point,
@c in these modes.
$BB?$/$N%W%m%0%i%`8@8l$G$O!"9T$4$H$K;z2<$2NL$,0[$J$j$^$9!#(B
$B$=$N$?$a!"$=$N$h$&$J8@8l8~$1$N%a%8%c!<%b!<%I$G$O!"(B
$B!J%3%^%s%I(B@code{backward-delete-char-untabify}$B$r;H$C$F!K(B
$B%?%VJ8;z$rEy2A$J8D?t$N6uGr$HF1$8$K07$&$h$&$K(B@key{DEL}$B$r:FDj5A$7$F$$$^$9!#(B
$B$=$N7k2L!";z2<$2$,6uGr$+%?%V$N$I$A$i$G9=@.$5$l$F$$$k$N$+5$$K$;$:$K!"(B
1$BEY$K(B1$B7e$:$D>C5n$9$k$3$H$,2DG=$H$J$j$^$9!#(B
$B$=$N$h$&$J%b!<%I$G$O!"%]%$%s%H$ND>A0$K$"$k%?%VJ8;z$r:o=|$9$k$K$O(B
@kbd{C-b C-d}$B$r;H$$$^$9!#(B
@c Programming language modes define paragraphs to be separated only by
@c blank lines, so that the paragraph commands remain useful. Auto Fill mode,
@c if enabled in a programming language major mode, indents the new lines
@c which it creates.
$B%W%m%0%i%`8@8l8~$1%b!<%I$G$O!"CJMn$O6u9T$GJ,3d$5$l$k$HDj5A$9$k$N$G!"(B
$BCJMn%3%^%s%I$bJXMx$K;H$($^$9!#(B
$B%W%m%0%i%`8@8l8~$1%a%8%c!<%b!<%I$G(B
$B<+F05M$a9~$_!J(Bauto-fill$B!K%b!<%I$,%*%s$N$H$-$K$O!"(B
$B?7$?$K9T$r:n$k$H<+F0E*$K;z2<$2$b9T$o$l$^$9!#(B
@c @cindex mode hook
@cindex $B%b!<%I%U%C%/(B
@vindex c-mode-hook
@vindex lisp-mode-hook
@vindex emacs-lisp-mode-hook
@vindex lisp-interaction-mode-hook
@vindex scheme-mode-hook
@vindex muddle-mode-hook
@c Turning on a major mode runs a normal hook called the @dfn{mode hook},
@c which is the value of a Lisp variable. Each major mode has a mode hook,
@c and the hook's name is always made from the mode command's name by
@c adding @samp{-hook}. For example, turning on C mode runs the hook
@c @code{c-mode-hook}, while turning on Lisp mode runs the hook
@c @code{lisp-mode-hook}. @xref{Hooks}.
$B%a%8%c!<%b!<%I$KF~$k$H!"(B@dfn{$B%b!<%I%U%C%/(B}$B!J(Bmode hook$B!K$H(B
$B8F$P$l$k%N!<%^%k%U%C%/$,<B9T$5$l$^$9!#(B
$B%b!<%I%U%C%/$O!"(BLisp$BJQ?t$NCM$G$9!#(B
$B3F%a%8%c!<%b!<%I$K$O%b!<%I%U%C%/$,$"$j!"(B
$B%U%C%/L>$O$D$M$K%b!<%I$KF~$k$?$a$N%3%^%s%IL>$K(B@samp{-hook}$B$rIU2C$7$?$b$N$G$9!#(B
$B$?$H$($P!"(BC$B%b!<%I$KF~$k$H%U%C%/(B@code{c-mode-hook}$B$,<B9T$5$l!"(B
Lisp$B%b!<%I$G$O%U%C%/(B@code{lisp-mode-hook}$B$,<B9T$5$l$^$9!#(B
@xref{Hooks}$B!#(B
@node Lists
@c @section Lists and Sexps
@section $B%j%9%H$H(BS$B<0(B
@c @cindex Control-Meta
@cindex $B%3%s%H%m!<%k!&%a%?(B
@c By convention, Emacs keys for dealing with balanced expressions are
@c usually Control-Meta characters. They tend to be analogous in
@c function to their Control and Meta equivalents. These commands are
@c usually thought of as pertaining to expressions in programming
@c languages, but can be useful with any language in which some sort of
@c parentheses exist (including human languages).
$B47=,$H$7$F!"D`$j9g$C$?<0$r07$&(BEmacs$B$N%-!<$O!"IaDL!"%3%s%H%m!<%k!&%a%?J8;z$G$9!#(B
$B$3$l$i$O!"%3%s%H%m!<%k$d%a%?$@$1$NBP1~$7$?%-!<$N5!G=$K;w$;$F$"$j$^$9!#(B
$B$3$l$i$O!"%W%m%0%i%`8@8l$N<0$@$1$K4X78$7$?%3%^%s%I$@$H9M$($i$l$,$A$G$9$,!"(B
$B$"$k<o$N3g8L$,B8:_$9$k!J<+A38@8l$b4^$a$?!KG$0U$N8@8l$KBP$7$F$bM-1W$J$b$N$G$9!#(B
@c @cindex list
@c @cindex sexp
@c @cindex expression
@cindex $B%j%9%H(B
@cindex S$B<0(B
@cindex $B<0(B
@c These commands fall into two classes. Some deal only with @dfn{lists}
@c (parenthetical groupings). They see nothing except parentheses, brackets,
@c braces (whichever ones must balance in the language you are working with),
@c and escape characters that might be used to quote those.
$B$3$l$i$N%3%^%s%I$O!"(B2$B$D$N%0%k!<%W$KJ,$1$i$l$^$9!#(B
$B0lJ}$O!J3g8L$G$^$H$a$?!K(B@dfn{$B%j%9%H(B}$B!J(Blist$B!K(B@footnote{$B!ZLuCm![(B
$B$3$3$G$O!"(BLisp$B$N!V%j%9%H!W$G$O$J$/!"(B
$BC1$K3g8L$G3g$C$?0l2t$N$3$H!#(B}$B$@$1$r07$&$b$N$G!"(B
$B4]3g8L!"3Q3g8L!"Cf3g8L!J;HMQ8@8l$K$*$$$FBP1~$,<h$l$F$$$kI,MW$,$"$k3g8L!K$H!"(B
$B$=$l$i$r%/%)!<%H$9$k%(%9%1!<%WJ8;z$@$1$KCmL\$9$k%3%^%s%I72$G$9!#(B
@c The other commands deal with expressions or @dfn{sexps}. The word `sexp'
@c is derived from @dfn{s-expression}, the ancient term for an expression in
@c Lisp. But in Emacs, the notion of `sexp' is not limited to Lisp. It
@c refers to an expression in whatever language your program is written in.
@c Each programming language has its own major mode, which customizes the
@c syntax tables so that expressions in that language count as sexps.
$B$b$&0lJ}$O!"<0$"$k$$$O(B@dfn{S$B<0(B}$B!J(Bsexp$B!K$r07$&%3%^%s%I72$G$9!#(B
$B!V(Bsexp$B!W$H$$$&MQ8l$O!"(B
Lisp$B$N<0$r0UL#$9$k8E$/$+$i$NMQ8l(B@dfn{s-expression}$B$KM3Mh$7$^$9!#(B
Emacs$B$G$O!V(BS$B<0!W$N35G0$r(BLisp$B$K8BDj$7$^$;$s!#(B
$B%W%m%0%i%`$r5-=R$7$?8@8l$,2?$G$"$C$F$b!"$=$N<0$r(BS$B<0$H8F$S$^$9!#(B
$B3F%W%m%0%i%`8@8l$K$OFH<+$N%a%8%c!<%b!<%I$,$"$j!"(B
$B$=$3$G$O!"$=$N8@8l$N<0$r(BS$B<0$H$_$J$9$h$&$K9=J8%F!<%V%k$rD4@0$7$F$"$j$^$9!#(B
@c Sexps typically include symbols, numbers, and string constants, as well
@c as anything contained in parentheses, brackets or braces.
$B0lHL$K(BS$B<0$K$O!"4]3g8L!"3Q3g8L!"Cf3g8L$K0O$^$l$?ItJ,$@$1$G$J$/!"(B
$B%7%s%\%k!"?tCM!"J8;zNsDj?t$b4^$^$l$^$9!#(B
@c In languages that use prefix and infix operators, such as C, it is not
@c possible for all expressions to be sexps. For example, C mode does not
@c recognize @samp{foo + bar} as a sexp, even though it @emph{is} a C expression;
@c it recognizes @samp{foo} as one sexp and @samp{bar} as another, with the
@c @samp{+} as punctuation between them. This is a fundamental ambiguity:
@c both @samp{foo + bar} and @samp{foo} are legitimate choices for the sexp to
@c move over if point is at the @samp{f}. Note that @samp{(foo + bar)} is a
@c single sexp in C mode.
C$B$N$h$&$KA0CV1i;;;R$HCfCV1i;;;R$r;H$&8@8l$G$O!"(B
$B$9$Y$F$N<0$r(BS$B<0$H$7$F07$&$3$H$OIT2DG=$G$9!#(B
$B$?$H$($P!"(BC$B%b!<%I$G$O!"(B@samp{foo + bar}$B$O(BC$B$N<0(B@emph{$B$G$9(B}$B$,!"(B
S$B<0$H$7$F$OG'<1$7$^$;$s!#(B
$B$+$o$j$K!"(B@samp{foo}$B$H(B@samp{bar}$B$r$=$l$>$l(B1$B$D$N(BS$B<0$H$7$FG'<1$7!"(B
@samp{+}$B$O$"$$$@$K$"$k6gFIE@$H$7$FG'<1$7$^$9!#(B
$B$3$l$O:,K\E*$K[#Kf$J$N$G$9!#(B
$B$?$H$($P!"%]%$%s%H$,(B@samp{f}$B$K$"$k$H$-!"2#CG$9$Y$-(BS$B<0$H$7$F$O!"(B
@samp{foo + bar}$B$G$b(B@samp{foo}$B$G$b@5Ev$JA*Br;h$G$9!#(B
@samp{(foo + bar)}$B$O!"(BC$B%b!<%I$K$*$$$FC10l$N(BS$B<0$G$"$k$3$H$KCm0U$7$F$/$@$5$$!#(B
@c Some languages have obscure forms of expression syntax that nobody
@c has bothered to make Emacs understand properly.
$B<0$N9=J8$,[#Kf$J$?$a$K!"(B
Emacs$B$,@5$7$/2r<a$G$-$k$h$&$K$7$h$&$J$I$H$OC/$b;W$o$J$$8@8l$b$"$j$^$9!#(B
@node List Commands
@c @section List And Sexp Commands
@section $B%j%9%H$H(BS$B<0$KBP$9$k%3%^%s%I(B
@c doublewidecommands
@table @kbd
@item C-M-f
@c Move forward over a sexp (@code{forward-sexp}).
S$B<0$r2#CG$7$FA08~$-$K0\F0$9$k!J(B@code{forward-sexp}$B!K!#(B
@item C-M-b
@c Move backward over a sexp (@code{backward-sexp}).
S$B<0$r2#CG$7$F8e8~$-$K0\F0$9$k!J(B@code{backward-sexp}$B!K!#(B
@item C-M-k
@c Kill sexp forward (@code{kill-sexp}).
$BA08~$-$K(BS$B<0$r%-%k$9$k!J(B@code{kill-sexp}$B!K!#(B
@item C-M-@key{DEL}
@c Kill sexp backward (@code{backward-kill-sexp}).
$B8e8~$-$K(BS$B<0$r%-%k$9$k!J(B@code{backward-kill-sexp}$B!K!#(B
@item C-M-u
@c Move up and backward in list structure (@code{backward-up-list}).
$B%j%9%H9=B$$r(B1$B%l%Y%k>e$,$C$F8e8~$-$K0\F0$9$k!J(B@code{backward-up-list}$B!K!#(B
@item C-M-d
@c Move down and forward in list structure (@code{down-list}).
$B%j%9%H9=B$$r(B1$B%l%Y%k2<$,$C$FA08~$-$K0\F0$9$k!J(B@code{down-list}$B!K!#(B
@item C-M-n
@c Move forward over a list (@code{forward-list}).
$B%j%9%H$r2#CG$7$FA08~$-$K0\F0$9$k!J(B@code{forward-list}$B!K!#(B
@item C-M-p
@c Move backward over a list (@code{backward-list}).
$B%j%9%H$r2#CG$7$F8e8~$-$K0\F0$9$k!J(B@code{backward-list}$B!K!#(B
@item C-M-t
@c Transpose expressions (@code{transpose-sexps}).
$B<0$rF~$lBX$($k!J(B@code{transpose-sexps}$B!K!#(B
@item C-M-@@
@c Put mark after following expression (@code{mark-sexp}).
$B$D$.$N<0$ND>8e$K%^!<%/$r@_Dj$9$k!J(B@code{mark-sexp}$B!K!#(B
@end table
@kindex C-M-f
@kindex C-M-b
@findex forward-sexp
@findex backward-sexp
@c To move forward over a sexp, use @kbd{C-M-f} (@code{forward-sexp}). If
@c the first significant character after point is an opening delimiter
@c (@samp{(} in Lisp; @samp{(}, @samp{[} or @samp{@{} in C), @kbd{C-M-f}
@c moves past the matching closing delimiter. If the character begins a
@c symbol, string, or number, @kbd{C-M-f} moves over that.
S$B<0$r2#CG$7$FA08~$-$K0\F0$9$k$K$O!"(B
@kbd{C-M-f}$B!J(B@code{forward-sexp}$B!K$r;H$$$^$9!#(B
$B%]%$%s%H$KB3$/:G=i$N0UL#$"$kJ8;z$,3+$-6h@Z$j(B
$B!J(BLisp $B$G$O(B@samp{(}$B!"(BC$B$G$O(B@samp{(}$B$d(B@samp{[}$B$d(B@samp{@{}$B!K$G$"$l$P!"(B
$BBP1~$9$kJD$86h@Z$j$N$&$7$m$K0\F0$7$^$9!#(B
$B%7%s%\%k!"J8;zNs!"?tCM$r;O$a$kJ8;z$N>l9g$K$O!"(B
$B$=$l$i$r2#CG$7$F$=$NKvHx$K0\F0$7$^$9!#(B
@c The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a
@c sexp. The detailed rules are like those above for @kbd{C-M-f}, but with
@c directions reversed. If there are any prefix characters (single-quote,
@c backquote and comma, in Lisp) preceding the sexp, @kbd{C-M-b} moves back
@c over them as well. The sexp commands move across comments as if they
@c were whitespace in most modes.
$B%3%^%s%I(B@kbd{C-M-b}$B!J(B@code{backward-sexp}$B!K$O!"(B
S$B<0$r2#CG$7$F8e8~$-$K0\F0$7$^$9!#(B
$B0\F0$N>\$7$$5,B'$O>e5-$N(B@kbd{C-M-f}$B$HF1MM$G$9$,!"J}8~$O5U$G$9!#(B
S$B<0$N$^$($K@\F,<-J8;z!J(BLisp$B$G$O%7%s%0%k%/%)!<%H!"%P%C%/%/%)!<%H!"%3%s%^!K$,(B
$B$"$k>l9g$K$O!"$=$l$i$b2#CG$7$^$9!#(B
$B$[$H$s$I$N%b!<%I$G$O!"(BS$B<0%3%^%s%I$O%3%a%s%H$r6uGr$G$"$k$+$N$h$&$K(B
$BHt$S1[$($^$9!#(B
@c @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation the
@c specified number of times; with a negative argument, it moves in the
@c opposite direction.
@kbd{C-M-f}$B$d(B@kbd{C-M-b}$B$K0z?t$r;XDj$9$k$H!"(B
$B;XDj$5$l$?2s?t$@$1F0:n$r7+$jJV$7$^$9!#(B
$BIi$N0z?t$G$O!"5U8~$-$K0\F0$7$^$9!#(B
@kindex C-M-k
@findex kill-sexp
@kindex C-M-DEL
@findex backward-kill-sexp
@c Killing a whole sexp can be done with @kbd{C-M-k} (@code{kill-sexp})
@c or @kbd{C-M-@key{DEL}} (@code{backward-kill-sexp}). @kbd{C-M-k} kills
@c the characters that @kbd{C-M-f} would move over, and @kbd{C-M-@key{DEL}}
@c kills the characters that @kbd{C-M-b} would move over.
1$B$D$N(BS$B<0A4BN$r%-%k$9$k$K$O!"(B@kbd{C-M-k}$B!J(B@code{kill-sexp}$B!K$d(B
@kbd{C-M-@key{DEL}}$B!J(B@code{backward-kill-sexp}$B!K$G9T$$$^$9!#(B
@kbd{C-M-k}$B$O(B@kbd{C-M-f}$B$G2#CG$9$k$@$1$NJ8;z$r%-%k$7!"(B
@kbd{C-M-@key{DEL}}$B$O(B@kbd{C-M-b}$B$G2#CG$9$k$@$1$NJ8;z$r%-%k$7$^$9!#(B
@kindex C-M-n
@kindex C-M-p
@findex forward-list
@findex backward-list
@c The @dfn{list commands} move over lists, as the sexp commands do, but skip
@c blithely over any number of other kinds of sexps (symbols, strings, etc.).
@c They are @kbd{C-M-n} (@code{forward-list}) and @kbd{C-M-p}
@c (@code{backward-list}). The main reason they are useful is that they
@c usually ignore comments (since the comments usually do not contain any
@c lists).@refill
S$B<0%3%^%s%I$HF1MM$K!"(B@dfn{$B%j%9%H%3%^%s%I(B}$B$O%j%9%H$r2#CG$7$^$9$,!"(B
$B%j%9%H0J30$N(BS$B<0!J%7%s%\%k$dJ8;zNs$J$I!K$OHt$S1[$7$^$9!#(B
$B$3$l$i$N%3%^%s%I$O!"(B@kbd{C-M-n}$B!J(B@code{forward-list}$B!K$H(B
@kbd{C-M-p}$B!J(B@code{backward-list}$B!K$G$9!#(B
$B$3$l$i$N%3%^%s%I$,JXMx$G$"$k<g$JM}M3$O!"(B
$B!J%3%a%s%H$K$O%j%9%H$,2?$b4^$^$l$J$$$N$,IaDL$J$N$G!K(B
$B%3%a%s%H$rL5;k$9$k$+$i$G$9!#(B
@kindex C-M-u
@kindex C-M-d
@findex backward-up-list
@findex down-list
@c @kbd{C-M-n} and @kbd{C-M-p} stay at the same level in parentheses, when
@c that's possible. To move @emph{up} one (or @var{n}) levels, use @kbd{C-M-u}
@c (@code{backward-up-list}).
@c @kbd{C-M-u} moves backward up past one unmatched opening delimiter. A
@c positive argument serves as a repeat count; a negative argument reverses
@c direction of motion and also requests repetition, so it moves forward and
@c up one or more levels.@refill
@kbd{C-M-n}$B$H(B@kbd{C-M-p}$B$O!"2DG=$J8B$jF1$8%l%Y%k$N3g8L$K$H$I$^$j$^$9!#(B
1$B$D!J$"$k$$$O(B@var{n}$B$@$1!K(B@emph{$B>e$N(B}$B%l%Y%k$K0\F0$9$k$K$O!"(B
@kbd{C-M-u}$B!J(B@code{backward-up-list}$B!K$r;H$$$^$9!#(B
@kbd{C-M-u}$B$O!"BP1~$N<h$l$F$$$J$$3+$-6h@Z$j$N$^$($X8e8~$-$K0\F0$7$F!"(B
1$B$D%l%Y%k$r>e$2$^$9!#(B
$B@5$N0z?t$OH?I|2s?t$K$J$j$^$9!#(B
$BIi$N0z?t$O!"0\F0$r5U8~$-$K$7$^$9$,!"$d$O$jH?I|2s?t$G$9!#(B
$B$D$^$j!"A08~$-$K0\F0$7$F!"(B1$B$D0J>e%l%Y%k$r>e$2$^$9!#(B
@c To move @emph{down} in list structure, use @kbd{C-M-d}
@c (@code{down-list}). In Lisp mode, where @samp{(} is the only opening
@c delimiter, this is nearly the same as searching for a @samp{(}. An
@c argument specifies the number of levels of parentheses to go down.
$B%j%9%H9=B$Cf$G(B@emph{$B2<(B}$B$N%l%Y%k$K0\F0$9$k$K$O!"(B
@kbd{C-M-d}$B!J(B@code{down-list}$B!K$r;H$$$^$9!#(B
Lisp$B%b!<%I$G$O!"(B@samp{(}$B$,M#0l$N3+$-6h@Z$j$J$N$G!"(B
$B$3$N%3%^%s%I$O(B@samp{(}$B$rC5:w$9$k$N$H$[$H$s$IF1$8$G$9!#(B
$B0z?t$O2<$,$k$Y$-3g8L$N%l%Y%k$r;XDj$7$^$9!#(B
@c @cindex transposition
@cindex $BF~$lBX$((B
@kindex C-M-t
@findex transpose-sexps
@c A somewhat random-sounding command which is nevertheless handy is
@c @kbd{C-M-t} (@code{transpose-sexps}), which drags the previous sexp
@c across the next one. An argument serves as a repeat count, and a
@c negative argument drags backwards (thus canceling out the effect of
@c @kbd{C-M-t} with a positive argument). An argument of zero, rather than
@c doing nothing, transposes the sexps ending after point and the mark.
$BK\Ev$OLr$KN)$D$N$K!"2?$NLr$KN)$D$N$@$m$&$H;W$o$l$k%3%^%s%I$,(B
@kbd{C-M-t}$B!J(B@code{transpose-sexps}$B!K$G$9!#(B
$B$3$l$O%]%$%s%H$N$^$($K$"$k(BS$B<0$r!"$D$.$K$"$k(BS$B<0$r1[$($F0\F0$9$k%3%^%s%I$G$9!#(B
$B0z?t$OH?I|2s?t$H$J$j!"Ii$N0z?t$G$O8e8~$-$K(BS$B<0$r0\F0$7$^$9(B
$B!J$D$^$j@5$N0z?t$r;XDj$7$?(B@kbd{C-M-t}$B$N8z2L$rBG$A>C$;$k!K!#(B
$B0z?t$,(B0$B$N>l9g$O!"2?$b$7$J$$$N$G$O$J$/$F!"(B
$B%]%$%s%H$N$"$H$K$"$k(BS$B<0$H%^!<%/$N$"$H$K$"$k(BS$B<0$rF~$lBX$($^$9!#(B
@kindex C-M-@@
@findex mark-sexp
@c To set the region around the next sexp in the buffer, use @kbd{C-M-@@}
@c (@code{mark-sexp}), which sets mark at the same place that @kbd{C-M-f}
@c would move to. @kbd{C-M-@@} takes arguments like @kbd{C-M-f}. In
@c particular, a negative argument is useful for putting the mark at the
@c beginning of the previous sexp.
$B%P%C%U%!Fb$G$D$.$K$"$k(BS$B<0$N<~$j$K%j!<%8%g%s$r@_Dj$9$k$K$O!"(B
@kbd{C-M-@@}$B!J(B@code{mark-sexp}$B!K$r;H$$$^$9!#(B
$B$3$N%3%^%s%I$O!"(B@kbd{C-M-f}$B$K$h$k0\F0@h$K%^!<%/$r@_Dj$7$^$9!#(B
@kbd{C-M-@@}$B$O!"(B@kbd{C-M-f}$B$HF1MM$K0z?t$r<h$j$^$9!#(B
$B$H$j$o$1!"Ii$N0z?t$O!"D>A0$N(BS$B<0$N@hF,$K%^!<%/$r@_Dj$9$k$N$KJXMx$G$9!#(B
@c The list and sexp commands' understanding of syntax is completely
@c controlled by the syntax table. Any character can, for example, be
@c declared to be an opening delimiter and act like an open parenthesis.
@c @xref{Syntax}.
$B%j%9%H$*$h$S(BS$B<0%3%^%s%I$,9T$&9=J8$N2r<a$O!"(B
$B9=J8%F!<%V%k$K40A4$K;YG[$5$l$^$9!#(B
$B$?$H$($P!"G$0U$NJ8;z$r3+$-6h@Z$j$H$7$F@k8@$G$-$F!"(B
$B$=$&$9$k$H3+$-3g8L$N$h$&$K$U$k$^$&$h$&$K$J$j$^$9!#(B
@xref{Syntax}$B!#(B
@node Defuns
@c @section Defuns
@section $B4X?tDj5A!J(Bdefun$B!K(B
@c @cindex defuns
@cindex $B4X?tDj5A!J(Bdefun$B!K(B
@cindex defun$B!J4X?tDj5A!K(B
@c In Emacs, a parenthetical grouping at the top level in the buffer is
@c called a @dfn{defun}. The name derives from the fact that most top-level
@c lists in a Lisp file are instances of the special form @code{defun}, but
@c any top-level parenthetical grouping counts as a defun in Emacs parlance
@c regardless of what its contents are, and regardless of the programming
@c language in use. For example, in C, the body of a function definition is a
@c defun.
Emacs$B$G$O!"%H%C%W%l%Y%k$N3g8L$G%0%k!<%W2=$7$?$b$N$O(B
@dfn{$B4X?tDj5A(B}$B!J(Bdefun$B!K$H8F$P$l$^$9!#(B
$B$3$NL>A0$O!"(BLisp$B%U%!%$%k$G$O%H%C%W%l%Y%k$K$"$k%j%9%H$NBgH>$,(B
$B%9%Z%7%c%k%U%)!<%`(B@code{defun}$B$G$"$k$H$$$&;v<B$KM3Mh$7$^$9!#(B
$B$7$+$7!"$=$NCf?H$,2?$G$"$m$&$H$b!"$^$?!";HMQ%W%m%0%i%`8@8l$,2?$G$"$m$&$H$b!"(B
Emacs$BN.$K$O!"%H%C%W%l%Y%k$N3g8L$G%0%k!<%W2=$5$l$?$b$N$O(B
$B$9$Y$F4X?tDj5A!J(Bdefun$B!K$G$9!#(B
$B$?$H$($P!"(BC$B$N4X?tDj5A$NK\BN$O4X?tDj5A!J(Bdefun$B!K$G$9!#(B
@c doublewidecommands
@table @kbd
@item C-M-a
@c Move to beginning of current or preceding defun
@c (@code{beginning-of-defun}).
$B8=:_$N4X?tDj5A!"$"$k$$$O!"D>A0$N4X?tDj5A$N@hF,$K0\F0$9$k(B
$B!J(B@code{beginning-of-defun}$B!K!#(B
@item C-M-e
@c Move to end of current or following defun (@code{end-of-defun}).
$B8=:_$N4X?tDj5A!"$"$k$$$O!"$D$.$N4X?tDj5A$NKvHx$K0\F0$9$k(B
$B!J(B@code{end-of-defun}$B!K!#(B
@item C-M-h
@c Put region around whole current or following defun (@code{mark-defun}).
$B8=:_$N4X?tDj5A!"$"$k$$$O!"$D$.$N4X?tDj5A$r0O$`%j!<%8%g%s$r@_Dj$9$k(B
$B!J(B@code{mark-defun}$B!K!#(B
@end table
@kindex C-M-a
@kindex C-M-e
@kindex C-M-h
@findex beginning-of-defun
@findex end-of-defun
@findex mark-defun
@c The commands to move to the beginning and end of the current defun are
@c @kbd{C-M-a} (@code{beginning-of-defun}) and @kbd{C-M-e} (@code{end-of-defun}).
$B8=:_$N4X?tDj5A$N@hF,$dKvHx$K0\F0$9$k%3%^%s%I$O!"(B
@kbd{C-M-a}$B!J(B@code{beginning-of-defun}$B!K$H(B
@kbd{C-M-e}$B!J(B@code{end-of-defun}$B!K$G$9!#(B
@findex c-mark-function
@c If you wish to operate on the current defun, use @kbd{C-M-h}
@c (@code{mark-defun}) which puts point at the beginning and mark at the end
@c of the current or next defun. For example, this is the easiest way to get
@c ready to move the defun to a different place in the text. In C mode,
@c @kbd{C-M-h} runs the function @code{c-mark-function}, which is almost the
@c same as @code{mark-defun}; the difference is that it backs up over the
@c argument declarations, function name and returned data type so that the
@c entire C function is inside the region. @xref{Marking Objects}.
$B8=:_$N4X?tDj5A$rA`:n$7$?$$$N$G$"$l$P!"(B
@kbd{C-M-h}$B!J(B@code{mark-defun}$B!K$r;H$C$F!"(B
$B8=:_$N4X?tDj5A$+$D$.$N4X?tDj5A$N@hF,$K%]%$%s%H$rCV$-!"(B
$B$=$NKvHx$K%^!<%/$r@_Dj$7$^$9!#(B
$B$?$H$($P!"4X?tDj5A$r%F%-%9%H$NJL$N0LCV$K0\F0$9$k=`Hw$r$9$k$K$O!"(B
$B$3$N%3%^%s%I$r;H$&$N$,$b$C$H$b4JC1$JJ}K!$G$9!#(B
C$B%b!<%I$G$O!"(B@kbd{C-M-h}$B$O(B@code{c-mark-function}$B$r<B9T$7$^$9$,!"(B
@code{mark-defun}$B$H$[$H$s$IF1$8$G$9!#(B
$B0c$$$O!"0z?t@k8@!"4X?tL>!"La$jCM$N7?L>$HAL$C$F!"(B
C$B$N4X?tA4BN$r%j!<%8%g%s$K4^$a$k$3$H$G$9!#(B
@xref{Marking Objects}$B!#(B
@c Emacs assumes that any open-parenthesis found in the leftmost column
@c is the start of a defun. Therefore, @strong{never put an
@c open-parenthesis at the left margin in a Lisp file unless it is the
@c start of a top-level list. Never put an open-brace or other opening
@c delimiter at the beginning of a line of C code unless it starts the body
@c of a function.} The most likely problem case is when you want an
@c opening delimiter at the start of a line inside a string. To avoid
@c trouble, put an escape character (@samp{\}, in C and Emacs Lisp,
@c @samp{/} in some other Lisp dialects) before the opening delimiter. It
@c will not affect the contents of the string.
Emacs$B$O!"$b$C$H$b:8$N7e$G$_$D$1$?G$0U$N3+$-3g8L$r(B
$B4X?tDj5A$N;O$^$j$G$"$k$H2>Dj$7$^$9!#(B
$B$7$?$,$C$F!"(B@strong{$B%H%C%W%l%Y%k$N%j%9%H$N;O$^$j$G$J$$8B$j!"(B
Lisp$B%U%!%$%k$NCf$G$O:8C<$K3+$-3g8L$rCV$$$F$O$$$1$^$;$s!#(B
$B$^$?!"4X?tK\BN$N;O$^$j$rI=$9$N$G$J$$8B$j!"(B
C$B$N%3!<%I$N9TF,$K3+$-Cf3g8L$d3+$-6h@Z$j$rCV$$$F$O$$$1$^$;$s!#(B}
$B$b$C$H$b5/$3$j$d$9$$>lLL$O!"(B
$BJ8;zNs$NESCf$G!"9TF,$K3+$-6h@Z$j$rF~$l$?$$>l9g$G$9!#(B
$B%H%i%V%k$rHr$1$k$?$a$K!"3+$-6h@Z$j$N$^$($K(B
$B%(%9%1!<%WJ8;z!J(BC$B$d(BEmacs Lisp$B$G$O(B @samp{\}$B!"(B
$B$=$NB>$N(BLisp$BJ}8@$N$$$/$D$+$G$O(B@samp{/}$B!K$rF~$l$F$/$@$5$$!#(B
$B$3$l$GJ8;zNs$NFbMF$,1F6A$r<u$1$k$3$H$O$"$j$^$;$s!#(B
@c In the remotest past, the original Emacs found defuns by moving upward a
@c level of parentheses until there were no more levels to go up. This always
@c required scanning all the way back to the beginning of the buffer, even for
@c a small function. To speed up the operation, Emacs was changed to assume
@c that any @samp{(} (or other character assigned the syntactic class of
@c opening-delimiter) at the left margin is the start of a defun. This
@c heuristic is nearly always right and avoids the costly scan; however,
@c it mandates the convention described above.
$BBg@N$N$b$H$b$H$N(BEmacs$B$G$O!"4X?tDj5A$rC5$9$?$a$K!"(B
$B$h$j>e0L%l%Y%k$N3g8L$,$J$/$J$k$^$GAL$C$F$$$^$7$?!#(B
$B$3$NJ}K!$G$O!"$?$H$(>.$5$J4X?t$G$"$C$F$b!"(B
$B%P%C%U%!$N@hF,$^$GAL$C$FAv::$9$k$3$H$,$D$M$KI,MW$G$7$?!#(B
$B$3$l$r9bB.2=$9$k$?$a$K!":8C<Fb$NG$0U$N(B@samp{(}
$B!J$"$k$$$O!"3+$-6h@Z$j$H@k8@$5$l$?G$0U$NJ8;z!K$,(B
$B4X?tDj5A$N;O$^$j$G$"$k$H2>Dj$9$k$h$&$K!"(BEmacs$B$rJQ99$7$^$7$?!#(B
$B$3$NH/8+E*<jK!$G!"$[$H$s$I@5$7$/=hM}$G$-$F!";~4V$N$+$+$kAv::$r2sHr$G$-$^$9!#(B
$B$7$+$7!">e=R$NLsB+;v$OI,MW$G$9!#(B
@node Program Indent
@c @section Indentation for Programs
@section $B%W%m%0%i%`$N;z2<$2(B
@c @cindex indentation for programs
@cindex $B%W%m%0%i%`$N;z2<$2(B
@c The best way to keep a program properly indented is to use Emacs to
@c reindent it as you change it. Emacs has commands to indent properly
@c either a single line, a specified number of lines, or all of the lines
@c inside a single parenthetical grouping.
$B@5$7$/;z2<$2$5$l$?>uBV$K%W%m%0%i%`$rJ]$D:GNI$NJ}K!$O!"(B
$BJQ99$7$?$i(BEmacs$B$K;z2<$2$r$d$jD>$5$;$k$3$H$G$9!#(B
Emacs$B$K$O!"(B1$B9T$N;z2<$2!";XDj$5$l$?9T?t$N;z2<$2!"$"$k$$$O!"(B
$B3g8L$G%0%k!<%W2=$7$?FbIt$N$9$Y$F$N9T$N;z2<$2$r9T$&%3%^%s%I$,$"$j$^$9!#(B
@menu
* Basic Indent:: Indenting a single line.
* Multi-line Indent:: Commands to reindent many lines at once.
* Lisp Indent:: Specifying how each Lisp function should be indented.
* C Indent:: Extra features for indenting C and related modes.
* Custom C Indent:: Controlling indentation style for C and related modes.
@end menu
@c Emacs also provides a Lisp pretty-printer in the library @code{pp}.
@c This program reformats a Lisp object with indentation chosen to look nice.
Emacs$B$G$O!"%i%$%V%i%j(B@code{pp}$B$K(BLisp$B$N%W%j%F%#%W%j%s%?(B@footnote{$B!ZLuCm![(B
$B%W%m%0%i%`$N%=!<%9%3!<%I$rH~$7$/@6=q$9$k%W%m%0%i%`$r(B
$B0lHL$K%W%j%F%#%W%j%s%?!J(Bpretty-printer$B!K$H8F$V!#(B}
$B$b$"$j$^$9!#(B
$B$3$N%W%m%0%i%`$O!"H~$7$/8+$($k$h$&$K;z2<$2$r;\$7$F(BLisp$B%*%V%8%'%/%H$r(B
$B@6=q$9$k%W%m%0%i%`$G$9!#(B
@node Basic Indent
@c @subsection Basic Program Indentation Commands
@subsection $B%W%m%0%i%`$N;z2<$24pK\%3%^%s%I(B
@c WideCommands
@table @kbd
@item @key{TAB}
@c Adjust indentation of current line.
$B8=:_9T$N;z2<$2$rD4@0$9$k!#(B
@item C-j
@c Equivalent to @key{RET} followed by @key{TAB} (@code{newline-and-indent}).
@key{RET}$B$KB3$1$F(B@key{TAB}$B$HBG80$9$k$N$HF1$8(B
$B!J(B@code{newline-and-indent}$B!K!#(B
@end table
@c @kindex TAB @r{(programming modes)}
@kindex TAB @r{$B!J%W%m%0%i%_%s%0%b!<%I!K(B}
@findex c-indent-line
@findex lisp-indent-line
@c The basic indentation command is @key{TAB}, which gives the current line
@c the correct indentation as determined from the previous lines. The
@c function that @key{TAB} runs depends on the major mode; it is @code{lisp-indent-line}
@c in Lisp mode, @code{c-indent-line} in C mode, etc. These functions
@c understand different syntaxes for different languages, but they all do
@c about the same thing. @key{TAB} in any programming-language major mode
@c inserts or deletes whitespace at the beginning of the current line,
@c independent of where point is in the line. If point is inside the
@c whitespace at the beginning of the line, @key{TAB} leaves it at the end of
@c that whitespace; otherwise, @key{TAB} leaves point fixed with respect to
@c the characters around it.
$B4pK\E*$J;z2<$2%3%^%s%I$O(B@key{TAB}$B$G$9!#(B
$BD>A0$N?t9T$+$iH=CG$7$?@5$7$$;z2<$2$r8=:_9T$K;\$7$^$9!#(B
@key{TAB}$B$,<B9T$9$k4X?t$O!"%a%8%c!<%b!<%I$K0MB8$7$^$9!#(B
$B$?$H$($P!"(BLisp$B%b!<%I$G$O(B@code{lisp-indent-line}$B!"(B
C$B%b!<%I$G$O(B@code{c-indent-line}$B$,<B9T$5$l$^$9!#(B
$B$3$l$i$N4X?t$O$=$l$>$l$N8@8l$N9=J8$r2r<a$7$^$9$,!"(B
$B$I$l$bF1$8$3$H$r9T$&$?$a$N$b$N$G$9!#(B
$B%W%m%0%i%`8@8l8~$1%a%8%c!<%b!<%I$K$*$$$F$O!"(B
@key{TAB}$B$O!"8=:_9T$N$I$3$K%]%$%s%H$,$"$C$F$b!"(B
$B8=:_9T$N@hF,$KGrJ8;z$rA^F~$7$?$j:o=|$7$?$j$7$^$9!#(B
$B%]%$%s%H$,9TF,$NGrJ8;z$NCf$K$"$C$?$H$-$O!"(B
@key{TAB}$B$O:G8e$NGrJ8;z$N$&$7$m$K%]%$%s%H$rCV$-$^$9!#(B
$B$=$&$G$J$1$l$P!"(B@key{TAB}$B$rBG$C$?$H$-$NJ8;z$N$H$3$m$KN1$^$j$^$9!#(B
@c Use @kbd{C-q @key{TAB}} to insert a tab at point.
$B%]%$%s%H0LCV$K%?%V$rA^F~$9$k$K$O!"(B@kbd{C-q @key{TAB}}$B$r;H$$$^$9!#(B
@kindex C-j
@findex newline-and-indent
@c When entering lines of new code, use @kbd{C-j} (@code{newline-and-indent}),
@c which is equivalent to a @key{RET} followed by a @key{TAB}. @kbd{C-j} creates
@c a blank line and then gives it the appropriate indentation.
$B?7$?$K%=!<%9%3!<%I9T$rF~NO$9$k$H$-$K$O!"(B
@kbd{C-j}$B!J(B@code{newline-and-indent}$B!K$r;H$C$F$/$@$5$$!#(B
$B$3$l$O!"(B@key{RET}$B$KB3$1$F(B@key{TAB}$B$rBG80$9$k$3$H$HEy2A$G$9!#(B
@kbd{C-j}$B$O!"6u9T$r:n$C$F$+$i!"$=$N9T$GE,@Z$J;z2<$2$r9T$$$^$9!#(B
@c @key{TAB} indents the second and following lines of the body of a
@c parenthetical grouping each under the preceding one; therefore, if you
@c alter one line's indentation to be nonstandard, the lines below will
@c tend to follow it. This behavior is convenient in cases where you have
@c overridden the standard result of @key{TAB} because you find it
@c unaesthetic for a particular line.
$B3g8L$G%0%k!<%W$K$^$H$a$?$H$3$m$G$O!"(B
@key{TAB}$B$O!"(B2$B9TL\0J9_$N9T$r$=$l$>$lD>A0$N9T$N??2<$K$/$k$h$&$K;z2<$2$7$^$9!#(B
$B$7$?$,$C$F!"$"$k9T$rHsI8=`E*$J;z2<$2$K$9$k$H!"(B
$B0J9_$N9T$b$=$N;z2<$2$K=>$&$3$H$K$J$j$^$9!#(B
@key{TAB}$B$K$h$kI8=`E*$J;z2<$2$,!"(B
$BFCDj$N9T$G$OH~$7$/$J$$$N$GL5;k$7$?$$>l9g$K$O!"(B
$B;z2<$2$N$3$N$h$&$J$U$k$^$$$,JXMx$G$9!#(B
@c Remember that an open-parenthesis, open-brace or other opening delimiter
@c at the left margin is assumed by Emacs (including the indentation routines)
@c to be the start of a function. Therefore, you must never have an opening
@c delimiter in column zero that is not the beginning of a function, not even
@c inside a string. This restriction is vital for making the indentation
@c commands fast; you must simply accept it. @xref{Defuns}, for more
@c information on this.
$B!J;z2<$2=hM}$r4^$a$F!K(BEmacs$B$O!":8C<$K$"$k!"3+$-4]3g8L!"3+$-Cf3g8L!"(B
$B$*$h$S!"$=$NB>$N3+$-6h@Z$j$r4X?t$N;O$^$j$H2>Dj$9$k$3$H$r(B
$B3P$($F$*$-$^$7$g$&!#(B
$B$?$H$(J8;zNs$NCf$G$"$C$F$b!"(B
$B4X?t$N;O$^$j$G$J$$3+$-6h@Z$j$r$1$C$7$F(B0$B7eL\$KCV$$$F$O$$$1$^$;$s!#(B
$B$3$N@)Ls$O;z2<$2%3%^%s%I$r9bB.$K$9$k$?$a$K$-$o$a$F=EMW$G$9!#(B
$BL5>r7o$G<u$1F~$l$F$/$@$5$$!#(B
$B$3$l$K4X$7$F$h$j>\$7$/$O!"(B@xref{Defuns}$B!#(B
@node Multi-line Indent
@c @subsection Indenting Several Lines
@subsection $BJ#?t9T$N;z2<$2(B
@c When you wish to reindent several lines of code which have been altered
@c or moved to a different level in the list structure, you have several
@c commands available.
$BJQ99$7$?J#?t9T$d!"%j%9%H9=B$Cf$N0[$J$k%l%Y%k2U=j$X0\$7$?J#?t$N9T$r(B
$B;z2<$2$7D>$9$K$O!"$$$/$D$+$N%3%^%s%I$rMxMQ$G$-$^$9!#(B
@table @kbd
@item C-M-q
@c Reindent all the lines within one list (@code{indent-sexp}).
$B%j%9%HFb$N$9$Y$F$N9T$r;z2<$2$7D>$9!J(B@code{indent-sexp}$B!K!#(B
@item C-u @key{TAB}
@c Shift an entire list rigidly sideways so that its first line
@c is properly indented.
$B%j%9%H$N:G=i$N9T$,@5$7$$;z2<$20LCV$K$/$k$h$&$K!"(B
$B%j%9%H$N$9$Y$F$N9T$r2#$K$=$N$^$^F0$+$9!#(B
@item C-M-\
@c Reindent all lines in the region (@code{indent-region}).
$B%j!<%8%g%sFb$N$9$Y$F$N9T$r;z2<$2$7D>$9!J(B@code{indent-region}$B!K!#(B
@end table
@kindex C-M-q
@findex indent-sexp
@c You can reindent the contents of a single list by positioning point
@c before the beginning of it and typing @kbd{C-M-q} (@code{indent-sexp} in
@c Lisp mode, @code{c-indent-exp} in C mode; also bound to other suitable
@c commands in other modes). The indentation of the line the sexp starts on
@c is not changed; therefore, only the relative indentation within the list,
@c and not its position, is changed. To correct the position as well, type a
@c @key{TAB} before the @kbd{C-M-q}.
1$B$D$N%j%9%H$NCf?H$r;z2<$2$7D>$9$K$O!"(B
$B%j%9%H$N;O$^$j0LCV$K%]%$%s%H$rCV$$$F(B
@kbd{C-M-q}$B!J(BLisp$B%b!<%I$G$O(B@code{indent-sexp}$B!"(B
C$B%b!<%I$G$O(B@code{c-indent-exp}$B!"(B
$BB>$N%b!<%I$G$OE,@Z$J%3%^%s%I$K%P%$%s%I$5$l$F$$$k!K$HBG$A$^$9!#(B
S$B<0$,;O$^$k9T$N;z2<$2$OJQ2=$7$^$;$s!#(B
$B$D$^$j!"%j%9%HFb$NAjBPE*$J;z2<$2$,JQ2=$9$k$@$1$G!"(B
$B%j%9%H$N0LCV$OJQ$o$j$^$;$s!#(B
$B%j%9%H$N3+;O0LCV$bD>$9$K$O!"(B@kbd{C-M-q}$B$N$^$($K(B@key{TAB}$B$rBG$C$F$/$@$5$$!#(B
@kindex C-u TAB
@c If the relative indentation within a list is correct but the
@c indentation of its first line is not, go to that line and type @kbd{C-u
@c @key{TAB}}. @key{TAB} with a numeric argument reindents the current
@c line as usual, then reindents by the same amount all the lines in the
@c grouping starting on the current line. In other words, it reindents the
@c whole grouping rigidly as a unit. It is clever, though, and does not
@c alter lines that start inside strings, or C preprocessor lines when in C
@c mode.
$B%j%9%HFb$NAjBPE*$J;z2<$2$O@5$7$$$1$l$I$b!"(B
$B%j%9%H$N3+;O9T$N;z2<$2$,@5$7$/$J$$>l9g$K$O!"(B
$B$=$N9T$K0\F0$7$F(B@kbd{C-u @key{TAB}}$B$HBG$A$^$9!#(B
@key{TAB}$B$K?t0z?t$r;XDj$9$k$H!"DL>o$I$*$j8=:_9T$r;z2<$2$7$F$+$i!"(B
$B$=$N9T$+$i;O$^$k%j%9%HFb$N$9$Y$F$N9T$K$bF1$8NL$N;z2<$2$r2C$($^$9!#(B
$B$$$$$+$($l$P!"%0%k!<%WA4BN$r$R$H$^$H$a$K;z2<$2$7D>$7$^$9!#(B
$B$?$@$7!"$3$N%3%^%s%I$O8-$/$F!"J8;zNs$NCf$N9T$O0\F0$7$^$;$s$7!"(B
C$B%b!<%I$G$O%W%j%W%m%;%C%59T$r0\F0$7$^$;$s!#(B
@c Another way to specify the range to be reindented is with the region.
@c The command @kbd{C-M-\} (@code{indent-region}) applies @key{TAB} to
@c every line whose first character is between point and mark.
$B;z2<$2$7D>$9HO0O$r;XDj$9$k$K$O!"%j!<%8%g%s$r;H$&$3$H$b$G$-$^$9!#(B
$B%3%^%s%I(B@kbd{C-M-\}$B!J(B@code{indent-region}$B!K$O!"(B
$B%]%$%s%H$H%^!<%/$N$"$$$@$K(B
$B9T$N@hF,J8;z$,4^$^$l$k$9$Y$F$N9T$K$D$$$F(B@key{TAB}$B$r<B9T$7$^$9!#(B
@node Lisp Indent
@c @subsection Customizing Lisp Indentation
@subsection Lisp$B$N;z2<$2$N%+%9%?%^%$%:(B
@c @cindex customizing Lisp indentation
@cindex Lisp$B$N;z2<$2$N%+%9%?%^%$%:(B
@c The indentation pattern for a Lisp expression can depend on the function
@c called by the expression. For each Lisp function, you can choose among
@c several predefined patterns of indentation, or define an arbitrary one with
@c a Lisp program.
Lisp$B<0$KBP$9$k;z2<$2$N;EJ}$r!"(B
$B$=$N<0$+$i8F$P$l$k4X?t$H4X78IU$1$k$3$H$,$G$-$^$9!#(B
$B3F(BLisp$B4X?t$KBP$7$F!"$"$i$+$8$aDj5A$5$l$?;z2<$2%Q%?!<%s$NCf$+$iA*$s$@$j!"(B
Lisp$B%W%m%0%i%`$GG$0U$N$b$N$rDj5A$7$?$j$G$-$^$9!#(B
@c The standard pattern of indentation is as follows: the second line of the
@c expression is indented under the first argument, if that is on the same
@c line as the beginning of the expression; otherwise, the second line is
@c indented underneath the function name. Each following line is indented
@c under the previous line whose nesting depth is the same.
$B;z2<$2$NI8=`%Q%?!<%s$O!"$D$.$N$H$*$j$G$9!#(B
$B<0$N3+;O9T$K4X?t8F$S=P$7$N0z?t$,$"$k>l9g$O!"(B
$B:G=i$N0z?t$ND>2<$K(B2$B9TL\$,$/$k$h$&$K;z2<$2$7$^$9!#(B
$B$=$l0J30$N>l9g$O!"4X?tL>$ND>2<$K(B2$B9TL\$,$/$k$h$&$K;z2<$2$7$^$9!#(B
$BB3$/3F9T$O!"F~$l;R$N?<$5$,F1$8$G$"$k9T$N;z2<$2$HF1$8$K$J$j$^$9!#(B
@vindex lisp-indent-offset
@c If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides
@c the usual indentation pattern for the second line of an expression, so that
@c such lines are always indented @code{lisp-indent-offset} more columns than
@c the containing list.
$BJQ?t(B@code{lisp-indent-offset}$B$,(B@code{nil}$B0J30$J$i$P!"(B
$B<0$N(B2$B9TL\$KBP$9$kDL>o$N;z2<$2%Q%?!<%s$rL58z$K$7$F!"(B
$B<0$N3+;O7e$+$i$D$M$K(B@code{lisp-indent-offset}$B$@$1;z2<$2$7$^$9!#(B
@vindex lisp-body-indent
@c The standard pattern is overridden for certain functions. Functions
@c whose names start with @code{def} always indent the second line by
@c @code{lisp-body-indent} extra columns beyond the open-parenthesis
@c starting the expression.
$BI8=`%Q%?!<%s$,;HMQ$5$l$J$$4X?t$b$$$/$D$+$"$j$^$9!#(B
$BL>A0$,(B@code{def}$B$G;O$^$k4X?t$KBP$7$F$O!"(B
$B<0$r3+;O$9$k3+$-3g8L$N7e0LCV$K(B@code{lisp-body-indent}$B$r2C$($?7e0LCV$X(B
2$B9TL\$,$/$k$h$&$K;z2<$2$7$^$9!#(B
@c The standard pattern can be overridden in various ways for individual
@c functions, according to the @code{lisp-indent-function} property of the
@c function name. There are four possibilities for this property:
$B4X?tL>$NB0@-(B@code{lisp-indent-function}$B$rJQ99$9$l$P!"(B
$B3F4X?t$4$H$KI8=`%Q%?!<%s0J30$N;z2<$2$r;\$;$^$9!#(B
$B$3$NB0@-$,<h$j$($kCM$K$O$D$.$N(B4$B$D$,$"$j$^$9!#(B
@table @asis
@item @code{nil}
@c This is the same as no property; the standard indentation pattern is used.
$BB0@-$,$J$$$N$HF1$8!#I8=`$N;z2<$2%Q%?!<%s$r;HMQ$9$k!#(B
@item @code{defun}
@c The pattern used for function names that start with @code{def} is used for
@c this function also.
$BL>A0$,(B@code{def}$B$G;O$^$k4X?t$KMQ$$$k;z2<$2%Q%?!<%s$r;HMQ$9$k!#(B
@c @item a number, @var{number}
@item $B?tCM(B @var{number}
@c The first @var{number} arguments of the function are
@c @dfn{distinguished} arguments; the rest are considered the @dfn{body}
@c of the expression. A line in the expression is indented according to
@c whether the first argument on it is distinguished or not. If the
@c argument is part of the body, the line is indented @code{lisp-body-indent}
@c more columns than the open-parenthesis starting the containing
@c expression. If the argument is distinguished and is either the first
@c or second argument, it is indented @emph{twice} that many extra columns.
@c If the argument is distinguished and not the first or second argument,
@c the standard pattern is followed for that line.
$B4X?t$N:G=i$N(B@var{number}$B8D$N0z?t$r(B@dfn{$B6hJL$5$l$?(B}$B0z?t$H8F$S!"(B
$B;D$j$r<0$N(B@dfn{$BK\BN(B}$B$H8F$V!#(B
$B9T$N:G=i$N0z?t$,6hJL$5$l$?0z?t$+$I$&$+$K$h$C$F!"3F9T$N;z2<$2$,0[$J$k!#(B
$B0z?t$,K\BN$N0lIt$J$i$P!"$=$l$r4^$s$@<0$r3+;O$9$k3+$-3g8L$N7e0LCV$K(B
@code{lisp-body-indent}$B$r2C$($?7e0LCV$X;z2<$2$9$k!#(B
$B0z?t$,6hJL$5$l$?0z?t$G:G=i$+(B2$BHVL\$J$i$P!"(B
@code{lisp-body-indent}$B$N(B@emph{2$BG\(B}$B$r2C$($?7e0LCV$X;z2<$2$9$k!#(B
$B0z?t$,6hJL$5$l$?0z?t$G$"$C$F$b(B3$BHVL\0J9_$J$i$P!"I8=`%Q%?!<%s$rE,MQ$9$k!#(B
@c @item a symbol, @var{symbol}
@item $B%7%s%\%k(B@var{symbol}
@c @var{symbol} should be a function name; that function is called to
@c calculate the indentation of a line within this expression. The
@c function receives two arguments:
@var{symbol}$B$O4X?tL>$G$"$k$3$H!#(B
$B$3$N4X?t$O!"Ev3:<0$N;z2<$2I}$r7W;;$9$k!#(B
$B$3$N4X?t$O$D$.$N(B2$B$D$N0z?t$r<u$1<h$k!#(B
@table @asis
@item @var{state}
@c The value returned by @code{parse-partial-sexp} (a Lisp primitive for
@c indentation and nesting computation) when it parses up to the
@c beginning of this line.
$BEv3:9T$N@hF,$^$G$r2r@O$7$?$H$-$N(B@code{parse-partial-sexp}
$B!J;z2<$2$HF~$l;R$N7W;;$r9T$&(BLisp$B$N4pK\E*$J4X?t!K$NLa$jCM!#(B
@item @var{pos}
@c The position at which the line being indented begins.
$B;z2<$2BP>]$N9T$N3+;O0LCV!#(B
@end table
@noindent
@c It should return either a number, which is the number of columns of
@c indentation for that line, or a list whose car is such a number. The
@c difference between returning a number and returning a list is that a
@c number says that all following lines at the same nesting level should
@c be indented just like this one; a list says that following lines might
@c call for different indentations. This makes a difference when the
@c indentation is being computed by @kbd{C-M-q}; if the value is a
@c number, @kbd{C-M-q} need not recalculate indentation for the following
@c lines until the end of the list.
$B$3$N4X?t$O!"Ev3:9T$KBP$9$k;z2<$2I}$N7e?t!"$"$k$$$O!"(B
$B%j%9%H$N(Bcar$B$,$=$N$h$&$J?tCM$G$"$k%j%9%H$rJV$9I,MW$,$"$k!#(B
$B?tCM$rJV$7$?>l9g$O!"3g8L$NF~$l;R%l%Y%k$,F1$89T$KBP$7$F$O(B
$BF1$8;z2<$2I}$r0UL#$9$k!#(B
$B%j%9%H$rJV$7$?>l9g$O!"8eB3$N9T$KBP$7$F$O;z2<$2I}$,0[$J$k2DG=@-$r0UL#$9$k!#(B
$B$3$N$h$&$J:90[$O!"(B@kbd{C-M-q}$B$G;z2<$2$r7W;;$9$k$H$-$K8=$l$k!#(B
$B?tCM$,JV$5$l$?>l9g!"(B@kbd{C-M-q}$B$O!"%j%9%H$NKvHx$KC#$9$k$^$G$O!"(B
$B;z2<$2$N:F7W;;$r9T$&I,MW$,$J$$!#(B
@end table
@node C Indent
@c @subsection Commands for C Indentation
@subsection C$B$N;z2<$2%3%^%s%I(B
@c Here are the commands for indentation in C mode and related modes:
$B$3$3$G$O!"(BC$B%b!<%I$H$=$N4XO"%b!<%I$K$*$1$k;z2<$2%3%^%s%I$r>R2p$7$^$9!#(B
@table @code
@item C-c C-q
@c @kindex C-c C-q @r{(C mode)}
@kindex C-c C-q @r{$B!J(BC$B%b!<%I!K(B}
@findex c-indent-defun
@c Reindent the current top-level function definition or aggregate type
@c declaration (@code{c-indent-defun}).
$B8=:_$N%H%C%W%l%Y%k$N4X?tDj5A!"$"$k$$$O!"7?@k8@$N=8$^$j$r;z2<$2$7D>$9(B
$B!J(B@code{c-indent-defun}$B!K!#(B
@item C-M-q
@c @kindex C-M-q @r{(C mode)}
@kindex C-M-q @r{$B!J(BC$B%b!<%I!K(B}
@findex c-indent-exp
@c Reindent each line in the balanced expression that follows point
@c (@code{c-indent-exp}). A prefix argument inhibits error checking and
@c warning messages about invalid syntax.
$B%]%$%s%H$N$&$7$m$K$"$kD`$j9g$C$?<0$NCf$N3F9T$r;z2<$2$7D>$9(B
$B!J(B@code{c-indent-exp}$B!K!#(B
$BA0CV0z?t$r;XDj$9$k$H!"(B
$BIT@5$J9=J8$KBP$9$k8!::$r$;$:$K!"7Y9p%a%C%;!<%8$bH/$7$J$$!#(B
@item @key{TAB}
@findex c-indent-command
@c Reindent the current line, and/or in some cases insert a tab character
@c (@code{c-indent-command}).
$B8=:_9T$r;z2<$2$7D>$9$+!"%?%VJ8;z$rA^F~$9$k(B
$B!J(B@code{c-indent-command}$B!K!#(B
@c If @code{c-tab-always-indent} is @code{t}, this command always reindents
@c the current line and does nothing else. This is the default.
@code{c-tab-always-indent}$B$,(B@code{t}$B$J$i$P!"(B
$B8=:_9T$r;z2<$2$7D>$9$@$1$G!"B>$K$O2?$b$7$J$$!#(B
$B$3$l$,%G%U%)%k%H!#(B
@c If that variable is @code{nil}, this command reindents the current line
@c only if point is at the left margin or in the line's indentation;
@c otherwise, it inserts a tab (or the equivalent number of spaces,
@c if @code{indent-tabs-mode} is @code{nil}).
$B$3$NJQ?t$,(B@code{nil}$B$J$i$P!"(B
$B%]%$%s%H$,:8C<$+;z2<$2$NM>GrItJ,$K$"$k>l9g$K8B$j!";z2<$2$7D>$9!#(B
$B$5$b$J$1$l$P!"%?%V(B
$B!J$"$k$$$O!"(B@code{indent-tabs-mode}$B$,(B@code{nil}$B$J$i$P!"(B
$BEy2A$J8D?t$N6uGr!K$rA^F~$9$k!#(B
@c Any other value (not @code{nil} or @code{t}) means always reindent the
@c line, and also insert a tab if within a comment, a string, or a
@c preprocessor directive.
$B>e5-$N!J(B@code{nil}$B$d(B@code{t}$B!K0J30$NCM$G$"$l$P!"DL>o$I$*$j;z2<$2$7D>$9!#(B
$B$?$@$7!"%3%a%s%H!"J8;zNs!"%W%j%W%m%;%C%5;XNa$NFbB&$G$O!"%?%V$rA^F~$9$k!#(B
@item C-u @key{TAB}
@c Reindent the current line according to its syntax; also rigidly reindent
@c any other lines of the expression that starts on the current line.
@c @xref{Multi-line Indent}.
$B8=:_9T$N9=J8$K=>$C$F8=:_9T$r;z2<$2$7D>$9!#(B
$B$J$*!"8=:_9T$+$i;O$^$k<0$r9=@.$9$k9T$bF1$8I}$@$1;z2<$2$7D>$9!#(B
@pxref{Multi-line Indent}$B!#(B
@end table
@c To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This
@c first selects the whole buffer as the region, then reindents that
@c region.
$B%+%l%s%H%P%C%U%!A4BN$r;z2<$2$7D>$9$K$O!"(B
@kbd{C-x h C-M-\}$B$HBG$A$^$9!#(B
$B$3$l$O!"$^$:!"%P%C%U%!A4BN$r%j!<%8%g%s$H$7$F$+$i!"(B
$B$=$N%j!<%8%g%s$r;z2<$2$7D>$7$^$9!#(B
@c To reindent the current block, use @kbd{C-M-u C-M-q}. This moves
@c to the front of the block and then reindents it all.
$B%+%l%s%H%V%m%C%/$r;z2<$2$7D>$9$K$O!"(B@kbd{C-M-u C-M-q}$B$HBG$A$^$9!#(B
$B$3$l$O!"$^$:!"%V%m%C%/$N@hF,$K0\F0$7$F$+$i!"(B
$B%V%m%C%/A4BN$r;z2<$2$7D>$7$^$9!#(B
@node Custom C Indent
@c @subsection Customizing C Indentation
@subsection C$B$N;z2<$2$N%+%9%?%^%$%:(B
@c C mode and related modes use a simple yet flexible mechanism for
@c customizing indentation. The mechanism works in two steps: first it
@c classifies the line syntactically according to its contents and context;
@c second, it associates each kind of syntactic construct with an
@c indentation offset which you can customize.
C$B%b!<%I$H$=$N4XO"%b!<%I$G$O!";z2<$2$N%+%9%?%^%$%:$K$O!"(B
$BC1=c$G$9$,=@Fp@-$N$"$k5!9=$rMQ$$$F$$$^$9!#(B
$B$3$N5!9=$O(B2$BCJ3,$GF0:n$7$^$9!#(B
$B$^$:!"9T$r$=$NFbMF$HJ8L.$+$i9=J8E*$KJ,N`$7$^$9!#(B
$B$D$.$K!"9=J89=@.MWAG$N3F<oN`$K!"(B
$B%+%9%?%^%$%:2DG=$J;z2<$2$N%*%U%;%C%H$rBP1~$5$;$^$9!#(B
@menu
* Syntactic Analysis::
* Indentation Calculation::
* Changing Indent Style::
* Syntactic Symbols::
* Variables for C Indent::
* C Indent Styles::
@end menu
@node Syntactic Analysis
@c @subsubsection Step 1---Syntactic Analysis
@subsubsection $BBh(B1$BCJ3,!]!]9=J82r@O(B
@c @cindex syntactic analysis
@cindex $B9=J82r@O(B
@c In the first step, the C indentation mechanism looks at the line
@c before the one you are currently indenting and determines the syntactic
@c components of the construct on that line. It builds a list of these
@c syntactic components, each of which contains a @dfn{syntactic symbol}
@c and sometimes also a buffer position. Some syntactic symbols describe
@c grammatical elements, for example @code{statement} and
@c @code{substatement}; others describe locations amidst grammatical
@c elements, for example @code{class-open} and @code{knr-argdecl}.
$BBh(B1$BCJ3,$G$O!"(BC$B$N;z2<$25!9=$O!";z2<$2$7$h$&$H$7$F$$$k$^$($N9T$rD4$Y$F!"(B
$B$=$N9T$r9=@.$9$k9=J8>e$N9=@.MWAG$r7hDj$7$^$9!#(B
$B$D$^$j!"(B@dfn{$B9=J8%7%s%\%k(B}$B$H%P%C%U%!Fb$NAjBP0LCV$rMWAG$H$9$k(B
$B9=J89=@.MWAG$N%j%9%H$rAH$_N)$F$^$9!#(B
$B9=J8%7%s%\%k$K$O!"(B@code{statement}$B!JJ8!K$d(B
@code{substatement}$B!JItJ,J8!K$N$h$&$K(B
$BJ8K!MWAG$r5-=R$9$k$b$N$H!"(B
@code{class-open}$B!J%/%i%93+;O!K$d(B
@code{knr-argdecl}$B!J(BK&R$BHG0z?t@k8@!K$N$h$&$KJ8K!MWAG$N$"$$$@$N0LCV$r(B
$B5-=R$9$k$b$N$,$"$j$^$9!#(B
@c Conceptually, a line of C code is always indented relative to the
@c indentation of some line higher up in the buffer. This is represented
@c by the buffer positions in the syntactic component list.
$B35G0E*$K$O!"(BC$B$N%3!<%I9T$O!"%P%C%U%!Cf$G$=$l$h$j$^$($K(B
$B$"$k$$$:$l$+$N9T$KBP$7$FI,$:AjBPE*$K;z2<$2$5$l$^$9!#(B
$B$3$l$O9=J89=@.MWAG%j%9%H$NCf$K$"$k%P%C%U%!Fb0LCV$H$7$FI=8=$5$l$^$9!#(B
@c Here is an example. Suppose we have the following code in a C++ mode
@c buffer (the line numbers don't actually appear in the buffer):
$B0J2<$KNc$r<($7$^$9!#(B
$B$D$.$N%3!<%I$,!"(BC++$B%b!<%I$N%P%C%U%!$KF~$C$F$$$k$H$7$^$7$g$&(B
$B!J<B:]$K%P%C%U%!$K9THV9f$,I=<($5$l$k$o$1$G$O$J$$!K!#(B
@example
1: void swap (int& a, int& b)
2: @{
3: int tmp = a;
4: a = b;
5: b = tmp;
6: @}
@end example
@c If you type @kbd{C-c C-s} (which runs the command
@c @code{c-show-syntactic-information}) on line 4, it shows the result of
@c the indentation mechanism for that line:
4$B9TL\$G!J(B@code{c-show-syntactic-information}$B$r<B9T$9$k!K(B
@kbd{C-c C-s}$B$rBG$D$H!"(B
$B$=$N9T$KBP$9$k;z2<$25!9=$N7k2L$,I=<($5$l$^$9!#(B
@example
((statement . 32))
@end example
@c This indicates that the line is a statement and it is indented
@c relative to buffer position 32, which happens to be the @samp{i} in
@c @code{int} on line 3. If you move the cursor to line 3 and type
@c @kbd{C-c C-s}, it displays this:
$B$3$l$O!"$=$N9T$,J8$G$"$j!"(B
$B%P%C%U%!Fb0LCV(B32$B$KBP$7$FAjBPE*$K;z2<$2$5$l$F$$$k$3$H$r<($7$^$9!#(B
$B%P%C%U%!Fb0LCV(B32$B$O!"(B3$B9TL\$N(B@code{int}$B$N(B@samp{i}$B$K$"$?$j$^$9!#(B
$B%+!<%=%k$r(B3$B9TL\$KF0$+$7$F(B@kbd{C-c C-s}$B$HBG$D$H!"(B
$B:#EY$O$D$.$N$h$&$KI=<($5$l$^$9!#(B
@example
((defun-block-intro . 28))
@end example
@c This indicates that the @code{int} line is the first statement in a
@c block, and is indented relative to buffer position 28, which is the
@c brace just after the function header.
$B$3$N7k2L$O!"(B@code{int}$B9T$,%V%m%C%/$N:G=i$NJ8$G$"$j!"(B
$B%P%C%U%!Fb0LCV(B28$B$KBP$7$FAjBPE*$K;z2<$2$5$l$F$$$k$3$H$r<($7$F$$$^$9!#(B
$B%P%C%U%!Fb0LCV(B28$B$O!"4X?t%X%C%@$ND>8e$NCf3g8L$K$"$?$j$^$9!#(B
@noindent
@c Here is another example:
$BJL$NNc$r8+$F$_$^$7$g$&!#(B
@example
1: int add (int val, int incr, int doit)
2: @{
3: if (doit)
4: @{
5: return (val + incr);
6: @}
7: return (val);
8: @}
@end example
@noindent
@c Typing @kbd{C-c C-s} on line 4 displays this:
4$B9TL\$G(B@kbd{C-c C-s}$B$HBG$D$H!"$D$.$N$h$&$KI=<($5$l$^$9!#(B
@example
((substatement-open . 43))
@end example
@c This says that the brace @emph{opens} a substatement block. By the
@c way, a @dfn{substatement} indicates the line after an @code{if},
@c @code{else}, @code{while}, @code{do}, @code{switch}, @code{for},
@c @code{try}, @code{catch}, @code{finally}, or @code{synchronized}
@c statement.
$B$3$l$O!"Cf3g8L$,ItJ,J8$N%V%m%C%/$r(B@emph{$B;O$a$F(B}$B$$$k$3$H$r<($7$F$$$^$9!#(B
$B$H$3$m$G!"(B@dfn{$BItJ,J8(B}$B$H$O!"(B@code{if}$B!"(B@code{else}$B!"(B@code{while}$B!"(B
@code{do}$B!"(B@code{switch}$B!"(B@code{for}$B!"(B@code{try}$B!"(B@code{catch}$B!"(B
@code{finally}$B!"(B@code{synchronized}$B$N$"$H$N9T$rI=$7$^$9!#(B
@c @cindex syntactic component
@c @cindex syntactic symbol
@cindex $B9=J89=@.MWAG(B
@cindex $B9=J8%7%s%\%k(B
@vindex c-syntactic-context
@c Within the C indentation commands, after a line has been analyzed
@c syntactically for indentation, the variable @code{c-syntactic-context}
@c contains a list that describes the results. Each element in this list
@c is a @dfn{syntactic component}: a cons cell containing a syntactic
@c symbol and (optionally) its corresponding buffer position. There may be
@c several elements in a component list; typically only one element has a
@c buffer position.
C$B$N;z2<$2%3%^%s%I$K$*$$$F$O!"(B
$B;z2<$2$N$?$a$K9T$r9=J82r@O$7=*$($k$H!"(B
$BJQ?t(B@code{c-syntactic-context}$B$K$O2r@O7k2L$rI=$9%j%9%H$,F~$j$^$9!#(B
$B$3$N%j%9%H$N3FMWAG$O(B@dfn{$B9=J89=@.MWAG(B}$B$G$"$j!"(B
$B9=J8%7%s%\%k$H!J>J$+$l$k$+$b$7$l$J$$!KBP1~$9$k%P%C%U%!Fb0LCV$N(B
$B%3%s%9%;%k$G$9!#(B
$B9=J89=@.MWAG%j%9%H$K$O!"J#?t$NMWAG$,4^$^$l$k$3$H$b$"$j$^$9!#(B
$B$^$?!"E57?E*$K$O!"%P%C%U%!Fb0LCV$r;}$DMWAG$O(B1$B$D$@$1$G$9!#(B
@node Indentation Calculation
@c @subsubsection Step 2---Indentation Calculation
@subsubsection $BBh(B2$BCJ3,!]!];z2<$27W;;(B
@c @cindex Indentation Calculation
@cindex $B;z2<$27W;;(B
@c The C indentation mechanism calculates the indentation for the current
@c line using the list of syntactic components, @code{c-syntactic-context},
@c derived from syntactic analysis. Each component is a cons cell that
@c contains a syntactic symbol and may also contain a buffer position.
C$B$N;z2<$25!9=$O!"9=J82r@O$GF@$i$l$?9=J89=@.MWAG%j%9%H(B
@code{c-syntactic-context}$B$r;H$C$F!"8=:_9T$N;z2<$2I}$r7W;;$7$^$9!#(B
$B$3$N%j%9%H$N3FMWAG$O!"9=J8%7%s%\%k$r4^$`%3%s%9%;%k$G$9$,!"(B
$B%P%C%U%!Fb0LCV$r4^$s$G$$$k>l9g$b$"$j$^$9!#(B
@c Each component contributes to the final total indentation of the line
@c in two ways. First, the syntactic symbol identifies an element of
@c @code{c-offsets-alist}, which is an association list mapping syntactic
@c symbols into indentation offsets. Each syntactic symbol's offset adds
@c to the total indentation. Second, if the component includes a buffer
@c position, the column number of that position adds to the indentation.
@c All these offsets and column numbers, added together, give the total
@c indentation.
$B%j%9%H$N3FMWAG$O!":G=*E*$JAm;z2<$2NL$K(B2$B$D$NJ}K!$G4sM?$7$^$9!#(B
$B$^$:!"3F9=J8%7%s%\%k$K;z2<$2%*%U%;%C%H$rBP1~IU$1$kO"A[%j%9%H(B
@code{c-offsets-alist}$B$+$iMWAG$rC5$9$?$a$K9=J8%7%s%\%k$,;H$o$l$^$9!#(B
$B3F9=J89=@.%7%s%\%k$N%*%U%;%C%H$rAm;z2<$2NL$K2C$($^$9!#(B
$B$D$.$K!"%j%9%H$NMWAG$K%P%C%U%!Fb0LCV$,4^$^$l$F$$$l$P!"(B
$B$=$N2U=j$N7e0LCV$r;z2<$2NL$K2C$($^$9!#(B
$B$3$l$i$N%*%U%;%C%H$H7e?t$r$9$Y$F2C$($k$3$H$G!"Am;z2<$2NL$,5a$^$j$^$9!#(B
@c The following examples demonstrate the workings of the C indentation
@c mechanism:
$B0J2<$NNc$G(BC$B$N;z2<$25!9=$NF0:n$r@bL@$7$^$7$g$&!#(B
@example
1: void swap (int& a, int& b)
2: @{
3: int tmp = a;
4: a = b;
5: b = tmp;
6: @}
@end example
@c Suppose that point is on line 3 and you type @key{TAB} to reindent the
@c line. As explained above (@pxref{Syntactic Analysis}), the syntactic
@c component list for that line is:
3$B9TL\$K%]%$%s%H$,$"$C$F!"$=$3$G(B@key{TAB}$B$HBG$C$F;z2<$2$7D>$9$H$7$^$7$g$&!#(B
$B>e!J(B@pxref{Syntactic Analysis}$B!K$G$b@bL@$7$^$7$?$,!"(B
$B$=$N9T$KBP$9$k9=J89=@.MWAG%j%9%H$O$D$.$N$h$&$K$J$j$^$9!#(B
@example
((defun-block-intro . 28))
@end example
@c In this case, the indentation calculation first looks up
@c @code{defun-block-intro} in the @code{c-offsets-alist} alist. Suppose
@c that it finds the integer 2; it adds this to the running total
@c (initialized to zero), yielding a updated total indentation of 2 spaces.
$B$3$3$G$O!"$^$:!"O"A[%j%9%H(B@code{c-offsets-alist}$B$+$i(B
@code{defun-block-intro}$B$rC5$9$3$H$+$i;O$a$^$9!#(B
$B$=$N7k2L$,@0?tCM(B2$B$G$"$C$?$H$7$^$7$g$&!#(B
$B$3$NCM$r7W;;Cf$N9g7W!J(B0$B$G=i4|2=$5$l$F$$$k!K$K2C$($F!"(B
$BAm;z2<$2NL$O6uGr(B2$BJ8;z$H99?7$5$l$^$9!#(B
@c The next step is to find the column number of buffer position 28.
@c Since the brace at buffer position 28 is in column zero, this adds 0 to
@c the running total. Since this line has only one syntactic component,
@c the total indentation for the line is 2 spaces.
$B$D$.$NCJ3,$O!"%P%C%U%!Fb0LCV(B28$B$N7e0LCV$r5a$a$k$3$H$G$9!#(B
$B%P%C%U%!Fb0LCV(B28$B$NCf3g8L$O(B0$B7eL\$K$"$k$N$G!"(B
0$B$r7W;;Cf$N9g7W$K2C$($^$9!#(B
3$B9TL\$K$O9=J8MWAG$,(B1$B$D$7$+$J$$$N$G!"Am;z2<$2NL$O6uGr(B2$BJ8;z$H$J$j$^$9!#(B
@example
1: int add (int val, int incr, int doit)
2: @{
3: if (doit)
4: @{
5: return(val + incr);
6: @}
7: return(val);
8: @}
@end example
@c If you type @key{TAB} on line 4, the same process is performed, but
@c with different data. The syntactic component list for this line is:
4$B9TL\$G(B@key{TAB}$B$HBG$D$H!"F1$82aDx$r7+$jJV$7$^$9$,!"(B
$B0[$J$kCM$r;H$C$F7W;;$5$l$^$9!#(B
$B$3$N9T$KBP$9$k9=J89=@.MWAG%j%9%H$O$D$.$N$H$*$j$G$9!#(B
@example
((substatement-open . 43))
@end example
@c Here, the indentation calculation's first job is to look up the
@c symbol @code{substatement-open} in @code{c-offsets-alist}. Let's assume
@c that the offset for this symbol is 2. At this point the running total
@c is 2 (0 + 2 = 2). Then it adds the column number of buffer position 43,
@c which is the @samp{i} in @code{if} on line 3. This character is in
@c column 2 on that line. Adding this yields a total indentation of 4
@c spaces.
$B$^$:$O!"%7%s%\%k(B@code{substatement-open}$B$rO"A[%j%9%H(B
@code{c-offsets-alist}$B$+$iC5$7$^$9!#(B
$B$3$N%7%s%\%k$KBP$9$k%*%U%;%C%H$,(B2$B$G$"$C$?$H$7$^$7$g$&!#(B
$B$3$N;~E@$G7W;;Cf$N9g7W$O(B2$B!J(B0 + 2 = 2$B!K$G$9!#(B
$B$D$.$K!"%P%C%U%!Fb0LCV(B43$B!J(B3$B9TL\$N(B@code{if}$B$N(B@samp{i}$B$N0LCV!K$N(B
$B7e0LCV(B2$B$r2C$($^$9!#(B
$B7k2L$H$7$F!"6uGr(B4$BJ8;z$H$$$&Am;z2<$2NL$,5a$^$j$^$9!#(B
@vindex c-strict-syntax-p
@c If a syntactic symbol in the analysis of a line does not appear in
@c @code{c-offsets-alist}, it is ignored; if in addition the variable
@c @code{c-strict-syntax-p} is non-@code{nil}, it is an error.
$B9T$r2r@O$7$?7k2L!"(B@code{c-offsets-alist}$B$K8=$l$J$$9=J8%7%s%\%k$,(B
$B$_$D$+$C$?>l9g!"$=$N%7%s%\%k$OL5;k$7$^$9!#(B
$B$7$+$7!"JQ?t(B@code{c-strict-syntax-p}$B$,(B@code{nil}$B0J30$NCM$G$"$l$P!"(B
$B%(%i!<$rJs9p$7$^$9!#(B
@node Changing Indent Style
@c @subsubsection Changing Indentation Style
@subsubsection $B;z2<$2%9%?%$%k$NJQ99(B
@c There are two ways to customize the indentation style for the C-like
@c modes. First, you can select one of several predefined styles, each of
@c which specifies offsets for all the syntactic symbols. For more
@c flexibility, you can customize the handling of individual syntactic
@c symbols. @xref{Syntactic Symbols}, for a list of all defined syntactic
@c symbols.
C$BN.$N%b!<%I$N;z2<$2$r%+%9%?%^%$%:$9$kJ}K!$O(B2$B$D$"$j$^$9!#(B
1$B$D$O!"$"$i$+$8$aDj5A$5$l$F$$$k%9%?%$%k$+$iA*Br$9$kJ}K!$G$9!#(B
$B$=$l$>$l$N%9%?%$%k$G$O!"3F9=J8%7%s%\%k$KBP$9$k%*%U%;%C%H$,Dj$a$i$l$F$$$^$9!#(B
$B$b$&(B1$B$D$O$h$j=@Fp$JJ}K!$G!"3F9=J8%7%s%\%k$N07$$J}$r%+%9%?%^%$%:$G$-$^$9!#(B
$BDj5A$5$l$F$$$k9=J8%7%s%\%k$N0lMw$K$D$$$F$O!"(B@xref{Syntactic Symbols}$B!#(B
@table @kbd
@item M-x c-set-style @key{RET} @var{style} @key{RET}
@c Select predefined indentation style @var{style}. Type @kbd{?} when
@c entering @var{style} to see a list of supported styles; to find out what
@c a style looks like, select it and reindent some C code.
$B$"$i$+$8$aDj5A$5$l$F$$$k;z2<$2%9%?%$%k(B@var{style}$B$rA*Br$9$k!#(B
@var{style}$B$rF~NO$9$k:]$K(B@kbd{?}$B$HBG$F$P!"(B
$BDj5A:Q$_$N%9%?%$%k0lMw$r8+$k$3$H$,$G$-$k!#(B
$B%9%?%$%k$N8+1I$($rD4$Y$k$K$O!"(B
$B$=$N%9%?%$%k$rA*Br$7$F!"E,Ev$J(BC$B$N%3!<%I$r;z2<$2$7D>$7$F$_$k!#(B
@item C-c C-o @var{symbol} @key{RET} @var{offset} @key{RET}
@c Set the indentation offset for syntactic symbol @var{symbol}
@c (@code{c-set-offset}). The second argument @var{offset} specifies the
@c new indentation offset.
$B9=J8%7%s%\%k(B@var{symbol}$B$KBP$9$k;z2<$2$N%*%U%;%C%H$r@_Dj$9$k(B
$B!J(B@code{c-set-offset}$B!K!#(B
2$BHVL\$N0z?t(B@var{offset}$B$G!";z2<$2$N%*%U%;%C%H$r;XDj$9$k!#(B
@end table
@c The @code{c-offsets-alist} variable controls the amount of
@c indentation to give to each syntactic symbol. Its value is an
@c association list, and each element of the list has the form
@c @code{(@var{syntactic-symbol} . @var{offset})}. By changing the offsets
@c for various syntactic symbols, you can customize indentation in fine
@c detail. To change this alist, use @code{c-set-offset} (see below).
$BJQ?t(B@code{c-offsets-alist}$B$O!"3F9=J8%7%s%\%k$KM?$($k;z2<$2NL$r@)8f$7$^$9!#(B
$B$3$NJQ?t$NCM$OO"A[%j%9%H$G$"$j!"(B
$B3FMWAG$O(B@code{(@var{syntactic-symbol} . @var{offset})}$B$N7A$r$7$F$$$^$9!#(B
$B$5$^$6$^$J9=J8%7%s%\%k$KBP$9$k%*%U%;%C%H$rJQ$($k$3$H$G!"(B
$B;z2<$2$r:Y$+$/%+%9%?%^%$%:$G$-$^$9!#(B
$BO"A[%j%9%H$rJQ99$9$k$K$O!"(B@code{c-set-offset}$B$r;H$$$^$9!J2<5-;2>H!K!#(B
@c Each offset value in @code{c-offsets-alist} can be an integer, a
@c function or variable name, a list, or one of the following symbols: @code{+},
@c @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}, indicating positive or negative
@c multiples of the variable @code{c-basic-offset}. Thus, if you want to
@c change the levels of indentation to be 3 spaces instead of 2 spaces, set
@c @code{c-basic-offset} to 3.
@code{c-offsets-alist}$BFb$N3F%*%U%;%C%H$K$O!"(B
$B@0?t!"4X?tL>$dJQ?tL>!"$"$k$$$O!"(B
$BJQ?t(B@code{c-basic-offset}$B$NCM$N@5Ii$NG\?t$rI=$9%7%s%\%k$G$"$k(B
@code{+}$B!"(B@code{-}$B!"(B@code{++}$B!"(B@code{--}$B!"(B@code{*}$B!"(B
@code{/}$B$N$$$:$l$+$r@_Dj$G$-$^$9!#(B
$B$7$?$,$C$F!"4pK\$N;z2<$2I}$r6uGr(B2$BJ8;z$+$i(B3$BJ8;z$KJQ99$7$?$1$l$P!"(B
@code{c-basic-offset}$B$K(B3$B$r@_Dj$7$^$9!#(B
@c Using a function as the offset value provides the ultimate flexibility
@c in customizing indentation. The function is called with a single
@c argument containing the @code{cons} of the syntactic symbol and
@c the buffer position, if any. The function should return an integer
@c offset.
$B%*%U%;%C%H$K4X?t$rMQ$$$k$H!"(B
$B;z2<$2$N%+%9%?%^%$%:$K5f6K$N=@Fp@-$r;}$?$;$i$l$^$9!#(B
$B$3$N4X?t$O!"9=J8%7%s%\%k$H%P%C%U%!Fb0LCV$,$"$l$P$=$l$r(B@code{cons}$B$7$?$b$N$r(B
$B0z?t$H$7$F8F$P$l$^$9!#(B
$BLa$jCM$H$7$F$O!"@0?tCM$N%*%U%;%C%H$rJV$9I,MW$,$"$j$^$9!#(B
@c If the offset value is a list, its elements are processed according
@c to the rules above until a non-@code{nil} value is found. That value is
@c then added to the total indentation in the normal manner. The primary
@c use for this is to combine the results of several functions.
$B%*%U%;%C%H$NCM$,%j%9%H$N>l9g!"(B
$B3FMWAG$O!"(B@code{nil}$B0J30$NCM$,$_$D$+$k$^$G>e$N5,B'$K$7$?$,$C$F=hM}$5$l$^$9!#(B
$B$=$N8e!"$=$NCM$O!"DL>o$N$h$&$K!";z2<$2$NAmNL$K2C$($i$l$^$9!#(B
$B$3$l$O!"$*$b$K!"J#?t$N4X?t$N7k2L$rAH$_9g$o$;$k$?$a$K;H$o$l$^$9!#(B
@c @kindex C-c C-o @r{(C mode)}
@kindex C-c C-o @r{$B!J(BC$B%b!<%I!K(B}
@findex c-set-offset
@c The command @kbd{C-c C-o} (@code{c-set-offset}) is the easiest way to
@c set offsets, both interactively or in your @file{~/.emacs} file. First
@c specify the syntactic symbol, then the offset you want. @xref{Syntactic
@c Symbols}, for a list of valid syntactic symbols and their meanings.
$BBPOCE*$K@_Dj$9$k$K$7$F$b%U%!%$%k(B@file{~/.emacs}$B$G@_Dj$9$k$K$7$F$b!"(B
$B%*%U%;%C%H$r@_Dj$9$k$b$C$H$b4JC1$JJ}K!$O!"(B
$B%3%^%s%I(B@kbd{C-c C-o}$B!J(B@code{c-set-offset}$B!K$r;H$&$3$H$G$9!#(B
$B:G=i$N0z?t$O9=J8%7%s%\%k!"(B2$BHVL\$N0z?t$O4uK>$N%*%U%;%C%H$G$9!#(B
$BM-8z$J9=J8%7%s%\%kL>$H$=$N0UL#$N0lMw$O!"(B@xref{Syntactic Symbols}$B!#(B
@node Syntactic Symbols
@c @subsubsection Syntactic Symbols
@subsubsection $B9=J8%7%s%\%k(B
@c Here is a table of valid syntactic symbols for indentation in C and
@c related modes, with their syntactic meanings. Normally, most of these
@c symbols are assigned offsets in @code{c-offsets-alist}.
C$B%b!<%I$d4XO"$9$k%b!<%I$N;z2<$2$KBP$7$FM-8z$J9=J8%7%s%\%k$r!"(B
$B9=J8>e$N0UL#$H$H$b$K!"0J2<$K<($7$^$9!#(B
$B$3$l$i$N$[$H$s$I$N%7%s%\%k$K$O!"(B
@code{c-offsets-alist}$B$G%*%U%;%C%H$,M?$($i$l$F$$$^$9!#(B
@table @code
@item string
@c Inside a multi-line string.
$BJ#?t9T$K$*$h$VJ8;zNs$NFbB&!#(B
@item c
@c Inside a multi-line C style block comment.
$BJ#?t9T$K$*$h$V(BC$B%9%?%$%k$N%V%m%C%/%3%a%s%H$NFbB&!#(B
@item defun-open
@c On a brace that opens a function definition.
$B4X?tDj5A$r3+;O$9$kCf3g8L!#(B
@item defun-close
@c On a brace that closes a function definition.
$B4X?tDj5A$r=*N;$9$kCf3g8L!#(B
@item defun-block-intro
@c In the first line in a top-level defun.
$B%H%C%W%l%Y%k$N4X?tDj5A$N:G=i$N9T!#(B
@item class-open
@c On a brace that opens a class definition.
$B%/%i%9Dj5A$r3+;O$9$kCf3g8L!#(B
@item class-close
@c On a brace that closes a class definition.
$B%/%i%9Dj5A$r=*N;$9$kCf3g8L!#(B
@item inline-open
@c On a brace that opens an in-class inline method.
$B%/%i%9Fb$N%$%s%i%$%s%a%=%C%I$r3+;O$9$kCf3g8L!#(B
@item inline-close
@c On a brace that closes an in-class inline method.
$B%/%i%9Fb$N%$%s%i%$%s%a%=%C%I$r=*N;$9$kCf3g8L!#(B
@item extern-lang-open
@c On a brace that opens an external language block.
$B30It8@8l%V%m%C%/$r3+;O$9$kCf3g8L!#(B
@item extern-lang-close
@c On a brace that closes an external language block.
$B30It8@8l%V%m%C%/$r=*N;$9$kCf3g8L!#(B
@item func-decl-cont
@c The region between a function definition's argument list and the defun
@c opening brace (excluding K&R function definitions). In C, you cannot
@c put anything but whitespace and comments between them; in C++ and Java,
@c @code{throws} declarations and other things can appear in this context.
$B4X?tDj5A$N0z?t%j%9%H$H4X?tDj5A$NK\BN$r3+;O$9$kCf3g8L$N$"$$$@$NNN0h!#(B
$B$?$@$7!"(BK&R$BHG$N4X?tDj5A$r=|$/!#(B
C$B$G$O!"$3$NItJ,$K6uJ8;z$d%3%a%s%H0J30$OCV$1$J$$!#(B
C++$B$d(BJava$B$G$O!"(B@code{throws}$B@k8@$J$I$rCV$1$k!#(B
@item knr-argdecl-intro
@c On the first line of a K&R C argument declaration.
K&R$BHG(BC$B$N0z?t@k8@$N:G=i$N9T!#(B
@item knr-argdecl
@c In one of the subsequent lines in a K&R C argument declaration.
K&R$BHG(BC$B$N0z?t@k8@$N(B2$B9TL\0J9_!#(B
@item topmost-intro
@c On the first line in a topmost construct definition.
$B:G>e0L$N8@8l9=@.MWAG$N:G=i$N9T!#(B
@item topmost-intro-cont
@c On the topmost definition continuation lines.
$B:G>e0L$N8@8l9=@.MWAG$N(B2$B9TL\0J9_!#(B
@item member-init-intro
@c On the first line in a member initialization list.
$B!J9=B$BN$N!K%a%s%P=i4|2=%j%9%H$N:G=i$N9T!#(B
@item member-init-cont
@c On one of the subsequent member initialization list lines.
$B!J9=B$BN$N!K%a%s%P=i4|2=%j%9%H$N(B2$B9TL\0J9_!#(B
@item inher-intro
@c On the first line of a multiple inheritance list.
$BB?=E7Q>5%j%9%H$N:G=i!#(B
@item inher-cont
@c On one of the subsequent multiple inheritance lines.
$BB?=E7Q>5%j%9%H$N(B2$B9TL\0J9_!#(B
@item block-open
@c On a statement block open brace.
$BJ8%V%m%C%/$r3+;O$9$kCf3g8L!#(B
@item block-close
@c On a statement block close brace.
$BJ8%V%m%C%/$r=*N;$9$kCf3g8L!#(B
@item brace-list-open
@c On the opening brace of an @code{enum} or @code{static} array list.
@code{enum}$B$N%j%9%H$d@EE*G[Ns$N=i4|2=%j%9%H$r3+;O$9$kCf3g8L!#(B
@item brace-list-close
@c On the closing brace of an @code{enum} or @code{static} array list.
@code{enum}$B$N%j%9%H$d@EE*G[Ns$N=i4|2=%j%9%H$r=*N;$9$kCf3g8L!#(B
@item brace-list-intro
@c On the first line in an @code{enum} or @code{static} array list.
@code{enum}$B$N%j%9%H$d@EE*G[Ns$N=i4|2=%j%9%H$N:G=i$N9T!#(B
@item brace-list-entry
@c On one of the subsequent lines in an @code{enum} or @code{static} array
@c list.
@code{enum}$B$N%j%9%H$d@EE*G[Ns$N=i4|2=%j%9%H$N(B2$B9TL\0J9_!#(B
@item brace-entry-open
@c On one of the subsequent lines in an @code{enum} or @code{static} array
@c list, when the line begins with an open brace.
$B9T$,3+$-Cf3g8L$G;O$^$k$H$-$N!"(B
@code{enum}$B$N%j%9%H$d@EE*G[Ns$N=i4|2=%j%9%H$N(B2$B9TL\0J9_!#(B
@item statement
@c On an ordinary statement.
$BDL>o$NJ8!#(B
@item statement-cont
@c On a continuation line of a statement.
$BJ8$N7QB39T!#(B
@item statement-block-intro
@c On the first line in a new statement block.
$B?75,J8%V%m%C%/$N:G=i$N9T!#(B
@item statement-case-intro
@c On the first line in a @code{case} ``block.''
@code{case}$B%V%m%C%/$N:G=i$N9T!#(B
@item statement-case-open
@c On the first line in a @code{case} block starting with brace.
$BCf3g8L$G;O$^$k(B@code{case}$B%V%m%C%/$N:G=i$N9T!#(B
@item inexpr-statement
@c On a statement block inside an expression. This is used for a GNU
@c extension to the C language, and for Pike special functions that take a
@c statement block as an argument.
$B<0$NFbB&$K$"$kJ8%V%m%C%/!#(B
$B$3$l$O!"(BC$B8@8l$N(BGNU$B3HD%$d!"(B
$BJ8%V%m%C%/$r0z?t$H$7$F$H$k(BPike$B$NFC<l4X?t$KMQ$$$k!#(B
@item inexpr-class
@c On a class definition inside an expression. This is used for anonymous
@c classes and anonymous array initializers in Java.
$B<0$NFbB&$K$"$k%/%i%9Dj5A!#(B
$B$3$l$O!"(BJava$B$NL5L>%/%i%9$dL5L>G[Ns$N=i4|2=<0$KMQ$$$k!#(B
@item substatement
@c On the first line after an @code{if}, @code{while}, @code{for},
@c @code{do}, or @code{else}.
@code{if}$B!"(B@code{while}$B!"(B@code{for}$B!"(B
@code{do}$B!"(B@code{else}$B$ND>8e$N:G=i$N9T(B
@item substatement-open
@c On the brace that opens a substatement block.
substatement$B$N%V%m%C%/$r3+;O$9$kCf3g8L!#(B
@item case-label
@c On a @code{case} or @code{default} label.
@code{case}$B$^$?$O(B@code{default}$B%i%Y%k$rI=$9!#(B
@item access-label
@c On a C++ @code{private}, @code{protected}, or @code{public} access label.
C++$B$N%"%/%;%9;XDj;R(B@code{private}$B!"(B@code{protected}$B!"(B@code{public}$B$rI=$9!#(B
@item label
@c On any ordinary label.
$BDL>o$N%i%Y%k!#(B
@item do-while-closure
@c On the @code{while} that ends a @code{do}-@code{while} construct.
@code{do}-@code{while}$BJ8$N(B@code{while}$B!#(B
@item else-clause
@c On the @code{else} of an @code{if}-@code{else} construct.
@code{if}-@code{else}$BJ8$N(B@code{else}$B!#(B
@item catch-clause
@c On the @code{catch} and @code{finally} lines in
@c @code{try}@dots{}@code{catch} constructs in C++ and Java.
C++$B$d(BJava$B$N(B@code{try}@dots{}@code{catch}$B9=@.$N(B
@code{catch}$B9T$d(B@code{finally}$B9T!#(B
@item comment-intro
@c On a line containing only a comment introduction.
$B%3%a%s%H$NF3F~ItJ,$@$1$r4^$s$@9T!#(B
@item arglist-intro
@c On the first line in an argument list.
$B0z?t%j%9%H$N:G=i$N9T!#(B
@item arglist-cont
@c On one of the subsequent argument list lines when no arguments follow on
@c the same line as the arglist opening parenthesis.
$B0z?t%j%9%H$r3+;O$9$k3g8L$N9T$K0z?t$,$J$$>l9g!"(B
$B0z?t%j%9%H$N(B2$B9TL\0J9_!#(B
@item arglist-cont-nonempty
@c On one of the subsequent argument list lines when at least one argument
@c follows on the same line as the arglist opening parenthesis.
$B0z?t%j%9%H$r3+;O$9$k3g8L$N9T$K>/$J$/$H$b(B1$B$D$N0z?t$,$"$k>l9g!"(B
$B0z?t%j%9%H$N(B2$B9TL\0J9_!#(B
@item arglist-close
@c On the closing parenthesis of an argument list.
$B0z?t%j%9%H$r=*N;$9$k3g8L!#(B
@item stream-op
@c On one of the lines continuing a stream operator construct.
$B%9%H%j!<%`1i;;;R$rMQ$$$?<0$,7QB3$9$k9T!#(B
@item inclass
@c On a construct that is nested inside a class definition. The
@c indentation is relative to the open brace of the class definition.
$B%/%i%9Dj5A$NFbB&$KF~$l;R$K$J$C$?8@8l9=@.MWAG!#(B
$B;z2<$2$O!"%/%i%9Dj5A$N3+$-Cf3g8L$KAjBP$G$"$k!#(B
@item inextern-lang
@c On a construct that is nested inside an external language block.
$B30It8@8l%V%m%C%/$NFbB&$KF~$l;R$K$J$C$?8@8l9=@.MWAG!#(B
@item inexpr-statement
@c On the first line of statement block inside an expression. This is used
@c for the GCC extension to C that uses the syntax @code{(@{ @dots{} @})}.
@c It is also used for the special functions that takes a statement block
@c as an argument in Pike.
$B<0$NFbB&$NJ8%V%m%C%/$N:G=i$N9T!#(B
$B$3$l$O!"9=J8(B@code{(@{ @dots{} @})}$B$r;H$&(BC$B$KBP$9$k(BGCC$B3HD%$KMQ$$$k!#(B
$BJ8%V%m%C%/$r0z?t$H$7$F$H$k(BPike$B$NFC<l4X?t$K$bMQ$$$k!#(B
@item inexpr-class
@c On the first line of a class definition inside an expression. This is
@c used for anonymous classes and anonymous array initializers in Java.
$B<0$NFbB&$N%/%i%9Dj5A$N:G=i$N9T!#(B
$B$3$l$O!"(BJava$B$NL5L>%/%i%9$dL5L>G[Ns$N=i4|2=<0$KMQ$$$k!#(B
@item cpp-macro
@c On the start of a cpp macro.
cpp$B%^%/%m$N3+;O!#(B
@item friend
@c On a C++ @code{friend} declaration.
C++$B$N(B@code{friend}$B@k8@!#(B
@item objc-method-intro
@c On the first line of an Objective-C method definition.
Objective-C$B$N%a%=%C%IDj5A$N:G=i$N9T!#(B
@item objc-method-args-cont
@c On one of the lines continuing an Objective-C method definition.
Objective-C$B$N%a%=%C%IDj5A$r7QB3$9$k9T!#(B
@item objc-method-call-cont
@c On one of the lines continuing an Objective-C method call.
Objective-C$B$N%a%=%C%I8F$S=P$7$r7QB3$9$k9T!#(B
@item inlambda
@c Like @code{inclass}, but used inside lambda (i.e. anonymous) functions. Only
@c used in Pike.
@code{inclass}$B$HF1MM$@$,!"%i%`%@!J$D$^$j!"L5L>!K4X?t$NFbB&$KMQ$$$k!#(B
Pike$B$N$_$GMQ$$$k!#(B
@item lambda-intro-cont
@c On a line continuing the header of a lambda function, between the
@c @code{lambda} keyword and the function body. Only used in Pike.
$B%-!<%o!<%I(B@code{lambda}$B$H4X?tK\BN$N$"$$$@$N!"(B
$B%i%`%@4X?t$N%X%C%@!<$N7QB39T!#(B
Pike$B$N$_$GMQ$$$k!#(B
@end table
@node Variables for C Indent
@c @subsubsection Variables for C Indentation
@subsubsection C$B$N;z2<$2$N$?$a$NJQ?t(B
@c This section describes additional variables which control the
@c indentation behavior of C mode and related mode.
$BK\@a$G$O!"(BC$B%b!<%I$H$=$N4XO"%b!<%I$N;z2<$2F0:n$r@)8f$9$k!"(B
$B%b!<%I$K8GM-$JJQ?t$K$D$$$F@bL@$7$^$9!#(B
@table @code
@item c-offsets-alist
@vindex c-offsets-alist
@c Association list of syntactic symbols and their indentation offsets.
@c You should not set this directly, only with @code{c-set-offset}.
@c @xref{Changing Indent Style}, for details.
$B9=J8%7%s%\%k$H$=$N;z2<$2%*%U%;%C%H$NO"A[%j%9%H!#(B
$B$3$N%j%9%H$KD>@\$KCM$r@_Dj$9$k$N$G$O$J$/!"(B
@code{c-set-offset}$B$r;H$&$3$H!#(B
$B>\:Y$K$D$$$F$O!"(B@pxref{Changing Indent Style}$B!#(B
@item c-style-alist
@vindex c-style-alist
@c Variable for defining indentation styles; see below.
$B;z2<$2%9%?%$%k$rDj5A$7$F$$$kJQ?t!#(B
$B2<5-;2>H!#(B
@item c-basic-offset
@vindex c-basic-offset
@c Amount of basic offset used by @code{+} and @code{-} symbols in
@c @code{c-offsets-alist}.@refill
@code{c-offsets-alist}$B$NCf$G!"(B
$B%7%s%\%k(B@code{+}$B$d(B@code{-}$B$,MQ$$$k%*%U%;%C%H$N4pK\NL!#(B
@item c-special-indent-hook
@vindex c-special-indent-hook
@c Hook for user-defined special indentation adjustments. This hook is
@c called after a line is indented by C mode and related modes.
$B%f!<%6!<Dj5A$NFCJL$J;z2<$2D4@0MQ$N%U%C%/!#(B
$B$3$N%U%C%/$O!"(BC$B%b!<%I$d$=$N4XO"%b!<%I$,9T$N;z2<$2$r=*$($?$"$H$K8F$P$l$k!#(B
@end table
@c The variable @code{c-style-alist} specifies the predefined indentation
@c styles. Each element has form @code{(@var{name}
@c @var{variable-setting}@dots{})}, where @var{name} is the name of the
@c style. Each @var{variable-setting} has the form @code{(@var{variable}
@c . @var{value})}; @var{variable} is one of the customization variables
@c used by C mode, and @var{value} is the value for that variable when
@c using the selected style.
$BJQ?t(B@code{c-style-alist}$B$O!"(B
$B$"$i$+$8$aDj5A$5$l$?;z2<$2%9%?%$%k$rJ];}$7$^$9!#(B
$B3FMWAG$O(B@code{(@var{name} @var{variable-setting}@dots{})}$B$N7A$r$7$F$$$F!"(B
@var{name}$B$O%9%?%$%kL>$G$9!#(B
$B$^$?!"3F(B@var{variable-setting}$B$O!"(B
@code{(@var{variable} . @var{value})}$B$N7A$r$7$F$$$^$9!#(B
@var{variable}$B$K$O!"(BC$B%b!<%I$,;HMQ$9$k%+%9%?%^%$%:MQJQ?t$N(B1$B$D$r;XDj$7$^$9!#(B
@var{value}$B$O!"A*Br$5$l$?%9%?%$%k$,;H$o$l$k$H$-$N(B@var{variable}$B$NCM$G$9!#(B
@c When @var{variable} is @code{c-offsets-alist}, that is a special case:
@c @var{value} is appended to the front of the value of @code{c-offsets-alist}
@c instead of replacing that value outright. Therefore, it is not necessary
@c for @var{value} to specify each and every syntactic symbol---only those
@c for which the style differs from the default.
@var{variable}$B$,(B@code{c-offsets-alist}$B$G$"$k>l9g$O!"FC<l$J%1!<%9$G$9!#(B
@code{c-offsets-alist}$B$NCM$r(B@var{value}$B$NCM$GCV$-49$($k$N$G$O$J$/!"(B
@code{c-offsets-alist}$B$NCM$N@hF,$K(B@var{value}$B$rDI2C$7$^$9!#(B
$B$7$?$,$C$F!"(B@var{value}$B$K$9$Y$F$N9=J8%7%s%\%k$r@_Dj$9$kI,MW$O$"$j$^$;$s!#(B
$B%G%U%)%k%H$H0[$J$k9=J8%7%s%\%k$@$1$rC1$K@_Dj$9$l$P$h$$$N$G$9!#(B
@c The indentation of lines containing only comments is also affected by
@c the variable @code{c-comment-only-line-offset} (@pxref{Comments in C}).
$B%3%a%s%H$@$1$r4^$s$@9T$N;z2<$2$b!"(B
$BJQ?t(B@code{c-comment-only-line-offset}
$B!J(B@pxref{Comments in C}$B!K$K1F6A$5$l$^$9!#(B
@node C Indent Styles
@c @subsubsection C Indentation Styles
@subsubsection C$B$N;z2<$2%9%?%$%k(B
@c @cindex c indentation styles
@cindex C$B$N;z2<$2%9%?%$%k(B
@c A @dfn{C style} is a collection of indentation style customizations.
@c Emacs comes with several predefined indentation styles for C and related
@c modes, including @code{gnu}, @code{k&r}, @code{bsd}, @code{stroustrup},
@c @code{linux}, @code{python}, @code{java}, @code{whitesmith},
@c @code{ellemtel}, and @code{cc-mode}. The default style is @code{gnu}.
@dfn{C$B%9%?%$%k(B}$B$H$O!"%+%9%?%^%$%:$5$l$?;z2<$2%9%?%$%k$N=89g$G$9!#(B
Emacs$B$K$O!"(BC$B%b!<%I$d4XO"$9$k%b!<%I$N$?$a$K$"$i$+$8$aDj5A$5$l$?!"(B
@code{gnu}$B!"(B@code{k&r}$B!"(B@code{bsd}$B!"(B@code{stroustrup}$B!"(B
@code{linux}$B!"(B@code{python}$B!"(B@code{java}$B!"(B@code{whitesmith}$B!"(B
@code{ellemtel}$B!"(B@code{cc-mode}$B$H$$$C$?;z2<$2%9%?%$%k$,$"$j$^$9!#(B
$B%G%U%)%k%H$N%9%?%$%k$O(B@code{gnu}$B$G$9!#(B
@findex c-set-style
@vindex c-default-style
@c To choose the style you want, use the command @kbd{M-x c-set-style}.
@c Specify a style name as an argument (case is not significant in C style
@c names). The chosen style only affects newly visited buffers, not those
@c you are already editing. You can also set the variable
@c @code{c-default-style} to specify the style for various major modes.
@c Its value should be an alist, in which each element specifies one major
@c mode and which indentation style to use for it. For example,
$BK>$_$N%9%?%$%k$rA*Br$9$k$K$O!"%3%^%s%I(B@kbd{M-x c-set-style}$B$r;H$$$^$9!#(B
$B0z?t$H$7$F%9%?%$%kL>$r;XDj$7$^$9(B
$B!J(BC$B%9%?%$%kL>$G$OBgJ8;z>.J8;z$O6hJL$7$J$$!K!#(B
$BA*Br$7$?%9%?%$%k$O?7$?$KK,Ld$7$?%P%C%U%!$K$@$11F6A$7!"(B
$B$9$G$KJT=8Cf$N%P%C%U%!$K$O1F6A$7$^$;$s!#(B
$B$5$^$6$^$J%a%8%c!<%b!<%I$N%9%?%$%k$r;XDj$9$k$?$a$K(B
$BJQ?t(B@code{c-default-style}$B$r@_Dj$9$k$3$H$b$G$-$^$9!#(B
$B$=$NCM$OO"A[%j%9%H$G$"$kI,MW$,$"$j!"(B
$B$=$N3FMWAG$O!"(B1$B$D$N%a%8%c!<%b!<%I$H(B
$B$=$N%b!<%I$G;H$&;z2<$2%9%?%$%k$r;XDj$7$^$9!#(B
$B$?$H$($P!"(B
@example
(setq c-default-style
'((java-mode . "java") (other . "gnu")))
@end example
@noindent
@c specifies an explicit choice for Java mode, and the default @samp{gnu}
@c style for the other C-like modes.
$B$O!"(BJava$B%b!<%I$K$OBP$7$F$OA*Br$rL@<($7!"(B
$BB>$N(BC$BN.%b!<%I$K$O(B@samp{gnu}$B$r%G%U%)%k%H$H$7$^$9!#(B
@findex c-add-style
@c To define a new C indentation style, call the function
@c @code{c-add-style}:
C$B$N;z2<$2%9%?%$%k$r?7$?$KDj5A$9$k$K$O!"4X?t(B@code{c-add-style}$B$r8F$S$^$9!#(B
@example
(c-add-style @var{name} @var{values} @var{use-now})
@end example
@noindent
@c Here @var{name} is the name of the new style (a string), and
@c @var{values} is an alist whose elements have the form
@c @code{(@var{variable} . @var{value})}. The variables you specify should
@c be among those documented in @ref{Variables for C Indent}.
$B$3$3$G!"(B@var{name}$B$O?7$7$$%9%?%$%k$NL>A0!JJ8;zNs!K!"(B
@var{values}$B$OMWAG$,(B@code{(@var{variable} . @var{value})}$B$N7A$r$7$?(B
$BO"A[%j%9%H$G$9!#(B
@var{variable}$B$K$O!"(B@ref{Variables for C Indent}$B$K(B
$B=q$+$l$F$$$k$b$N$r;XDj$7$F$/$@$5$$!#(B
@c If @var{use-now} is non-@code{nil}, @code{c-add-style} switches to the
@c new style after defining it.
@var{use-now}$B$,(B@code{nil}$B0J30$J$i$P!"(B
$B?7$7$$%9%?%$%k$NDj5A8e$9$0$K$=$l$K@Z$jBX$($^$9!#(B
@node Matching
@c @section Automatic Display Of Matching Parentheses
@section $BBP1~$7$F$$$k3g8L$N<+F0I=<((B
@c @cindex matching parentheses
@c @cindex parentheses
@cindex $BBP1~$7$F$$$k3g8L(B
@cindex $B3g8L(B
@c The Emacs parenthesis-matching feature is designed to show
@c automatically how parentheses match in the text. Whenever you type a
@c self-inserting character that is a closing delimiter, the cursor moves
@c momentarily to the location of the matching opening delimiter, provided
@c that is on the screen. If it is not on the screen, some text near it is
@c displayed in the echo area. Either way, you can tell what grouping is
@c being closed off.
Emacs$B$N3g8L$NBP1~IU$15!G=$O!"%F%-%9%HCf$G$I$N$h$&$K3g8L$,(B
$BBP1~$7$F$$$k$+<+F0E*$KI=<($9$k$h$&@_7W$5$l$F$$$^$9!#(B
$BJD$86h@Z$j$G$"$k<+8JA^F~J8;z$rBG$D$H!"(B
$B$=$l$KBP1~$9$k3+$-6h@Z$j$,2hLL>e$K$"$l$P!"(B
$B$=$N2U=j$K$[$s$N$7$P$i$/%+!<%=%k$,0\F0$7$^$9!#(B
$B2hLL>e$K$J$1$l$P!"%(%3!<NN0h$K$=$N2U=j$N6a$/$K$"$kJ8;zNs$rI=<($7$^$9!#(B
$B$$$:$l$K$7$F$b!"(B1$B$D$N$^$H$^$j$,JD$8$?$3$H$,H=$j$^$9!#(B
@c In Lisp, automatic matching applies only to parentheses. In C, it
@c applies to braces and brackets too. Emacs knows which characters to regard
@c as matching delimiters based on the syntax table, which is set by the major
@c mode. @xref{Syntax}.
Lisp$B$G$O!"3g8L$@$1$KBP$7$F<+F0E*$JBP1~IU$1$r9T$$$^$9!#(B
C$B$G$O!"Cf3g8L$d3Q3g8L$bBP>]$H$J$j$^$9!#(B
Emacs$B$O!"%a%8%c!<%b!<%I$,@_Dj$9$k9=J8%F!<%V%k$K4p$E$$$F!"(B
$B$I$NJ8;z$,BP1~4X78$K$"$k6h@Z$j$G$"$k$+H=Dj$7$^$9!#(B
@xref{Syntax}$B!#(B
@c If the opening delimiter and closing delimiter are mismatched---such as
@c in @samp{[x)}---a warning message is displayed in the echo area. The
@c correct matches are specified in the syntax table.
@samp{[x)}$B$N$h$&$K!"3+$-6h@Z$j$HJD$86h@Z$j$,BP1~$7$J$$>l9g!"(B
$B%(%3!<NN0h$K7Y9p%a%C%;!<%8$rI=<($7$^$9!#(B
$B@5$7$$BP1~4X78$O9=J8%F!<%V%k$G;XDj$7$^$9!#(B
@vindex blink-matching-paren
@vindex blink-matching-paren-distance
@vindex blink-matching-delay
@c Three variables control parenthesis match display.
@c @code{blink-matching-paren} turns the feature on or off; @code{nil}
@c turns it off, but the default is @code{t} to turn match display on.
@c @code{blink-matching-delay} says how many seconds to wait; the default
@c is 1, but on some systems it is useful to specify a fraction of a
@c second. @code{blink-matching-paren-distance} specifies how many
@c characters back to search to find the matching opening delimiter. If
@c the match is not found in that far, scanning stops, and nothing is
@c displayed. This is to prevent scanning for the matching delimiter from
@c wasting lots of time when there is no match. The default is 12,000.
$B3g8L$NBP1~I=<($r@)8f$9$kJQ?t$O(B3$B$D$"$j$^$9!#(B
@code{blink-maching-paren}$B$O!"BP1~I=<(5!G=$r%*%s$^$?$O%*%U$K$7$^$9!#(B
@code{nil}$B$r@_Dj$9$k$HBP1~I=<(5!G=$O%*%U$K$J$j$^$9$,!"(B
$B%G%U%)%k%H$O(B@code{t}$B$G$"$j!"BP1~I=<($r9T$$$^$9!#(B
@code{blink-matching-delay}$B$O!"BP1~I=<($N$?$a$KBT$DIC?t$r;XDj$7$^$9!#(B
$B%G%U%)%k%H$O(B1$BIC$G$9$,!"%7%9%F%`$K$h$C$F$O2?J,$N(B1$BIC$N$[$&$,JXMx$+$b$7$l$^$;$s!#(B
@code{blink-matching-paren-distance}$B$O!"(B
$BBP1~$7$F$$$k3+$-6h@Z$j$r$_$D$1$k$?$a$K!"(B
$B2?J8;zJ,$^$GLa$C$FC5:w$9$k$+;XDj$7$^$9!#(B
$B$=$NHO0OFb$GBP1~$9$k$b$N$,$_$D$+$i$J$1$l$P!"Av::$r$d$a$F2?$bI=<($7$^$;$s!#(B
$B$3$l$O!"B8:_$7$b$7$J$$BP1~$9$k6h@Z$j$rC5$9$3$H$K(B
$B;~4V$rO2Hq$9$k$N$rKI$0$?$a$G$9!#(B
$B%G%U%)%k%H$O(B12,000$B$G$9!#(B
@c @cindex Show Paren mode
@cindex $BBP1~3g8LI=<(!J(BShow Paren$B!K%b!<%I(B
@cindex show-paren$B%b!<%I(B
@cindex $B%b!<%I!"(BShow Paren
@findex show-paren-mode
@c When using X Windows, you can request a more powerful alternative kind
@c of automatic parenthesis matching by enabling Show Paren mode. This
@c mode turns off the usual kind of matching parenthesis display and
@c instead uses highlighting to show what matches. Whenever point is after
@c a close parenthesis, the close parenthesis and its matching open
@c parenthesis are both highlighted; otherwise, if point is before an open
@c parenthesis, the matching close parenthesis is highlighted. (There is
@c no need to highlight the open parenthesis after point because the cursor
@c appears on top of that character.) Use the command @kbd{M-x
@c show-paren-mode} to enable or disable this mode.
X$B%&%#%s%I%&%7%9%F%`$r;HMQ$7$F$$$k>l9g!"(B
$BBP1~3g8LI=<(!J(Bshow-paren$B!K%b!<%I$K$9$l$P!"(B
$B$h$j6/NO$J3g8L$NBP1~I=<($rMxMQ$G$-$^$9!#(B
$B$3$N%b!<%I$O!"DL>o$NBP1~I=<($r%*%U$K$9$k$+$o$j$K!"(B
$BBP1~$9$k3g8LF1;N$r<($9$?$a$K6/D4I=<($r9T$$$^$9!#(B
$B%]%$%s%H$,JD$83g8L$ND>8e$K$"$k$H$-$K$O!"(B
$BJD$83g8L$H$=$l$KBP1~$9$k3+$-3g8L$NN>J}$r6/D4I=<($7$^$9!#(B
$B%]%$%s%H$,3+$-3g8L$ND>A0$K$"$k$H$-$K$O!"BP1~$9$kJD$83g8L$r6/D4I=<($7$^$9!#(B
$B!J%]%$%s%H$ND>8e$K3+$-3g8L$,$"$k$H$-$K$O!"(B
$B%+!<%=%k$,3+$-3g8L$K=E$M$FI=<($5$l$k$N$G!"(B
$B3+$-3g8L$r6/D4I=<($9$kI,MW$O$J$$!#!K(B
$B$3$N%b!<%I$r%*%s!?%*%U$9$k$K$O!"(B
$B%3%^%s%I(B@kbd{M-x show-paren-mode}$B$r;H$$$^$9!#(B
@node Comments
@c @section Manipulating Comments
@section $B%3%a%s%H$NA`:n(B
@c @cindex comments
@cindex $B%3%a%s%H(B
@c Because comments are such an important part of programming, Emacs
@c provides special commands for editing and inserting comments.
$B%3%a%s%H$O%W%m%0%i%_%s%0$N=EMW$JItJ,$J$N$G!"(B
Emacs$B$K$O%3%a%s%H$NJT=8$dA^F~$r9T$&$?$a$NFCJL$J%3%^%s%I$,$"$j$^$9!#(B
@menu
* Comment Commands::
* Multi-Line Comments::
* Options for Comments::
@end menu
@node Comment Commands
@c @subsection Comment Commands
@subsection $B%3%a%s%HMQ%3%^%s%I(B
@kindex M-;
@c @cindex indentation for comments
@cindex $B%3%a%s%H$N;z2<$2(B
@findex indent-for-comment
@c The comment commands insert, kill and align comments.
$B%3%a%s%HMQ%3%^%s%I$O%3%a%s%H$NA^F~!":o=|!"$*$h$S0LCVB7$($r9T$$$^$9!#(B
@c WideCommands
@table @kbd
@item M-;
@c Insert or align comment (@code{indent-for-comment}).
$B%3%a%s%H$NA^F~!?0LCVB7$($r9T$&!J(B@code{indent-for-comment}$B!K!#(B
@item C-x ;
@c Set comment column (@code{set-comment-column}).
$B%3%a%s%H$N7e0LCV$r@_Dj$9$k!J(B@code{set-comment-column}$B!K!#(B
@item C-u - C-x ;
@c Kill comment on current line (@code{kill-comment}).
$B8=:_9T$N%3%a%s%H$r%-%k$9$k!J(B@code{kill-comment}$B!K!#(B
@item C-M-j
@c Like @key{RET} followed by inserting and aligning a comment
@c (@code{indent-new-comment-line}).
@key{RET}$B$KB3$1$F!"%3%a%s%H$NA^F~!?0LCVB7$($r9T$&(B
$B!J(B@code{indent-new-comment-line}$B!K!#(B
@item M-x comment-region
@c Add or remove comment delimiters on all the lines in the region.
$B%j!<%8%g%sFb$N3F9T$KBP$7$F!"%3%a%s%H6h@Z$j$rDI2C!?:o=|$9$k!#(B
@end table
@c The command that creates a comment is @kbd{M-;} (@code{indent-for-comment}).
@c If there is no comment already on the line, a new comment is created,
@c aligned at a specific column called the @dfn{comment column}. The comment
@c is created by inserting the string Emacs thinks comments should start with
@c (the value of @code{comment-start}; see below). Point is left after that
@c string. If the text of the line extends past the comment column, then the
@c indentation is done to a suitable boundary (usually, at least one space is
@c inserted). If the major mode has specified a string to terminate comments,
@c that is inserted after point, to keep the syntax valid.
$B%3%a%s%H$rA^F~$9$k%3%^%s%I$O(B@kbd{M-;}$B!J(B@code{indent-for-comment}$B!K$G$9!#(B
$B9T$K%3%a%s%H$,$J$1$l$P!"?75,$K%3%a%s%H$r:n@.$7$F!"(B
@dfn{$B%3%a%s%H7e0LCV(B}$B$H8F$P$l$kFCDj$N7e$KCV$-$^$9!#(B
$B%3%a%s%H$r:n@.$9$k:]$K$O!"(BEmacs$B$,@5$7$$$H?.$8$k%3%a%s%H3+;OJ8;zNs(B
$B!J(B@code{comment-start}$B$NCM!#2<5-;2>H!K$rA^F~$7$^$9!#(B
$B%]%$%s%H$O$=$NJ8;zNs$ND>8e$KCV$+$l$^$9!#(B
$B%3!<%I$N%F%-%9%H$,%3%a%s%H7e0LCV$r1[$($F$$$k$H$-$K$O!"(B
$BE,Ev$J6-3&$K;z2<$2$7$^$9!JDL>o$O>/$J$/$H$b6uGr(B1$BJ8;z!K!#(B
$B%a%8%c!<%b!<%I$G%3%a%s%H=*N;J8;zNs$,;XDj$5$l$F$$$l$P!"(B
$B9=J8$r@5$7$/J]$D$?$a$K!"%]%$%s%H$ND>8e$K$=$NJ8;zNs$rA^F~$7$^$9!#(B
@c @kbd{M-;} can also be used to align an existing comment. If a line
@c already contains the string that starts comments, then @kbd{M-;} just moves
@c point after it and reindents it to the conventional place. Exception:
@c comments starting in column 0 are not moved.
@kbd{M-;}$B$O!"4{B8$N%3%a%s%H$r0LCVB7$($9$k$?$a$K$b;H$($^$9!#(B
$B9T$K%3%a%s%H3+;OJ8;zNs$,$9$G$K4^$^$l$F$$$l$P!"(B
$B$=$NJ8;zNs$ND>8e$K%]%$%s%H$r0\F0$7$F$+$i!"E,@Z$J0LCV$K;z2<$2$7$^$9!#(B
$BNc30$H$7$F!"(B0$B7eL\$+$i;O$^$k%3%a%s%H$OF0$+$7$^$;$s!#(B
@c Some major modes have special rules for indenting certain kinds of
@c comments in certain contexts. For example, in Lisp code, comments which
@c start with two semicolons are indented as if they were lines of code,
@c instead of at the comment column. Comments which start with three
@c semicolons are supposed to start at the left margin. Emacs understands
@c these conventions by indenting a double-semicolon comment using @key{TAB},
@c and by not changing the indentation of a triple-semicolon comment at all.
$BFCDj$NJ8L.$K$*$1$k!"$"$k<o$N%3%a%s%H$N;z2<$2$K$OFC<l$J5,B'$r;}$D(B
$B%a%8%c!<%b!<%I$b$"$j$^$9!#(B
$B$?$H$($P!"(BLisp$B$N%3!<%I$G$O!"%;%_%3%m%s(B2$B$D$G;O$^$k%3%a%s%H$O!"(B
$B%3%a%s%H7e0LCV$KB7$($k$N$G$J$/!"%3!<%I$G$"$k$+$N$h$&$K;z2<$2$5$l$^$9!#(B
$B$^$?!"%;%_%3%m%s(B3$B$D$G;O$^$k%3%a%s%H$O:8C<$KCV$/$H2>Dj$5$l$^$9!#(B
Emacs$B$O$3$l$i$N47=,$rM}2r$7$F$$$F!"(B
$B%;%_%3%m%s(B2$B$D$N%3%a%s%H$O(B@key{TAB}$B$G;z2<$2$7!"(B
$B%;%_%3%m%s(B3$B$D$N%3%a%s%H$O;z2<$2$r$^$C$?$/JQ99$7$^$;$s!#(B
@example
;; This function is just an example
;;; Here either two or three semicolons are appropriate.
(defun foo (x)
;;; And now, the first part of the function:
;; The following line adds one.
(1+ x)) ; This line adds one.
@end example
@c In C code, a comment preceded on its line by nothing but whitespace
@c is indented like a line of code.
C$B$N%3!<%I$G$O!"%3%a%s%H$N$^$($KGrJ8;z$7$+$J$$>l9g$K$O!"(B
$B$=$N%3%a%s%H$r%3!<%I$N$h$&$K;z2<$2$7$^$9!#(B
@c Even when an existing comment is properly aligned, @kbd{M-;} is still
@c useful for moving directly to the start of the comment.
$B4{B8$N%3%a%s%H$N0LCV$,E,@Z$KB7$($i$l$F$$$k>l9g$G$b!"(B
$B%3%a%s%H3+;OD>8e$N0LCV$K$9$0$K0\F0$9$k$K$O(B@kbd{M-;}$B$,JXMx$G$9!#(B
@kindex C-u - C-x ;
@findex kill-comment
@c @kbd{C-u - C-x ;} (@code{kill-comment}) kills the comment on the current line,
@c if there is one. The indentation before the start of the comment is killed
@c as well. If there does not appear to be a comment in the line, nothing is
@c done. To reinsert the comment on another line, move to the end of that
@c line, do @kbd{C-y}, and then do @kbd{M-;} to realign it. Note that
@c @kbd{C-u - C-x ;} is not a distinct key; it is @kbd{C-x ;} (@code{set-comment-column})
@c with a negative argument. That command is programmed so that when it
@c receives a negative argument it calls @code{kill-comment}. However,
@c @code{kill-comment} is a valid command which you could bind directly to a
@c key if you wanted to.
@kbd{C-u - C-x ;}$B!J(B@code{kill-comment}$B!K$O!"(B
$B8=:_9T$K%3%a%s%H$,$"$l$P!"$=$l$r%-%k$7$^$9!#(B
$B%3%a%s%H3+;OJ8;zNs$N$^$($K$"$k;z2<$2$b%-%k$7$^$9!#(B
$B%3%a%s%H$H;W$o$l$k$b$N$,2?$b$J$1$l$P!"2?$b$7$^$;$s!#(B
$BB>$N9T$K%3%a%s%H$r:FA^F~$9$k$K$O!"(B
$B$=$N9T$NKvHx$K0\F0$7$F$+$i(B@kbd{C-y}$B$HBG$C$F!"(B
$B$5$i$K!"0LCV$r:FD4@0$9$k$?$a$K(B@kbd{M-;}$B$HBG$A$^$9!#(B
@kbd{C-u - C-x ;}$B$O$R$H$^$H$^$j$N%-!<$G$O$J$/!"(B
$BIi$N0z?t$r;XDj$7$?(B@kbd{C-x ;}$B!J(B@code{set-comment-column}$B!K$G(B
$B$"$k$3$H$KCm0U$7$^$7$g$&!#(B
$B$3$N%3%^%s%I$O!"Ii$N0z?t$r<u$1<h$k$H!"(B
@code{kill-comment}$B$r8F$V$h$&$K%W%m%0%i%`$5$l$F$$$^$9!#(B
@code{kill-comment}$B$O!"K>$`$J$i$P%-!<$KD>@\%P%$%s%I$G$-$kDL>o$N%3%^%s%I$G$9!#(B
@node Multi-Line Comments
@c @subsection Multiple Lines of Comments
@subsection $BJ#?t9T$K$o$?$k%3%a%s%H(B
@kindex C-M-j
@c @cindex blank lines in programs
@cindex $B%W%m%0%i%`Cf$N6u9T(B
@findex indent-new-comment-line
@c If you are typing a comment and wish to continue it on another line,
@c you can use the command @kbd{C-M-j} (@code{indent-new-comment-line}).
@c This terminates the comment you are typing, creates a new blank line
@c afterward, and begins a new comment indented under the old one. When
@c Auto Fill mode is on, going past the fill column while typing a comment
@c causes the comment to be continued in just this fashion. If point is
@c not at the end of the line when @kbd{C-M-j} is typed, the text on
@c the rest of the line becomes part of the new comment line.
$B%3%a%s%H$rF~NO$7$F$$$FJL$N9T$K7QB3$7$?$1$l$P!"(B
$B%3%^%s%I(B @kbd{C-M-j}$B!J(B@code{indent-new-comment-line}$B!K$rMxMQ$G$-$^$9!#(B
$B$3$N%3%^%s%I$O!"F~NOCf$N%3%a%s%H$r=*N;$7$F!"(B
$B$=$N$D$.$K6u9T$r:n$j!"(B
$BD>A0$N%3%a%s%H$ND>2<$K$/$k$h$&$K;z2<$2$7$F?7$?$J%3%a%s%H$r;O$a$^$9!#(B
$B<+F05M$a9~$_!J(Bauto-fill$B!K%b!<%I$,%*%s$J$i$P!"(B
$B%3%a%s%H$rF~NOCf$K5M$a9~$_7e$r1[$($k$H!"(B
$BF1MM$K%3%a%s%H$O$D$.$N9T$K7QB3$5$l$^$9!#(B
@kbd{C-M-j}$B$rBG$C$?$H$-$K%]%$%s%H$,9TKv$K$J$1$l$P!"(B
$B%]%$%s%H0LCV$+$i9TKv$^$G$N%F%-%9%H$O?7$?$J%3%a%s%H$N0lIt$K$J$j$^$9!#(B
@findex comment-region
@c To turn existing lines into comment lines, use the @kbd{M-x
@c comment-region} command. It adds comment delimiters to the lines that start
@c in the region, thus commenting them out. With a negative argument, it
@c does the opposite---it deletes comment delimiters from the lines in the
@c region.
$B4{B8$N9T$r%3%a%s%H$K$9$k$K$O!"(B
$B%3%^%s%I(B@kbd{M-x comment-region}$B$r;H$$$^$9!#(B
$B$3$N%3%^%s%I$O!"%j!<%8%g%sFb$G;O$^$k3F9T$K%3%a%s%H6h@Z$jJ8;zNs$r2C$($F(B
$B%3%a%s%H$K$7$^$9!#(B
$BIi$N0z?t$r;XDj$9$k$H5U$NA`:n!"(B
$B$D$^$j!"%3%a%s%H6h@Z$jJ8;zNs$r:o=|$7$^$9!#(B
@c With a positive argument, @code{comment-region} duplicates the last
@c character of the comment start sequence it adds; the argument specifies
@c how many copies of the character to insert. Thus, in Lisp mode,
@c @kbd{C-u 2 M-x comment-region} adds @samp{;;} to each line. Duplicating
@c the comment delimiter is a way of calling attention to the comment. It
@c can also affect how the comment is indented. In Lisp, for proper
@c indentation, you should use an argument of two, if between defuns, and
@c three, if within a defun.
$B@5$N0z?t$r;XDj$9$k$H!"(B@code{comment-region}$B$O!"(B
$BDI2C$9$k%3%a%s%H3+;OJ8;zNs$N:G8e$NJ8;z$r=EJ#$5$;$^$9!#(B
$B$D$^$j!"0z?t$O!"$=$NJ8;z$r2?2s=EJ#$5$;$k$+$r<($7$^$9!#(B
$B$?$H$($P!"(BLisp$B%b!<%I$G(B@kbd{C-u 2 M-x commment-region}$B$H$9$k$H!"(B
$B3F9T$K(B@samp{;;}$B$rIU2C$7$^$9!#(B
$B%3%a%s%H6h@Z$jJ8;z$r=EJ#$5$;$k$N$O!"%3%a%s%H$KCm0U$r0z$-IU$1$k$?$a$G$9!#(B
$B$^$?!"%3%a%s%H$N;z2<$2$K$b1F6A$7$^$9!#(B
Lisp$B$G$O!"E,@Z$J;z2<$2$K$J$k$h$&$K!"(B
$B4X?tDj5A!J(Bdefun$B!K$N$"$$$@$G$O0z?t$H$7$F(B3$B$r!"(B
$B4X?tDj5A$NFbB&$G$O0z?t$H$7$F(B2$B$r;XDj$9$Y$-$G$9!#(B
@vindex comment-padding
@c The variable @code{comment-padding} specifies how many spaces
@c @code{comment-region} should insert on each line between the
@c comment delimiter and the line's original text. The default is 1.
$BJQ?t(B@code{comment-padding}$B$O!"(B
@code{comment-region}$B$,%3%a%s%H6h@Z$j$H3F9T$N$b$H$N%F%-%9%H$H$N$"$$$@$K(B
$BA^F~$9$k6uGr$N8D?t$r;XDj$7$^$9!#(B
$B%G%U%)%k%H$O(B1$B$G$9!#(B
@node Options for Comments
@c @subsection Options Controlling Comments
@subsection $B%3%a%s%H$r@)8f$9$k%*%W%7%g%s(B
@vindex comment-column
@kindex C-x ;
@findex set-comment-column
@c The comment column is stored in the variable @code{comment-column}. You
@c can set it to a number explicitly. Alternatively, the command @kbd{C-x ;}
@c (@code{set-comment-column}) sets the comment column to the column point is
@c at. @kbd{C-u C-x ;} sets the comment column to match the last comment
@c before point in the buffer, and then does a @kbd{M-;} to align the
@c current line's comment under the previous one. Note that @kbd{C-u - C-x ;}
@c runs the function @code{kill-comment} as described above.
$B%3%a%s%H7e0LCV$O!"JQ?t(B@code{comment-column}$B$KF~$C$F$$$^$9!#(B
$B$3$NJQ?t$K$OL@<(E*$KCM$r@_Dj$G$-$^$9!#(B
$B$"$k$$$O!"%3%^%s%I(B @kbd{C-x ;}$B!J(B@code{set-comment-column}$B!K$r;H$C$F!"(B
$B%]%$%s%H0LCV$N7e$r%3%a%s%H7e0LCV$H$7$F@_Dj$G$-$^$9!#(B
@kbd{C-u C-x ;}$B$O!"%P%C%U%!Fb$G8=:_9T$h$j$^$($K$"$k:G8e$N%3%a%s%H$N7e0LCV$r(B
$B%3%a%s%H7e0LCV$H$7$F$+$i!"(B
@kbd{M-;}$B$r9T$C$F8=:_9T$N%3%a%s%H$r$^$($N%3%a%s%H$ND>2<$K$/$k$h$&$K(B
$B0LCV$rB7$($^$9!#(B
@kbd{C-u - C-x ;}$B$O!"A0=R$N$h$&$K(B
$B4X?t(B@code{kill-comment}$B$r<B9T$9$k$3$H$KCm0U$7$F$/$@$5$$!#(B
@c The variable @code{comment-column} is per-buffer: setting the variable
@c in the normal fashion affects only the current buffer, but there is a
@c default value which you can change with @code{setq-default}.
@c @xref{Locals}. Many major modes initialize this variable for the
@c current buffer.
$BJQ?t(B@code{comment-column}$B$O!"%P%C%U%!$4$H$NJQ?t$G$9!#(B
$B$D$^$j!"DL>o$NJ}K!$G@_Dj$9$k$H!"%+%l%s%H%P%C%U%!$@$1$K1F6A$7$^$9$,!"(B
@code{setq-default}$B$G%G%U%)%k%HCM$rJQ99$G$-$^$9!#(B
@xref{Locals}$B!#(B
$BB?$/$N%a%8%c!<%b!<%I$G$O!"$3$NJQ?t$r%+%l%s%H%P%C%U%!MQ$K=i4|2=$7$^$9!#(B
@vindex comment-start-skip
@c The comment commands recognize comments based on the regular
@c expression that is the value of the variable @code{comment-start-skip}.
@c Make sure this regexp does not match the null string. It may match more
@c than the comment starting delimiter in the strictest sense of the word;
@c for example, in C mode the value of the variable is @code{@t{"/\\*+
@c *"}}, which matches extra stars and spaces after the @samp{/*} itself.
@c (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in
@c the string, which is needed to deny the first star its special meaning
@c in regexp syntax. @xref{Regexps}.)
$B%3%a%s%HMQ%3%^%s%I$O!"JQ?t(B@code{comment-start-skip}$B$N@55,I=8=$K4p$E$$$F(B
$B%3%a%s%H$rG'<1$7$^$9!#(B
$B$3$N@55,I=8=$,6uJ8;zNs$K$O0lCW$7$J$$$h$&$K$7$F$/$@$5$$!#(B
$B87L)$K$O%3%a%s%H3+;OJ8;zNs$h$j$bD9$/0lCW$9$k$+$b$7$l$^$;$s!#(B
$B$?$H$($P!"(BC$B%b!<%I$G$O$3$NJQ?t$NCM$O(B@code{@t{"/\\*+ *"}}$B$G$9$,!"(B
$B$3$l$O(B @samp{/*}$B$N$&$7$m$NM>J,$J%"%9%?%j%9%/$H6uGr$K0lCW$7$^$9!#(B
$B!J(BLisp$B$N9=J8$G$O!"J8;zNsCf$K(B@samp{\}$B$r4^$a$k$?$a$K(B@samp{\\}$B$H$9$kI,MW$,$"$k!#(B
$B$3$N(B@samp{\}$B$O!":G=i$N%"%9%?%j%9%/$N@55,I=8=$K$*$1$kFCJL$J(B
$B0UL#$rM^@)$9$k$?$a$KI,MW!#(B
@pxref{Regexps}$B!#!K(B
@vindex comment-start
@vindex comment-end
@c When a comment command makes a new comment, it inserts the value of
@c @code{comment-start} to begin it. The value of @code{comment-end} is
@c inserted after point, so that it will follow the text that you will insert
@c into the comment. In C mode, @code{comment-start} has the value
@c @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}.
$B%3%a%s%HMQ%3%^%s%I$G?7$?$J%3%a%s%H$r:n$k$H!"(B
$B%3%a%s%H$r;O$a$k$?$a$K(B@code{comment-start}$B$NCM$rA^F~$7$^$9!#(B
$B$^$?!"%]%$%s%H$ND>8e$K$O(B@code{comment-end}$B$NCM$,A^F~$5$l$F!"(B
$B$3$l$+$iF~NO$9$k%F%-%9%H$N$"$H$KB3$/$3$H$K$J$j$^$9!#(B
C$B%b!<%I$G$O!"(B@code{comment-start}$B$NCM$O(B@w{@code{"/* "}}$B!"(B
@code{comment-end}$B$NCM$O(B@w{@code{" */"}}$B$G$9!#(B
@vindex comment-multi-line
@c The variable @code{comment-multi-line} controls how @kbd{C-M-j}
@c (@code{indent-new-comment-line}) behaves when used inside a comment. If
@c @code{comment-multi-line} is @code{nil}, as it normally is, then the
@c comment on the starting line is terminated and a new comment is started
@c on the new following line. If @code{comment-multi-line} is not
@c @code{nil}, then the new following line is set up as part of the same
@c comment that was found on the starting line. This is done by not
@c inserting a terminator on the old line, and not inserting a starter on
@c the new line. In languages where multi-line comments work, the choice
@c of value for this variable is a matter of taste.
$BJQ?t(B@code{comment-multi-line}$B$O!"(B
@kbd{C-M-j}$B!J(B@code{indent-new-comment-line}$B!K$,(B
$B%3%a%s%H$NFbB&$G;H$o$l$?$H$-$NF0:n$r@)8f$7$^$9!#(B
@code{comment-multi-line}$B$,(B@code{nil}$B!JDL>o$N@_Dj!K$J$i$P!"(B
$B8=:_9T$N%3%a%s%H$r=*N;$7!"?7$?$J%3%a%s%H$r$D$.$N9T$+$i;O$a$^$9!#(B
@code{comment-multi-line}$B$,(B@code{nil}$B0J30$J$i$P!"(B
$B8=:_9T$HF1$8%3%a%s%H$,7QB3$5$l$^$9!#(B
$B$D$^$j!"8=:_9T$N%3%a%s%H$r=*$($:!"?7$?$J9T$K$b3+;OJ8;zNs$rA^F~$7$^$;$s!#(B
$BJ#?t9T$K$o$?$k%3%a%s%H$r5v$98@8l$G$O!"(B
$B$3$NJQ?t$K@_Dj$9$kCM$O9%$_$NLdBj$G$9!#(B
@vindex comment-indent-function
@c The variable @code{comment-indent-function} should contain a function
@c that will be called to compute the indentation for a newly inserted
@c comment or for aligning an existing comment. It is set differently by
@c various major modes. The function is called with no arguments, but with
@c point at the beginning of the comment, or at the end of a line if a new
@c comment is to be inserted. It should return the column in which the
@c comment ought to start. For example, in Lisp mode, the indent hook
@c function bases its decision on how many semicolons begin an existing
@c comment, and on the code in the preceding lines.
$BJQ?t(B@code{comment-indent-function}$B$K$O!"(B
$B?7$?$KA^F~$7$?%3%a%s%H$N;z2<$2$d(B
$B4{B8$N%3%a%s%H$K7e$rB7$($k$?$a$N;z2<$2$r7W;;$9$k4X?t$r(B
$B@_Dj$9$kI,MW$,$"$j$^$9!#(B
$B$3$NJQ?t$K$O!"%a%8%c!<%b!<%I$4$H$K0[$J$C$?4X?t$,@_Dj$5$l$^$9!#(B
$B$3$N4X?t$O0z?t$J$7$G8F$P$l$^$9$,!"(B
$B%3%a%s%H$,$"$k$H$-$K$O$=$N3+;O0LCV$K%]%$%s%H$rCV$$$F!"(B
$B?75,%3%a%s%H$NA^F~;~$K$O9TKv$K%]%$%s%H$rCV$$$F8F$P$l$^$9!#(B
$BLa$jCM$O!"%3%a%s%H$r;O$a$k$Y$-7e0LCV$G$9!#(B
$B$?$H$($P!"(BLisp$B%b!<%I$G$O!"$3$N;z2<$2MQ%U%C%/4X?t$O!"(B
$B4{B8$N%3%a%s%H$N%;%_%3%m%s$N8D?t$H(B
$B$^$($N9T$N%3!<%I$K4p$E$$$F7W;;$r9T$$$^$9!#(B
@node Balanced Editing
@c @section Editing Without Unbalanced Parentheses
@section $B3g8L$NBP1~$rJ]$C$?JT=8(B
@table @kbd
@item M-(
@c Put parentheses around next sexp(s) (@code{insert-parentheses}).
$B$D$.$N!J(B1$B$D0J>e$N!K(BS$B<0$r3g8L$G0O$`!J(B@code{insert-parentheses}$B!K!#(B
@item M-)
@c Move past next close parenthesis and reindent
@c (@code{move-past-close-and-reindent}).
$B$D$.$NJD$83g8L$N$&$7$m$X0\F0$7$F$+$i;z2<$2$7D>$9(B
$B!J(B@code{move-past-close-and-reindent}$B!K!#(B
@end table
@kindex M-(
@kindex M-)
@findex insert-parentheses
@findex move-past-close-and-reindent
@c The commands @kbd{M-(} (@code{insert-parentheses}) and @kbd{M-)}
@c (@code{move-past-close-and-reindent}) are designed to facilitate a style
@c of editing which keeps parentheses balanced at all times. @kbd{M-(}
@c inserts a pair of parentheses, either together as in @samp{()}, or, if
@c given an argument, around the next several sexps. It leaves point after
@c the open parenthesis. The command @kbd{M-)} moves past the close
@c parenthesis, deleting any indentation preceding it, and indenting with
@c @kbd{C-j} after it.
$B%3%^%s%I(B@kbd{M-(}$B!J(B@code{insert-parenthesis}$B!K$H(B
@kbd{M-)}$B!J(B@code{move-past-close-and-reindent}$B!K$O!"(B
$B3g8L$NBP1~$r$D$M$KJ]$C$?$^$^JT=8$9$k$?$a$K@_7W$5$l$^$7$?!#(B
@kbd{M-(}$B$O0lBP$N3g8L$rA^F~$7$^$9!#(B
$B0z?t$,$J$1$l$P(B@samp{()}$B$rA^F~$7$^$9$,!"(B
$B0z?t$r;XDj$9$k$H!"$D$.$N$=$N8D?tJ,$N(BS$B<0$r3g8L$G0O$_$^$9!#(B
$B%]%$%s%H$O3+$-3g8L$ND>8e$KCV$+$l$^$9!#(B
$B%3%^%s%I(B@kbd{M-)}$B$O!"JD$83g8L$N$^$($K$"$k;z2<$2$r:o=|$7$J$,$i(B
$BJD$83g8L$N$&$7$m$K%]%$%s%H$r0\F0$7!"(B
$B$=$N$"$H!"(B@kbd{C-j}$B$G;z2<$2$7$^$9!#(B
@c For example, instead of typing @kbd{( F O O )}, you can type @kbd{M-(
@c F O O}, which has the same effect except for leaving the cursor before
@c the close parenthesis.
$B$?$H$($P!"(B@kbd{( F O O )}$B$HBG$D$+$o$j$K(B@kbd{M-( F O O}$B$HBG$F$P!"(B
$B%+!<%=%k$,JD$83g8L$N$^$($K$/$k$3$H$r=|$1$PF1$88z2L$rF@$i$l$^$9!#(B
@vindex parens-require-spaces
@c @kbd{M-(} may insert a space before the open parenthesis, depending on
@c the syntax class of the preceding character. Set
@c @code{parens-require-spaces} to @code{nil} value if you wish to inhibit
@c this.
@kbd{M-(}$B$O!"D>A0$NJ8;z$N9=J8%/%i%9$K$h$C$F$O!"(B
$B3+$-3g8L$N$^$($K6uGr$r(B1$B8DA^F~$9$k$3$H$,$"$j$^$9!#(B
$B$3$l$r6X;_$7$?$1$l$P!"(B
@code{parens-require-spaces}$B$K(B@code{nil}$B$r@_Dj$7$F$/$@$5$$!#(B
@node Symbol Completion
@c @section Completion for Symbol Names
@section $B%7%s%\%kL>$NJd40(B
@c @cindex completion (symbol names)
@cindex $BJd40!J%7%s%\%kL>!K(B
@c Usually completion happens in the minibuffer. But one kind of completion
@c is available in all buffers: completion for symbol names.
$BDL>o!"Jd40$O%_%K%P%C%U%!$G9T$o$l$^$9!#(B
$B$7$+$7!"$"$k<o$NJd40$OG$0U$N%P%C%U%!$GMxMQ$G$-$^$9!#(B
$B$=$l$O%7%s%\%kL>$KBP$9$kJd40$G$9!#(B
@kindex M-TAB
@c The character @kbd{M-@key{TAB}} runs a command to complete the partial
@c symbol before point against the set of meaningful symbol names. Any
@c additional characters determined by the partial name are inserted at
@c point.
@kbd{M-@key{TAB}}$B$O!"%]%$%s%HD>A0$NItJ,E*$J%7%s%\%k$r!"(B
$B0UL#$N$"$k%7%s%\%kL>$N=89g$+$iJd40$9$k%3%^%s%I$r<B9T$7$^$9!#(B
$BItJ,E*$JL>A0$+$iJd40$5$l$?DI2CJ8;z$O%]%$%s%H0LCV$KA^F~$5$l$^$9!#(B
@c If the partial name in the buffer has more than one possible completion
@c and they have no additional characters in common, a list of all possible
@c completions is displayed in another window.
$B%P%C%U%!Fb$NItJ,E*$JL>A0$KBP$7$F!"(B
$BJ#?t8D$NJd408uJd$,$"$j!"$7$+$b!"DI2C$G$-$k6&DLItJ,$,$J$$>l9g$K$O!"(B
$BJd408uJd0lMw$rJL$N%&%#%s%I%&$KI=<($7$^$9!#(B
@c @cindex completion using tags
@c @cindex tags completion
@c @cindex Info index completion
@cindex $B%?%0$rMQ$$$?Jd40(B
@cindex $B%?%0Jd40(B
@cindex info$B:w0zJd40(B
@findex complete-symbol
@c In most programming language major modes, @kbd{M-@key{TAB}} runs the
@c command @code{complete-symbol}, which provides two kinds of completion.
@c Normally it does completion based on a tags table (@pxref{Tags}); with a
@c numeric argument (regardless of the value), it does completion based on
@c the names listed in the Info file indexes for your language. Thus, to
@c complete the name of a symbol defined in your own program, use
@c @kbd{M-@key{TAB}} with no argument; to complete the name of a standard
@c library function, use @kbd{C-u M-@key{TAB}}. Of course, Info-based
@c completion works only if there is an Info file for the standard library
@c functions of your language, and only if it is installed at your site.
$B$[$H$s$I$N%W%m%0%i%`8@8l8~$1%a%8%c!<%b!<%I$G$O!"(B
@kbd{M-@key{TAB}}$B$O%3%^%s%I(B@code{complete-symbol}$B$r<B9T$7$^$9!#(B
$B$3$N4X?t$K$O!"(B2$B<oN`$NJd405!G=$,$"$j$^$9!#(B
$BDL>o!"$3$N%3%^%s%I$O%?%0%F!<%V%k!J(B@pxref{Tags}$B!K$K4p$E$$$FJd40$r9T$$$^$9!#(B
$B?t0z?t!JCM$OL54X78!K$r;XDj$9$k$H!"Ev3:8@8l$N(Binfo$B%U%!%$%k$N:w0z$K(B
$BJB$Y$i$l$?L>A0$rBP>]$H$7$FJd40$r9T$$$^$9!#(B
$B$9$J$o$A!"%W%m%0%i%`Cf$GDj5A$5$l$?%7%s%\%kL>$rJd40$9$k$K$O(B
$B0z?t$J$7$G(B@kbd{M-@key{TAB}}$B$r;H$$!"(B
$BI8=`%i%$%V%i%j4X?t$NL>A0$rJd40$9$k$K$O(B@kbd{C-u M-@key{TAB}}$B$r;H$$$^$9!#(B
$B$b$A$m$s!"(Binfo$B$K4p$E$$$?Jd40$O!";HMQ8@8l$NI8=`%i%$%V%i%j4X?t$KBP$9$k(B
info$B%U%!%$%k$,$"$j!"$+$D!"$=$l$,%$%s%9%H!<%k$5$l$F$$$k>l9g$K$@$1F0:n$7$^$9!#(B
@c @cindex Lisp symbol completion
@c @cindex completion in Lisp
@cindex Lisp$B%7%s%\%k$NJd40(B
@cindex Lisp$BCf$NJd40(B
@findex lisp-complete-symbol
@c In Emacs-Lisp mode, the name space for completion normally consists of
@c nontrivial symbols present in Emacs---those that have function
@c definitions, values or properties. However, if there is an
@c open-parenthesis immediately before the beginning of the partial symbol,
@c only symbols with function definitions are considered as completions.
@c The command which implements this is @code{lisp-complete-symbol}.
Emacs Lisp$B%b!<%I$G$O!"Jd40BP>]$NL>A06u4V$O!"(B
$B4X?tDj5A!"CM$dB0@-$r;}$D(BEmacs$BCf$NFC<l$J%7%s%\%k$+$i@.$j$^$9!#(B
$B$7$+$7!"ItJ,E*$J%7%s%\%k$ND>A0$K3+$-3g8L$,$"$l$P!"(B
$B4X?tDj5A$r;}$D%7%s%\%k$@$1$rJd40BP>]$H$7$^$9!#(B
$B$3$l$r<B8=$9$k%3%^%s%I$O(B@code{lisp-complete-symbol}$B$G$9!#(B
@c In Text mode and related modes, @kbd{M-@key{TAB}} completes words
@c based on the spell-checker's dictionary. @xref{Spelling}.
$B%F%-%9%H!J(Btext$B!K%b!<%I$H$=$N4XO"%b!<%I$G$O!"(B
@kbd{M-@key{TAB}}$B$O%9%Z%k%A%'%C%+$N<-=q$K4p$E$$$?Jd40$r9T$$$^$9!#(B
@xref{Spelling}$B!#(B
@node Which Function
@c @section Which Function Mode
@section $B4X?tL>I=<(%b!<%I!J(Bwhich-function$B%b!<%I!K(B
@c Which Function mode is a minor mode that displays the current function
@c name in the mode line, as you move around in a buffer.
$B4X?tL>I=<(!J(Bwhich-function$B!K%b!<%I$O!"(B
$B%P%C%U%!Fb$rF0$-2v$k$K=>$C$F8=:_$N4X?tL>$r%b!<%I9T$KI=<($9$k(B
$B%^%$%J%b!<%I$G$9!#(B
@findex which-function-mode
@vindex which-func-modes
@c To enable (or disable) Which Function mode, use the command @kbd{M-x
@c which-function-mode}. This command is global; it applies to all
@c buffers, both existing ones and those yet to be created. However, this
@c only affects certain major modes, those listed in the value of
@c @code{which-func-modes}. (If the value is @code{t}, then Which Function
@c mode applies to all major modes that know how to support it---which are
@c the major modes that support Imenu.)
$B4X?tL>I=<(!J(Bwhich-function$B!K%b!<%I$r%*%s!J$"$k$$$O%*%U!K$K$9$k$K$O!"(B
$B%3%^%s%I(B@kbd{M-x which-function-mode}$B$r;H$$$^$9!#(B
$B$3$N%3%^%s%I$O%0%m!<%P%k$G$9!#(B
$B$D$^$j!"4{B8$N%P%C%U%!$G$b$3$l$+$i:n$k%P%C%U%!$G$b!"(B
$B$9$Y$F$N%P%C%U%!$KDLMQ$7$^$9!#(B
$B$7$+$7!"(B@code{which-func-modes}$B$NCM$G;XDj$5$l$?(B
$BFCDj$N%a%8%c!<%b!<%I$G$N$_8z2L$,$"$j$^$9!#(B
$B!J(B@code{which-func-modes}$B$N%G%U%)%k%HCM$O(B@code{t}$B$G$"$j!"(B
$B4X?tL>I=<(!J(Bwhich-function$B!K%b!<%I$N;Y1gJ}K!$rCN$C$F$$$k(B
$B$9$Y$F$N%a%8%c!<%b!<%I$KE,MQ$5$l$k$3$H$r0UL#$9$k!#(B
$B6qBNE*$K$O!"(Bimenu$B$r;H$($k%a%8%c!<%b!<%I!#!K(B
@node Documentation
@c @section Documentation Commands
@section $B@bL@J8=qMQ%3%^%s%I(B
@c As you edit Lisp code to be run in Emacs, the commands @kbd{C-h f}
@c (@code{describe-function}) and @kbd{C-h v} (@code{describe-variable}) can
@c be used to print documentation of functions and variables that you want to
@c call. These commands use the minibuffer to read the name of a function or
@c variable to document, and display the documentation in a window.
Emacs$B$G<B9T$9$k(BLisp$B%3!<%I$rJT=8$9$k$H$-$K$O!"(B
$B4X?t$dJQ?t$N@bL@J8;zNs$rI=<($9$k%3%^%s%I!"(B
@kbd{C-h f}$B!J(B@code{describe-function}$B!K$d(B
@kbd{C-h v}$B!J(B@code{describe-variable}$B!K$rMxMQ$G$-$^$9!#(B
$B$3$l$i$N%3%^%s%I$O!"@bL@J8;zNs$rI=<($7$?$$4X?t$dJQ?t$NL>A0$r(B
$B%_%K%P%C%U%!$+$iFI$_<h$j!"%&%#%s%I%&$K@bL@J8;zNs$rI=<($7$^$9!#(B
@c For extra convenience, these commands provide default arguments based on
@c the code in the neighborhood of point. @kbd{C-h f} sets the default to the
@c function called in the innermost list containing point. @kbd{C-h v} uses
@c the symbol name around or adjacent to point as its default.
$B$?$$$X$sJXMx$J$3$H$K!"$3$l$i$N%3%^%s%I$O%]%$%s%H6aK5$N%3!<%I$+$i!"(B
$B%G%U%)%k%H$N0z?t$rA*Br$7$^$9!#(B
@kbd{C-h f}$B$O!"%]%$%s%H$r4^$`$b$C$H$bFbB&$N%j%9%H$G8F$P$l$k4X?t$r%G%U%)%k%H(B
$B$H$7$^$9!#(B
@kbd{C-h v}$B$O!"%]%$%s%H$N<~JU$K$"$k$+NY@\$9$k%7%s%\%kL>$r(B
$B%G%U%)%k%H$H$7$^$9!#(B
@c @cindex Eldoc mode
@cindex eldoc$B%b!<%I(B
@cindex $B%b!<%I!"(BEldoc
@findex eldoc-mode
@c For Emacs Lisp code, you can also use Eldoc mode. This minor mode
@c constantly displays in the echo area the argument list for the function
@c being called at point. (In other words, it finds the function call that
@c point is contained in, and displays the argument list of that function.)
@c Eldoc mode applies in Emacs Lisp and Lisp Interaction modes only. Use
@c the command @kbd{M-x eldoc-mode} to enable or disable this feature.
Emacs Lisp$B%3!<%I$KBP$7$F$O!"(Beldoc$B%b!<%I$b;H$($^$9!#(B
$B$3$N%^%$%J%b!<%I$O!"%]%$%s%H0LCV$G8F$S=P$5$l$F$$$k4X?t$N0z?t%j%9%H$r!"(B
$B$?$($:%(%3!<NN0h$KI=<($7$^$9!#(B
$B!J$$$$$+$($l$P!"%]%$%s%H$r4^$`4X?t8F$S=P$7$rC5$7!"(B
$B$=$N4X?t$N0z?t%j%9%H$rI=<($9$k!#!K(B
eldoc$B%^%$%J%b!<%I$O!"(BEmacs Lisp$B%b!<%I$H(B
Lisp$BBPOC!J(Blisp-interaction$B!K%b!<%I$@$1$KE,MQ$G$-$^$9!#(B
$B$3$N5!G=$r%*%s!?%*%U$9$k$K$O!"%3%^%s%I(B@kbd{M-x eldoc-mode}$B$r;H$$$^$9!#(B
@findex info-lookup-symbol
@findex info-lookup-file
@kindex C-h C-i
@c For C, Lisp, and other languages, you can use @kbd{C-h C-i}
@c (@code{info-lookup-symbol}) to view the Info documentation for a symbol.
@c You specify the symbol with the minibuffer; by default, it uses the
@c symbol that appears in the buffer at point. The major mode determines
@c where to look for documentation for the symbol---which Info files and
@c which indices. You can also use @kbd{M-x info-lookup-file} to look for
@c documentation for a file name.
C$B!"(BLisp$B!"$=$NB>8@8l$N%7%s%\%k$N(Binfo$BJ8=q$r8+$k$K$O(B
@kbd{C-h C-i}$B!J(B@code{info-lookup-symbol}$B!K$r;H$$$^$9!#(B
$B%_%K%P%C%U%!$G%7%s%\%k$r;XDj$7$^$9!#(B
$B%G%U%)%k%H$O!"%P%C%U%!Cf$N%]%$%s%H0LCV$K$"$k%7%s%\%k$G$9!#(B
$B%7%s%\%k$KBP$9$k@bL@J8=q$rC5$9>l=j!"$D$^$j!"(B
$B$I$N(Binfo$B%U%!%$%k$N$I$N:w0z$rC5$;$P$h$$$+$O!"(B
$B%a%8%c!<%b!<%I$,7hDj$7$^$9!#(B
$B$^$?!"%U%!%$%kL>$KBP$9$k@bL@J8=q$rC5$9$K$O(B
@kbd{M-x info-lookup-file}$B$r;H$$$^$9!#(B
@findex manual-entry
@c You can read the ``man page'' for an operating system command, library
@c function, or system call, with the @kbd{M-x manual-entry} command. It
@c runs the @code{man} program to format the man page, and runs it
@c asynchronously if your system permits, so that you can keep on editing
@c while the page is being formatted. (MS-DOS and MS-Windows 3 do not
@c permit asynchronous subprocesses, so on these systems you cannot edit
@c while Emacs waits for @code{man} to exit.) The result goes in a buffer
@c named @samp{*Man @var{topic}*}. These buffers use a special major mode,
@c Man mode, that facilitates scrolling and examining other manual pages.
@c For details, type @kbd{C-h m} while in a man page buffer.
@kbd{M-x manual-entry}$B%3%^%s%I$r;H$C$F!"(B
$B%*%Z%l!<%F%#%s%0%7%9%F%`$N%3%^%s%I!"%i%$%V%i%j4X?t!"%7%9%F%`%3!<%k$N(B
$B!X%^%K%e%"%k%Z!<%8!Y$rFI$`$3$H$,$G$-$^$9!#(B
$B$3$N%3%^%s%I$O!"%^%K%e%"%k%Z!<%8$r@6=q$9$k$?$a$K(B
@code{man}$B%W%m%0%i%`$r<B9T$7$^$9!#(B
$B%7%9%F%`$,5v$;$PHsF14|$K<B9T$9$k$N$G!"(B
$B%^%K%e%"%k%Z!<%8$,@6=q$5$l$k$^$G!"JT=8$r7QB3$G$-$^$9(B
$B!J(BMS-DOS$B$d(BMS-Windows 3.x$B$G$O!"HsF14|E*$J%5%V%W%m%;%9$r<B9T$G$-$J$$!#(B
$B$3$N$?$a!"$3$l$i$N%7%9%F%`$G$O(B@code{man}$B$N=*N;$r(BEmacs$B$,BT$D$"$$$@$O(B
$BJT=8$G$-$J$$!K!#(B
$B7k2L$O!"(B@samp{*Man @var{topic}*}$B$H$$$&L>A0$N%P%C%U%!$KF~$j$^$9!#(B
$B$3$l$i$N%P%C%U%!$G$O%^%s!J(Bman$B!K%b!<%I$H8F$P$l$kFCJL$J(B
$B%a%8%c!<%b!<%I$,;H$o$l!"(B
$B%9%/%m!<%k$dB>$N%^%K%e%"%k%Z!<%8$ND4::$rMF0W$K9T$($^$9!#(B
$B$h$j>\$7$/$O!"%^%K%e%"%k%Z!<%8MQ$N%P%C%U%!$G!"(B
@kbd{C-h m}$B$HBG$C$F$/$@$5$$!#(B
@vindex Man-fontify-manpage-flag
@c For a long man page, setting the faces properly can take substantial
@c time. By default, Emacs uses faces in man pages if Emacs can display
@c different fonts or colors. You can turn off use of faces in man pages
@c by setting the variable @code{Man-fontify-manpage-flag} to @code{nil}.
$BD9$$%^%K%e%"%k%Z!<%8$G$O!"E,@Z$J%U%'%$%9$r@_Dj$9$k$K$O$H$F$b;~4V$,$+$+$j$^$9!#(B
$B$5$^$6$^$J%U%)%s%H$dI=<(?'$rI=<($G$-$k4D6-$G$"$l$P!"(B
$B%G%U%)%k%H$G%^%K%e%"%k%Z!<%8$K%U%'%$%9$rMQ$$$k$h$&$K$J$C$F$$$^$9!#(B
$BJQ?t(B@code{Man-fontify-manpage-flag}$B$K(B@code{nil}$B$r@_Dj$9$l$P!"(B
$B%^%K%e%"%k%Z!<%8$K$*$1$k%U%'%$%9$N;HMQ$r%*%U$K$G$-$^$9!#(B
@findex Man-fontify-manpage
@c If you insert the text of a man page into an Emacs buffer in some
@c other fashion, you can use the command @kbd{M-x Man-fontify-manpage} to
@c perform the same conversions that @kbd{M-x manual-entry} does.
$BB>$NJ}K!$G%^%K%e%"%k%Z!<%8$N%F%-%9%H$r(BEmacs$B%P%C%U%!$KA^F~$7$?>l9g!"(B
@kbd{M-x manual-entry}$B$HF1$8JQ49$r;\$9$K$O!"(B
$B$=$3$G(B@kbd{M-x Man-fontify-manpage}$B%3%^%s%I$r<B9T$7$^$9!#(B
@c Eventually the GNU project hopes to replace most man pages with
@c better-organized manuals that you can browse with Info. @xref{Misc
@c Help}. Since this process is only partially completed, it is still
@c useful to read manual pages.
GNU$B%W%m%8%'%/%H$G$O:G=*E*$K!"$[$H$s$I$N%^%K%e%"%k%Z!<%8$r(B
info$B$G1\Mw2DG=$J$h$j$h$/9=@.$5$l$?%^%K%e%"%k$KCV$-49$($k$3$H$rK>$s$G$$$^$9!#(B
@xref{Misc Help}$B!#(B
$B$3$N:n6H$O!"$[$s$N0lIt$,40N;$7$?$@$1$J$N$G!"(B
$B$^$@%^%K%e%"%k%Z!<%8$rFI$a$k$3$H$OM-1W$G$9!#(B
@node Change Log
@c @section Change Logs
@section $BJQ995-O?(B
@c @cindex change log
@cindex $BJQ995-O?(B
@cindex $B%A%'%s%8%m%0(B
@kindex C-x 4 a
@findex add-change-log-entry-other-window
@c The Emacs command @kbd{C-x 4 a} adds a new entry to the change log
@c file for the file you are editing
@c (@code{add-change-log-entry-other-window}).
$B%3%^%s%I(B@kbd{C-x 4 a}$B$O!"JT=8Cf$N%U%!%$%k$KBP$9$k(B
$B?7$?$J9`L\$rJQ995-O?%U%!%$%k$KDI2C$7$^$9(B
$B!J(B@code{add-change-log-entry-other-window}$B!K!#(B
@c A change log file contains a chronological record of when and why you
@c have changed a program, consisting of a sequence of entries describing
@c individual changes. Normally it is kept in a file called
@c @file{ChangeLog} in the same directory as the file you are editing, or
@c one of its parent directories. A single @file{ChangeLog} file can
@c record changes for all the files in its directory and all its
@c subdirectories.
$BJQ995-O?%U%!%$%k$O!"%W%m%0%i%`$rJQ99$7$?F|IU$d$=$NM}M3$r(B
$B;~4V=g$K5-O?$7$?$b$N$G!"8D!9$NJQ99$r5-=R$7$?9`L\$NJB$S$+$i@.$j$^$9!#(B
$BDL>o$O!"JT=8$7$F$$$k%U%!%$%k$HF1$8%G%#%l%/%H%j!"$"$k$$$O!"(B
$B$=$N?F%G%#%l%/%H%j$KCV$$$?(B@file{ChangeLog}$B$H8F$P$l$k(B
$B%U%!%$%k$KJ]B8$5$l$F$$$^$9!#(B
1$B$D$N(B@file{ChangeLog}$B%U%!%$%k$G!"$3$N%U%!%$%k$rCV$$$?%G%#%l%/%H%j$d(B
$B$=$N%5%V%G%#%l%/%H%j$KCV$$$?A4%U%!%$%k$NJQ99$r5-O?$G$-$^$9!#(B
@c A change log entry starts with a header line that contains your name,
@c your email address (taken from the variable @code{user-mail-address}),
@c and the current date and time. Aside from these header lines, every
@c line in the change log starts with a space or a tab. The bulk of the
@c entry consists of @dfn{items}, each of which starts with a line starting
@c with whitespace and a star. Here are two entries, both dated in May
@c 1993, each with two items:
$BJQ995-O?9`L\$O!"L>A0!"!J(B@code{user-mail-address}$B$+$iF@$i$l$?!K(B
$BEE;R%a%$%k%"%I%l%9!"8=:_$NF|IU$H;~9o$+$i@.$k%X%C%@9T$G;O$^$j$^$9!#(B
$BJQ995-O?Fb$N3F9T$O%X%C%@9T$r=|$$$F!"$D$M$K6uGr$+%?%V$G;O$^$j$^$9!#(B
1$B$D$N9`L\$O(B@dfn{$B>.9`L\(B}$B$+$i9=@.$5$l!"(B
$B3F>.9`L\$O6uGr$H@10u$G;O$^$k9T$G;O$^$j$^$9!#(B
$B0J2<$O!"(B1993$BG/(B5$B7nIU$1$N(B2$B$D$N9`L\$G!"(B
$B$=$l$>$l$K(B2$B$D$N>.9`L\$,$"$j$^$9!#(B
@iftex
@medbreak
@end iftex
@smallexample
1993-05-25 Richard Stallman <rms@@gnu.org>
* man.el: Rename symbols `man-*' to `Man-*'.
(manual-entry): Make prompt string clearer.
* simple.el (blink-matching-paren-distance):
Change default to 12,000.
1993-05-24 Richard Stallman <rms@@gnu.org>
* vc.el (minor-mode-map-alist): Don't use it if it's void.
(vc-cancel-version): Doc fix.
@end smallexample
@noindent
@c (Previous Emacs versions used a different format for the date.)
$B!J(BEmacs$B$N0JA0$NHG$G$O!"F|IU$N7A<0$,0[$J$k!#!K(B
@c One entry can describe several changes; each change should have its
@c own item. Normally there should be a blank line between items. When
@c items are related (parts of the same change, in different places), group
@c them by leaving no blank line between them. The second entry above
@c contains two items grouped in this way.
1$B$D$N9`L\$GJ#?t$NJQ99$r5-=R$G$-$^$9!#(B
$B3FJQ99$K$D$$$F!"$=$l$>$l$N>.9`L\$rMQ0U$7$J$/$F$O$$$1$^$;$s!#(B
$BDL>o!">.9`L\$N$"$$$@$K$O6u9T$,$J$/$F$O$$$1$^$;$s!#(B
$B>.9`L\$,4XO"$7$F$$$k!J>l=j$O0[$J$k$,F1$8JQ99$N0lItJ,$N!K>l9g$K$O!"(B
$B$=$l$i$N$"$$$@$K$O6u9T$rF~$l$:$K0l2t$K$7$F$*$-$^$9!#(B
$B>e5-$N(B2$BHVL\$N9`L\$K$O!"$3$N$h$&$K$7$F$^$H$a$?(B2$B$D$N>.9`L\$,4^$^$l$F$$$^$9!#(B
@c @kbd{C-x 4 a} visits the change log file and creates a new entry
@c unless the most recent entry is for today's date and your name. It also
@c creates a new item for the current file. For many languages, it can
@c even guess the name of the function or other object that was changed.
@kbd{C-x 4 a}$B$O!"JQ995-O?%U%!%$%k$rK,Ld$7$F!"(B
$B:G?7$N9`L\$,:#F|$NF|IU$GEv?M$NL>A0$N$b$N$G$J$1$l$P!"(B
$B?7$?$K9`L\$r:n@.$7$^$9!#(B
$B$^$?!"8=:_$N%U%!%$%k$KBP$9$k?7$?$J>.9`L\$b:n@.$7$^$9!#(B
$BB?$/$N8@8l$KBP$7$F!"JQ99$5$l$?4X?tL>$d$=$NB>$N%*%V%8%'%/%H$r(B
$B?dB,$9$k$3$H$b$G$-$^$9!#(B
@c @cindex Change Log mode
@cindex $BJQ995-O?%b!<%I!J(BChange Log mode$B!K(B
@cindex change-log$B%b!<%I(B
@cindex $B%b!<%I!"(BChange Log
@findex change-log-mode
@c The change log file is visited in Change Log mode. In this major
@c mode, each bunch of grouped items counts as one paragraph, and each
@c entry is considered a page. This facilitates editing the entries.
@c @kbd{C-j} and auto-fill indent each new line like the previous line;
@c this is convenient for entering the contents of an entry.
$BJQ995-O?%U%!%$%k$O!"JQ995-O?!J(Bchange-log$B!K%b!<%I$GK,Ld$7$^$9!#(B
$B$3$N%a%8%c!<%b!<%I$G$O!"!J6u9T$G6h@Z$i$J$$!K$R$H$^$H$^$j$N>.9`L\72$r(B
$BCJMn$H$7$F07$$!"3F9`L\$r%Z!<%8$H$7$F07$$$^$9!#(B
$B$3$l$K$h$j9`L\$NJT=8$,MF0W$K$J$j$^$9!#(B
@kbd{C-j}$B$d<+F05M$a9~$_$K$h$j!"(B
$B?7$?$J9T$OD>A0$N9T$HF1MM$K;z2<$2$5$l$^$9!#(B
$B$3$l$O9`L\FbMF$rF~NO$9$k$N$KJXMx$G$9!#(B
@c Version control systems are another way to keep track of changes in your
@c program and keep a change log. @xref{Log Buffer}.
$B%W%m%0%i%`$NJQ99$r>80.$7!"JQ995-O?$r0];}$9$kB>$N<jCJ$H$7$F$O!"(B
$BHG4IM}!J%P!<%8%g%s%3%s%H%m!<%k!K%7%9%F%`$,$"$j$^$9!#(B
@xref{Log Buffer}$B!#(B
@node Tags
@c @section Tags Tables
@section $B%?%0%F!<%V%k(B
@c @cindex tags table
@cindex $B%?%0%F!<%V%k(B
@c A @dfn{tags table} is a description of how a multi-file program is
@c broken up into files. It lists the names of the component files and the
@c names and positions of the functions (or other named subunits) in each
@c file. Grouping the related files makes it possible to search or replace
@c through all the files with one command. Recording the function names
@c and positions makes possible the @kbd{M-.} command which finds the
@c definition of a function by looking up which of the files it is in.
@dfn{$B%?%0%F!<%V%k(B}$B$H$O!"J#?t$N%U%!%$%k$G9=@.$5$l$k%W%m%0%i%`$,!"(B
$B$I$N$h$&$K3F%U%!%$%k$KJ,3d$5$l$F$$$k$N$+5-=R$7$?$b$N$G$9!#(B
$B$3$l$O!"%W%m%0%i%`$r9=@.$9$k%U%!%$%kL>!"(B
$B$=$N%U%!%$%k$KF~$C$F$$$k4X?t$NL>A0!J$^$?$O!"L>A0$NIU$$$?JL$NC10L!K$d(B
$B%U%!%$%kFb$N0LCV$N0lMw$G$9!#(B
$B$3$&$7$F4XO"$9$k%U%!%$%k$r$^$H$a$F$*$1$P!"(B
$BA4%U%!%$%k$rBP>]$H$7$?C5:w$dCV49$r%3%^%s%I(B1$B$D$G9T$($^$9!#(B
$B$^$?!"4X?tL>$H$=$N0LCV$r5-O?$7$F$"$k$N$G!"(B
$B4X?t$,$I$N%U%!%$%k$KF~$C$F$$$k$+D4$Y$F4X?tDj5A$r$_$D$1$@$9(B
@kbd{M-.}$B$N$h$&$J%3%^%s%I$r<B8=$G$-$^$9!#(B
@c Tags tables are stored in files called @dfn{tags table files}. The
@c conventional name for a tags table file is @file{TAGS}.
$B%?%0%F!<%V%k$O!"(B@dfn{$B%?%0%F!<%V%k%U%!%$%k(B}$B$H8F$P$l$k%U%!%$%k$K3JG<$5$l$^$9!#(B
$B$3$N%U%!%$%k$N47=,E*$JL>A0$O(B@file{TAGS}$B$G$9!#(B
@c Each entry in the tags table records the name of one tag, the name of the
@c file that the tag is defined in (implicitly), and the position in that file
@c of the tag's definition.
$B%?%0%F!<%V%k$N3F9`L\$O!"%?%0L>!"%?%0$,!J0EL[$K!KDj5A$5$l$F$$$k%U%!%$%k$NL>A0!"(B
$B$=$7$F!"%U%!%$%kCf$G%?%0$,Dj5A$5$l$F$$$k0LCV$r5-O?$7$F$$$^$9!#(B
@c Just what names from the described files are recorded in the tags table
@c depends on the programming language of the described file. They
@c normally include all functions and subroutines, and may also include
@c global variables, data types, and anything else convenient. Each name
@c recorded is called a @dfn{tag}.
$B$b$H$N%W%m%0%i%`%U%!%$%k$+$i!"$I$s$JL>A0$,%?%0%F!<%V%k$K5-O?$5$l$k$+$O!"(B
$B%W%m%0%i%`8@8l$K$h$C$F0[$J$j$^$9!#(B
$B0lHLE*$K$O!"$9$Y$F$N4X?t$d%5%V%k!<%A%s$r4^$_!"(B
$BBg0hJQ?t!"%G!<%?7?!"$"$k$HJXMx$J$=$NB>$N>pJs$J$I$r4^$`$3$H$b$"$j$^$9!#(B
$B5-O?$5$l$?8D!9$NL>A0$r(B@dfn{$B%?%0(B}$B$H8F$S$^$9!#(B
@menu
* Tag Syntax:: Tag syntax for various types of code and text files.
* Create Tags Table:: Creating a tags table with @code{etags}.
* Select Tags Table:: How to visit a tags table.
* Find Tag:: Commands to find the definition of a specific tag.
* Tags Search:: Using a tags table for searching and replacing.
* List Tags:: Listing and finding tags defined in a file.
@end menu
@node Tag Syntax
@c @subsection Source File Tag Syntax
@subsection $B%=!<%9%U%!%$%k$N%?%09=J8(B
@c Here is how tag syntax is defined for the most popular languages:
$B$3$3$G$O!"9-$/0lHL$K;H$o$l$F$$$k8@8l$KBP$9$k%?%09=J8$NDj5A$r>R2p$7$^$9!#(B
@itemize @bullet
@item
@c In C code, any C function or typedef is a tag, and so are definitions of
@c @code{struct}, @code{union} and @code{enum}. @code{#define} macro
@c definitions and @code{enum} constants are also tags, unless you specify
@c @samp{--no-defines} when making the tags table. Similarly, global
@c variables are tags, unless you specify @samp{--no-globals}. Use of
@c @samp{--no-globals} and @samp{--no-defines} can make the tags table file
@c much smaller.
C$B$N%3!<%I$G$O!"4X?t$d(Btypedef$B$GDj5A$5$l$k7?$O%?%0$G$"$j!"(B
@code{struct}$B!"(B@code{union}$B!"(B@code{enum}$B$NDj5A$b$d$O$j%?%0$G$"$k!#(B
$B$^$?!"%?%0%F!<%V%k$r:n@.$9$k$H$-$K%*%W%7%g%s(B@samp{--no-defines}$B$r(B
$B;XDj$7$J$1$l$P!"(B@code{#define}$B$K$h$k%^%/%mDj5A$d(B
@code{enum}$B$NDj?t$b%?%0$H$7$F07$&!#(B
$BF1MM$K!"Bg0hJQ?t$b(B@samp{--no-globals}$B$r;XDj$7$J$$8B$j%?%0$K$J$k!#(B
@samp{--no-globals}$B$H(B@samp{--no-defines}$B$r;XDj$9$k$H!"(B
$B%?%0%F!<%V%k%U%!%$%k$O$+$J$j>.$5$/$J$k!#(B
@item
@c In C++ code, in addition to all the tag constructs of C code, member
@c functions are also recognized, and optionally member variables if you
@c use the @samp{--members} option. Tags for variables and functions in
@c classes are named @samp{@var{class}::@var{variable}} and
@c @samp{@var{class}::@var{function}}.
C++$B$N%3!<%I$G$O!"(BC$B$N%3!<%I$N%?%09=@.MWAG$K2C$($F!"(B
$B%a%s%P4X?t$b%?%0$H$7$FG'<1$5$l$k!#(B
@samp{--members}$B%*%W%7%g%s$r;XDj$9$l$P!"%a%s%PJQ?t$b%?%0$K$J$k!#(B
$B%/%i%9Fb$NJQ?t$H4X?t$KBP$9$k%?%0$K$O!"$=$l$>$l!"(B
@samp{@var{class}::@var{variable}}$B!"(B@samp{@var{class}::@var{function}}$B$H(B
$BL>A0$,IU$/!#(B
@item
@c In Java code, tags include all the constructs recognized in C++, plus
@c the @code{extends} and @code{implements} constructs. Tags for variables
@c and functions in classes are named @samp{@var{class}.@var{variable}} and
@c @samp{@var{class}.@var{function}}.
Java$B$N%3!<%I$G$O!"(BC++$B$N%?%09=@.MWAG$K2C$($F!"(B
@code{extends}$B$H(B@code{implements}$B$K8=$l$kL>A0$b%?%0$H$7$F4^$`!#(B
$B%/%i%9Fb$NJQ?t$H4X?t$KBP$9$k%?%0$K$O!"$=$l$>$l!"(B
@samp{@var{class}.@var{variable}}$B!"(B
@samp{@var{class}.@var{function}}$B$HL>A0$,IU$/!#(B
@item
@c In La@TeX{} text, the argument of any of the commands @code{\chapter},
@c @code{\section}, @code{\subsection}, @code{\subsubsection},
@c @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem},
@c @code{\part}, @code{\appendix}, @code{\entry}, or @code{\index}, is a
@c tag.@refill
La@TeX{}$B$N%F%-%9%H$G$O!"(B@code{\chapter}$B!"(B@code{\section}$B!"(B@code{\subsection}$B!"(B
@code{\subsubsection}$B!"(B@code{\eqno}$B!"(B@code{\label}$B!"(B@code{\ref}$B!"(B
@code{\cite}$B!"(B@code{\bibitem}$B!"(B@code{\part}$B!"(B@code{\appendix}$B!"(B
@code{\entry}$B!"(B@code{\index}$B$N%3%^%s%I$N0z?t$,%?%0$K$J$k!#(B
@c Other commands can make tags as well, if you specify them in the
@c environment variable @code{TEXTAGS} before invoking @code{etags}. The
@c value of this environment variable should be a colon-separated list of
@c command names. For example,
$B$=$NB>$N(BLa@TeX{}$B%3%^%s%I$G$b!"(B@code{etags}$B$r5/F0$9$k$^$($K!"(B
$B4D6-JQ?t(B@code{TEXTAGS}$B$K$=$l$i$N%3%^%s%I$r;XDj$7$F$*$1$P%?%0$NBP>]$K$J$k!#(B
$B$3$N4D6-JQ?t$NCM$O!"%3%^%s%IL>$r%3%m%s$G6h@Z$C$?JB$S!#(B
$B$?$H$($P!"!J(Bbourne$B%7%'%k$G$O!K(B
@example
TEXTAGS="def:newcommand:newenvironment"
export TEXTAGS
@end example
@noindent
@c specifies (using Bourne shell syntax) that the commands @samp{\def},
@c @samp{\newcommand} and @samp{\newenvironment} also define tags.
$B$H$9$k$H!"(B@samp{\def}$B!"(B@samp{\newcommand}$B!"(B@samp{\newenvironment}$B$N(B
$B%3%^%s%I$N0z?t$b%?%0$NBP>]$K$J$k!#(B
@item
@c In Lisp code, any function defined with @code{defun}, any variable
@c defined with @code{defvar} or @code{defconst}, and in general the first
@c argument of any expression that starts with @samp{(def} in column zero, is
@c a tag.
Lisp$B%3!<%I$G$O!"(B@code{defun}$B$GDj5A$7$?4X?t!"(B
@code{defvar}$B$d(B@code{defconst}$B$GDj5A$7$?JQ?t!"(B
$B$*$h$S!"0lHL$K(B0$B7eL\$+$i(B@samp{(def}$B$G;O$^$kG$0U$N<0$N:G=i$N0z?t$,%?%0!#(B
@item
@c In Scheme code, tags include anything defined with @code{def} or with a
@c construct whose name starts with @samp{def}. They also include variables
@c set with @code{set!} at top level in the file.
Scheme$B%3!<%I$G$O!"(B
@code{def}$B$GDj5A$5$l$k$b$N$H!"L>A0$,(B@samp{def}$B$G;O$^$k$b$N$,%?%0$K4^$^$l$k!#(B
$B$^$?!"%U%!%$%kFb$N%H%C%W%l%Y%k$G(B@code{set!}$B$r(B
$B;H$C$FCM$,@_Dj$5$l$kJQ?t$b%?%0!#(B
@end itemize
@c Several other languages are also supported:
$BB>$K$b0J2<$N8@8l$G;H$($^$9!#(B
@itemize @bullet
@item
@c In assembler code, labels appearing at the beginning of a line,
@c followed by a colon, are tags.
$B%"%;%s%V%j%3!<%I$G$O!"9T$N@hF,$+$i;O$^$j%3%m%s$,B3$/%i%Y%k$O%?%0!#(B
@item
@c In Bison or Yacc input files, each rule defines as a tag the nonterminal
@c it constructs. The portions of the file that contain C code are parsed
@c as C code.
Bison$B$d(BYacc$B$NF~NO%U%!%$%k$G$O!"(B
$B3F9=J85,B'$GDj5A$9$kHs=*C<5-9f$r%?%0$H$9$k!#(B
$B%U%!%$%kFb$N(BC$B%3!<%I$NItJ,$KBP$7$F$O!"(BC$B$N%3!<%I$H$7$F%?%0$N2r@O$r9T$&!#(B
@item
@c In Cobol code, tags are paragraph names; that is, any word starting in
@c column 8 and followed by a period.
Cobol$B$G$O!"CJMnL>!"$9$J$o$A!"(B8$B7eL\$+$i;O$^$j%T%j%*%I$,B3$/G$0U$NC18l$,%?%0!#(B
@item
@c In Erlang code, the tags are the functions, records, and macros defined
@c in the file.
Erlang$B%3!<%I$G$O!"%U%!%$%kFb$GDj5A$5$l$?4X?t!"%l%3!<%I!"%^%/%m$,%?%0!#(B
@item
@c In Fortran code, functions, subroutines and blockdata are tags.
Fortran$B%3!<%I$G$O!"4X?t!"%5%V%k!<%A%s!"%V%m%C%/%G!<%?$,%?%0!#(B
@item
@c In Objective C code, tags include Objective C definitions for classes,
@c class categories, methods, and protocols.
Objective-C$B%3!<%I$G$O!"%/%i%9!"%/%i%9%+%F%4%j!"%a%=%C%I!"(B
$B%W%m%H%3%k$NDj5A$,%?%0!#(B
@item
@c In Pascal code, the tags are the functions and procedures defined in
@c the file.
Pascal$B%3!<%I$G$O!"4X?t$H<jB3$-$,%?%0!#(B
@item
@c In Perl code, the tags are the procedures defined by the @code{sub}
@c keyword.
Perl$B%3!<%I$G$O!"%-!<%o!<%I(B@code{sub}$B$GDj5A$5$l$k<jB3$-$,%?%0!#(B
@item
@c In Postscript code, the tags are the functions.
Postscript$B%3!<%I$G$O!"4X?t!J1i;;;R!K$,%?%0!#(B
@item
@c In Prolog code, a tag name appears at the left margin.
Prolog$B%3!<%I$G$O!":8C<$K8=$l$kL>A0$,%?%0!#(B
@end itemize
@c You can also generate tags based on regexp matching (@pxref{Create
@c Tags Table}) to handle other formats and languages.
$B@55,I=8=$K4p$E$$$F%?%0$r@8@.$9$kJ}K!(B
$B!J(B@pxref{Create Tags Table}$B!K$b$"$k$N$G!"(B
$B>e5-0J30$N7A<0$d8@8l$r07$&$3$H$b$G$-$^$9!#(B
@node Create Tags Table
@c @subsection Creating Tags Tables
@subsection $B%?%0%F!<%V%k$N:n@.(B
@c @cindex @code{etags} program
@cindex @code{etags}$B%W%m%0%i%`(B
@c The @code{etags} program is used to create a tags table file. It knows
@c the syntax of several languages, as described in
$B%?%0%F!<%V%k%U%!%$%k$r:n@.$9$k$K$O!"(B@code{etags}$B%W%m%0%i%`$r;H$$$^$9!#(B
@code{etags}$B$O!"?t<oN`$N8@8l$K$D$$$F!"(B
$B9=J8$r2r@O$7%?%0$r<h$j=P$9$3$H$,$G$-$^$9!#(B
@iftex
@c the previous section.
$B$3$l$OA0@a$G=R$Y$?$H$*$j$G$9!#(B
@end iftex
@ifinfo
@c @ref{Tag Syntax}.
@ref{Tag Syntax}$B!#(B
@end ifinfo
@c Here is how to run @code{etags}:
$B$D$.$N$h$&$K<B9T$7$^$9!#(B
@example
etags @var{inputfiles}@dots{}
@end example
@noindent
@c The @code{etags} program reads the specified files, and writes a tags table
@c named @file{TAGS} in the current working directory. @code{etags}
@c recognizes the language used in an input file based on its file name and
@c contents. You can specify the language with the
@c @samp{--language=@var{name}} option, described below.
@code{etags}$B$O;XDj$5$l$?%U%!%$%k$rFI$_!"(B
$B%+%l%s%H:n6H%G%#%l%/%H%j$N(B@file{TAGS}$B$H$$$&L>A0$N%U%!%$%k$K(B
$B%?%0%F!<%V%k$r=q$-=P$7$^$9!#(B
@code{etags}$B$O!"%U%!%$%kL>$H$=$NFbMF$+$i<+F0E*$K;HMQ8@8l$r<1JL$7$^$9!#(B
$B8e=R$N(B@samp{--language=@var{name}}$B%*%W%7%g%s$G!"(B
$B8@8l$rL@<($9$k$3$H$b$G$-$^$9!#(B
@c If the tags table data become outdated due to changes in the files
@c described in the table, the way to update the tags table is the same way it
@c was made in the first place. It is not necessary to do this often.
$B%U%!%$%k$rJQ99$9$k$J$I$7$F%?%0%F!<%V%k$NFbMF$,8E$/$J$C$?>l9g!"(B
$B%F!<%V%k$r99?7$9$k$K$O!":G=i$K%?%0%F!<%V%k$r:n@.$7$?<j=g$r(B
$B7+$jJV$7$^$9!#(B
$BIQHK$K99?7$9$kI,MW$O$"$j$^$;$s!#(B
@c If the tags table fails to record a tag, or records it for the wrong
@c file, then Emacs cannot possibly find its definition. However, if the
@c position recorded in the tags table becomes a little bit wrong (due to
@c some editing in the file that the tag definition is in), the only
@c consequence is a slight delay in finding the tag. Even if the stored
@c position is very wrong, Emacs will still find the tag, but it must
@c search the entire file for it.
$B%?%0%F!<%V%k$K5-O?$G$-$J$+$C$?$j!"8m$C$?%U%!%$%k$r5-O?$7$F$7$^$C$?>l9g!"(B
Emacs$B$O%?%0$NDj5A$r$_$D$1$k$3$H$O$G$-$^$;$s!#(B
$B$7$+$7!"!J%?%0$NDj5A$r4^$s$@%U%!%$%k$rB?>/JT=8$9$k$J$I$7$?$?$a$K!K(B
$B%?%0%F!<%V%k$K5-O?$5$l$?0LCV$,B?>/%:%l$F$$$kDxEY$J$i$P!"(B
$B%?%0$r$_$D$1$k$N$KDL>o$h$j>/$7;~4V$,$+$+$k$@$1$G$9!#(B
$B5-O?$5$l$?0LCV$,BgI}$K68$C$F$$$?$H$7$F$b!"(B
Emacs$B$O%?%0$r$_$D$1$k$3$H$,$G$-$^$9$,!"(B
$B$=$N$?$a$K%U%!%$%kA4BN$rD4$Y$J$/$F$O$J$j$^$;$s!#(B
@c So you should update a tags table when you define new tags that you want
@c to have listed, or when you move tag definitions from one file to another,
@c or when changes become substantial. Normally there is no need to update
@c the tags table after each edit, or even every day.
$B$G$9$+$i!"?7$7$$%?%0$rDj5A$7$?$H$-!"%?%0$NDj5A$rJL$N%U%!%$%k$K0\F0$7$?$H$-!"(B
$B%U%!%$%k$rAjEvJQ99$7$?$H$-$K$O!"%?%0%F!<%V%k$N99?7$,I,MW$G$9!#(B
$B$7$+$7!"%U%!%$%k$rJT=8$9$k$D$I%?%0%F!<%V%k$r99?7$9$kI,MW$O$"$j$^$;$s$7!"(B
$BKhF|99?7$9$kI,MW$9$i$J$$$G$7$g$&!#(B
@c One tags table can effectively include another. Specify the included
@c tags file name with the @samp{--include=@var{file}} option when creating
@c the file that is to include it. The latter file then acts as if it
@c contained all the files specified in the included file, as well as the
@c files it directly contains.
$B%?%0%F!<%V%k$KJL$N%?%0%F!<%V%k$r<h$j9~$`$3$H$b$G$-$^$9!#(B
$B<h$j9~$`%?%0%U%!%$%kL>$r%*%W%7%g%s(B@samp{--include=@var{file}}$B$G(B
$B;XDj$7$F%?%0%U%!%$%k$r:n@.$7$^$9!#(B
$B$3$N$h$&$K:n@.$7$?%?%0%U%!%$%k$K$O!"(B
$B;XDj$7$?%=!<%9%U%!%$%k$K2C$($F!"(B
$B<h$j9~$s$@%?%0%U%!%$%k$K5-O?$5$l$F$$$?%U%!%$%k$b4^$^$l$^$9!#(B
@c If you specify the source files with relative file names when you run
@c @code{etags}, the tags file will contain file names relative to the
@c directory where the tags file was initially written. This way, you can
@c move an entire directory tree containing both the tags file and the
@c source files, and the tags file will still refer correctly to the source
@c files.
@code{etags}$B$r<B9T$9$k$H$-$KAjBP%U%!%$%kL>$G%=!<%9%U%!%$%k$r;XDj$9$k$H!"(B
$B%?%0%U%!%$%k$K$O!"%?%0%U%!%$%k$r=q$-=P$7$?$H$-$N%G%#%l%/%H%j$r(B
$B4p=`$K$7$?%U%!%$%kL>$,5-O?$5$l$^$9!#(B
$B$3$&$7$?>l9g!"(B
$B%?%0%U%!%$%k$H%=!<%9%U%!%$%k$r4^$s$@%G%#%l%/%H%jLZ9=B$A4BN$r(B
$B0\F0$9$k$3$H$,$G$-!"$7$+$b!"%?%0%U%!%$%k$O%=!<%9%U%!%$%k$r@5$7$/;X$7B3$1$^$9!#(B
@c If you specify absolute file names as arguments to @code{etags}, then
@c the tags file will contain absolute file names. This way, the tags file
@c will still refer to the same files even if you move it, as long as the
@c source files remain in the same place. Absolute file names start with
@c @samp{/}, or with @samp{@var{device}:/} on MS-DOS and MS-Windows.
@code{etags}$B$N0z?t$H$7$F@dBP%U%!%$%kL>$r;XDj$9$k$H!"(B
$B%?%0%U%!%$%k$K$O@dBP%U%!%$%kL>$,5-O?$5$l$^$9!#(B
$B$3$&$7$?>l9g!"%=!<%9%U%!%$%k$,F1$8>l=j$K$"$k8B$j!"(B
$B%?%0%U%!%$%k$r0\F0$7$F$b%?%0%U%!%$%k$OF1$8%U%!%$%k$r;X$7B3$1$^$9!#(B
$B@dBP%U%!%$%kL>$O!"(B@samp{/}$B!"$"$k$$$O!"(B
MS-DOS$B$H(BMS-Windows$B$G$O(B@samp{@var{device}:/}$B$G;O$^$j$^$9!#(B
@c When you want to make a tags table from a great number of files, you
@c may have problems listing them on the command line, because some systems
@c have a limit on its length. The simplest way to circumvent this limit
@c is to tell @code{etags} to read the file names from its standard input,
@c by typing a dash in place of the file names, like this:
$BHs>o$KB??t$N%U%!%$%k$+$i%?%0%F!<%V%k$r:n@.$9$k>l9g!"(B
$B%3%^%s%I9T$ND9$5$r@)8B$7$F$$$k%7%9%F%`$b$"$k$N$G!"(B
$B%U%!%$%kL>$r%3%^%s%I%i%$%s$G;XDj$9$k$H$-$KLdBj$,5/$3$k2DG=@-$,$"$j$^$9!#(B
$B$3$N@)8B$r2sHr$9$k$b$C$H$bC1=c$JJ}K!$O!"(B
$B$D$.$N$h$&$K!"%U%!%$%kL>$r;XDj$9$k0LCV$K%@%C%7%e$rBG$C$F!"(B
@code{etags}$B$KI8=`F~NO$+$i%U%!%$%kL>$rFI$_9~$^$;$k$3$H$G$9!#(B
@example
find . -name "*.[chCH]" -print | etags -
@end example
@c Use the option @samp{--language=@var{name}} to specify the language
@c explicitly. You can intermix these options with file names; each one
@c applies to the file names that follow it. Specify
@c @samp{--language=auto} to tell @code{etags} to resume guessing the
@c language from the file names and file contents. Specify
@c @samp{--language=none} to turn off language-specific processing
@c entirely; then @code{etags} recognizes tags by regexp matching alone.
@c @samp{etags --help} prints the list of the languages @code{etags} knows,
@c and the file name rules for guessing the language.
$B%*%W%7%g%s(B@samp{--language=@var{name}}$B$r;H$($P!"(B
$B8@8l$rL@<(E*$K;XDj$G$-$^$9!#(B
$B$3$N%*%W%7%g%s$O%U%!%$%kL>$H:.$<$F$$$/$D$G$b;HMQ$G$-$^$9!#(B
$B$=$l$>$l!"$"$H$KB3$/%U%!%$%kL>$KE,MQ$5$l$^$9!#(B
@samp{--language=auto}$B$r;XDj$9$k$H!"(B
@code{etags}$B$O%U%!%$%kL>$H$=$NFbMF$+$i$U$?$?$S;HMQ8@8l$r?dB,$7$^$9!#(B
@samp{--language=none}$B$r;XDj$9$l$P!"(B
$B8@8l$K0MB8$7$?=hM}$r$$$C$5$$9T$o$J$$$h$&$K$J$j$^$9!#(B
$B$9$k$H!"(B@code{etags}$B$O@55,I=8=$K$h$k0lCW$@$1$K(B
$B4p$E$$$F%?%0$rG'<1$7$^$9!#(B
@code{etags}$B$,CN$C$F$$$k8@8l$H!"8@8l$r?dB,$9$k%U%!%$%kL>5,B'$rI=<($9$k$K$O!"(B
@samp{etags --help}$B$r;XDj$7$^$9!#(B
@c The @samp{--regex} option provides a general way of recognizing tags
@c based on regexp matching. You can freely intermix it with file names.
@c Each @samp{--regex} option adds to the preceding ones, and applies only
@c to the following files. The syntax is:
@samp{--regex}$B%*%W%7%g%s$O!"(B
$B@55,I=8=$K$h$k0lCW$K4p$E$$$F%?%0$rG'<1$5$;$k0lHLE*$JJ}K!$G$9!#(B
$B$3$N%*%W%7%g%s$H%U%!%$%kL>$r<+M3$K:.$<$F;HMQ$G$-$^$9!#(B
$B3F(B@samp{--regex}$B%*%W%7%g%s$O!"$=$l0JA0$K;XDj$7$?@55,I=8=$KDI2C$5$l!"(B
$B%*%W%7%g%s$N$"$H$K$"$k%U%!%$%k$KE,MQ$5$l$^$9!#(B
$B%*%W%7%g%s$N9=J8$O$D$.$N$H$*$j$G$9!#(B
@example
--regex=/@var{tagregexp}[/@var{nameregexp}]/
@end example
@noindent
@c where @var{tagregexp} is used to match the lines to tag. It is always
@c anchored, that is, it behaves as if preceded by @samp{^}. If you want
@c to account for indentation, just match any initial number of blanks by
@c beginning your regular expression with @samp{[ \t]*}. In the regular
@c expressions, @samp{\} quotes the next character, and @samp{\t} stands
@c for the tab character. Note that @code{etags} does not handle the other
@c C escape sequences for special characters.
$B$3$3$G!"(B@var{tagregexp}$B$O!"9T$K0lCW$5$;$F%?%0$r<h$j=P$9$?$a$K;H$o$l$^$9!#(B
$B$3$l$O$D$M$K0LCV$,8GDj$5$l$F$$$^$9!#(B
$B$D$^$j!"(B@samp{^}$B$,A0CV$5$l$F$$$k$+$N$h$&$K07$o$l$^$9!#(B
$B;z2<$2J,$r9MN8$7$?$1$l$P!"@55,I=8=$r(B@samp{[ \t]*}$B$G;O$a$F!"(B
$B9TF,$NG$0U8D$N6uGr$K0lCW$9$k$h$&$K$7$^$9!#(B
$B@55,I=8=$K$*$$$F$O!"(B@samp{\}$B$OD>8e$NJ8;z$r%/%)!<%H$7!"(B
@samp{\t}$B$O%?%VJ8;z$rI=$7$^$9!#(B
@code{etags}$B$G$O!"$3$l$i0J30$K$O(BC$B$G;H$o$l$k%(%9%1!<%W%7!<%1%s%9$r(B
$B07$($J$$$3$H$KCm0U$7$F$/$@$5$$!#(B
@c @cindex interval operator (in regexps)
@cindex $BH?I|2s?t1i;;;R!J@55,I=8=!K(B
@c The syntax of regular expressions in @code{etags} is the same as in
@c Emacs, augmented with the @dfn{interval operator}, which works as in
@c @code{grep} and @code{ed}. The syntax of an interval operator is
@c @samp{\@{@var{m},@var{n}\@}}, and its meaning is to match the preceding
@c expression at least @var{m} times and up to @var{n} times.
@code{etags}$B$N@55,I=8=$N9=J8$O!"(BEmacs$B$N$b$N$HF1$8$G!"(B
@dfn{$BH?I|2s?t1i;;;R(B}$B!J(Binterval operator$B!K$,3HD%$5$l$F$$$^$9!#(B
$B$3$N1i;;;R$O!"(B@code{grep}$B$d(B@code{ed}$B$G;H$($k$b$N$HF1$8F0:n$r$7$^$9!#(B
$BH?I|2s?t1i;;;R$N9=J8$O(B@samp{\@{@var{m},@var{n}\@}}$B$G$"$j!"(B
$BD>A0$N@55,I=8=$N(B@var{m}$B2s0J>e(B@var{n}$B2s0J2<$N7+$jJV$7$K0lCW$7$^$9!#(B
@c You should not match more characters with @var{tagregexp} than that
@c needed to recognize what you want to tag. If the match is such that
@c more characters than needed are unavoidably matched by @var{tagregexp},
@c you may find useful to add a @var{nameregexp}, in order to narrow the tag
@c scope. You can find some examples below.
@var{tagregexp}$B$,%?%0$H$7$FG'<1$7$?$$ItJ,$h$j$bD9$/0lCW$9$k$h$&$K$O(B
$B$7$J$$$G$/$@$5$$!#(B
@var{tagregexp}$B$K0lCW$9$kItJ,$,I,MW0J>e$KD9$/$J$k$N$,Hr$1$i$l$J$$$J$i$P!"(B
$B%?%0$NHO0O$r69$a$k$?$a$K(B@var{nameregexp}$B$rDI2C$9$k$H$h$$$+$b$7$l$^$;$s!#(B
$B@55,I=8=$rMxMQ$7$?Nc$r$$$/$D$+>R2p$7$^$7$g$&!#(B
@c The @samp{-R} option deletes all the regexps defined with
@c @samp{--regex} options. It applies to the file names following it, as
@c you can see from the following example:
@samp{-R}$B%*%W%7%g%s$O!"$=$l$^$G$K(B@samp{--regex}$B%*%W%7%g%s$GDj5A$7$?(B
$B$9$Y$F$N@55,I=8=$r:o=|$7$^$9!#(B
$B$D$.$N;HMQNc$+$i$b$o$+$k$h$&$K!"(B
$B%*%W%7%g%s$N$"$H$KB3$/%U%!%$%k$KE,MQ$5$l$^$9!#(B
@example
etags --regex=/@var{reg1}/ voo.doo --regex=/@var{reg2}/ \
bar.ber -R --lang=lisp los.er
@end example
@noindent
@c Here @code{etags} chooses the parsing language for @file{voo.doo} and
@c @file{bar.ber} according to their contents. @code{etags} also uses
@c @var{reg1} to recognize additional tags in @file{voo.doo}, and both
@c @var{reg1} and @var{reg2} to recognize additional tags in
@c @file{bar.ber}. @code{etags} uses the Lisp tags rules, and no regexp
@c matching, to recognize tags in @file{los.er}.
$B$3$NNc$G$O!"(B@code{etags}$B$O!"(B
@file{voo.doo}$B$H(B@file{bar.ber}$B$KBP$7$F$O!"$=$NFbMF$+$i;HMQ8@8l$r?dDj$7$^$9!#(B
$B$5$i$K!"(B@file{voo.doo}$B$+$iM>J,$K%?%0$rG'<1$9$k$?$a$K(B@var{reg1}$B$r;H$$!"(B
@file{bar.ber}$B$+$iM>J,$K%?%0$rG'<1$9$k$?$a$K$O(B
@var{reg1}$B$H(B@var{reg2}$B$NN>J}$r;H$$$^$9!#(B
@file{los.er}$B$+$i%?%0$rG'<1$9$k$K$O!"(B
Lisp$B$N%?%09=J85,B'$@$1$r;H$$!"@55,I=8=$K$h$k0lCW$O$$$C$5$$;H$$$^$;$s!#(B
@c Here are some more examples. The regexps are quoted to protect them
@c from shell interpretation.
$BJL$NNc$r<($7$^$7$g$&!#(B
$B$3$3$G$O!"%7%'%k$,2r<a$7$J$$$h$&$K@55,I=8=$r%/%)!<%H$7$^$9!#(B
@itemize @bullet
@item
@c Tag the @code{DEFVAR} macros in the emacs source files:
Emacs$B$N%=!<%9%U%!%$%k$K4^$^$l$k(B@code{DEFVAR}$B%^%/%m$r%?%0$H$9$k!#(B
@smallexample
--regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
@end smallexample
@item
@c Tag VHDL files (this example is a single long line, broken here for
@c formatting reasons):
VHDL$B%U%!%$%k$+$i%?%0$r<h$j=P$9(B
$B!J$3$NNc$OK\Mh$OC10l$ND9$$9T$@$,!"0u:~$N4X78$GJ,3d$7$F$"$k!K!#(B
@smallexample
--language=none
--regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/'
--regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
\( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
@end smallexample
@item
@c Tag Tcl files (this last example shows the usage of a @var{nameregexp}):
Tcl$B%U%!%$%k$+$i%?%0$r<h$j=P$9(B
$B!J$3$NNc$O(B@var{nameregexp}$B$N;HMQNc$G$b$"$k!K!#(B
@smallexample
--lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
@end smallexample
@end itemize
@c For a list of the other available @code{etags} options, execute
@c @code{etags --help}.
$BB>$N%*%W%7%g%s0lMw$rI=<($9$k$K$O!"(B
@code{etags --help}$B$r<B9T$7$F$/$@$5$$!#(B
@node Select Tags Table
@c @subsection Selecting a Tags Table
@subsection $B%?%0%F!<%V%k$NA*Br(B
@vindex tags-file-name
@findex visit-tags-table
@c Emacs has at any time one @dfn{selected} tags table, and all the commands
@c for working with tags tables use the selected one. To select a tags table,
@c type @kbd{M-x visit-tags-table}, which reads the tags table file name as an
@c argument. The name @file{TAGS} in the default directory is used as the
@c default file name.
Emacs$B$G$O!"$$$D$G$b(B1$B$D$N(B@dfn{$BA*Br$5$l$?(B}$B%?%0%F!<%V%k$,$"$j!"(B
$B%?%0%F!<%V%k$r;H$C$FF0:n$9$k%3%^%s%I$OA*Br$5$l$?%?%0%F!<%V%k$r;HMQ$7$^$9!#(B
$B%?%0%F!<%V%k$rA*Br$9$k$K$O!"(B@kbd{M-x visit-tags-table}$B$HBG$A$^$9!#(B
$B$9$k$H!"%?%0%F!<%V%k%U%!%$%kL>$rJ9$$$F$-$^$9!#(B
$B%G%U%)%k%H$N%U%!%$%kL>$O!"%G%U%)%k%H%G%#%l%/%H%j$N(B@file{TAGS}$B$G$9!#(B
@c All this command does is store the file name in the variable
@c @code{tags-file-name}. Emacs does not actually read in the tags table
@c contents until you try to use them. Setting this variable yourself is just
@c as good as using @code{visit-tags-table}. The variable's initial value is
@c @code{nil}; that value tells all the commands for working with tags tables
@c that they must ask for a tags table file name to use.
$B$3$N%3%^%s%I$O!"%U%!%$%kL>$rJQ?t(B@code{tags-file-name}$B$K3JG<$9$k$@$1$G$9!#(B
$B%?%0%F!<%V%k$r;H$*$&$H$7$J$$8B$j!"(B
Emacs$B$O<B:]$K$O%?%0%F!<%V%k$NFbMF$rFI$_9~$_$^$;$s!#(B
@code{visit-tags-table}$B$r;H$o$:$K!"(B
$B<+J,<+?H$G$3$NJQ?t$K%U%!%$%kL>$r@_Dj$7$F$b$+$^$$$^$;$s!#(B
$B$3$NJQ?t$N=i4|CM$O(B@code{nil}$B$G$9!#(B
$B$3$l$O!"%?%0%F!<%V%k$r;H$&$9$Y$F$N%3%^%s%I$K!"(B
$B;HMQ$9$k%?%0%F!<%V%k%U%!%$%k$r?R$M$5$;$k$3$H$K$J$j$^$9!#(B
@c Using @code{visit-tags-table} when a tags table is already loaded
@c gives you a choice: you can add the new tags table to the current list
@c of tags tables, or start a new list. The tags commands use all the tags
@c tables in the current list. If you start a new list, the new tags table
@c is used @emph{instead} of others. If you add the new table to the
@c current list, it is used @emph{as well as} the others. When the tags
@c commands scan the list of tags tables, they don't always start at the
@c beginning of the list; they start with the first tags table (if any)
@c that describes the current file, proceed from there to the end of the
@c list, and then scan from the beginning of the list until they have
@c covered all the tables in the list.
$B$9$G$K%?%0%F!<%V%k$rFI$_9~$s$G$"$k$H$-$K(B@code{visit-tags-table}$B$r;H$&$H!"(B
2$B$D$NA*Br;h$,$"$j$^$9!#(B
$B8=:_$N%?%0%F!<%V%k%j%9%H$K?7$?$K%?%0%F!<%V%k$rDI2C$9$k$+!"(B
$B%?%0%F!<%V%k%j%9%H$r?75,$K;O$a$k$+$G$9!#(B
$B%?%0%3%^%s%I$O!"8=:_$N%j%9%H$K$"$k$9$Y$F$N%?%0%F!<%V%k$r;HMQ$7$^$9!#(B
$B?7$?$J%?%0%F!<%V%k%j%9%H$r;O$a$k$H!"B>$N%?%0%F!<%V%k$N(B@emph{$B$+$o$j(B}$B$K(B
$B?7$?$J%?%0%F!<%V%k$,;H$o$l$^$9!#(B
$B8=:_$N%j%9%H$K?7$?$J%?%0%F!<%V%k$rDI2C$9$k$H!"(B
$BB>$N%?%0%F!<%V%k$H(B@emph{$B$H$b$K(B}$B?7$?$J$b$N$b;H$o$l$^$9!#(B
$B%?%0%3%^%s%I$,%?%0%F!<%V%k%j%9%H$rAv::$9$k$H$-$K$O!"(B
$B$D$M$K%j%9%H$N@hF,$+$i;O$a$k$o$1$G$O$"$j$^$;$s!#(B
$B8=:_$N%U%!%$%k$r5-O?$7$F$$$k%?%0%F!<%V%k$,$"$l$P!"(B
$B$^$:$=$l$+$i;O$a$F%j%9%H$NKvHx$^$G?J$_$^$9!#(B
$B$=$7$F!"%j%9%H$N@hF,$+$i%j%9%H$K4^$^$l$k(B
$B$9$Y$F$N%?%0%F!<%V%k$rD4$Y=*$k$^$GAv::$rB3$1$^$9!#(B
@vindex tags-table-list
@c You can specify a precise list of tags tables by setting the variable
@c @code{tags-table-list} to a list of strings, like this:
$BJQ?t(B@code{tags-table-list}$B$KJ8;zNs$N%j%9%H$r@_Dj$9$l$P!"(B
$B%?%0%F!<%V%k$N@53N$J%j%9%H$r$"$i$+$8$a;XDj$G$-$^$9!#(B
$B$?$H$($P!"$D$.$N$h$&$K$7$^$9!#(B
@c keep this on two lines for formatting in smallbook
@example
@group
(setq tags-table-list
'("~/emacs" "/usr/local/lib/emacs/src"))
@end group
@end example
@noindent
@c This tells the tags commands to look at the @file{TAGS} files in your
@c @file{~/emacs} directory and in the @file{/usr/local/lib/emacs/src}
@c directory. The order depends on which file you are in and which tags
@c table mentions that file, as explained above.
$B$3$N@_DjNc$G$O!"%?%0%3%^%s%I$O!"(B
$B8D?M$N(B@file{~/emacs}$B%G%#%l%/%H%j$H(B
@file{/usr/local/lib/emacs/src}$B%G%#%l%/%H%j$N(B
$B!J(B2$B$D$N!K(B@file{TAGS}$B%U%!%$%k$r8+$K$$$-$^$9!#(B
$B>e$G=R$Y$?$h$&$K!"%?%0%U%!%$%k$r;H$&=gHV$O!"(B
$BBP>]$H$7$F$$$k%U%!%$%k$d$=$N%U%!%$%k$r5-=R$7$F$$$k%?%0%F!<%V%k$K0MB8$7$^$9!#(B
@c Do not set both @code{tags-file-name} and @code{tags-table-list}.
@code{tags-file-name}$B$H(B@code{tags-table-list}$B$NN>J}$K(B
$BCM$r@_Dj$7$F$O$$$1$^$;$s!#(B
@node Find Tag
@c @subsection Finding a Tag
@subsection $B%?%0$NC5:w(B
@c The most important thing that a tags table enables you to do is to find
@c the definition of a specific tag.
$B%?%0%F!<%V%k$G<B8=$5$l$k$b$C$H$b=EMW$J5!G=$O!"(B
$B;XDj$7$?%?%0$NDj5A$rC5$7=P$9$3$H$G$9!#(B
@table @kbd
@item M-.@: @var{tag} @key{RET}
@c Find first definition of @var{tag} (@code{find-tag}).
$B%?%0(B@var{tag}$B$N:G=i$NDj5A$rC5$9!J(B@code{find-tag}$B!K!#(B
@item C-u M-.
@c Find next alternate definition of last tag specified.
$B:G8e$K;XDj$7$?%?%0$N$D$.$NDj5A$rC5$9!#(B
@item C-u - M-.
@c Go back to previous tag found.
$B$^$($K$_$D$+$C$?%?%0$KLa$k!#(B
@item C-M-. @var{pattern} @key{RET}
@c Find a tag whose name matches @var{pattern} (@code{find-tag-regexp}).
$BL>A0$,(B@var{pattern}$B$K0lCW$9$k%?%0$rC5$9!J(B@code{find-tag-regexp}$B!K!#(B
@item C-u C-M-.
@c Find the next tag whose name matches the last pattern used.
$B:G8e$K;HMQ$7$?%Q%?!<%s$K0lCW$9$k$D$.$N%?%0$rC5$9$k!#(B
@item C-x 4 .@: @var{tag} @key{RET}
@c Find first definition of @var{tag}, but display it in another window
@c (@code{find-tag-other-window}).
$B%?%0(B@var{tag}$B$N:G=i$NDj5A$rC5$7!"(B
$BJL$N%&%#%s%I%&$KI=<($9$k!J(B@code{find-tag-other-window}$B!K!#(B
@item C-x 5 .@: @var{tag} @key{RET}
@c Find first definition of @var{tag}, and create a new frame to select the
@c buffer (@code{find-tag-other-frame}).
$B%?%0(B@var{tag}$B$N:G=i$NDj5A$rC5$7!"(B
$B%P%C%U%!$rA*Br$9$k$?$a$N?7$?$J%U%l!<%`$r:n$k!#(B
$B!J(B@code{find-tag-other-frame}$B!K!#(B
@item M-*
@c Pop back to where you previously invoked @kbd{M-.} and friends.
$B$^$($K(B@kbd{M-.}$B$r5/F0$7$?>l=j$XLa$k!#(B
@end table
@kindex M-.
@findex find-tag
@c @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of
@c a specified tag. It searches through the tags table for that tag, as a
@c string, and then uses the tags table info to determine the file that the
@c definition is in and the approximate character position in the file of
@c the definition. Then @code{find-tag} visits that file, moves point to
@c the approximate character position, and searches ever-increasing
@c distances away to find the tag definition.
@kbd{M-.}@:$B!J(B@code{find-tag}$B!K$O!";XDj$7$?%?%0$NDj5A$rC5$9%3%^%s%I$G$9!#(B
$B$^$:!"%?%0%F!<%V%k$NCf$GJ8;zNs$H$7$F%?%0L>$rC5$7!"(B
$B%?%0%F!<%V%k$N>pJs$rMQ$$$F!"(B
$BDj5A$5$l$F$$$k%U%!%$%k$NL>A0$H%U%!%$%kFb$G$N$*$*$h$=$NJ8;z0LCV$r5a$a$^$9!#(B
$BB3$$$F!"(B@code{find-tag}$B$O$=$N%=!<%9%U%!%$%k$rK,$l$F!"(B
$B%]%$%s%H$r$*$*$h$=$NJ8;z0LCV$K0\F0$7$F$+$i!"(B
$BHO0O$r9-$2$J$,$i%?%0$NDj5A$rC5$7$^$9!#(B
@c If an empty argument is given (just type @key{RET}), the sexp in the
@c buffer before or around point is used as the @var{tag} argument.
@c @xref{Lists}, for info on sexps.
$B!JC1$K(B@key{RET}$B$HBG$C$F!K0z?t$r;XDj$7$J$$$H!"(B
$B%]%$%s%H$ND>A0$^$?$O<~JU$K$"$k(BS$B<0$r(B@var{tag}$B0z?t$H$7$F;H$$$^$9!#(B
S$B<0$K4X$7$F$O!"(B@xref{Lists}$B!#(B
@c You don't need to give @kbd{M-.} the full name of the tag; a part
@c will do. This is because @kbd{M-.} finds tags in the table which
@c contain @var{tag} as a substring. However, it prefers an exact match
@c to a substring match. To find other tags that match the same
@c substring, give @code{find-tag} a numeric argument, as in @kbd{C-u
@c M-.}; this does not read a tag name, but continues searching the tags
@c table's text for another tag containing the same substring last used.
@c If you have a real @key{META} key, @kbd{M-0 M-.}@: is an easier
@c alternative to @kbd{C-u M-.}.
$B%3%^%s%I(B@kbd{M-.}$B$K%?%0$NL>A0$r40A4$KM?$($kI,MW$O$"$j$^$;$s!#(B
$B$=$N0lItJ,$G==J,$G$9!#(B
$B$H$$$&$N$O!"(B@kbd{M-.}$B$O!"ItJ,J8;zNs$H$7$F(B@var{tag}$B$r4^$`(B
$B%?%0$r%?%0%F!<%V%k$GC5$9$+$i$G$9!#(B
$B$b$A$m$s!"ItJ,0lCW$h$j$bA40lCW$N$[$&$,K>$^$7$$$G$9!#(B
$BF1$8ItJ,J8;zNs$K0lCW$9$kJL$N%?%0$rC5$9$K$O!"(B
@kbd{C-u M-.}$B$N$h$&$K(B@code{find-tag}$B$K?t0z?t$r;XDj$7$^$9!#(B
$B$3$&$9$k$H%?%0L>$rJ9$$$F$-$^$;$s$,!"(B
$B:G8e$K;H$C$?$b$N$HF1$8ItJ,J8;zNs$r4^$`JL$N%?%0$r(B
$B%?%0%F!<%V%k$+$iC5$7$^$9!#(B
$B$b$7K\J*$N(B@key{META}$B%-!<$,;H$($k$N$G$"$l$P!"(B
@kbd{C-u M-.}$B$N$+$o$j$K(B@kbd{M-0 M-.}@:$B$HBG$D$[$&$,4JC1$G$7$g$&!#(B
@kindex C-x 4 .
@findex find-tag-other-window
@kindex C-x 5 .
@findex find-tag-other-frame
@c Like most commands that can switch buffers, @code{find-tag} has a
@c variant that displays the new buffer in another window, and one that
@c makes a new frame for it. The former is @kbd{C-x 4 .}, which invokes
@c the command @code{find-tag-other-window}. The latter is @kbd{C-x 5 .},
@c which invokes @code{find-tag-other-frame}.
$B%P%C%U%!$N@Z$jBX$($rH<$&B>$N%3%^%s%I$HF1MM$K!"(B
@code{find-tag}$B$K$b?7$?$J%P%C%U%!$rJL$N%&%#%s%I%&$KI=<($7$?$j!"(B
$B?75,:n@.$7$?%U%l!<%`$KI=<($9$kJQ<o$,$"$j$^$9!#(B
$BA0<T$O(B@kbd{C-x 4 .}$B$G$"$j!"%3%^%s%I(B@code{find-tag-other-window}$B$r5/F0$7$^$9!#(B
$B8e<T$O(B@kbd{C-x 5 .}$B$G$"$j!"(B@code{find-tag-other-frame}$B$r5/F0$7$^$9!#(B
@c To move back to places you've found tags recently, use @kbd{C-u -
@c M-.}; more generally, @kbd{M-.} with a negative numeric argument. This
@c command can take you to another buffer. @kbd{C-x 4 .} with a negative
@c argument finds the previous tag location in another window.
$B:G6a$K$_$D$1$?%?%00LCV$KLa$k$K$O!"(B@kbd{C-u - M-.}$B$r;H$$$^$9!#(B
$B$h$j0lHLE*$K$O!"(B@kbd{M-.}$B$KIi$N?t0z?t$r;XDj$7$^$9!#(B
$B$3$N%3%^%s%I$O!"JL$N%P%C%U%!$X$b0\F0$7$^$9!#(B
@kbd{C-x 4 .}$B$KIi$N?t0z?t$r;XDj$9$k$H!"(B
$BJL$N%&%#%s%I%&$G$^$($N%?%00LCV$KLa$j$^$9!#(B
@kindex M-*
@findex pop-tag-mark
@vindex find-tag-marker-ring-length
@c As well as going back to places you've found tags recently, you can go
@c back to places @emph{from where} you found them. Use @kbd{M-*}, which
@c invokes the command @code{pop-tag-mark}, for this. Typically you would
@c find and study the definition of something with @kbd{M-.} and then
@c return to where you were with @kbd{M-*}.
$B:G6a$K$_$D$1$?%?%00LCV$KLa$k$@$1$G$J$/!"(B
$B%?%0$r(B@emph{$BC5$7$?$H$-(B}$B$N>l=j$XLa$k$3$H$b$G$-$^$9!#(B
$B$=$l$K$O!"%3%^%s%I(B@code{pop-tag-mark}$B$r5/F0$9$k(B@kbd{M-*}$B$r;H$$$^$9!#(B
$BE57?E*$J;H$$J}$G$O!"(B@kbd{M-.}$B$G2?$+$NDj5A$rD4$Y$F$+$i!"(B
@kbd{M-*}$B$G$b$H$N>l=j$KLa$j$^$9!#(B
@c Both @kbd{C-u - M-.} and @kbd{M-*} allow you to retrace your steps to
@c a depth determined by the variable @code{find-tag-marker-ring-length}.
@kbd{C-u - M-.}$B$H(B@kbd{M-*}$B$N$I$A$i$b!"(B
$BJQ?t(B@code{find-tag-marker-ring-length}$B$G;XDj$5$l$k?<$5$^$G!"(B
$BC)$C$?7PO)$r0z$-JV$;$^$9!#(B
@findex find-tag-regexp
@kindex C-M-.
@c The command @kbd{C-M-.} (@code{find-tag-regexp}) visits the tags that
@c match a specified regular expression. It is just like @kbd{M-.} except
@c that it does regexp matching instead of substring matching.
$B%3%^%s%I(B@kbd{C-M-.}$B!J(B@code{find-tag-regexp}$B!K$O!"(B
$B;XDj$7$?@55,I=8=$K0lCW$9$k%?%0$rK,$l$^$9!#(B
$BItJ,J8;zNs$G$O$J$/@55,I=8=$K0lCW$9$k$b$N$G$"$k$3$H$r=|$1$P!"(B
@kbd{M-.}$B$HF1$8$G$9!#(B
@node Tags Search
@c @subsection Searching and Replacing with Tags Tables
@subsection $B%?%0%F!<%V%k$rMQ$$$?C5:w$HCV49(B
@c The commands in this section visit and search all the files listed in the
@c selected tags table, one by one. For these commands, the tags table serves
@c only to specify a sequence of files to search.
$B$3$3$G>R2p$9$k%3%^%s%I$O!"A*Br$5$l$?%?%0%F!<%V%k$K5-O?$5$l$F$$$k(B
$B$9$Y$F$N%U%!%$%k$r(B1$B$D(B1$B$DK,$l$F$OC5:w$r9T$$$^$9!#(B
$B$3$l$i$N%3%^%s%I$KBP$7$F$O!"%?%0%F!<%V%k$OC5:wBP>]$H$J$k(B
$B0lO"$N%U%!%$%k$r;XDj$9$k$@$1$G$9!#(B
@table @kbd
@item M-x tags-search @key{RET} @var{regexp} @key{RET}
@c Search for @var{regexp} through the files in the selected tags
@c table.
$BA*Br$5$l$?%?%0%F!<%V%kFb$N3F%U%!%$%k$+$i(B
$B;XDj$5$l$?(B@var{$B@55,I=8=(B}$B$rC5:w$9$k!#(B
@item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
@c Perform a @code{query-replace-regexp} on each file in the selected tags table.
$BA*Br$5$l$?%?%0%F!<%V%kFb$N3F%U%!%$%k$KBP$7$F!"(B
@code{query-replace-regexp}$B$r<B9T$9$k!#(B
@item M-,
@c Restart one of the commands above, from the current location of point
@c (@code{tags-loop-continue}).
$B%]%$%s%H0LCV$+$i>e5-$N%3%^%s%I$N$$$:$l$+$r:F<B9T$9$k(B
$B!J(B@code{tags-loop-continue}$B!K!#(B
@end table
@findex tags-search
@c @kbd{M-x tags-search} reads a regexp using the minibuffer, then
@c searches for matches in all the files in the selected tags table, one
@c file at a time. It displays the name of the file being searched so you
@c can follow its progress. As soon as it finds an occurrence,
@c @code{tags-search} returns.
@kbd{M-x tags-search}$B$O!"%_%K%P%C%U%!$G@55,I=8=$rFI$_<h$j!"(B
$BA*Br$5$l$?%?%0%F!<%V%kFb$N$9$Y$F$N%U%!%$%k(B1$B$D(B1$B$D$K$D$$$F!"(B
$B@55,I=8=$K0lCW$9$kItJ,$rC5$7$^$9!#(B
$B$3$N%3%^%s%I$OC5:w$7$F$$$k%U%!%$%kL>$rI=<($9$k$N$G!"(B
$B?J9T>u67$,$o$+$j$^$9!#(B
$B@55,I=8=$K0lCW$9$kItJ,$,$_$D$+$k$H!"(B@code{tags-search}$B$O$9$0$KLa$j$^$9!#(B
@kindex M-,
@findex tags-loop-continue
@c Having found one match, you probably want to find all the rest. To find
@c one more match, type @kbd{M-,} (@code{tags-loop-continue}) to resume the
@c @code{tags-search}. This searches the rest of the current buffer, followed
@c by the remaining files of the tags table.@refill
$B0lCW$9$kItJ,$r$_$D$1$?$"$H$K!";D$j$bC5$7$?$/$J$k$G$7$g$&!#(B
$B$D$.$N0lCW$rC5$9$K$O!"(B
@kbd{M-,}$B!J(B@code{tags-loop-continue}$B!K$HBG$C$F!"(B
@code{tags-search}$B$r:F3+$7$^$9!#(B
$B$3$l$O!"%+%l%s%H%P%C%U%!$N;D$j$rC5:w$7$F$+$i!"(B
$B%?%0%F!<%V%k$N;D$j$N%U%!%$%k$K$D$$$F$bC5:w$7$^$9!#(B
@findex tags-query-replace
@c @kbd{M-x tags-query-replace} performs a single
@c @code{query-replace-regexp} through all the files in the tags table. It
@c reads a regexp to search for and a string to replace with, just like
@c ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x
@c tags-search}, but repeatedly, processing matches according to your
@c input. @xref{Replace}, for more information on query replace.
@kbd{M-x tags-query-replace}$B$O!"%?%0%F!<%V%kFb$N$9$Y$F$N%U%!%$%k$rBP>]$K!"(B
@code{query-replace-regexp}$B$r<B9T$7$^$9!#(B
$B$3$N%3%^%s%I$O!"DL>o$N(B@kbd{M-x query-replace-regexp}
$B!JLd$$9g$o$;7?CV49!K$HF1$8$/!"(B
$BC5:w$9$Y$-@55,I=8=$HCV49J8;zNs$rFI$_<h$j$^$9!#(B
$B$=$7$F!"(B@kbd{M-x tags-search}$B$N$h$&$KC5:w$r9T$$!"(B
$BMxMQ<T$NF~NO$K1~$8$F0lCWItJ,$r=hM}$9$k$3$H$r7+$jJV$7$^$9!#(B
$BLd$$9g$o$;7?CV49$K$D$$$F>\$7$/$O!"(B@xref{Replace}$B!#(B
@c It is possible to get through all the files in the tags table with a
@c single invocation of @kbd{M-x tags-query-replace}. But often it is
@c useful to exit temporarily, which you can do with any input event that
@c has no special query replace meaning. You can resume the query replace
@c subsequently by typing @kbd{M-,}; this command resumes the last tags
@c search or replace command that you did.
@kbd{M-x tags-query-replace}$B$r0lEY5/F0$9$k$@$1$G!"(B
$B%?%0%F!<%V%kFb$NA4%U%!%$%k$NCV49$r9T$&$3$H$,$G$-$^$9!#(B
$B$7$+$7!"0l;~E*$KCV49:n6H$+$iH4$1=P$7$F!"(B
$BLd$$9g$o$;7?CV49$H$O4X78$J$$$3$H$r9T$($k$HJXMx$G$9!#(B
@kbd{M-,}$B$HBG$F$P!"Ld$$9g$o$;7?CV49$r:F3+$G$-$^$9!#(B
$B$3$N%3%^%s%I$O!":G8e$K9T$C$?%?%0$NC5:w%3%^%s%I$+CV49%3%^%s%I$r(B
$B:F3+$7$^$9!#(B
@c The commands in this section carry out much broader searches than the
@c @code{find-tag} family. The @code{find-tag} commands search only for
@c definitions of tags that match your substring or regexp. The commands
@c @code{tags-search} and @code{tags-query-replace} find every occurrence
@c of the regexp, as ordinary search commands and replace commands do in
@c the current buffer.
$B$3$3$G>R2p$7$?%3%^%s%I$O!"(B@code{find-tag}$B7ONs$N%3%^%s%I$h$j$b!"(B
$BI}9-$$C5:w$r<B9T$7$^$9!#(B
@code{find-tag}$B%3%^%s%I$O!";XDj$7$?ItJ,J8;zNs$d@55,I=8=$K0lCW$9$k(B
$B%?%0$NDj5A$@$1$r$_$D$1$^$9!#(B
$B%3%^%s%I(B@code{tags-search}$B$H(B@code{tags-query-replace}$B$O!"(B
$BDL>o$NC5:w%3%^%s%I$dCV49%3%^%s%I$,%+%l%s%H%P%C%U%!$G9T$&$h$&$K!"(B
$B@55,I=8=$K0lCW$9$k$"$i$f$kItJ,$rC5$7=P$7$^$9!#(B
@c These commands create buffers only temporarily for the files that they
@c have to search (those which are not already visited in Emacs buffers).
@c Buffers in which no match is found are quickly killed; the others
@c continue to exist.
$B$3$l$i$N%3%^%s%I$O!"!J(BEmacs$B%P%C%U%!$K$^$@K,$l$F$$$J$$$b$N$KBP$7$F$O!K(B
$BC5:w$9$Y$-%U%!%$%kMQ$K0l;~E*$J%P%C%U%!$r:n@.$7$^$9!#(B
$B0lCWItJ,$,$_$D$+$i$J$1$l$P%P%C%U%!$O$?$@$A$K>C$5$l$^$9$,!"(B
$B$_$D$+$l$PB8B3$7$^$9!#(B
@c It may have struck you that @code{tags-search} is a lot like
@c @code{grep}. You can also run @code{grep} itself as an inferior of
@c Emacs and have Emacs show you the matching lines one by one. This works
@c much like running a compilation; finding the source locations of the
@c @code{grep} matches works like finding the compilation errors.
@c @xref{Compilation}.
@code{tags-search}$B$O!"(B@code{grep}$B%W%m%0%i%`$K$?$$$X$s$h$/;w$F$$$k$H(B
$B;W$o$l$?$+$b$7$l$^$;$s!#(B
Emacs$B$N2<0L%W%m%;%9$H$7$F(B@code{grep}$B$r<B9T$7$F!"(B
Emacs$B$K0lCW$7$?9T$r(B1$B$D$:$DI=<($5$;$k$3$H$b$G$-$^$9!#(B
$B$3$l$O!"%3%s%Q%$%k$r<B9T$9$k$N$HF1$8$h$&$KF0:n$7$^$9!#(B
@code{grep}$B$,0lCW$r8!=P$7$?%=!<%92U=j$rC5$9$3$H$O!"(B
$B%3%s%Q%$%k%(%i!<$rC5$9$N$HF1MM$KF0:n$7$^$9!#(B
@xref{Compilation}$B!#(B
@node List Tags
@c @subsection Tags Table Inquiries
@subsection $B%?%0%F!<%V%k$N>H2q(B
@table @kbd
@item M-x list-tags @key{RET} @var{file} @key{RET}
@c Display a list of the tags defined in the program file @var{file}.
$B%W%m%0%i%`%U%!%$%k(B@var{file}$B$GDj5A$5$l$F$$$k%?%0$N0lMw$rI=<($9$k!#(B
@item M-x tags-apropos @key{RET} @var{regexp} @key{RET}
@c Display a list of all tags matching @var{regexp}.
@var{regexp}$B$K0lCW$9$k$9$Y$F$N%?%0$rI=<($9$k!#(B
@end table
@findex list-tags
@c @kbd{M-x list-tags} reads the name of one of the files described by
@c the selected tags table, and displays a list of all the tags defined in
@c that file. The ``file name'' argument is really just a string to
@c compare against the file names recorded in the tags table; it is read as
@c a string rather than as a file name. Therefore, completion and
@c defaulting are not available, and you must enter the file name the same
@c way it appears in the tags table. Do not include a directory as part of
@c the file name unless the file name recorded in the tags table includes a
@c directory.
@kbd{M-x list-tags}$B$O!"A*Br$5$l$?%?%0%F!<%V%k$K5-:\$5$l$F$$$k(B
$B%U%!%$%k$N$I$l$+(B1$B$D$N%U%!%$%kL>$rFI$_<h$j!"(B
$B$=$N%U%!%$%k$GDj5A$5$l$F$$$k$9$Y$F$N%?%0$rI=<($7$^$9!#(B
$B0z?t$N!X%U%!%$%kL>!Y$O!"%?%0%F!<%V%k$K5-O?$5$l$?%U%!%$%kL>$H(B
$BC1=c$KJ8;zNs$H$7$FHf3S$5$l$^$9!#(B
$B%U%!%$%kL>$H$$$&$h$j$O!"J8;zNs$H$7$FFI$^$l$^$9!#(B
$B$7$?$,$C$F!"Jd40$d%G%U%)%k%H$O$"$j$^$;$s$7!"(B
$B%?%0%F!<%V%k$K3JG<$5$l$F$$$k$H$*$j$K@53N$K%U%!%$%kL>$rF~NO$9$kI,MW$,$"$j$^$9!#(B
$B%?%0%F!<%V%kFb$N%U%!%$%kL>$K%G%#%l%/%H%j$,4^$^$l$J$$8B$j!"(B
$B%U%!%$%kL>$K$b%G%#%l%/%H%j$r4^$a$F$O$$$1$^$;$s!#(B
@findex tags-apropos
@c @kbd{M-x tags-apropos} is like @code{apropos} for tags
@c (@pxref{Apropos}). It reads a regexp, then finds all the tags in the
@c selected tags table whose entries match that regexp, and displays the
@c tag names found.
@kbd{M-x tags-appropos}$B$O!"%?%0$KBP$9$k(B@code{apropos}$B$K$"$?$j$^$9(B
$B!J(B@pxref{Apropos}$B!K!#(B
$B$3$N%3%^%s%I$O!"@55,I=8=$rFI$_<h$j!"(B
$BA*Br$5$l$?%?%0%F!<%V%k$NCf$+$i@55,I=8=$K0lCW$9$k9`L\$N%?%0$r(B
$B$9$Y$F$_$D$1$@$7!"$=$N%?%0L>$rI=<($7$^$9!#(B
@c You can also perform completion in the buffer on the name space of tag
@c names in the current tags tables. @xref{Symbol Completion}.
$B8=:_$N%?%0%F!<%V%k$K4^$^$l$k%?%0L>$rL>A06u4V$H$7$F!"(B
$B%P%C%U%!Fb$GJd40$r9T$&$3$H$b$G$-$^$9!#(B
@xref{Symbol Completion}$B!#(B
@node Emerge
@c @section Merging Files with Emerge
@section emerge$B$rMQ$$$?%U%!%$%k$NJ;9g(B
@c @cindex Emerge
@cindex emerge
@c @cindex merging files
@cindex $B%U%!%$%k$NJ;9g(B
@c It's not unusual for programmers to get their signals crossed and modify
@c the same program in two different directions. To recover from this
@c confusion, you need to merge the two versions. Emerge makes this
@c easier. See also @ref{Comparing Files}, for commands to compare
@c in a more manual fashion, and @ref{Emerge,,, ediff, The Ediff Manual}.
$B$A$g$C$H$7$?%_%9$G!"(B1$B$D$N%W%m%0%i%`$+$i(B2$B$D$NJL$NHG$r(B
$B:n$C$F$7$^$&$3$H$b$"$j$^$9!#(B
$B$3$N:.Mp$7$?>uBV$r<}=&$9$k$K$O!"$=$l$i$rJ;9g$9$kI,MW$,$"$j$^$9!#(B
emerge$B$r;H$&$H!"J;9g:n6H$,MF0W$K$J$j$^$9!#(B
$B<jF0$GHf3S$9$k%3%^%s%I$K$D$$$F$O!"(B@ref{Comparing Files}$B$H(B
@ref{Emerge,,, ediff, The Ediff Manual}$B$r;2>H$7$F$/$@$5$$!#(B
@menu
* Overview of Emerge:: How to start Emerge. Basic concepts.
* Submodes of Emerge:: Fast mode vs. Edit mode.
Skip Prefers mode and Auto Advance mode.
* State of Difference:: You do the merge by specifying state A or B
for each difference.
* Merge Commands:: Commands for selecting a difference,
changing states of differences, etc.
* Exiting Emerge:: What to do when you've finished the merge.
* Combining in Emerge:: How to keep both alternatives for a difference.
* Fine Points of Emerge:: Misc.
@end menu
@node Overview of Emerge
@c @subsection Overview of Emerge
@subsection emerge$B$N35MW(B
@c To start Emerge, run one of these four commands:
$B0J2<$N(B4$B$D$N%3%^%s%I$N$$$:$l$+$G(Bemerge$B$r<B9T$7$^$9!#(B
@table @kbd
@item M-x emerge-files
@findex emerge-files
@c Merge two specified files.
$B;XDj$7$?(B2$B$D$N%U%!%$%k$rJ;9g$9$k!#(B
@item M-x emerge-files-with-ancestor
@findex emerge-files-with-ancestor
@c Merge two specified files, with reference to a common ancestor.
$B6&DL$NAD@h$r;2>H$7$J$,$i!";XDj$7$?(B2$B$D$N%U%!%$%k$rJ;9g$9$k!#(B
@item M-x emerge-buffers
@findex emerge-buffers
@c Merge two buffers.
2$B$D$N%P%C%U%!$rJ;9g$9$k!#(B
@item M-x emerge-buffers-with-ancestor
@findex emerge-buffers-with-ancestor
@c Merge two buffers with reference to a common ancestor in a third
@c buffer.
3$BHVL\$N%P%C%U%!$KF~$C$F$$$k6&DL$NAD@h$r;2>H$7$J$,$i!"(B2$B$D$N%P%C%U%!$rJ;9g$9$k!#(B
@end table
@c @cindex merge buffer (Emerge)
@c @cindex A and B buffers (Emerge)
@cindex $BJ;9g%P%C%U%!!J(Bemerge$B!K(B
@cindex A$B%P%C%U%!$H(BB$B%P%C%U%!!J(Bemerge$B!K(B
@c The Emerge commands compare two files or buffers, and display the
@c comparison in three buffers: one for each input text (the @dfn{A buffer}
@c and the @dfn{B buffer}), and one (the @dfn{merge buffer}) where merging
@c takes place. The merge buffer shows the full merged text, not just the
@c differences. Wherever the two input texts differ, you can choose which
@c one of them to include in the merge buffer.
emerge$B%3%^%s%I$O!"(B2$B$D$N%U%!%$%k!"$"$k$$$O!"(B2$B$D$N%P%C%U%!$rHf3S$7$F!"(B
$BHf3S7k2L$r(B3$B$D$N%P%C%U%!!"$D$^$j!"(B
$B3FF~NO%F%-%9%H$K(B1$B$D$:$D!J(B@dfn{A$B%P%C%U%!(B}$B$H(B@dfn{B$B%P%C%U%!(B}$B!K$H!"(B
$BJ;9g$r<B;\$9$k%P%C%U%!!J(B@dfn{$BJ;9g%P%C%U%!(B}$B!K$KI=<($7$^$9!#(B
$BJ;9g%P%C%U%!$K$O!"Hf3S$K$h$C$FF@$i$l$k:9J,$@$1$G$J$/!"(B
$BJ;9g$7$?%F%-%9%HA4BN$,I=<($5$l$^$9!#(B
2$B$D$NF~NO%F%-%9%H$,Aj0c$7$F$$$k2U=j$K$D$$$F$O!"(B
$B$I$A$i$N%F%-%9%H$rJ;9g%P%C%U%!$K4^$a$k$+A*Br$G$-$^$9!#(B
@c The Emerge commands that take input from existing buffers use only the
@c accessible portions of those buffers, if they are narrowed
@c (@pxref{Narrowing}).
$B4{B8$N%P%C%U%!$rF~NO8;$H$9$k(Bemerge$B%3%^%s%I$G$O!"(B
$BF~NO%P%C%U%!$,%J%m%$%s%0$5$l$F$$$k$H!"(B
$B%P%C%U%!$N;2>H2DG=$JItJ,$@$1$r;H$$$^$9!J(B@pxref{Narrowing}$B!K!#(B
@c If a common ancestor version is available, from which the two texts to
@c be merged were both derived, Emerge can use it to guess which
@c alternative is right. Wherever one current version agrees with the
@c ancestor, Emerge presumes that the other current version is a deliberate
@c change which should be kept in the merged version. Use the
@c @samp{with-ancestor} commands if you want to specify a common ancestor
@c text. These commands read three file or buffer names---variant A,
@c variant B, and the common ancestor.
$BJ;9g$7$?$$(B2$B$D$N%F%-%9%H$N$b$H$G$"$k6&DL$NAD@h$K$"$?$kHG$rMxMQ$G$-$k$H$-$K$O!"(B
emerge$B$O$=$l$r;H$C$F$I$A$i$NA*Br;h$,@5$7$$$N$+?dB,$7$^$9!#(B
$B0lJ}$NF~NO$HAD@h$H$N0lCWItJ,$,$I$3$+$K$"$l$P!"(B
$B$b$&0lJ}$NF~NO$K$OJ;9g7k2L$K;D$9$Y$-0U?^E*$JJQ99$,$J$5$l$F$$$k$H?dB,$7$^$9!#(B
$B6&DL$NAD@h$N%F%-%9%H$r;XDj$9$k$K$O!"(B
$BL>A0$K(B@samp{with-ancestor}$B$NIU$$$?%3%^%s%I$r;H$C$F$/$@$5$$!#(B
$B$3$l$i$N%3%^%s%I$O!"(BA$BHG!"(BB$BHG!"6&DL$NAD@h$KBP1~$9$k(B
3$B$D$N%U%!%$%kL>$+%P%C%U%!L>$rFI$_<h$j$^$9!#(B
@c After the comparison is done and the buffers are prepared, the
@c interactive merging starts. You control the merging by typing special
@c @dfn{merge commands} in the merge buffer. The merge buffer shows you a
@c full merged text, not just differences. For each run of differences
@c between the input texts, you can choose which one of them to keep, or
@c edit them both together.
$BF~NO$rHf3S$7$F%P%C%U%!$N=`Hw$r=*$($k$H!"$D$.$OBPOCE*$JJ;9g:n6H$,;O$^$j$^$9!#(B
$BJ;9g%P%C%U%!$GFCJL$J(B@dfn{$BJ;9g%3%^%s%I(B}$B$rBG$C$FJ;9g:n6H$r@)8f$7$^$9!#(B
$BJ;9g%P%C%U%!$K$O!"C1$J$k:9J,$G$O$J$/J;9g$7$?%F%-%9%HA4BN$,I=<($5$l$^$9!#(B
$BF~NO%F%-%9%H$N3FAj0c2U=j$KBP$7$F!"$I$A$iB&$r;D$9$+A*Br$7$?$j!"(B
$BN><T$r$b$H$K$7$FJT=8$G$-$^$9!#(B
@c The merge buffer uses a special major mode, Emerge mode, with commands
@c for making these choices. But you can also edit the buffer with
@c ordinary Emacs commands.
$BJ;9g%P%C%U%!$G$O!"(Bemerge$B%b!<%I$H8F$P$l$kFCJL$J%a%8%c!<%b!<%I$,;H$o$l!"(B
$B$3$l$i$rA*Br$9$k%3%^%s%I$,$"$j$^$9!#(B
$B$b$A$m$s!"DL>o$N(BEmacs$B%3%^%s%I$G%P%C%U%!$rJT=8$9$k$3$H$b$G$-$^$9!#(B
@c At any given time, the attention of Emerge is focused on one
@c particular difference, called the @dfn{selected} difference. This
@c difference is marked off in the three buffers like this:
emerge$B$NCm0U$O!"$$$D$G$b(B@dfn{$BCmL\(B}$BAj0c2U=j$H8F$P$l$k(B
$BAj0c2U=j$K8~$1$i$l$F$$$^$9!#(B
3$B$D$N%P%C%U%!Fb$G$O!"CmL\Aj0cE@$O$D$.$N$h$&$K0u$,IU$1$i$l$^$9!#(B
@example
vvvvvvvvvvvvvvvvvvvv
@var{text that differs}
^^^^^^^^^^^^^^^^^^^^
@end example
@noindent
@c Emerge numbers all the differences sequentially and the mode
@c line always shows the number of the selected difference.
emerge$B$O$9$Y$F$NAj0c2U=j$K=g$KHV9f$r$U$j$^$9!#(B
$B$5$i$K!"%b!<%I9T$K$O$D$M$KCmL\Aj0c2U=j$NHV9f$,I=<($5$l$^$9!#(B
@c Normally, the merge buffer starts out with the A version of the text.
@c But when the A version of a difference agrees with the common ancestor,
@c then the B version is initially preferred for that difference.
$BDL>o!"J;9g%P%C%U%!$O(BA$BHG$NFbMF$G;O$^$j$^$9!#(B
$B$7$+$7!"(BA$BHG$NFbMF$,6&DL$NAD@h$NFbMF$H0lCW$9$k$H$-$K$O!"(B
$BJ;9g%P%C%U%!$O(BB$BHG$NFbMF$G;O$^$j$^$9!#(B
@c Emerge leaves the merged text in the merge buffer when you exit. At
@c that point, you can save it in a file with @kbd{C-x C-w}. If you give a
@c numeric argument to @code{emerge-files} or
@c @code{emerge-files-with-ancestor}, it reads the name of the output file
@c using the minibuffer. (This is the last file name those commands read.)
@c Then exiting from Emerge saves the merged text in the output file.
emerge$B$r=*$($k$H!"J;9g%P%C%U%!$K$O$=$N;~E@$NJ;9g:Q$_%F%-%9%H$,;D$j$^$9!#(B
emerge$B=*N;;~$K$O!"(B@kbd{C-x C-w}$B$G%U%!%$%k$KJ]B8$G$-$^$9!#(B
@code{emerge-files}$B$d(B@code{emerge-files-with-ancestor}$B$K(B
$B?t0z?t$r;XDj$9$k$H!"%_%K%P%C%U%!$G=PNO%U%!%$%kL>$rFI$_<h$j$^$9!#(B
$B!J$I$A$i$N>l9g$G$b!"$3$l$,$$$A$P$s:G8e$KJ9$+$l$k%U%!%$%kL>!#!K(B
$B$9$k$H!"(Bemerge$B=*N;;~$K$O!"J;9g:Q$_$N%F%-%9%H$,$=$N=PNO%U%!%$%k$KJ]B8$5$l$^$9!#(B
@c Normally, Emerge commands save the output buffer in its file when you
@c exit. If you abort Emerge with @kbd{C-]}, the Emerge command does not
@c save the output buffer, but you can save it yourself if you wish.
emerge$B$r=*$($k$H!"DL>o!"(Bemerge$B%3%^%s%I$,J;9g%P%C%U%!$r%U%!%$%k$KJ]B8$7$^$9!#(B
emerge$B$r(B@kbd{C-]}$B$G%"%\!<%H$9$k$H(Bemerge$B%3%^%s%I$OJ;9g%P%C%U%!$rJ]B8$7$^$;$s$,!"(B
$BI,MW$J$i$P%f!<%6!<<+?H$GJ]B8$G$-$^$9!#(B
@node Submodes of Emerge
@c @subsection Submodes of Emerge
@subsection emerge$B$N%5%V%b!<%I(B
@c You can choose between two modes for giving merge commands: Fast mode
@c and Edit mode. In Fast mode, basic merge commands are single
@c characters, but ordinary Emacs commands are disabled. This is
@c convenient if you use only merge commands. In Edit mode, all merge
@c commands start with the prefix key @kbd{C-c C-c}, and the normal Emacs
@c commands are also available. This allows editing the merge buffer, but
@c slows down Emerge operations.
$BJ;9g%3%^%s%I$r;X<($9$k$?$a$N%b!<%I$,(B2$B$D!"$D$^$j!"(B
$B9bB.%b!<%I!J(BFast mode$B!K$HJT=8%b!<%I!J(BEdit mode$B!K$,$"$j!"$I$A$i$+$rA*$Y$^$9!#(B
$B9bB.%b!<%I$G$O!"4pK\E*$JJ;9g%3%^%s%I$O(B1$BJ8;z$GI=$5$l!"(B
$BDL>o$N(BEmacs$B%3%^%s%I$O6X;_$5$l$F$$$^$9!#(B
$BJ;9g%3%^%s%I$@$1$r;HMQ$9$k$N$G$"$l$P!"9bB.%b!<%I$,JXMx$G$9!#(B
$BJT=8%b!<%I$G$O!"$9$Y$F$NJ;9g%3%^%s%I$O%W%l%U%#%C%/%9(B@kbd{C-c C-c}$B$G;O$^$j!"(B
$BDL>o$N(BEmacs$B%3%^%s%I$b;H$($^$9!#(B
$B$3$N%b!<%I$G$O!"J;9g%P%C%U%!$rJT=8$G$-$^$9$,!"(Bemerge$B$N=hM}$OCY$/$J$j$^$9!#(B
@c Use @kbd{e} to switch to Edit mode, and @kbd{C-c C-c f} to switch to
@c Fast mode. The mode line indicates Edit and Fast modes with @samp{E}
@c and @samp{F}.
$BJT=8%b!<%I$K@Z$jBX$($k$K$O(B@kbd{e}$B$r;H$$!"(B
$B9bB.%b!<%I$K@Z$jBX$($k$K$O(B@kbd{C-c C-c f}$B$r;H$$$^$9!#(B
$B%b!<%I9T$K$O!"JT=8%b!<%I$O(B@samp{E}$B!"9bB.%b!<%I$O(B@samp{F}$B$HI=<($5$l$^$9!#(B
@c Emerge has two additional submodes that affect how particular merge
@c commands work: Auto Advance mode and Skip Prefers mode.
emerge$B$K$O!"FCDj$NJ;9g%3%^%s%I$NF0:n$K1F6A$rM?$($k%5%V%b!<%I$,(B
$B$5$i$K(B2$B$D$"$j$^$9!#(B
$B<+F0A0?J!J(Bauto-advance$B!K%b!<%I$H(B
$BM%@h2U=j%9%-%C%W!J(Bskip-prefers$B!K%b!<%I$G$9!#(B
@c If Auto Advance mode is in effect, the @kbd{a} and @kbd{b} commands
@c advance to the next difference. This lets you go through the merge
@c faster as long as you simply choose one of the alternatives from the
@c input. The mode line indicates Auto Advance mode with @samp{A}.
$B<+F0A0?J%b!<%I$,%*%s$G$"$k$H!"%3%^%s%I(B@kbd{a}$B$H(B@kbd{b}$B$O!"(B
$B<+F0E*$K$D$.$NAj0c2U=j$K%]%$%s%H$r?J$a$^$9!#(B
$B$3$N%b!<%I$G$O!"$I$A$i$+$NF~NO$@$1$rA*$V>u67$G$"$k8B$j!"9bB.$KJ;9g$r9T$($^$9!#(B
$B%b!<%I9T$K$O(B@samp{A}$B$HI=<($5$l!"<+F0A0?J%b!<%I$G$"$k$r<($7$^$9!#(B
@c If Skip Prefers mode is in effect, the @kbd{n} and @kbd{p} commands
@c skip over differences in states prefer-A and prefer-B (@pxref{State of
@c Difference}). Thus you see only differences for which neither version
@c is presumed ``correct.'' The mode line indicates Skip Prefers mode with
@c @samp{S}.
$BM%@h2U=j%9%-%C%W%b!<%I$,%*%s$G$"$k$H!"(B
$B%3%^%s%I(B@kbd{n}$B$H(B@kbd{p}$B$O!"(B
A$BM%@h!?(BB$BM%@h$N>uBV$K$"$kAj0c2U=j$r%9%-%C%W$7$^$9(B
$B!J(B@pxref{State of Difference}$B!K!#(B
$B$D$^$j!"$I$A$i$NHG$b!X@5$7$$!Y$H?dDj$5$l$J$$Aj0c2U=j$@$1$rD4$Y$3$H$K$J$j$^$9!#(B
$B%b!<%I9T$K$O(B@samp{S}$B$HI=<($5$l!"M%@h2U=j%9%-%C%W%b!<%I$G$"$k$3$H$r<($7$^$9!#(B
@findex emerge-auto-advance-mode
@findex emerge-skip-prefers-mode
@c Use the command @kbd{s a} (@code{emerge-auto-advance-mode}) to set or
@c clear Auto Advance mode. Use @kbd{s s}
@c (@code{emerge-skip-prefers-mode}) to set or clear Skip Prefers mode.
@c These commands turn on the mode with a positive argument, turns it off
@c with a negative or zero argument, and toggle the mode with no argument.
$B<+F0A0?J%b!<%I$r%*%s!?%*%U$9$k$K$O!"(B
$B%3%^%s%I(B@kbd{s a}$B!J(B@code{emerge-auto-advance-mode}$B!K$r;H$$$^$9!#(B
$BM%@h2U=j%9%-%C%W%b!<%I$r%*%s!?%*%U$9$k$K$O!"(B
$B%3%^%s%I(B@kbd{s s}$B!J(B@code{emerge-skip-prefers-mode}$B!K$r;H$$$^$9!#(B
$B$I$A$i$N%3%^%s%I$b!"@5$N?t0z?t$r;XDj$9$k$H%*%s$K$7!"(B
$BIi$"$k$$$O(B0$B$N?t0z?t$r;XDj$9$k$H%*%U$K$7!"(B
$B0z?t$r;XDj$7$J$$$H%H%0%k!J@Z$jBX$(!K$7$^$9!#(B
@node State of Difference
@c @subsection State of a Difference
@subsection $BAj0c2U=j$N>uBV(B
@c In the merge buffer, a difference is marked with lines of @samp{v} and
@c @samp{^} characters. Each difference has one of these seven states:
$BJ;9g%P%C%U%!Fb$G$O!"Aj0c2U=j$O(B@samp{v}$B$H(B@samp{^}$B$NJ8;z$@$1$N9T$K(B
$B64$^$l$F<($5$l$^$9!#(B
$B3FAj0c2U=j$O!"$D$.$N(B7$B$D$N$$$:$l$+$N>uBV$K$J$C$F$$$^$9!#(B
@table @asis
@c @item A
@item $B>uBV(BA
@c The difference is showing the A version. The @kbd{a} command always
@c produces this state; the mode line indicates it with @samp{A}.
$B$3$NAj0c2U=j$O(BA$BHG$NFbMF$G$"$k!#(B
@kbd{a}$B%3%^%s%I$OI,$:$3$N>uBV$K$9$k!#(B
$B%b!<%I9T$K$O(B@samp{A}$B$HI=<($5$l$k!#(B
@c @item B
@item $B>uBV(BB
@c The difference is showing the B version. The @kbd{b} command always
@c produces this state; the mode line indicates it with @samp{B}.
$B$3$NAj0c2U=j$O(BB$BHG$NFbMF$G$"$k!#(B
@kbd{b}$B%3%^%s%I$OI,$:$3$N>uBV$K$9$k!#(B
$B%b!<%I9T$K$O(B@samp{B}$B$HI=<($5$l$k!#(B
@c @item default-A
@c @itemx default-B
@item $B%G%U%)%k%H(BA
@itemx $B%G%U%)%k%H(BB
@c The difference is showing the A or the B state by default, because you
@c haven't made a choice. All differences start in the default-A state
@c (and thus the merge buffer is a copy of the A buffer), except those for
@c which one alternative is ``preferred'' (see below).
$B$^$@7h?4$7$F$$$J$$$N$G!"!X%G%U%)%k%H!Y$G!"(B
$BAj0c2U=j$O>uBV(BA$B!J(BA$BHG$NFbMF!K$+>uBV(BB$B!J(BB$BHG$NFbMF!K$G$"$k!#(B
$B$I$A$i$+$NA*Br;h$,!XM%@h$5$l$k!Y!J2<5-;2>H!K>l9g$r=|$$$F!"(B
$BAj0c2U=j$O$9$Y$F%G%U%)%k%H(BA$B$G;O$^$k(B
$B!J$D$^$j!"J;9g%P%C%U%!$NFbMF$O(BA$B%P%C%U%!$N%3%T!<!K!#(B
@c When you select a difference, its state changes from default-A or
@c default-B to plain A or B. Thus, the selected difference never has
@c state default-A or default-B, and these states are never displayed in
@c the mode line.
$BAj0c2U=j$rA*Br$9$k$H!"$=$N>uBV$O!"%G%U%)%k%H(BA$B$d%G%U%)%k%H(BB$B$+$i(B
$B>uBV(BA$B$d>uBV(BB$B$KA+0\$9$k!#(B
$B$D$^$j!"0lEY$G$bA*Br$7$?Aj0c2U=j$O!"(B
$B%G%U%)%k%H(BA$B$d%G%U%)%k%H(BB$B$N>uBV$G$"$k$3$H$O$J$/!"(B
$B$3$l$i$N>uBV$O$1$C$7$F%b!<%I9T$K$OI=<($5$l$J$$!#(B
@c The command @kbd{d a} chooses default-A as the default state, and @kbd{d
@c b} chooses default-B. This chosen default applies to all differences
@c which you haven't ever selected and for which no alternative is preferred.
@c If you are moving through the merge sequentially, the differences you
@c haven't selected are those following the selected one. Thus, while
@c moving sequentially, you can effectively make the A version the default
@c for some sections of the merge buffer and the B version the default for
@c others by using @kbd{d a} and @kbd{d b} between sections.
$B%G%U%)%k%H$N>uBV$H$7$F!"(B
$B%3%^%s%I(B@kbd{d a}$B$O%G%U%)%k%H(BA$B$rA*$S!"(B
@kbd{d b}$B%G%U%)%k%H(BB$B$rA*$V!#(B
$B$3$l$i$N%3%^%s%I$GA*$s$@%G%U%)%k%H$N>uBV$O!"(B
$B0lEY$bA*Br$7$F$J$/!"$+$D!"$I$A$i$NHG$bM%@h$5$l$J$$Aj0c2U=j$KE,MQ$5$l$k!#(B
$BJ;9g:n6H$r@hF,$+$i=g$K9T$C$F$$$k>l9g!"(B
$B:G8e$KA*Br$7$?Aj0c2U=j$KB3$/Aj0c2U=j72$,0lEY$bA*Br$5$l$F$$$J$$$b$N$G$"$k!#(B
$B$7$?$,$C$F!"@hF,$+$i=g$K?J$a$k$N$G$"$l$P!"(B
@kbd{d a}$B$H(B@kbd{d b}$B$r;H$$J,$1$F!"(B
$BJ;9g%P%C%U%!$N$"$kItJ,$G$O(BA$BHG$r%G%U%)%k%H$H$7!"(B
$BJL$NItJ,$G$O(BB$BHG$r%G%U%)%k%H$H$9$k$3$H$,$G$-$k!#(B
@c @item prefer-A
@c @itemx prefer-B
@item $BM%@h(BA
@itemx $BM%@h(BB
@c The difference is showing the A or B state because it is
@c @dfn{preferred}. This means that you haven't made an explicit choice,
@c but one alternative seems likely to be right because the other
@c alternative agrees with the common ancestor. Thus, where the A buffer
@c agrees with the common ancestor, the B version is preferred, because
@c chances are it is the one that was actually changed.
$B$I$A$i$+$,(B@dfn{$BM%@h$5$l(B}$B$F$$$k$N$G!"(B
$BAj0c2U=j$O>uBV(BA$B!J(BA$BHG$NFbMF!K$+>uBV(BB$B!J(BB$BHG$NFbMF!K$G$"$k!#(B
$B$D$^$j!"L@<(E*$K$O$^$@A*Br$7$F$$$J$$$,!"Ev3:2U=j$G$O!"(B
$B0lJ}$NHG$,6&DL$NAD@h$K0lCW$9$k$?$a!"(B
$BB>J}$NHG$N$[$&$,@5$7$/;W$o$l$k$N$G$"$k!#(B
$B$7$?$,$C$F!"(BA$B%P%C%U%!$,6&DL$NAD@h$H0lCW$9$k2U=j$G$O!"(B
$B<B:]$KJQ99$5$l$?$[$&$,@5$7$$$b$N$G$"$k2DG=@-$,$"$k$N$G!"(B
B$BHG$,M%@h$5$l$k!#(B
@c These two states are displayed in the mode line as @samp{A*} and @samp{B*}.
$B$3$l$i$N(B2$B$D$N>uBV$O!"%b!<%I9T$G$O(B@samp{A*}$B$d(B@samp{B*}$B$HI=<($5$l$k!#(B
@c @item combined
@item $B:.9g>uBV(B
@c The difference is showing a combination of the A and B states, as a
@c result of the @kbd{x c} or @kbd{x C} commands.
@kbd{x c}$B$d(B@kbd{x C}$B%3%^%s%I$N7k2L!"(B
$BAj0c2U=j$O!">uBV(BA$B!J(BA$BHG$NFbMF!K$H>uBV(BB$B!J(BB$BHG$NFbMF!K$N:.9g>uBV$K$J$C$F$$$k!#(B
@c Once a difference is in this state, the @kbd{a} and @kbd{b} commands
@c don't do anything to it unless you give them a numeric argument.
$BAj0c2U=j$,$$$C$?$s$3$N>uBV$K$J$k$H!"(B
$B%3%^%s%I(B@kbd{a}$B$d(B@kbd{b}$B$K?t0z?t$r;XDj$7$J$$8B$j!"2?$b$7$J$$!#(B
@c The mode line displays this state as @samp{comb}.
$B$3$N>uBV$O!"%b!<%I9T$G$O(B@samp{comb}$B$HI=<($5$l$k!#(B
@end table
@node Merge Commands
@c @subsection Merge Commands
@subsection $BJ;9g%3%^%s%I(B
@c Here are the Merge commands for Fast mode; in Edit mode, precede them
@c with @kbd{C-c C-c}:
$B$3$3$G$O!"9bB.%b!<%I$NJ;9gA`:n%3%^%s%I$r<($7$^$9!#(B
$BJT=8%b!<%I$G$O!"$3$l$i$N%3%^%s%I$N$^$($K(B@kbd{C-c C-c}$B$rIU$1$^$9!#(B
@table @kbd
@item p
@c Select the previous difference.
$B$^$($NAj0c2U=j$rA*Br$9$k!#(B
@item n
@c Select the next difference.
$B$D$.$NAj0c2U=j$rA*Br$9$k!#(B
@item a
@c Choose the A version of this difference.
$B$3$NAj0c2U=j$r(BA$BHG$K$9$k!J>uBV(BA$B!K!#(B
@item b
@c Choose the B version of this difference.
$B$3$NAj0c2U=j$r(BB$BHG$K$9$k!J>uBV(BB$B!K!#(B
@item C-u @var{n} j
@c Select difference number @var{n}.
$BHV9f(B@var{n}$B$NAj0c2U=j$rA*Br$9$k!#(B
@item .
@c Select the difference containing point. You can use this command in the
@c merge buffer or in the A or B buffer.
$B%]%$%s%H$r4^$`Aj0c2U=j$rA*Br$9$k!#(B
$B$3$N%3%^%s%I$O!"J;9g%P%C%U%!!"(BA$B%P%C%U%!!"(BB$B%P%C%U%!$N$$$:$l$G$b;H$($k!#(B
@item q
@c Quit---finish the merge.
$B=*N;$9$k!#(B
$BJ;9g:n6H$r40N;!#(B
@item C-]
@c Abort---exit merging and do not save the output.
$B%"%\!<%H$9$k!#(B
$BJ;9g:n6H$r$d$a!"J;9g7k2L$bJ]B8$7$J$$!#(B
@item f
@c Go into Fast mode. (In Edit mode, this is actually @kbd{C-c C-c f}.)
$B9bB.%b!<%I$K0\9T$9$k!#(B
$B!JJT=8%b!<%I$G$O!"<B:]$K$O(B@kbd{C-c C-c f}$B%3%^%s%I!#!K(B
@item e
@c Go into Edit mode.
$BJT=8%b!<%I$K0\9T$9$k!#(B
@item l
@c Recenter (like @kbd{C-l}) all three windows.
3$B$D$N%&%#%s%I%&$9$Y$F$r!J(B@kbd{C-l}$B$N$h$&$K!K:FI=<($9$k!#(B
@item -
@c Specify part of a prefix numeric argument.
$B?t0z?t$N0lIt$r;XDj$9$k!#(B
@item @var{digit}
@c Also specify part of a prefix numeric argument.
$B$3$l$b!"?t0z?t$N0lIt$r;XDj$9$k!#(B
@item d a
@c Choose the A version as the default from here down in
@c the merge buffer.
$BJ;9g%P%C%U%!$N$3$l0J9_$G$O!"(BA$BHG$rA*$V!J%G%U%)%k%H(BA$B!K!#(B
@item d b
@c Choose the B version as the default from here down in
@c the merge buffer.
$BJ;9g%P%C%U%!$N$3$l0J9_$G$O!"(BB$BHG$rA*$V!J%G%U%)%k%H(BB$B!K!#(B
@item c a
@c Copy the A version of this difference into the kill ring.
$B$3$NAj0c2U=j$N(BA$BHG$N%F%-%9%H$r%-%k%j%s%0$K%3%T!<$9$k!#(B
@item c b
@c Copy the B version of this difference into the kill ring.
$B$3$NAj0c2U=j$N(BB$BHG$N%F%-%9%H$r%-%k%j%s%0$K%3%T!<$9$k!#(B
@item i a
@c Insert the A version of this difference at point.
$B$3$NAj0c2U=j$N(BA$BHG$N%F%-%9%H$r%]%$%s%H0LCV$KA^F~$9$k!#(B
@item i b
@c Insert the B version of this difference at point.
$B$3$NAj0c2U=j$N(BB$BHG$N%F%-%9%H$r%]%$%s%H0LCV$KA^F~$9$k!#(B
@item m
@c Put point and mark around the difference.
$BAj0c2U=j$N<~$j$K%]%$%s%H$H%^!<%/$r@_Dj$9$k!#(B
@item ^
@c Scroll all three windows down (like @kbd{M-v}).
3$B$D$N%&%#%s%I%&$9$Y$F$r!J(B@kbd{M-v}$B$N$h$&$K!K2<$K%9%/%m!<%k$9$k!#(B
@item v
@c Scroll all three windows up (like @kbd{C-v}).
3$B$D$N%&%#%s%I%&$9$Y$F$r!J(B@kbd{C-v}$B$N$h$&$K!K>e$K%9%/%m!<%k$9$k!#(B
@item <
@c Scroll all three windows left (like @kbd{C-x <}).
3$B$D$N%&%#%s%I%&$9$Y$F$r!J(B@kbd{C-x <}$B$N$h$&$K!K:8$K%9%/%m!<%k$9$k!#(B
@item >
@c Scroll all three windows right (like @kbd{C-x >}).
3$B$D$N%&%#%s%I%&$9$Y$F$r!J(B@kbd{C-x >}$B$N$h$&$K!K1&$K%9%/%m!<%k$9$k!#(B
@item |
@c Reset horizontal scroll on all three windows.
3$B$D$N%&%#%s%I%&$9$Y$F$G!"?eJ?J}8~$N%9%/%m!<%kJ,$r%j%;%C%H$9$k!#(B
@item x 1
@c Shrink the merge window to one line. (Use @kbd{C-u l} to restore it
@c to full size.)
$BJ;9g%P%C%U%!$rI=<($7$F$$$k%&%#%s%I%&$N9b$5$r(B1$B9T$K=L>.$9$k!#(B
$B!J%U%k%5%$%:$KLa$9$K$O(B@kbd{C-u l}$B$r;H$&!#!K(B
@item x c
@c Combine the two versions of this difference (@pxref{Combining in
@c Emerge}).
$B$3$NAj0c2U=j$N(B2$B$D$NHG$r:.9g$9$k!J(B@pxref{Combining in Emerge}$B!K!#(B
@item x f
@c Show the names of the files/buffers Emerge is operating on, in a Help
@c window. (Use @kbd{C-u l} to restore windows.)
emerge$B$G:n6H$7$F$$$k%U%!%$%k!?%P%C%U%!$NL>A0$r!"(B
$B%X%k%WMQ%&%#%s%I%&$KI=<($9$k!#(B
$B!J%&%#%s%I%&$r$b$H$N>uBV$KLa$9$K$O(B@kbd{C-u l}$B$r;H$&!#!K(B
@item x j
@c Join this difference with the following one.
@c (@kbd{C-u x j} joins this difference with the previous one.)
$B$3$NAj0c2U=j$r!"$D$.$NAj0c2U=j$H7k9g$9$k!#(B
$B!J(B@kbd{C-u x j}$B$G$O!"$^$($NAj0c2U=j$H7k9g$9$k!#!K(B
@item x s
@c Split this difference into two differences. Before you use this
@c command, position point in each of the three buffers at the place where
@c you want to split the difference.
$B$3$NAj0c2U=j$r(B2$B$D$KJ,3d$9$k!#(B
$B$3$N%3%^%s%I$r;H$&$^$($K!"(B3$B$D$N%P%C%U%!$=$l$>$l$G!"(B
$BAj0c2U=j$rJ,3d$7$?$$0LCV$K%]%$%s%H$r0\F0$7$F$*$/!#(B
@item x t
@c Trim identical lines off the top and bottom of the difference.
@c Such lines occur when the A and B versions are
@c identical but differ from the ancestor version.
$BAj0c2U=j$N@hF,$dKvHx$K$"$kF1$89T$r<h$j5n$k!#(B
$B$3$N$h$&$J9T$,8=$l$k$N$O!"(B
A$BHG$H(BB$BHG$O0lCW$7$F$$$k$,!"6&DL$NAD@h$H$O0lCW$7$J$$>l9g!#(B
@end table
@node Exiting Emerge
@c @subsection Exiting Emerge
@subsection emerge$B$N=*N;(B
@c The @kbd{q} command (@code{emerge-quit}) finishes the merge, storing
@c the results into the output file if you specified one. It restores the
@c A and B buffers to their proper contents, or kills them if they were
@c created by Emerge and you haven't changed them. It also disables the
@c Emerge commands in the merge buffer, since executing them later could
@c damage the contents of the various buffers.
@kbd{q}$B%3%^%s%I!J(B@code{emerge-quit}$B!K$O!"J;9g$r=*N;$7!"(B
$B=PNO%U%!%$%k$r;XDj$7$F$"$l$P!"$=$3$K7k2L$rJ]B8$7$^$9!#(B
A$B%P%C%U%!$H(BB$B%P%C%U%!$O@5$7$$FbMF$KI|85$5$l$^$9$,!"(B
emerge$B$,(BA$B%P%C%U%!$H(BB$B%P%C%U%!$r:n@.$7$F!"$+$D!"JT=8$5$l$F$$$J$1$l$P!"(B
$B$=$l$i$r%-%k$7$^$9!#(B
$B$5$i$K!"J;9g%P%C%U%!$G$N(Bemerge$B%3%^%s%I$r;HMQ6X;_$K$7$^$9!#(B
$B$H$$$&$N$O!"$3$l0J9_$KJ;9g%3%^%s%I$r<B9T$9$k$H(B
$B$5$^$6$^$J%P%C%U%!$,0-1F6A$r<u$1$k2DG=@-$,$"$k$+$i$G$9!#(B
@c @kbd{C-]} aborts the merge. This means exiting without writing the
@c output file. If you didn't specify an output file, then there is no
@c real difference between aborting and finishing the merge.
@kbd{C-]}$B$O!"J;9g:n6H$r%"%\!<%H$7$^$9!#(B
$B$D$^$j!"=PNO%U%!%$%k$K=q$-=P$5$:$K=*$j$^$9!#(B
$B=PNO%U%!%$%k$r;XDj$7$F$$$J$1$l$P!"J;9g:n6H$r%"%\!<%H$7$h$&$,=*N;$7$h$&$,!"(B
$B2?$N0c$$$b$"$j$^$;$s!#(B
@c If the Emerge command was called from another Lisp program, then its
@c return value is @code{t} for successful completion, or @code{nil} if you
@c abort.
$BB>$N(BLisp$B%W%m%0%i%`$+$i(Bemerge$B%3%^%s%I$,8F$S=P$5$l$?>l9g!"(B
$B@5$7$/=*N;$9$k$H(B@code{t}$B!"%"%\!<%H$7$?$H$-$O(B@code{nil}$B$,JV$5$l$^$9!#(B
@node Combining in Emerge
@c @subsection Combining the Two Versions
@subsection 2$B$D$NHG$N:.9g(B
@c Sometimes you want to keep @emph{both} alternatives for a particular
@c difference. To do this, use @kbd{x c}, which edits the merge buffer
@c like this:
$BAj0c2U=j$K$h$C$F$O!"(B@emph{$BN>J}(B}$B$NHG$r;D$7$?$$$3$H$b$"$k$G$7$g$&!#(B
$B$=$N$h$&$J>l9g$K$O!"(B@kbd{x c}$B$r;H$$$^$9!#(B
$B$9$k$H!"J;9g%P%C%U%!$O$D$.$N$h$&$K$J$j$^$9!#(B
@example
@group
#ifdef NEW
@var{version from A buffer}
#else /* not NEW */
@var{version from B buffer}
#endif /* not NEW */
@end group
@end example
@noindent
@vindex emerge-combine-versions-template
@c While this example shows C preprocessor conditionals delimiting the two
@c alternative versions, you can specify the strings to use by setting
@c the variable @code{emerge-combine-versions-template} to a string of your
@c choice. In the string, @samp{%a} says where to put version A, and
@c @samp{%b} says where to put version B. The default setting, which
@c produces the results shown above, looks like this:
$B$3$NNc$G$O!"(B2$B$D$NHG$r(BC$B$N%W%j%W%m%;%C%5$N>r7o@a$GJ,$1$F$$$^$9$,!"(B
$BJQ?t(B@code{emerge-combine-versions-template}$B$K9%$_$NJ8;zNs$r@_Dj$9$l$P!"(B
$B$3$N%3%^%s%I$G;HMQ$9$kJ8;zNs$r;XDj$G$-$^$9!#(B
$B$3$NJ8;zNsFb$G$O!"(BA$BHG$N%F%-%9%H$rCV$/2U=j$K$O(B@samp{%a}$B$r!"(B
B$BHG$N$rCV$/2U=j$K$O(B@samp{%b}$B$r;XDj$7$^$9!#(B
$B>e$K<($7$?7k2L$r@8$8$k%G%U%)%k%H$N@_Dj$O$D$.$N$H$*$j$G$9!#(B
@example
@group
"#ifdef NEW\n%a#else /* not NEW */\n%b#endif /* not NEW */\n"
@end group
@end example
@node Fine Points of Emerge
@c @subsection Fine Points of Emerge
@subsection $B:Y$+$JCm0UE@(B
@c During the merge, you mustn't try to edit the A and B buffers yourself.
@c Emerge modifies them temporarily, but ultimately puts them back the way
@c they were.
$BJ;9g:n6HCf$K$O!"(BA$B%P%C%U%!$d(BB$B%P%C%U%!$r>!<j$KJT=8$7$F$O$$$1$^$;$s!#(B
emerge$B$O0l;~E*$K$3$l$i$N%P%C%U%!$NFbMF$rJQ99$7$^$9$,!"(B
$B:G=*E*$K$O$b$H$N>uBV$KLa$7$^$9!#(B
@c You can have any number of merges going at once---just don't use any one
@c buffer as input to more than one merge at once, since the temporary
@c changes made in these buffers would get in each other's way.
$BJ#?t$NJ;9g=hM}$rF1;~$K?J$a$k$3$H$b$G$-$^$9$,!"(B
$BJL$NJ;9g=hM}$NF~NO$KF1$8%P%C%U%!$r;HMQ$7$F$O$$$1$^$;$s!#(B
$B$H$$$&$N$O!"0l;~E*$K$;$h!"8_$$$K0[$J$kJ#?t$NJQ99$,(B
1$B$D$N%P%C%U%!$K2C$($i$l$F$7$^$&$+$i$G$9!#(B
@c Starting Emerge can take a long time because it needs to compare the
@c files fully. Emacs can't do anything else until @code{diff} finishes.
@c Perhaps in the future someone will change Emerge to do the comparison in
@c the background when the input files are large---then you could keep on
@c doing other things with Emacs until Emerge is ready to accept
@c commands.
$BF~NO%U%!%$%kA4BN$rHf3S$9$kI,MW$,$"$k$?$a!"(B
emerge$B$N3+;O$K$O$7$P$i$/;~4V$,$+$+$k>l9g$b$"$j$^$9!#(B
$B$^$?!"(B@code{diff}$B%3%^%s%I$,40N;$9$k$^$G!"(Bemerge$B$O2?$b$G$-$^$;$s!#(B
$B$?$V$s!"$=$N$&$AC/$+$,(Bemerge$B$rJQ99$7$F!"(B
$BF~NO%U%!%$%k$,Bg$-$$$H$-$K$O%P%C%/%0%i%&%s%I$GHf3S$r9T$&$h$&$K$9$k$G$7$g$&!#(B
$B$=$&$9$l$P!"(Bemerge$B$,%3%^%s%I$r<u$1IU$1$k$h$&$K$J$k$^$G!"(B
Emacs$B$GB>$N:n6H$rB3$1$i$l$^$9!#(B
@vindex emerge-startup-hook
@c After setting up the merge, Emerge runs the hook
@c @code{emerge-startup-hook} (@pxref{Hooks}).
$B%U%C%/(B@code{emerge-startup-hook}$B!J(B@pxref{Hooks}$B!K$,!"J;9g=hM}$N@_Dj$N:G8e(B
$B$K<B9T$5$l$^$9!#(B
@node C Modes
@c @section C and Related Modes
@section C$B%b!<%I$H4XO"$9$k%b!<%I(B
@c @cindex C mode
@c @cindex Java mode
@c @cindex Pike mode
@c @cindex IDL mode
@c @cindex CORBA IDL mode
@c @cindex Objective C mode
@c @cindex C++ mode
@c @cindex mode, Java
@c @cindex mode, C
@c @cindex mode, Objective C
@c @cindex mode, CORBA IDL
@c @cindex mode, Pike
@cindex C$B%b!<%I(B
@cindex Java$B%b!<%I(B
@cindex Pike$B%b!<%I(B
@cindex IDL$B%b!<%I(B
@cindex CORBA IDL$B%b!<%I(B
@cindex Objective C$B%b!<%I(B
@cindex C++$B%b!<%I(B
@cindex $B%b!<%I!"(BJava
@cindex $B%b!<%I!"(BC
@cindex $B%b!<%I!"(BObjective C
@cindex $B%b!<%I!"(BCORBA IDL
@cindex $B%b!<%I!"(BPike
@c This section describes special features available in C, C++,
@c Objective-C, Java, CORBA IDL, and Pike modes. When we say ``C mode and
@c related modes,'' those are the modes we mean.
$BK\@a$G$O!"(BC$B!"(BC++$B!"(BObjective-C$B!"(BJava$B!"(BCORBA IDL$B!"(B
Pike$BMQ$N3F%b!<%I$GMxMQ2DG=$JFCJL$J5!G=$K$D$$$F=R$Y$^$9!#(B
$B!X(BC$B%b!<%I$H4XO"$9$k%b!<%I!Y$H=q$$$?$H$-$K$O!"(B
$B$3$l$i$N%b!<%I$r0UL#$7$^$9!#(B
@menu
* Motion in C::
* Electric C::
* Hungry Delete::
* Other C Commands::
* Comments in C::
@end menu
@node Motion in C
@c @subsection C Mode Motion Commands
@subsection C$B%b!<%I$N0\F0%3%^%s%I(B
@c This section describes commands for moving point, in C mode and
@c related modes.
$BK\@a$G$O!"(BC$B%b!<%I$H$=$N4XO"%b!<%I$G%]%$%s%H$r0\F0$9$k(B
$B%3%^%s%I$K$D$$$F=R$Y$^$9!#(B
@table @code
@item C-c C-u
@c @kindex C-c C-u @r{(C mode)}
@kindex C-c C-u @r{$B!J(BC$B%b!<%I!K(B}
@findex c-up-conditional
@c Move point back to the containing preprocessor conditional, leaving the
@c mark behind. A prefix argument acts as a repeat count. With a negative
@c argument, move point forward to the end of the containing
@c preprocessor conditional. When going backwards, @code{#elif} is treated
@c like @code{#else} followed by @code{#if}. When going forwards,
@c @code{#elif} is ignored.@refill
$B%^!<%/$r%]%$%s%H0LCV$K@_Dj$7!"(B
$B%]%$%s%H$r4^$`%W%j%W%m%;%C%5$N>r7o@a$N@hF,$K8e8~$-$K%]%$%s%H$rLa$9!#(B
$B?t0z?t$OH?I|2s?t$H$7$FF/$/!#(B
$BIi$N0z?t$r;XDj$9$k$H!">r7o@a$NKvHx$KA08~$-$K%]%$%s%H$r0\F0$9$k!#(B
$B8e8~$-$KLa$k>l9g!"(B
@code{#elif}$B$O!"(B@code{#if}$B$,B3$/(B@code{#else}$B$N$h$&$K07$o$l$k!#(B
$BA08~$-$K?J$`>l9g!"(B@code{#elif}$B$OL5;k$5$l$k(B
@footnote{$B!ZLuCm![(B@code{#elif}$B$N$H$3$m$G;_$^$C$F$7$^$&!#(B}$B!#(B
@item C-c C-p
@c @kindex C-c C-p @r{(C mode)}
@kindex C-c C-p @r{$B!J(BC$B%b!<%I!K(B}
@findex c-backward-conditional
@c Move point back over a preprocessor conditional, leaving the mark
@c behind. A prefix argument acts as a repeat count. With a negative
@c argument, move forward.
$B%^!<%/$r%]%$%s%H0LCV$K@_Dj$7!"(B
$B%W%j%W%m%;%C%5$N>r7o@a$r2#CG$7$F8e8~$-$K%]%$%s%H$r0\F0$9$k!#(B
$B?t0z?t$OH?I|2s?t$H$7$FF/$/!#(B
$BIi$N0z?t$r;XDj$9$k$H!"A08~$-$K0\F0$9$k!#(B
@item C-c C-n
@c @kindex C-c C-n @r{(C mode)}
@kindex C-c C-n @r{$B!J(BC$B%b!<%I!K(B}
@findex c-forward-conditional
@c Move point forward across a preprocessor conditional, leaving the mark
@c behind. A prefix argument acts as a repeat count. With a negative
@c argument, move backward.
$B%^!<%/$r%]%$%s%H0LCV$K@_Dj$7!"(B
$B%W%j%W%m%;%C%5$N>r7o@a$r2#CG$7$FA08~$-$K%]%$%s%H$r0\F0$9$k!#(B
$B?t0z?t$OH?I|2s?t$H$7$FF/$/!#(B
$BIi$N0z?t$r;XDj$9$k$H!"8e8~$-$K0\F0$9$k!#(B
@item M-a
@kindex ESC a
@findex c-beginning-of-statement
@c Move point to the beginning of the innermost C statement
@c (@code{c-beginning-of-statement}). If point is already at the beginning
@c of a statement, move to the beginning of the preceding statement. With
@c prefix argument @var{n}, move back @var{n} @minus{} 1 statements.
$B$b$C$H$bFbB&$N(BC$B$NJ8$N@hF,$K%]%$%s%H$r0\F0$9$k(B
$B!J(B@code{c-beginning-of-statement}$B!K!#(B
$B$9$G$KJ8$N@hF,$K%]%$%s%H$,$"$k>l9g!"D>A0$NJ8$N@hF,$K0\F0$9$k!#(B
$B?t0z?t(B@var{n}$B$r;XDj$9$k$H!"(B@var{n}@minus{}1$B$@$1$^$($NJ8$K0\F0$9$k!#(B
@c If point is within a string or comment, or next to a comment (only
@c whitespace between them), this command moves by sentences instead of
@c statements.
$B%]%$%s%H$,!"J8;zNs$d%3%a%s%H$NFbB&!"$"$k$$$O!"(B
$B%3%a%s%H$N$&$7$m!J%3%a%s%H$N$"$$$@$KGrJ8;z$,$"$k>l9g$N$_!K$K$"$k>l9g!"(B
C$B$NJ8$G$O$J$/<+A38@8l$NJ8C10L$G0\F0$9$k!#(B
@c When called from a program, this function takes three optional
@c arguments: the numeric prefix argument, a buffer position limit
@c (don't move back before that place), and a flag that controls whether
@c to do sentence motion when inside of a comment.
$B%W%m%0%i%`$+$i8F$P$l$k$H$-$K$O!"$3$N4X?t$O!"(B3$B$D$N0z?t!"$D$^$j!"(B
$BH?I|2s?t!"!J$3$l$h$j$b8e8~$-$K$OLa$i$J$$!K0\F08B3&!"(B
$B%]%$%s%H$,%3%a%s%H$NFbB&$K$"$k>l9g$K<+A38@8l$NJ8C10L$N0\F0$r$9$k$+$I$&$+!"(B
$B$r<h$k$,!"$3$l$i$O>JN,$G$-$k!#(B
@item M-e
@kindex ESC e
@findex c-end-of-statement
@c Move point to the end of the innermost C statement; like @kbd{M-a}
@c except that it moves in the other direction (@code{c-end-of-statement}).
$B$b$C$H$bFbB&$N(BC$B$NJ8$NKvHx$K%]%$%s%H$r0\F0$9$k!#(B
@kbd{M-a}$B$HF1$8$@$,!"0\F0J}8~$,5U!J(B@code{c-end-of-statement}$B!K!#(B
@item M-x c-backward-into-nomenclature
@findex c-backward-into-nomenclature
@c Move point backward to beginning of a C++ nomenclature section or word.
@c With prefix argument @var{n}, move @var{n} times. If @var{n} is
@c negative, move forward. C++ nomenclature means a symbol name in the
@c style of NamingSymbolsWithMixedCaseAndNoUnderlines; each capital letter
@c begins a section or word.
C++$B$NL?L>8lK!$NItJ,$dC18l$N@hF,$K8e8~$-$K%]%$%s%H$r0\F0$9$k!#(B
$B?t0z?t(B@var{n}$B$r;XDj$9$k$H!"(B@var{n}$B2s0\F0$9$k!#(B
@var{n}$B$,Ii$J$i$P!"A08~$-$K0\F0$9$k!#(B
C++$B$NL?L>8lK!$H$O!"(B
NamingSymbolsWithMixedCaseAndNoUnderlines$B$N$h$&$J7A$N%7%s%\%kL>$N$3$H(B
$B!J$D$^$j!"BgJ8;z$G;O$a$?C18l$rO"7k$7$?$b$N!K!#(B
$B3FBgJ8;z$,ItJ,$dC18l$N@hF,$H$J$k!#(B
@c In the GNU project, we recommend using underscores to separate words
@c within an identifier in C or C++, rather than using case distinctions.
GNU$B%W%m%8%'%/%H$G$O!"(B
C$B$d(BC++$B$N<1JL;R$O!"BgJ8;z>.J8;z$G6hJL$9$k$N$G$O$J$/!"(B
$BC18l$r2<@~$G6h@Z$k$3$H$r?d>)$9$k!#(B
@item M-x c-forward-into-nomenclature
@findex c-forward-into-nomenclature
@c Move point forward to end of a C++ nomenclature section or word.
@c With prefix argument @var{n}, move @var{n} times.
C++$B$NL?L>8lK!$NItJ,$dC18l$NKvHx$KA08~$-$K%]%$%s%H$r0\F0$9$k!#(B
$B?t0z?t(B@var{n}$B$r;XDj$9$k$H!"(B@var{n}$B2s0\F0$9$k!#(B
@end table
@node Electric C
@c @subsection Electric C Characters
@subsection $B%(%l%/%H%j%C%/(BC$BJ8;z(B
@c In C mode and related modes, certain printing characters are
@c ``electric''---in addition to inserting themselves, they also reindent
@c the current line and may insert newlines. This feature is controlled by
@c the variable @code{c-auto-newline}. The ``electric'' characters are
@c @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#}, @kbd{;}, @kbd{,}, @kbd{<},
@c @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and @kbd{)}.
C$B%b!<%I$H$=$N4XO"%b!<%I$G$O!"$"$k<o$N0u;zJ8;z$O!X%(%l%/%H%j%C%/!Y$G$9!#(B
$B$D$^$j!"$=$NJ8;z<+?H$rA^F~$9$k$3$H$K2C$($F!"(B
$B8=:_9T$r;z2<$2$7D>$7$?$j!"2~9T$bA^F~$9$k$3$H$5$($"$j$^$9!#(B
$B$3$N5!G=$O!"JQ?t(B@code{c-auto-newline}$B$G@)8f$5$l$^$9!#(B
$B!X%(%l%/%H%j%C%/!YJ8;z$O!"(B@kbd{@{}$B!"(B@kbd{@}}$B!"(B@kbd{:}$B!"(B@kbd{#}$B!"(B
@kbd{;}$B!"(B@kbd{,}$B!"(B@kbd{<}$B!"(B@kbd{>}$B!"(B@kbd{/}$B!"(B@kbd{*}$B!"(B@kbd{(}$B!"(B@kbd{)}$B$G$9!#(B
@c Electric characters insert newlines only when the @dfn{auto-newline}
@c feature is enabled (indicated by @samp{/a} in the mode line after the
@c mode name). This feature is controlled by the variable
@c @code{c-auto-newline}. You can turn this feature on or off with the
@c command @kbd{C-c C-a}:
@dfn{$B<+F02~9T(B}$B!J(Bauto-newline$B!K5!G=$,%*%s(B
$B!J%b!<%I9T$N%b!<%IL>$N$"$H$K(B@samp{/a}$B$HI=<($5$l$k!K$N>l9g$K8B$j!"(B
$B%(%l%/%H%j%C%/J8;z$O2~9T$rA^F~$7$^$9!#(B
$B$3$N5!G=$O!"JQ?t(B@code{c-auto-newline}$B$G@)8f$5$l$^$9!#(B
$B%3%^%s%I(B@kbd{C-c C-a}$B$G$3$N5!G=$r%*%s!?%*%U$G$-$^$9!#(B
@table @kbd
@item C-c C-a
@c @kindex C-c C-a @r{(C mode)}
@kindex C-c C-a @r{$B!J(BC$B%b!<%I!K(B}
@findex c-toggle-auto-state
@c Toggle the auto-newline feature (@code{c-toggle-auto-state}). With a
@c prefix argument, this command turns the auto-newline feature on if the
@c argument is positive, and off if it is negative.
$B<+F02~9T5!G=$r%*%s!?%*%U$9$k!J(B@code{c-toggle-auto-state}$B!K!#(B
$B?t0z?t$r;XDj$7$?>l9g!"@5$J$i$P<+F02~9T5!G=$r%*%s$K$7!"(B
$BIi$J$i$P%*%U$K$9$k!#(B
@end table
@c The colon character is electric because that is appropriate for a
@c single colon. But when you want to insert a double colon in C++, the
@c electric behavior of colon is inconvenient. You can insert a double
@c colon with no reindentation or newlines by typing @kbd{C-c :}:
$B%3%m%s(B@kbd{:}$B$O%(%l%/%H%j%C%/$G$9!#(B
$B$J$<$J$i!"C1FH$N%3%m%s$NF~NO$N2r<a$H$7$F$O$=$l$,E,@Z$@$+$i$G$9!#(B
$B$7$+$7!"(BC++$B$G(B2$B$D$NO"B3$9$k%3%m%s$rA^F~$9$k>l9g!"(B
$B%3%m%s$N%(%l%/%H%j%C%/$JF0:n$OITJX$G$9!#(B
@kbd{C-c :}$B$HBG$F$P!";z2<$2$b2~9T$NA^F~$b9T$o$:$K%3%m%s$r(B2$B$DA^F~$G$-$^$9!#(B
@table @kbd
@item C-c :
@c @kindex C-c : @r{(C mode)}
@kindex C-c : @r{$B!J(BC$B%b!<%I!K(B}
@findex c-scope-operator
@c Insert a double colon scope operator at point, without reindenting the
@c line or adding any newlines (@code{c-scope-operator}).
$B9T$N;z2<$2$b2~9T$NA^F~$b$;$:$K!"(B
$B%9%3!<%W1i;;;R$rI=$9%3%m%s(B2$B$D$r%]%$%s%H0LCV$KA^F~$9$k(B
$B!J(B@code{c-scope-operator}$B!K!#(B
@end table
@c The electric @kbd{#} key reindents the line if it appears to be the
@c beginning of a preprocessor directive. This happens when the value of
@c @code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn
@c this feature off by setting @code{c-electric-pound-behavior} to
@c @code{nil}.
$B%(%l%/%H%j%C%/%-!<(B@kbd{#}$B$O!"(B
$B%W%j%W%m%;%C%5;XNa$N;O$^$j$H;W$o$l$k0LCV$G$O!"9T$r;z2<$2$7D>$7$^$9!#(B
$BJQ?t(B@code{c-electric-pound-behavior}$B$NCM$,(B@code{(alignleft)}$B$N$H$-$K$O!"(B
$B$3$N$h$&$K$J$j$^$9!#(B
$B$3$N5!G=$r%*%U$K$9$k$K$O!"(B
@code{c-electric-pound-behavior}$B$K(B@code{nil}$B$r@_Dj$7$^$9!#(B
@c The variable @code{c-hanging-braces-alist} controls the insertion of
@c newlines before and after inserted braces. It is an association list
@c with elements of the following form: @code{(@var{syntactic-symbol}
@c . @var{nl-list})}. Most of the syntactic symbols that appear in
@c @code{c-offsets-alist} are meaningful here as well.
$BJQ?t(B@code{c-hanging-braces-alist}$B$O!"(B
$BA^F~$5$l$?Cf3g8L$NA0!?8e$X$N2~9T$NA^F~$r@)8f$7$^$9!#(B
$B$3$l$O!"(B@code{(@var{syntactic-symbol} . @var{nl-list})}$B$N7A$NMWAG(B
$B$+$i@.$kO"A[%j%9%H$G$9!#(B
@code{c-offsets-alist}$B$K8=$l$k$[$H$s$I$N9=J8%7%s%\%k$O!"(B
$B$3$3$G$b0UL#$r;}$A$^$9!#(B
@c The list @var{nl-list} may contain either of the symbols
@c @code{before} or @code{after}, or both; or it may be @code{nil}. When a
@c brace is inserted, the syntactic context it defines is looked up in
@c @code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used
@c to determine where newlines are inserted: either before the brace,
@c after, or both. If not found, the default is to insert a newline both
@c before and after braces.
$B%j%9%H(B@var{nl-list}$B$O!"%7%s%\%k(B@code{before}$B$+(B@code{after}$B$N$$$:$l$+!"(B
$B$"$k$$$O$=$NN>J}!"$b$7$/$O(B@code{nil}$B$r4^$_$^$9!#(B
$BCf3g8L$,A^F~$5$l$k$H$-$K$O!"$=$NCf3g8L$,Dj5A$9$k9=J8>e$NJ8L.$r(B
@code{c-hanging-braces-alist}$B$+$iC5$7$^$9!#(B
$B$_$D$+$l$P!"(B@var{nl-list}$B$r;H$C$F(B
$BCf3g8L$NA0!?8e!?A08e$N$I$3$K2~9T$rA^F~$9$k$+7hDj$7$^$9!#(B
$B$_$D$+$i$J$1$l$P!"%G%U%)%k%H$H$7$FCf3g8L$NA08e$K2~9T$rA^F~$7$^$9!#(B
@c The variable @code{c-hanging-colons-alist} controls the insertion of
@c newlines before and after inserted colons. It is an association list
@c with elements of the following form: @code{(@var{syntactic-symbol}
@c . @var{nl-list})}. The list @var{nl-list} may contain either of the
@c symbols @code{before} or @code{after}, or both; or it may be @code{nil}.
$BJQ?t(B@code{c-hanging-colons-alist}$B$O!"(B
$BA^F~$5$l$?%3%m%s$NA0!?8e$X$N2~9T$NA^F~$r@)8f$7$^$9!#(B
$B$3$l$O!"(B@code{(@var{syntactic-symbol} . @var{nl-list})}$B$N7A$NMWAG(B
$B$+$i@.$kO"A[%j%9%H$G$9!#(B
$B%j%9%H(B@var{nl-list}$B$O!"%7%s%\%k(B@code{before}$B$+(B@code{after}$B$N$$$:$l$+!"(B
$B$"$k$$$O$=$NN>J}!"$b$7$/$O(B@code{nil}$B$r4^$_$^$9!#(B
@c When a colon is inserted, the syntactic symbol it defines is looked
@c up in this list, and if found, the @var{nl-list} is used to determine
@c where newlines are inserted: either before the brace, after, or both.
@c If the syntactic symbol is not found in this list, no newlines are
@c inserted.
$B%3%m%s$,A^F~$5$l$k$H$-$K$O!"$=$N%3%m%s$,Dj5A$9$k9=J8%7%s%\%k$r(B
$B$3$NO"A[%j%9%H$+$iC5$7$^$9!#(B
$B$_$D$+$l$P!"(B@var{nl-list}$B$r;H$C$F(B
$B%3%m%s$NA0!?8e$N$I$3$K2~9T$rA^F~$9$k$+7hDj$7$^$9!#(B
$B$_$D$+$i$J$1$l$P!"2~9T$rA^F~$7$^$;$s!#(B
@c Electric characters can also delete newlines automatically when the
@c auto-newline feature is enabled. This feature makes auto-newline more
@c acceptable, by deleting the newlines in the most common cases where you
@c do not want them. Emacs can recognize several cases in which deleting a
@c newline might be desirable; by setting the variable
@c @code{c-cleanup-list}, you can specify @emph{which} of these cases that
@c should happen. The variable's value is a list of symbols, each
@c describing one case for possible deletion of a newline. Here are the
@c meaningful symbols, and their meanings:
$B<+F02~9T5!G=$,%*%s$N$H$-$K$O!"%(%l%/%H%j%C%/J8;z$O<+F0E*$K2~9T$r:o=|$7$^$9!#(B
$B$3$N5!G=$K$h$j!"(B
$B2~9T$,ITMW$@$H;W$o$l$k$b$C$H$b0lHLE*$J>lLL$G2~9T$r:o=|$9$k$N$G!"(B
$B<+F02~9T5!G=$r%f!<%6!<$K$h$j<u$1F~$l$d$9$/$7$F$$$^$9!#(B
Emacs$B$O2~9T$r:o=|$9$k$3$H$,K>$^$7$$$$$/$D$+$N>lLL$rG'<1$G$-$^$9$,!"(B
$BJQ?t(B@code{c-cleanup-list}$B$r@_Dj$9$l$P!"(B@emph{$B$I$N(B}$B>lLL$G9T$&$+;XDj$G$-$^$9!#(B
$B$3$NJQ?t$NCM$O%7%s%\%k$N%j%9%H$G$9!#(B
$B3FMWAG$O!"2~9T$r:o=|$7$F$h$$>lLL$r(B1$B$D;XDj$7$^$9!#(B
$B0J2<$K;XDj$G$-$k%7%s%\%k$H$=$N0UL#$r<($7$^$9!#(B
@table @code
@item brace-catch-brace
@c Clean up @samp{@} catch (@var{condition}) @{} constructs by placing the
@c entire construct on a single line. The clean-up occurs when you type
@c the @samp{@{}, if there is nothing between the braces aside from
@c @code{catch} and @var{condition}.
@samp{@} catch (@var{condition}) @{}$B$N9=B$A4BN$r(B1$B9T$K:FG[CV$9$k!#(B
@code{catch}$B$d(B@var{condition}$B0J30$KCf3g8L$N$"$$$@$K$J$K$b$J$$$H$-$K(B
@samp{@{}$B$rBG$D$H:FG[CV$9$k!#(B
@item brace-else-brace
@c Clean up @samp{@} else @{} constructs by placing the entire construct on
@c a single line. The clean-up occurs when you type the @samp{@{} after
@c the @code{else}, but only if there is nothing but white space between
@c the braces and the @code{else}.
@samp{@} else @{}$B$N9=B$A4BN$r(B1$B9T$K:FG[CV$9$k!#(B
@code{else}$B$KB3$1$F(B@samp{@{}$B$rBG$C$?$H$-$K:FG[CV$9$k$,!"(B
$BCf3g8L$H(B@code{else}$B$N$"$$$@$K6uGr0J30$NJ8;z$,$J$$>l9g$K8B$k!#(B
@item brace-elseif-brace
@c Clean up @samp{@} else if (@dots{}) @{} constructs by placing the entire
@c construct on a single line. The clean-up occurs when you type the
@c @samp{@{}, if there is nothing but white space between the @samp{@}} and
@c @samp{@{} aside from the keywords and the @code{if}-condition.
@samp{@} else if (@dots{}) @{}$B$N9=B$A4BN$r(B1$B9T$KG[CV$9$k!#(B
@samp{@{}$B$rBG$C$?$H$-$K:FG[CV$9$k$,!"(B
$B%-!<%o!<%I$H(B@code{if}$B$N>r7o<0$r=|$$$F!"(B
@samp{@}}$B$H(B@samp{@{}$B$N$"$$$@$K6uGr0J30$NJ8;z$,$J$$>l9g$K8B$k!#(B
@item empty-defun-braces
@c Clean up empty defun braces by placing the braces on the same
@c line. Clean-up occurs when you type the closing brace.
$B6u$N4X?tDj5A$NCf3g8L!"(B@samp{@{}$B$H(B@samp{@}}$B$rF1$89T$K:FG[CV$9$k!#(B
$BJD$8Cf3g8L(B@samp{@}}$B$rBG$C$?$H$-$K:FG[CV$9$k!#(B
@item defun-close-semi
@c Clean up the semicolon after a @code{struct} or similar type
@c declaration, by placing the semicolon on the same line as the closing
@c brace. Clean-up occurs when you type the semicolon.
@code{struct}$B$dF1MM$N7?@k8@$N$"$H$N%;%_%3%m%s$rJD$8Cf3g8L$HF1$89T$K:FG[CV$9$k!#(B
$B%;%_%3%m%s$rBG$C$?$H$-$K:FG[CV$9$k!#(B
@item list-close-comma
@c Clean up commas following braces in array and aggregate
@c initializers. Clean-up occurs when you type the comma.
$BG[Ns!?9g@.BN$N=i4|2=<0$NCf$NJD$8Cf3g8L$H$=$l$KB3$/%3%s%^$rF1$89T$K:FG[CV$9$k!#(B
$B%3%s%^$rBG$C$?$H$-$K:FG[CV$9$k!#(B
@item scope-operator
@c Clean up double colons which may designate a C++ scope operator, by
@c placing the colons together. Clean-up occurs when you type the second
@c colon, but only when the two colons are separated by nothing but
@c whitespace.
C++$B$N%9%3!<%W1i;;;R$rI=$7$F$$$k2DG=@-$,$"$k(B2$B$D$N%3%m%s$r0l=o$K$9$k!#(B
2$B$D$a$N%3%m%s$rBG$C$?$H$-$K0l=o$K$9$k$,!"(B
$B%3%m%s$N$"$$$@$KGrJ8;z0J30$NJ8;z$,$J$$>l9g$K8B$k!#(B
@end table
@node Hungry Delete
@c @subsection Hungry Delete Feature in C
@subsection C$B$NM_D%$j$J:o=|5!G=(B
@c When the @dfn{hungry-delete} feature is enabled (indicated by
@c @samp{/h} or @samp{/ah} in the mode line after the mode name), a single
@c @key{DEL} command deletes all preceding whitespace, not just one space.
@c To turn this feature on or off, use @kbd{C-c C-d}:
@dfn{$BM_D%$j$J:o=|(B}$B5!G=$r%*%s(B
$B!J%b!<%I9T$N%b!<%IL>$N$"$H$K(B@samp{/h}$B$+(B@samp{/ah}$B$GI=<($5$l$k!K$K$9$k$H!"(B
1$B$D$N(B@key{DEL}$B%3%^%s%I$G!"D>A0$N6uGr(B1$B$D$@$1$G$J$/!"GrJ8;z$9$Y$F$r:o=|$7$^$9!#(B
$B$3$N5!G=$r%*%s!?%*%U$K$9$k$K$O!"(B@kbd{C-c C-d}$B$r;H$$$^$9!#(B
@table @kbd
@item C-c C-d
@c @kindex C-c C-d @r{(C mode)}
@kindex C-c C-d @r{$B!J(BC$B%b!<%I!K(B}
@findex c-toggle-hungry-state
@c Toggle the hungry-delete feature (@code{c-toggle-hungry-state}). With a
@c prefix argument, this command turns the hungry-delete feature on if the
@c argument is positive, and off if it is negative.
$BM_D%$j:o=|5!G=!J(B@code{c-toggle-hungry-state}$B!K$r%*%s!?%*%U$9$k!#(B
$B?t0z?t$r;XDj$7$?>l9g!"@5$J$i$PM_D%$j:o=|5!G=$r%*%s$K$7!"(B
$BIi$J$i$P%*%U$K$9$k!#(B
@item C-c C-t
@c @kindex C-c C-t @r{(C mode)}
@kindex C-c C-t @r{$B!J(BC$B%b!<%I!K(B}
@findex c-toggle-auto-hungry-state
@c Toggle the auto-newline and hungry-delete features, both at once
@c (@code{c-toggle-auto-hungry-state}).
$B<+F02~9T5!G=$HM_D%$j:o=|5!G=$rF1;~$K%*%s!?%*%U$9$k(B
$B!J(B@code{c-toggle-auto-hungry-state}$B!K!#(B
@end table
@vindex c-hungry-delete-key
@c The variable @code{c-hungry-delete-key} controls whether the
@c hungry-delete feature is enabled.
$BJQ?t(B@code{c-hungry-delete-key}$B$O!"(B
$BM_D%$j:o=|5!G=$,%*%s$+%*%U$+$r@)8f$7$^$9!#(B
@node Other C Commands
@c @subsection Other Commands for C Mode
@subsection C$B%b!<%I$N$=$NB>$N%3%^%s%I(B
@table @kbd
@item C-M-h
@findex c-mark-function
@c @kindex C-M-h @r{(C mode)}
@kindex C-M-h @r{$B!J(BC$B%b!<%I!K(B}
@c Put mark at the end of a function definition, and put point at the
@c beginning (@code{c-mark-function}).
$B4X?tDj5A$NKvHx$K%^!<%/$r@_Dj$7!"@hF,$K%]%$%s%H$rCV$/(B
$B!J(B@code{c-mark-function}$B!K!#(B
@item M-q
@c @kindex M-q @r{(C mode)}
@kindex M-q @r{$B!J(BC$B%b!<%I!K(B}
@findex c-fill-paragraph
@c Fill a paragraph, handling C and C++ comments (@code{c-fill-paragraph}).
@c If any part of the current line is a comment or within a comment, this
@c command fills the comment or the paragraph of it that point is in,
@c preserving the comment indentation and comment delimiters.
C$B$d(BC++$B$N%3%a%s%H$r9MN8$7$F!"CJMn$r5M$a9~$`(B
$B!J(B@code{c-fill-paragraph}$B!K!#(B
$B8=:_9T$K%3%a%s%H$,$"$C$?$j!"8=:_9T$,%3%a%s%H$NFbB&$J$i!"(B
$B%3%a%s%H$N;z2<$2$H%3%a%s%H6h@Z$j$rJ]B8$7$?$^$^!"(B
$B%]%$%s%H0LCV$N%3%a%s%H$dCJMn$r5M$a9~$`!#(B
@item C-c C-e
@c @cindex macro expansion in C
@c @cindex expansion of C macros
@cindex C$B$N%^%/%mE83+(B
@cindex $BE83+!"(BC$B$N%^%/%m(B
@findex c-macro-expand
@c @kindex C-c C-e @r{(C mode)}
@kindex C-c C-e @r{$B!J(BC$B%b!<%I!K(B}
@c Run the C preprocessor on the text in the region, and show the result,
@c which includes the expansion of all the macro calls
@c (@code{c-macro-expand}). The buffer text before the region is also
@c included in preprocessing, for the sake of macros defined there, but the
@c output from this part isn't shown.
$B%j!<%8%g%sFb$N%F%-%9%H$KBP$7$F(BC$B%W%j%W%m%;%C%5$r<B9T$7!"(B
$B%^%/%m8F$S=P$7$rE83+$7$?7k2L$rI=<($9$k!J(B@code{c-macro-expand}$B!K!#(B
$B%j!<%8%g%s$N$^$($K$"$k%F%-%9%H$K%^%/%mDj5A$,$"$k$3$H$b$"$k$N$G!"(B
$B$=$l$i$b%W%j%W%m%;%C%5$KEO$5$l$k$,!"$=$NItJ,$N=PNO$OI=<($7$J$$!#(B
@c When you are debugging C code that uses macros, sometimes it is hard to
@c figure out precisely how the macros expand. With this command, you
@c don't have to figure it out; you can see the expansions.
$B%^%/%m$rMQ$$$?(BC$B$N%3!<%I$r%G%P%C%0$9$k$H$-!"(B
$B$I$N$h$&$K%^%/%m$,E83+$5$l$k$+@53N$KM}2r$9$k$N$,Fq$7$$$3$H$,$"$k!#(B
$B$3$N%3%^%s%I$r;H$($P!"%^%/%mE83+$N$3$H$r9M$($kI,MW$O$J$$!#(B
$BE83+7k2L$rL\$K$9$k$3$H$,$G$-$k!#(B
@item C-c C-\
@findex c-backslash-region
@c @kindex C-c C-\ @r{(C mode)}
@kindex C-c C-\ @r{$B!J(BC$B%b!<%I!K(B}
@c Insert or align @samp{\} characters at the ends of the lines of the
@c region (@code{c-backslash-region}). This is useful after writing or
@c editing a C macro definition.
$B%j!<%8%g%sFb$N9TKv$K(B@samp{\}$BJ8;z$rA^F~$7$?$j!"(B
$B9TKv$N(B@samp{\}$B$N0LCVB7$($r9T$&!J(B@code{c-backslash-region}$B!K!#(B
C$B$N%^%/%mDj5A$r=q$$$?$jJT=8$7$?$"$H$KJXMx$J%3%^%s%I!#(B
@c If a line already ends in @samp{\}, this command adjusts the amount of
@c whitespace before it. Otherwise, it inserts a new @samp{\}. However,
@c the last line in the region is treated specially; no @samp{\} is
@c inserted on that line, and any @samp{\} there is deleted.
$B9TKv$,$9$G$K(B@samp{\}$B$G=*$C$F$$$k$J$i!"$=$N$^$($KCV$/GrJ8;z$N8D?t$rD4@0$9$k!#(B
$B$=$&$G$J$1$l$P!"?7$?$K(B@samp{\}$B$rA^F~$9$k!#(B
$B$?$@$7!"%j!<%8%g%sFb$N:G8e$N9T$OFCJL07$$$9$k!#(B
$B$=$N9T$K(B@samp{\}$B$rA^F~$9$k$3$H$O$J$/!"$^$?!"(B@samp{\}$B$,$"$k>l9g$K$O:o=|$9$k!#(B
@item M-x cpp-highlight-buffer
@c @cindex preprocessor highlighting
@cindex $B%W%j%W%m%;%C%56/D4I=<((B
@findex cpp-highlight-buffer
@c Highlight parts of the text according to its preprocessor conditionals.
@c This command displays another buffer named @samp{*CPP Edit*}, which
@c serves as a graphic menu for selecting how to display particular kinds
@c of conditionals and their contents. After changing various settings,
@c click on @samp{[A]pply these settings} (or go to that buffer and type
@c @kbd{a}) to rehighlight the C mode buffer accordingly.
$B%W%j%W%m%;%C%5;XNa$N>r7o@a$K=>$C$F!"%F%-%9%H$N0lIt$r6/D4I=<($9$k!#(B
$B$3$N%3%^%s%I$O(B@samp{*CPP Edit*}$B$H$$$&L>A0$N%P%C%U%!$rI=<($9$k!#(B
$B$3$N%P%C%U%!$O!"FCDj$N%W%j%W%m%;%C%5>r7o$H$=$NFbMF$r$I$N$h$&$KI=<($9$k$+$r(B
$BA*Br$9$k%0%i%U%#%C%/%a%K%e!<!#(B
$B$5$^$6$^@_Dj$rJQ99$7$?$"$H$G!"(B@samp{[A]pply these settings}$B$r%/%j%C%/$9$k(B
$B!J$"$k$$$O!"$=$N%P%C%U%!$X0\F0$7$F(B@kbd{a}$B$HBG$D!K$H!"(B
$B@_Dj$K1~$8$F(BC$B%b!<%I$N%P%C%U%!$r6/D4I=<($7D>$9!#(B
@item C-c C-s
@findex c-show-syntactic-information
@c @kindex C-c C-s @r{(C mode)}
@kindex C-c C-s @r{$B!J(BC$B%b!<%I!K(B}
@c Display the syntactic information about the current source line
@c (@code{c-show-syntactic-information}). This is the information that
@c directs how the line is indented.
$B8=:_$N%=!<%99T$K4X$9$k9=J8>e$N>pJs$rI=<($9$k(B
$B!J(B@code{c-show-syntactic-information}$B!K!#(B
$B$3$N>pJs$O9T$N;z2<$2$r;X<($9$k!#(B
@end table
@node Comments in C
@c @subsection Comments in C Modes
@subsection C$B%b!<%I$N%3%a%s%H(B
@c C mode and related modes use a number of variables for controlling
@c comment format.
C$B%b!<%I$H$=$N4XO"%b!<%I$G$O!"(B
$B%3%a%s%H$N@07A$K$$$/$D$+$NJQ?t$r;H$$$^$9!#(B
@table @code
@item c-comment-only-line-offset
@vindex c-comment-only-line-offset
@c Extra offset for line which contains only the start of a comment. It
@c can be either an integer or a cons cell of the form
@c @code{(@var{non-anchored-offset} . @var{anchored-offset})}, where
@c @var{non-anchored-offset} is the amount of offset given to
@c non-column-zero anchored comment-only lines, and @var{anchored-offset}
@c is the amount of offset to give column-zero anchored comment-only lines.
@c Just an integer as value is equivalent to @code{(@var{val} . 0)}.
$B%3%a%s%H3+;OItJ,$@$1$r4^$s$@9T$KM?$($kM>J,$N%*%U%;%C%H!#(B
$B$3$NJQ?t$NCM$O@0?t!"$"$k$$$O(B
@code{(@var{non-anchored-offset} . @var{anchored-offset})}$B$N7A$N(B
$B%3%s%9%;%k$N$I$A$i$G$b$+$^$o$J$$!#(B
$B$3$3$G!"(B@var{non-anchored-offset}$B$O!"(B
1$B7eL\0J9_$+$i;O$^$k%3%a%s%H$KM?$($k%*%U%;%C%H!#(B
@var{anchored-offset}$B$O!"(B0$B7eL\$+$i;O$^$k%3%a%s%H$KM?$($k%*%U%;%C%H!#(B
$B@0?tCM$@$1$N>l9g$O!"(B@code{(@var{val} . 0)}$B$HEy2A!#(B
@item c-comment-start-regexp
@vindex c-comment-start-regexp
@c This buffer-local variable specifies how to recognize the start of a comment.
$B%3%a%s%H3+;O$N<1JLJ}K!$r;XDj$9$k%P%C%U%!$K%m!<%+%k$JJQ?t!#(B
@item c-hanging-comment-ender-p
@vindex c-hanging-comment-ender-p
@c If this variable is @code{nil}, @code{c-fill-paragraph} leaves the
@c comment terminator of a block comment on a line by itself. The default
@c value is @code{t}, which puts the comment-end delimiter @samp{*/} at the
@c end of the last line of the comment text.
$B$3$NJQ?t$,(B@code{nil}$B$G$"$k$H!"(B@code{c-fill-paragraph}$B$O!"(B
$B%V%m%C%/%3%a%s%H$N%3%a%s%H=*N;6h@Z$j$@$1$N9T$r:n$k!#(B
$B%G%U%)%k%HCM$O(B@code{t}$B$G!"(B
$B%3%a%s%H=*N;6h@Z$j(B@samp{*/}$B$r%3%a%s%H$N:G8e$N9T$NKvHx$KCV$/!#(B
@item c-hanging-comment-starter-p
@vindex c-hanging-comment-starter-p
@c If this variable is @code{nil}, @code{c-fill-paragraph} leaves the
@c starting delimiter of a block comment on a line by itself. The default
@c value is @code{t}, which puts the comment-start delimiter @samp{/*} at
@c the beginning of the first line of the comment text.
$B$3$NJQ?t$,(B@code{nil}$B$G$"$k$H!"(B@code{c-fill-paragraph}$B$O!"(B
$B%V%m%C%/%3%a%s%H$N%3%a%s%H3+;O6h@Z$j$@$1$N9T$r:n$k!#(B
$B%G%U%)%k%HCM$O(B@code{t}$B$G!"(B
$B%3%a%s%H3+;O6h@Z$j(B@samp{/*}$B$r%3%a%s%H$N:G=i$N9T$N@hF,$KCV$/!#(B
@end table
@node Fortran
@c @section Fortran Mode
@section Fortran$B%b!<%I(B
@c @cindex Fortran mode
@c @cindex mode, Fortran
@cindex Fortran$B%b!<%I(B
@cindex $B%b!<%I!"(BFortran
@c Fortran mode provides special motion commands for Fortran statements and
@c subprograms, and indentation commands that understand Fortran conventions
@c of nesting, line numbers and continuation statements. Fortran mode has
@c its own Auto Fill mode that breaks long lines into proper Fortran
@c continuation lines.
Fortran$B%b!<%I$K$O!"(BFortran$B$NJ8$HI{%W%m%0%i%`8~$1$NFCJL$J0\F0%3%^%s%I!"(B
Fortran$B$NF~$l;R!"9THV9f$H7QB3J8$NLsB+;v$K=>$&;z2<$2%3%^%s%I$,$"$j$^$9!#(B
Fortran$B%b!<%I$K$O!"D9$$9T$rE,@Z$J(BFortran$B$N7QB39T$KJ,$1$k(B
$B@lMQ$N<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$,$"$j$^$9!#(B
@c Special commands for comments are provided because Fortran comments
@c are unlike those of other languages. Built-in abbrevs optionally save
@c typing when you insert Fortran keywords.
Fortran$B$N%3%a%s%H$OB>$N8@8l$N%3%a%s%H$H$O0[$J$C$F$$$k$N$G!"(B
$B%3%a%s%H$KBP$9$kFCJL$J%3%^%s%I$b$"$j$^$9!#(B
Fortran$B$N%-!<%o!<%I$rF~NO$9$k$H$-$NBG80NL$r8:$i$;$k!"(B
$BAH$_9~$_$NN,8l$b$"$j$^$9!#(B
@findex fortran-mode
@c Use @kbd{M-x fortran-mode} to switch to this major mode. This command
@c runs the hook @code{fortran-mode-hook} (@pxref{Hooks}).
Fortran$BMQ$N%a%8%c!<%b!<%I$K@Z$jBX$($k$K$O!"(B@kbd{M-x fortran-mode}$B$r;H$$$^$9!#(B
$B$3$N%3%^%s%I$O!"%U%C%/(B@code{fortran-mode-hook}$B$r<B9T$7$^$9!J(B@pxref{Hooks}$B!K!#(B
@menu
* Motion: Fortran Motion. Moving point by statements or subprograms.
* Indent: Fortran Indent. Indentation commands for Fortran.
* Comments: Fortran Comments. Inserting and aligning comments.
* Autofill: Fortran Autofill. Auto fill minor mode for Fortran.
* Columns: Fortran Columns. Measuring columns for valid Fortran.
* Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
* Misc: Fortran Misc. Other Fortran mode features.
@end menu
@node Fortran Motion
@c @subsection Motion Commands
@subsection $B0\F0%3%^%s%I(B
@c Fortran mode provides special commands to move by subprograms (functions
@c and subroutines) and by statements. There is also a command to put the
@c region around one subprogram, convenient for killing it or moving it.
Fortran $B%b!<%I$K$O!"I{%W%m%0%i%`!J4X?t$d%5%V%k!<%A%s!K$dJ8$rC10L$H$F(B
$B0\F0$9$k$?$a$NFCJL$J%3%^%s%I$,$"$j$^$9!#(B
$B$^$?!"I{%W%m%0%i%`$r0O$`%j!<%8%g%s$r@_Dj$9$k%3%^%s%I$b$"$j!"(B
$BI{%W%m%0%i%`$r%-%k$7$?$j0\F0$7$?$j$9$k$N$KJXMx$G$9!#(B
@c @kindex C-M-a @r{(Fortran mode)}
@c @kindex C-M-e @r{(Fortran mode)}
@c @kindex C-M-h @r{(Fortran mode)}
@c @kindex C-c C-p @r{(Fortran mode)}
@c @kindex C-c C-n @r{(Fortran mode)}
@kindex C-M-a @r{$B!J(BFortran$B%b!<%I!K(B}
@kindex C-M-e @r{$B!J(BFortran$B%b!<%I!K(B}
@kindex C-M-h @r{$B!J(BFortran$B%b!<%I!K(B}
@kindex C-c C-p @r{$B!J(BFortran$B%b!<%I!K(B}
@kindex C-c C-n @r{$B!J(BFortran$B%b!<%I!K(B}
@findex beginning-of-fortran-subprogram
@findex end-of-fortran-subprogram
@findex mark-fortran-subprogram
@findex fortran-previous-statement
@findex fortran-next-statement
@table @kbd
@item C-M-a
@c Move to beginning of subprogram
@c (@code{beginning-of-fortran-subprogram}).
$BI{%W%m%0%i%`$N@hF,$K0\F0$9$k!J(B@code{beginning-of-fortran-subprogram}$B!K!#(B
@item C-M-e
@c Move to end of subprogram (@code{end-of-fortran-subprogram}).
$BI{%W%m%0%i%`$NKvHx$K0\F0$9$k!J(B@code{end-of-fortran-subprogram}$B!K!#(B
@item C-M-h
@c Put point at beginning of subprogram and mark at end
@c (@code{mark-fortran-subprogram}).
$BI{%W%m%0%i%`$N@hF,$K%]%$%s%H$rCV$-!"KvHx$K%^!<%/$r@_Dj$9$k(B
$B!J(B@code{mark-fortran-subprogram}$B!K!#(B
@item C-c C-n
@c Move to beginning of current or next statement
@c (@code{fortran-next-statement}).
$B8=:_$NJ8$+$D$.$NJ8$N@hF,$K0\F0$9$k!J(B@code{fortran-next-statement}$B!K!#(B
@item C-c C-p
@c Move to beginning of current or previous statement
@c (@code{fortran-previous-statement}).
$B8=:_$NJ8$+$^$($NJ8$N@hF,$K0\F0$9$k(B
$B!J(B@code{fortran-previous-statement}$B!K!#(B
@end table
@node Fortran Indent
@c @subsection Fortran Indentation
@subsection Fortran$B$N;z2<$2(B
@c Special commands and features are needed for indenting Fortran code in
@c order to make sure various syntactic entities (line numbers, comment line
@c indicators and continuation line flags) appear in the columns that are
@c required for standard Fortran.
Fortran$B$N%3!<%I$G$O!"9=J8>e$N3F<oMWAG!J9THV9f!"%3%a%s%H9T;X<(;R!"(B
$B7QB3%^!<%/!K$OI8=`(BFortran$B$,MW5a$9$k7e$K8=$l$k$h$&$K$7$J$/$F$O$$$1$J$$$N$G!"(B
$B;z2<$2$K4X$9$kFCJL$J%3%^%s%I$H5!G=$,I,MW$G$9!#(B
@menu
* Commands: ForIndent Commands. Commands for indenting Fortran.
* Contline: ForIndent Cont. How continuation lines indent.
* Numbers: ForIndent Num. How line numbers auto-indent.
* Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
* Vars: ForIndent Vars. Variables controlling Fortran indent style.
@end menu
@node ForIndent Commands
@c @subsubsection Fortran Indentation Commands
@subsubsection Fortran$B$N;z2<$2%3%^%s%I(B
@table @kbd
@item @key{TAB}
@c Indent the current line (@code{fortran-indent-line}).
$B8=:_9T$r;z2<$2$9$k!J(B@code{fortran-indent-line}$B!K!#(B
@item C-j
@c Indent the current and start a new indented line
@c (@code{fortran-indent-new-line}).
$B8=:_9T$r;z2<$2$7$F$+$i!";z2<$2$7$??7$?$J9T$r;O$a$k(B
$B!J(B@code{fortran-indent-new-line}$B!K!#(B
@item C-M-j
@c Break the current line and set up a continuation line.
$B%]%$%s%H0LCV$G8=:_9T$rJ,3d$7!"7QB39T$r@_Dj$9$k!#(B
@item M-^
@c Join this line to the previous line.
$B8=:_9T$HD>A0$N9T$r7R$2$k!#(B
@item C-M-q
@c Indent all the lines of the subprogram point is in
@c (@code{fortran-indent-subprogram}).
$B%]%$%s%H$r4^$`I{%W%m%0%i%`$N9T$r$9$Y$F;z2<$2$9$k(B
$B!J(B@code{fortran-indent-subprogram}$B!K!#(B
@end table
@findex fortran-indent-line
@c Fortran mode redefines @key{TAB} to reindent the current line for
@c Fortran (@code{fortran-indent-line}). This command indents line numbers
@c and continuation markers to their required columns, and independently
@c indents the body of the statement based on its nesting in the program.
Fortran$B%b!<%I$G$O!"(BFortran$B$N9T$r;z2<$2$9$k$h$&$K(B@key{TAB}$B$r:FDj5A$7$^$9(B
$B!J(B@code{fortran-indent-line}$B!K!#(B
$B$3$N%3%^%s%I$O!"9THV9f$H7QB3%^!<%/$rMW5a$5$l$k7e0LCV$K;z2<$2$7$?$&$(!"(B
$B$=$l$H$OFHN)$K%W%m%0%i%`Cf$NF~$l;R$K4p$E$$$FJ8K\BN$r;z2<$2$7$^$9!#(B
@c @kindex C-j @r{(Fortran mode)}
@kindex C-j @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-indent-new-line
@c The key @kbd{C-j} runs the command @code{fortran-indent-new-line},
@c which reindents the current line then makes and indents a new line.
@c This command is useful to reindent the closing statement of @samp{do}
@c loops and other blocks before starting a new line.
$B%-!<(B@kbd{C-j}$B$O(B@code{fortran-indent-new-line}$B$r<B9T$7$^$9!#(B
$B$3$l$O!"8=:_9T$r;z2<$2$7$F$+$i!"?7$?$J9T$r:n@.$7$F;z2<$2$7$^$9!#(B
$B?7$?$J9T$r;O$a$k$^$($K!"(B@samp{do}$B%k!<%W$d$=$NB>$N%V%m%C%/$r(B
$BJD$8$kJ8$r;z2<$2$7D>$9$N$KJXMx$G$9!#(B
@c @kindex C-M-q @r{(Fortran mode)}
@kindex C-M-q @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-indent-subprogram
@c The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command
@c to reindent all the lines of the Fortran subprogram (function or
@c subroutine) containing point.
$B%-!<(B@kbd{C-M-q}$B$O!"%]%$%s%H$r4^$`(BFortran$B$NI{%W%m%0%i%`(B
$B!J4X?t$d%5%V%k!<%A%s!K$N9T$9$Y$F$r;z2<$2$9$k(B
$B%3%^%s%I(B@code{fortran-indent-subprogram}$B$r<B9T$7$^$9!#(B
@c @kindex C-M-j @r{(Fortran mode)}
@kindex C-M-j @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-split-line
@c The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits
@c a line in the appropriate fashion for Fortran. In a non-comment line,
@c the second half becomes a continuation line and is indented
@c accordingly. In a comment line, both halves become separate comment
@c lines.
$B%-!<(B@kbd{C-M-j}$B$O!"E,@Z$JJ}K!$G(BFortran$B$N9T$rJ,3d$9$k%3%^%s%I(B
@code{fortran-split-line}$B$r<B9T$7$^$9!#(B
$B%3%a%s%H9T$G$J$1$l$P!"8eH>It$r7QB39T$K$7!"$=$l$K1~$8$F;z2<$2$7$^$9!#(B
$B%3%a%s%H9T$J$i$P!"A08eH>ItJ,$H$bFHN)$7$?%3%a%s%H9T$K$J$j$^$9!#(B
@c @kindex M-^ @r{(Fortran mode)}
@kindex M-^ @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-join-line
@c @kbd{M-^} runs the command @code{fortran-join-line}, which is more or
@c less the inverse of @code{fortran-split-line}. It joins the current
@c line to the previous line in a suitable way for Fortran code.
@kbd{M-^}$B$O!"(B@code{fortran-split-line}$B$N5UA`:n$r9T$&(B
$B%3%^%s%I(B@code{fortran-join-line}$B$r<B9T$7$^$9!#(B
$B8=:_9T$HD>A0$N9T$r!"(BFortran$B%3!<%I$H$7$FE,@Z$K7R$2$^$9!#(B
@node ForIndent Cont
@c @subsubsection Continuation Lines
@subsubsection $B7QB39T(B
@c @cindex Fortran continuation lines
@cindex Fortran$B$N7QB39T(B
@vindex fortran-continuation-string
@c Most modern Fortran compilers allow two ways of writing continuation
@c lines. If the first non-space character on a line is in column 5, then
@c that line is a continuation of the previous line. We call this
@c @dfn{fixed format}. (In GNU Emacs we always count columns from 0.) The
@c variable @code{fortran-continuation-string} specifies what character to
@c put on column 5. A line that starts with a tab character followed by
@c any digit except @samp{0} is also a continuation line. We call this
@c style of continuation @dfn{tab format}.
$B6aBeE*$J$[$H$s$I$N(BFortran$B%3%s%Q%$%i$K$O!"(B
$B7QB39T$N5-=RJ}K!$,(B2$B$DMQ0U$5$l$F$$$^$9!#(B
$B$"$k9T$N6uGr$G$J$$:G=i$NJ8;z$,(B5$B7eL\$K$"$l$P!"@h9T$9$k9T$N7QB39T$G$9!#(B
$B$3$N%9%?%$%k$r(B@dfn{$B8GDj%U%)!<%^%C%H(B}$B$H8F$S$^$9!#(B
$B!J(BGNU Emacs$B$G$O!"7e0LCV$O$D$M$K(B0$B$+$i?t$($k!#!K(B
$BJQ?t(B@code{fortran-continuation-string}$B$O!"(B5$B7eL\$KCV$/J8;z$r;XDj$7$^$9!#(B
$B%?%VJ8;z$G;O$^$j(B@samp{0}$B0J30$N?t;z$,B3$/9T$b7QB39T$G$9!#(B
$B$3$N%9%?%$%k$r(B@dfn{$B%?%V%U%)!<%^%C%H(B}$B$H8F$S$^$9!#(B
@c @vindex indent-tabs-mode @r{(Fortran mode)}
@vindex indent-tabs-mode @r{$B!J(BFortran$B%b!<%I!K(B}
@c Fortran mode can make either style of continuation line, but you
@c must specify which one you prefer. The value of the variable
@c @code{indent-tabs-mode} controls the choice: @code{nil} for fixed
@c format, and non-@code{nil} for tab format. You can tell which style
@c is presently in effect by the presence or absence of the string
@c @samp{Tab} in the mode line.
Fortran$B%b!<%I$G$O$I$A$i$N%9%?%$%k$N7QB39T$bMxMQ$G$-$^$9$,!"(B
$B4uK>$9$k$[$&$r;XDj$9$kI,MW$,$"$j$^$9!#(B
$BJQ?t(B@code{indent-tabs-mode}$B$NCM$G4uK>$r;XDj$7$^$9!#(B
@code{nil}$B$J$i$P8GDj%U%)!<%^%C%H!"(B
@code{nil}$B0J30$J$i$P%?%V%U%)!<%^%C%H$K$J$j$^$9!#(B
$B%b!<%I9T$KJ8;zNs(B@samp{Tab}$B$,$"$k$+$I$&$+$G!"(B
$B8=:_;HMQ$7$F$$$k%9%?%$%k$,$o$+$j$^$9!#(B
@c If the text on a line starts with the conventional Fortran
@c continuation marker @samp{$}, or if it begins with any non-whitespace
@c character in column 5, Fortran mode treats it as a continuation line.
@c When you indent a continuation line with @key{TAB}, it converts the line
@c to the current continuation style. When you split a Fortran statement
@c with @kbd{C-M-j}, the continuation marker on the newline is created
@c according to the continuation style.
Fortran$B%b!<%I$G$O!"%F%-%9%H$,47MQE*$J(BFortran$B$N7QB3%^!<%/(B@samp{$}$B$G;O$^$k!"(B
$B$"$k$$$O!"(B
5$B7eL\$+$iGrJ8;z0J30$NJ8;z$G;O$^$k>l9g$K$O!"$=$N9T$r7QB39T$H$7$F07$$$^$9!#(B
@key{TAB}$B$G7QB39T$r;z2<$2$9$k$H!"(B
$BA*Br$5$l$F$$$k7QB39T$N%9%?%$%k$KJQ49$7$^$9!#(B
@kbd{C-M-j}$B$G(BFortran$B$NJ8$rJ,3d$9$k$H!"(B
$B7QB39T$N%9%?%$%k$K1~$8$F?7$?$J9T$K$O7QB3%^!<%/$rIU$1$^$9!#(B
@c The setting of continuation style affects several other aspects of
@c editing in Fortran mode. In fixed format mode, the minimum column
@c number for the body of a statement is 6. Lines inside of Fortran
@c blocks that are indented to larger column numbers always use only the
@c space character for whitespace. In tab format mode, the minimum
@c column number for the statement body is 8, and the whitespace before
@c column 8 must always consist of one tab character.
$B7QB39T$N%9%?%$%k$O!"(BFortran$B%b!<%I$G$NJT=8$K4X$o$k(B
$B$=$NB>$NB&LL$K$b1F6A$7$^$9!#(B
$B8GDj%U%)!<%^%C%H$G$O!"J8K\BN$rCV$/:G>.7e0LCV$O(B6$B$K$J$j$^$9!#(B
Fortran$B$N%V%m%C%/$NFbB&$K$"$k9T$r(B7$B7eL\0J9_$K;z2<$2$9$k$H$-$K$O!"(B
$BGrJ8;z$K$O6uGrJ8;z$r;H$$$^$9!#(B
$B0lJ}!"%?%V%U%)!<%^%C%H$G$O!"J8K\BN$rCV$/:G>.7e0LCV$O(B8$B$G!"(B
8$B7eL\$h$j$^$($NGrJ8;z$O$D$M$K%?%VJ8;z$G$9!#(B
@vindex fortran-tab-mode-default
@vindex fortran-analyze-depth
@c When you enter Fortran mode for an existing file, it tries to deduce the
@c proper continuation style automatically from the file contents. The first
@c line that begins with either a tab character or six spaces determines the
@c choice. The variable @code{fortran-analyze-depth} specifies how many lines
@c to consider (at the beginning of the file); if none of those lines
@c indicates a style, then the variable @code{fortran-tab-mode-default}
@c specifies the style. If it is @code{nil}, that specifies fixed format, and
@c non-@code{nil} specifies tab format.
$B4{B8$N%U%!%$%k$KBP$7$F(BFortran$B%b!<%I$KF~$k$H!"(B
$B$=$NFbMF$+$i<+F0E*$KE,@Z$J7QB39T$N%9%?%$%k$r?dB,$7$h$&$H$7$^$9!#(B
$B%?%VJ8;z$+6uGr(B6$B8D$G;O$^$k:G=i$N9T$G%9%?%$%k$rH=CG$7$^$9!#(B
$BJQ?t(B@code{fortran-analyze-depth}$B$G!"(B
$B!J%U%!%$%k$N@hF,$+$i!K2?9TJ,$r%9%?%$%kH=CG$K;HMQ$9$k$+;XDj$7$^$9!#(B
$B$3$NHO0OFb$K%9%?%$%k$r<($9$h$&$J9T$,$_$D$+$i$J$1$l$P!"(B
$BJQ?t(B@code{fortran-tab-mode-default}$B$,%9%?%$%k$r;XDj$7$^$9!#(B
@code{nil}$B$J$i8GDj%U%)!<%^%C%H!"(B@code{nil}$B0J30$J$i%?%V%U%)!<%^%C%H$G$9!#(B
@node ForIndent Num
@c @subsubsection Line Numbers
@subsubsection $B9THV9f(B
@c If a number is the first non-whitespace in the line, Fortran
@c indentation assumes it is a line number and moves it to columns 0
@c through 4. (Columns always count from 0 in GNU Emacs.)
$B$"$k9T$NGrJ8;z0J30$N:G=i$NJ8;z$,?t;z$G$"$l$P!"(B
Fortran$B$N;z2<$2$G$O$=$l$r9THV9f$H$_$J$7$F(B0$B7eL\$+$i(B4$B7eL\$N$"$$$@$K0\F0$7$^$9!#(B
$B!J(BGNU Emacs$B$G$O!"7e0LCV$O$D$M$K(B0$B$+$i;O$^$k!#!K(B
@vindex fortran-line-number-indent
@c Line numbers of four digits or less are normally indented one space.
@c The variable @code{fortran-line-number-indent} controls this; it
@c specifies the maximum indentation a line number can have. Line numbers
@c are indented to right-justify them to end in column 4 unless that would
@c require more than this maximum indentation. The default value of the
@c variable is 1.
$BDL>o!"(B4$B7e0J2<$N9THV9f$O6uGr(B1$B8D$G;z2<$2$7$^$9!#(B
$BJQ?t(B@code{fortran-line-number-indent}$B$G$3$N;z2<$2I}$r@)8f$7$^$9!#(B
$B$3$NJQ?t$NCM$O!"9THV9f$N:GBg;z2<$2I}$rI=$7$^$9!#(B
$B:GBg;z2<$2I}$^$G;z2<$2$G$-$J$/$J$k$H!"(B
$B9THV9f$N:G8e$N7e$,(B4$B7eL\$K$J$k$h$&$K1&B7$($G;z2<$2$7$^$9!#(B
$B$3$NJQ?t$N%G%U%)%k%HCM$O(B1$B$G$9!#(B
@vindex fortran-electric-line-number
@c Simply inserting a line number is enough to indent it according to
@c these rules. As each digit is inserted, the indentation is recomputed.
@c To turn off this feature, set the variable
@c @code{fortran-electric-line-number} to @code{nil}. Then inserting line
@c numbers is like inserting anything else.
$B$3$l$i$N5,B'$K=>$C$F9THV9f$r;z2<$2$9$k$K$O!"(B
$B9THV9f$rA^F~$9$k$@$1$G==J,$G$9!#(B
$B9THV9f$N3F7e$,A^F~$5$l$k$?$S$K!";z2<$2I}$r:F7W;;$7$^$9!#(B
$B$3$N5!G=$r%*%U$K$9$k$K$O!"(B
$BJQ?t(B@code{fortran-electric-line-number}$B$K(B@code{nil}$B$r@_Dj$7$^$9!#(B
$B$3$&$9$k$H!"9THV9f$NA^F~$O$=$NB>$NJ8;z$NA^F~$HF1MM$K9T$o$l$^$9!#(B
@node ForIndent Conv
@c @subsubsection Syntactic Conventions
@subsubsection $B9=J8>e$N5,Ls(B
@c Fortran mode assumes that you follow certain conventions that simplify
@c the task of understanding a Fortran program well enough to indent it
@c properly:
Fortran$B%b!<%I$G$O!"E,@Z$J;z2<$2$r$9$k$?$a$N(BFortran$B%W%m%0%i%`$N2r<a$r(B
$B4JC1$K$9$k$?$a$K!"0J2<$N5,Ls$K=>$C$F$$$k$b$N$H2>Dj$7$^$9!#(B
@itemize @bullet
@item
@c Two nested @samp{do} loops never share a @samp{continue} statement.
2$B$D$NF~$l;R$K$J$C$?(B@samp{do}$B%k!<%W$O!"(B
$B$1$C$7$F(B@samp{continue}$BJ8$r6&M-$7$J$$!#(B
@item
@c Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do}
@c and others are written without embedded whitespace or line breaks.
@samp{if}$B!"(B@samp{else}$B!"(B@samp{then}$B!"(B@samp{do}$B$H$$$C$?(B
Fortran$B$N%-!<%o!<%I$O!"$"$$$@$K6uGr$,$"$C$?$j!"ESCf$G9TJ,$1$5$l$J$$!#(B
@c Fortran compilers generally ignore whitespace outside of string
@c constants, but Fortran mode does not recognize these keywords if they
@c are not contiguous. Constructs such as @samp{else if} or @samp{end do}
@c are acceptable, but the second word should be on the same line as the
@c first and not on a continuation line.
$B0lHL$K(BFortran$B%3%s%Q%$%i$OJ8;zNsDj?t$N30B&$K$"$k6uGr$rL5;k$9$k$,!"(B
Fortran$B%b!<%I$OESCf$K6uGr$,F~$C$F$$$k%-!<%o!<%I$rG'<1$7$J$$!#(B
@samp{else if}$B$d(B@samp{end do}$B$N$h$&$J=q$-J}$O5v$5$l$k$,!"(B
2$B$D$NC18l$rF1$89T$KCV$$$?>l9g$K8B$k!#(B
$B7QB39T$KJ,$+$l$F$$$k$HG'<1$7$J$$!#(B
@end itemize
@noindent
@c If you fail to follow these conventions, the indentation commands may
@c indent some lines unaesthetically. However, a correct Fortran program
@c retains its meaning when reindented even if the conventions are not
@c followed.
$B0J>e$N5,Ls$K=>$C$F$$$J$$>l9g$K$O!"9T$rH~$7$/;z2<$2$G$-$J$$$3$H$b$"$j$^$9!#(B
$B$7$+$7$J$,$i!"$?$H$(5,Ls$K=>$C$F$$$J$/$F$b!"(B
$B@5$7$$(BFortran$B%W%m%0%i%`$G$"$l$P;z2<$2$K$h$C$F0UL#$,JQ$o$k$3$H$O$"$j$^$;$s!#(B
@node ForIndent Vars
@c @subsubsection Variables for Fortran Indentation
@subsubsection Fortran$B$N;z2<$2$N$?$a$NJQ?t(B
@vindex fortran-do-indent
@vindex fortran-if-indent
@vindex fortran-structure-indent
@vindex fortran-continuation-indent
@vindex fortran-check-all-num@dots{}
@vindex fortran-minimum-statement-indent@dots{}
@c Several additional variables control how Fortran indentation works:
Fortran$B$N;z2<$2F0:n$K1F6A$9$kJQ?t$,$$$/$D$+$"$j$^$9!#(B
@table @code
@item fortran-do-indent
@c Extra indentation within each level of @samp{do} statement (default 3).
@samp{do}$BJ8$N3F%l%Y%k$4$H$KDI2C$9$k;z2<$2I}!J%G%U%)%k%H$O(B3$B!K!#(B
@item fortran-if-indent
@c Extra indentation within each level of @samp{if} statement (default 3).
@c This value is also used for extra indentation within each level of the
@c Fortran 90 @samp{where} statement.
@samp{if}$BJ8$N3F%l%Y%k$4$H$KDI2C$9$k;z2<$2I}!J%G%U%)%k%H$O(B3$B!K!#(B
$B$3$NCM$O!"(BFortran 90$B$N(B@samp{where}$BJ8$N;z2<$2$K$b;H$o$l$k!#(B
@item fortran-structure-indent
@c Extra indentation within each level of @samp{structure}, @samp{union}, or
@c @samp{map} statements (default 3).
@samp{structure}$B!"(B@samp{union}$B!"(B@samp{map}$B$N3FJ8$N3F%l%Y%k$4$H$K(B
$BDI2C$9$k;z2<$2I}!J%G%U%)%k%H$O(B3$B!K!#(B
@item fortran-continuation-indent
@c Extra indentation for bodies of continuation lines (default 5).
$B7QB39T$NJ8K\BN$KDI2C$9$k;z2<$2I}!J%G%U%)%k%H$O(B5$B!K!#(B
@item fortran-check-all-num-for-matching-do
@c If this is @code{nil}, indentation assumes that each @samp{do} statement
@c ends on a @samp{continue} statement. Therefore, when computing
@c indentation for a statement other than @samp{continue}, it can save time
@c by not checking for a @samp{do} statement ending there. If this is
@c non-@code{nil}, indenting any numbered statement must check for a
@c @samp{do} that ends there. The default is @code{nil}.
$B$3$NJQ?t$,(B@code{nil}$B$J$i!";z2<$2=hM}$G$O!"(B
@samp{do}$BJ8$O(B@samp{continue}$BJ8$G=*$C$F$$$k$H2>Dj$9$k!#(B
$B$3$&$9$k$H!"(B@samp{continue}$B0J30$NJ8$N;z2<$2$r7W;;$9$k$H$-$K!"(B
$BEv3:J8$,(B@samp{do}$BJ8$r=*$($k$+$I$&$+8!::$7$J$/$F$h$$$N$G!"(B
$B;~4V$r@aLs$G$-$k!#(B
$B$3$NJQ?t$,(B@code{nil}$B0J30$G$"$l$P!"(B
$B9THV9f$,IU$$$?J8$N;z2<$2$r7W;;$9$k$H$-$K$O!"(B
$BEv3:J8$,(B@samp{do}$BJ8$r=*$($k$+$I$&$+8!::$9$kI,MW$,$"$k!#(B
$B%G%U%)%k%HCM$O(B@code{nil}$B!#(B
@item fortran-blink-matching-if
@c If this is @code{t}, indenting an @samp{endif} statement moves the
@c cursor momentarily to the matching @samp{if} statement to show where it
@c is. The default is @code{nil}.
$B$3$NJQ?t$,(B@code{t}$B$J$i!"(B@samp{endif}$BJ8$N;z2<$2$r9T$&$H$-$K!"(B
$BBP1~$9$k(B@samp{if}$BJ8$r<($9$?$a$K0l;~E*$K%+!<%=%k$r0\F0$9$k!#(B
$B%G%U%)%k%HCM$O(B@code{nil}$B!#(B
@item fortran-minimum-statement-indent-fixed
@c Minimum indentation for fortran statements when using fixed format
@c continuation line style. Statement bodies are never indented less than
@c this much. The default is 6.
$B8GDj%U%)!<%^%C%H$N7QB39T%9%?%$%k$r:NMQ$7$?$H$-$N!"J8$KBP$9$k:G>.;z2<$2I}!#(B
$BJ8K\BN$N;z2<$2I}$,$3$NCM$h$j>.$5$/$J$k$3$H$O$J$$!#(B
$B%G%U%)%k%HCM$O(B6$B!#(B
@item fortran-minimum-statement-indent-tab
@c Minimum indentation for fortran statements for tab format continuation line
@c style. Statement bodies are never indented less than this much. The
@c default is 8.
$B%?%V%U%)!<%^%C%H$N7QB39T%9%?%$%k$r:NMQ$7$?$H$-$N!"J8$KBP$9$k:G>.;z2<$2I}!#(B
$BJ8K\BN$N;z2<$2I}$,$3$NCM$h$j>.$5$/$J$k$3$H$O$J$$!#(B
$B%G%U%)%k%HCM$O(B8$B!#(B
@end table
@node Fortran Comments
@c @subsection Fortran Comments
@subsection Fortran$B$N%3%a%s%H(B
@c The usual Emacs comment commands assume that a comment can follow a line
@c of code. In Fortran, the standard comment syntax requires an entire line
@c to be just a comment. Therefore, Fortran mode replaces the standard Emacs
@c comment commands and defines some new variables.
Emacs$B$NDL>o$N%3%a%s%HMQ%3%^%s%I$O!"%3%a%s%H$r%3!<%I$N$"$H$K$bCV$1$k$H2>Dj$7$^$9!#(B
Fortran$B$G$O!"I8=`E*$J%3%a%s%H$N9=J8$O!"(B1$B$D$N9TA4BN$rI,MW$H$7$^$9!#(B
$B$=$N$?$a!"(BFortran$B%b!<%I$G$O!"(B
Emacs$B$NDL>o$N%3%a%s%HMQ%3%^%s%I$rCV$-49$(!"?7$?$JJQ?t$r$$$/$D$+Dj5A$7$F$$$^$9!#(B
@c Fortran mode can also handle a nonstandard comment syntax where comments
@c start with @samp{!} and can follow other text. Because only some Fortran
@c compilers accept this syntax, Fortran mode will not insert such comments
@c unless you have said in advance to do so. To do this, set the variable
@c @code{comment-start} to @samp{"!"} (@pxref{Variables}).
Fortran$B%b!<%I$G$O!"J8;z(B@samp{!}$B$G;O$^$jB>$N%F%-%9%H$N$"$H$K$bCV$1$k(B
$BHsI8=`E*$J%3%a%s%H$N9=J8$b07$($^$9!#(B
$B$7$+$7!"$3$N9=J8$r<u$1IU$1$k(BFortran$B%3%s%Q%$%i$O8B$i$l$k$?$a!"(B
$B$^$($b$C$F;XDj$7$F$*$+$J$$8B$j!"(B
Fortran$B%b!<%I$OHsI8=`$N%3%a%s%H$r;H$$$^$;$s!#(B
$B$3$N%9%?%$%k$N%3%a%s%H$r;H$&$K$O!"(B
$BJQ?t(B@code{comment-start}$B$K(B@samp{"!"}$B$r@_Dj$7$^$9!J(B@pxref{Variables}$B!K!#(B
@table @kbd
@item M-;
@c Align comment or insert new comment (@code{fortran-comment-indent}).
$B%3%a%s%H$N0LCV$rB7$($?$j!"?7$?$J%3%a%s%H$rA^F~$9$k(B
$B!J(B@code{fortran-indent-comment}$B!K!#(B
@item C-x ;
@c Applies to nonstandard @samp{!} comments only.
$BHsI8=`$N(B@samp{!}$B%3%a%s%H$@$1$K:nMQ$9$k!#(B
@item C-c ;
@c Turn all lines of the region into comments, or (with argument) turn them back
@c into real code (@code{fortran-comment-region}).
$B%j!<%8%g%sFb$N$9$Y$F$N9T$r%3%a%s%H$K$9$k!#(B
$B$"$k$$$O!"!J0z?t$r;XDj$9$k$H!K%3%a%s%H$r%3!<%I$KLa$9(B
$B!J(B@code{fortran-comment-region}$B!K!#(B
@end table
@c @kbd{M-;} in Fortran mode is redefined as the command
@c @code{fortran-comment-indent}. Like the usual @kbd{M-;} command, this
@c recognizes any kind of existing comment and aligns its text appropriately;
@c if there is no existing comment, a comment is inserted and aligned. But
@c inserting and aligning comments are not the same in Fortran mode as in
@c other modes.
Fortran$B%b!<%I$N(B@kbd{M-;}$B$O!"(B
$B%3%^%s%I(B@code{fortran-indent-comment}$B$K:FDj5A$5$l$F$$$^$9!#(B
$BDL>o$N(B@kbd{M-;}$B$HF1$8$/!"4{B8$N%3%a%s%H$rG'<1$7$F!"(B
$B$=$N%F%-%9%H$N7e0LCV$rB7$($^$9!#(B
$B%3%a%s%H$,$J$1$l$P!"%3%a%s%H$rA^F~$7$F7e0LCV$rB7$($^$9!#(B
$B$7$+$7!"(BFortran$B%b!<%I$N%3%a%s%H$NA^F~$HB7$(J}$O!"(B
$BB>$N%b!<%I$HF1$8$G$O$"$j$^$;$s!#(B
@c When a new comment must be inserted, if the current line is blank, a
@c full-line comment is inserted. On a non-blank line, a nonstandard @samp{!}
@c comment is inserted if you have said you want to use them. Otherwise a
@c full-line comment is inserted on a new line before the current line.
$B?7$?$K%3%a%s%H$rA^F~$9$k>l9g!"(B
$B8=:_9T$,6u9T$N$H$-$O!J(B1$B9TA4BN$r@j$a$k!K9T%3%a%s%H$rA^F~$7$^$9!#(B
$B6u9T$G$J$$$H$-!"HsI8=`$N%3%a%s%H$r;H$&$h$&$K;XDj$7$F$"$l$P(B
$BHsI8=`$N(B@samp{!}$B%3%a%s%H$rA^F~$7$^$9!#(B
$B$$$:$l$G$b$J$$$H$-$K$O!"8=:_9T$N$^$($K9T%3%a%s%H$rA^F~$7$^$9!#(B
@c Nonstandard @samp{!} comments are aligned like comments in other
@c languages, but full-line comments are different. In a standard full-line
@c comment, the comment delimiter itself must always appear in column zero.
@c What can be aligned is the text within the comment. You can choose from
@c three styles of alignment by setting the variable
@c @code{fortran-comment-indent-style} to one of these values:
$BHsI8=`$N(B@samp{!}$B%3%a%s%H$OB>$N8@8l$N%3%a%s%H$HF1$8$h$&$KB7$($i$l$^$9$,!"(B
$B9T%3%a%s%H$N>l9g$O$h$&$9$,0[$J$j$^$9!#(B
$BI8=`$N9T%3%a%s%H$G$O!"%3%a%s%H6h@Z$j$O$D$M$K(B0$B7eL\$K$"$kI,MW$,$"$j$^$9!#(B
$B%3%a%s%HFbIt$N%F%-%9%H$@$1$rB7$($^$9!#(B
@code{fortran-comment-indent-style}$B$r@_Dj$7$F!"(B
3$B<oN`$NB7$(J}$rA*$Y$^$9!#(B
@vindex fortran-comment-indent-style
@vindex fortran-comment-line-extra-indent
@table @code
@item fixed
@c Align the text at a fixed column, which is the sum of
@c @code{fortran-comment-line-extra-indent} and the minimum statement
@c indentation. This is the default.
@code{fortran-comment-line-extra-indent}$B$HJ8$KBP$9$k:G>.;z2<$2I}$r9g7W$7(B
$B$?7e0LCV$K%F%-%9%H$rB7$($k!#(B
$B%G%U%)%k%H$O$3$l!#(B
@c The minimum statement indentation is
@c @code{fortran-minimum-statement-indent-fixed} for fixed format
@c continuation line style and @code{fortran-minimum-statement-indent-tab}
@c for tab format style.
$BJ8$N:G>.;z2<$2I}$O!"(B
$B8GDj%U%)!<%^%C%H$N7QB39T%9%?%$%k$N>l9g$K$O(B
@code{fortran-minimum-statement-indent-fixed}$B$NCM!"(B
$B%?%V%U%)!<%^%C%H$N>l9g$K$O(B@code{fortran-minimum-statement-indent-tab}$B$NCM!#(B
@item relative
@c Align the text as if it were a line of code, but with an additional
@c @code{fortran-comment-line-extra-indent} columns of indentation.
$B%3!<%I9T$G$"$k$+$N$h$&$KB7$($k$,!"(B
@code{fortran-comment-line-extra-indent}$B$@$1M>7W$K7e$r$:$i$9!#(B
@item nil
@c Don't move text in full-line comments automatically at all.
$B9T%3%a%s%H$N%F%-%9%H$r>!<j$KF0$+$5$J$$!#(B
@end table
@vindex fortran-comment-indent-char
@c In addition, you can specify the character to be used to indent within
@c full-line comments by setting the variable
@c @code{fortran-comment-indent-char} to the single-character string you want
@c to use.
$B$^$?!"9T%3%a%s%H$N;z2<$2J8;z$rJQ99$7$?$1$l$P!"(B
$BJQ?t(B@code{fortran-comment-indent-char}$B$K9%$_$N(B1$BJ8;z$r@_Dj$7$F$/$@$5$$!#(B
@vindex comment-line-start
@vindex comment-line-start-skip
@c Fortran mode introduces two variables @code{comment-line-start} and
@c @code{comment-line-start-skip}, which play for full-line comments the same
@c roles played by @code{comment-start} and @code{comment-start-skip} for
@c ordinary text-following comments. Normally these are set properly by
@c Fortran mode, so you do not need to change them.
Fortran$B%b!<%I$K$O!"(B@code{comment-line-start}$B$H(B
@code{comment-line-start-skip}$B$N(B2$B$D$NJQ?t$,?7$?$KF3F~$5$l$F$$$^$9!#(B
$B$3$l$i$O!"%3!<%I$N$"$H$KCV$/DL>o$N%3%a%s%H$KBP$9$k(B@code{comment-start}$B$H(B
@code{comment-start-skip}$B$HF1MM$NLr3d$r!"9T%3%a%s%H$KBP$7$F2L$?$7$^$9!#(B
$B$I$A$i$b(BFortran$B%b!<%I$,E,@Z$K@_Dj$9$k$N$G!"(B
$BJQ99$9$kI,MW$O$"$j$^$;$s!#(B
@c The normal Emacs comment command @kbd{C-x ;} has not been redefined. If
@c you use @samp{!} comments, this command can be used with them. Otherwise
@c it is useless in Fortran mode.
Emacs$B$NDL>o$N%3%a%s%HMQ%3%^%s%I(B@kbd{C-x ;}$B$O!":FDj5A$5$l$F$$$^$;$s!#(B
$B$3$N%3%^%s%I$O(B@samp{!}$B%3%a%s%H$r07$($^$9!#(B
@samp{!}$B%3%a%s%H$r;H$C$F$$$J$$>l9g$K$O!"(B
$B$3$N%3%^%s%I$O(BFortran$B%b!<%I$G$OLr$KN)$A$^$;$s!#(B
@c @kindex C-c ; @r{(Fortran mode)}
@kindex C-c ; @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-comment-region
@vindex fortran-comment-region
@c The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the
@c lines of the region into comments by inserting the string @samp{C$$$} at
@c the front of each one. With a numeric argument, it turns the region
@c back into live code by deleting @samp{C$$$} from the front of each line
@c in it. The string used for these comments can be controlled by setting
@c the variable @code{fortran-comment-region}. Note that here we have an
@c example of a command and a variable with the same name; these two uses
@c of the name never conflict because in Lisp and in Emacs it is always
@c clear from the context which one is meant.
$B%3%^%s%I(B@kbd{C-c ;}$B!J(B@code{fortran-comment-region}$B!K$O!"(B
$B%j!<%8%g%sFb$N$9$Y$F$N9T$N@hF,$K(B@samp{C$$$}$B$rA^F~$7$F(B
$B%3%a%s%H$KJQ$($^$9!#(B
$B?t0z?t$r;XDj$9$k$H!"9T$N@hF,$+$i(B@samp{C$$$}$B$r:o=|$7$F!"(B
$B%j!<%8%g%s$r@8$-$?%3!<%I$KLa$7$^$9!#(B
$B$3$l$i$N%3%a%s%H$K;H$&J8;zNs$O!"(B
$BJQ?t(B@code{fortran-comment-region}$B$N@_Dj$G@)8f$G$-$^$9!#(B
$B$H$3$m$G!"$3$3$G$O%3%^%s%I$HJQ?t$KF1$8L>A0$,;H$o$l$F$$$^$9!#(B
Lisp$B$d(BEmacs$B$K$*$$$F$O!";HMQ$5$l$kJ8L.$+$i(B
$B%3%^%s%I$HJQ?t$r$D$M$K6hJL$G$-$k$N$G!"(B
$B$3$N$h$&$JL>A0$N;H$$J}$,LdBj$r5/$3$9$3$H$O$"$j$^$;$s!#(B
@node Fortran Autofill
@c @subsection Fortran Auto Fill Mode
@subsection Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I(B
@c Fortran Auto Fill mode is a minor mode which automatically splits
@c Fortran statements as you insert them when they become too wide.
@c Splitting a statement involves making continuation lines using
@c @code{fortran-continuation-string} (@pxref{ForIndent Cont}). This
@c splitting happens when you type @key{SPC}, @key{RET}, or @key{TAB}, and
@c also in the Fortran indentation commands.
Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$O!"(B
$BA^F~$7$?(BFortran$B$NJ8$,D9$/$J$j$9$.$k$H<+F0E*$KJ8$rJ,3d$9$k%^%$%J%b!<%I$G$9!#(B
$BJ8$rJ,3d$9$k$K$O!"(B
@code{fortran-continuation-string}$B!J(B@pxref{ForIndent Cont}$B!K$rMQ$$$F(B
$B7QB39T$r:n$j$^$9!#(B
@key{SPC}$B!"(B@key{RET}$B!"(B@key{TAB}$B$rBG$C$?$H$-$d!"(B
$B;z2<$2%3%^%s%I$r;H$C$?$H$-$KJ,3d$5$l$^$9!#(B
@findex fortran-auto-fill-mode
@c @kbd{M-x fortran-auto-fill-mode} turns Fortran Auto Fill mode on if it
@c was off, or off if it was on. This command works the same as @kbd{M-x
@c auto-fill-mode} does for normal Auto Fill mode (@pxref{Filling}). A
@c positive numeric argument turns Fortran Auto Fill mode on, and a
@c negative argument turns it off. You can see when Fortran Auto Fill mode
@c is in effect by the presence of the word @samp{Fill} in the mode line,
@c inside the parentheses. Fortran Auto Fill mode is a minor mode, turned
@c on or off for each buffer individually. @xref{Minor Modes}.
@kbd{M-x fortran-auto-fill-mode}$B$O!"(B
Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$,%*%s$J$i$P%*%U$K$7!"(B
$B%*%U$J$i$P%*%s$K$7$^$9!#(B
$B$3$N%3%^%s%I$O!"DL>o$N<+F05M$a9~$_!J(Bauto-fill$B!K%b!<%I(B
$B!J(B@pxref{Filling}$B!K$G$"$k(B@kbd{M-x auto-fill-mode}$B$,9T$&$N$H(B
$BF1$8$h$&$KF/$-$^$9!#(B
$B@5$N?t0z?t$r;XDj$9$k$H!"(B
Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$r%*%s$K$7!"(B
$BIi$G$"$l$P%*%U$K$7$^$9!#(B
$B$3$N%b!<%I$N%*%s!?%*%U$O!"%b!<%I9T$N3g8L$NCf$K(B@samp{Fill}$B$,(B
$B$"$k$+$I$&$+$GH=CG$G$-$^$9!#(B
Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$O%^%$%J%b!<%I$J$N$G!"(B
$B3F%P%C%U%!$4$H$KFHN)$K%*%s!?%*%U$K$G$-$^$9!#(B
@xref{Minor Modes}$B!#(B
@vindex fortran-break-before-delimiters
@c Fortran Auto Fill mode breaks lines at spaces or delimiters when the
@c lines get longer than the desired width (the value of @code{fill-column}).
@c The delimiters that Fortran Auto Fill mode may break at are @samp{,},
@c @samp{'}, @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, and @samp{)}.
@c The line break comes after the delimiter if the variable
@c @code{fortran-break-before-delimiters} is @code{nil}. Otherwise (and by
@c default), the break comes before the delimiter.
Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$O!"(B
$B9T$ND9$5$,5,Dj$NI}!J(B@code{fill-column}$B$NCM!K$r1[$($k$H!"(B
$B6uGr$d6h@Z$j$N0LCV$G9T$rJ,3d$7$^$9!#(B
Fortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K$,J,3d$9$k6h@Z$j$O!"(B
@samp{,}$B!"(B@samp{'}$B!"(B@samp{+}$B!"(B@samp{-}$B!"(B@samp{/}$B!"(B@samp{*}$B!"(B
@samp{=}$B!"(B@samp{)}$B$G$9!#(B
$BJQ?t(B@code{fortran-break-before-delimiters}$B$,(B@code{nil}$B$N>l9g$K$O!"(B
$B6h@Z$j$N$&$7$m$GJ,3d$7$^$9!#(B
$B$=$l0J30!J%G%U%)%k%H$G$b$"$k!K$G$O!"6h@Z$j$N$^$($GJ,3d$7$^$9!#(B
@c By default, Fortran Auto Fill mode is not enabled. If you want this
@c feature turned on permanently, add a hook function to
@c @code{fortran-mode-hook} to execute @code{(fortran-auto-fill-mode 1)}.
@c @xref{Hooks}.
$B%G%U%)%k%H$G$O(BFortran$B@lMQ<+F05M$a9~$_!J(Bfortran-auto-fill$B!K%b!<%I$O%*%U$G$9!#(B
$B$3$N5!G=$r91>oE*$K;H$$$?$1$l$P!"(B
@code{(fortran-auto-fill-mode 1)}$B$r<B9T$9$k%U%C%/4X?t$r(B
@code{fortran-mode-hook}$B$KDI2C$7$F$/$@$5$$!#(B
@xref{Hooks}$B!#(B
@node Fortran Columns
@c @subsection Checking Columns in Fortran
@subsection $B7e0LCV$N3NG'(B
@table @kbd
@item C-c C-r
@c Display a ``column ruler'' momentarily above the current line
@c (@code{fortran-column-ruler}).
$B8=:_9T$N>e$K$7$P$i$/$N$"$$$@!X7eDj5,!Y$rI=<($9$k(B
$B!J(B@code{fortran-column-ruler}$B!K!#(B
@item C-c C-w
@c Split the current window horizontally temporarily so that it is 72
@c columns wide. This may help you avoid making lines longer than the
@c 72-character limit that some Fortran compilers impose
@c (@code{fortran-window-create-momentarily}).
$B8=:_$N%&%#%s%I%&$r0l;~E*$KJ,3d$7$FI}$r(B72$B7e$K$9$k!#(B
$B0lIt$N(BFortran$B%3%s%Q%$%i$O(B1$B9T$r(B72$BJ8;z0JFb$K@)8B$7$F$$$k$N$G!"(B
$B$3$N%3%^%s%I$r;HMQ$9$l$P(B1$B9T$,D9$/$J$j$9$.$k$3$H$rKI$2$k(B
$B!J(B@code{fortran-window-create-momentarily}$B!K!#(B
@end table
@c @kindex C-c C-r @r{(Fortran mode)}
@kindex C-c C-r @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-column-ruler
@vindex fortran-column-ruler
@c The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column
@c ruler momentarily above the current line. The comment ruler is two lines
@c of text that show you the locations of columns with special significance in
@c Fortran programs. Square brackets show the limits of the columns for line
@c numbers, and curly brackets show the limits of the columns for the
@c statement body. Column numbers appear above them.
$B%3%^%s%I(B@kbd{C-c C-r}$B!J(B@code{fortran-column-ruler}$B!K$O!"(B
$B7eDj5,$r$7$P$i$/$N$"$$$@!"8=:_9T$N>e$KI=<($7$^$9!#(B
$B7eDj5,$O!"(BFortran$B%W%m%0%i%`$K$*$$$FFCJL$J0UL#$r$b$D7e0LCV$rI=$9(B
2$B9T$N%F%-%9%H$G$9!#(B
2$B9TL\$N3Q3g8L$HCf3g8L$G!"$=$l$>$l!"9THV9f$HJ8$NK\BN$NHO0O$rI=$7$^$9!#(B
$B7eHV9f$O!J$=$l$i$N>e$N!K(B1$B9TL\$KI=<($5$l$^$9!#(B
@c Note that the column numbers count from zero, as always in GNU Emacs.
@c As a result, the numbers may be one less than those you are familiar
@c with; but the positions they indicate in the line are standard for
@c Fortran.
GNU Emacs$B$G$O7eHV9f$r$D$M$K(B0$B$+$i?t$($k$3$H$KCm0U$7$F$/$@$5$$!#(B
$B$=$N7k2L!"7eDj5,$K<($5$l$k7eHV9f$O!"(B
$B47$l?F$7$s$@$b$N$h$j(B1$B$@$1>.$5$/$J$j$^$9!#(B
$B$7$+$7!"$=$l$i$,I=$90LCV$O(BFortran$B$NI8=`$K=>$C$?$b$N$G$9!#(B
@c The text used to display the column ruler depends on the value of
@c the variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is
@c @code{nil}, then the value of the variable
@c @code{fortran-column-ruler-fixed} is used as the column ruler.
@c Otherwise, the variable @code{fortran-column-ruler-tab} is displayed.
@c By changing these variables, you can change the column ruler display.
$B7eDj5,$NI=<($KMQ$$$k%F%-%9%H$O!"(B
$BJQ?t(B@code{indent-tabs-mode}$B$NCM$K0MB8$7$^$9!#(B
$B$3$NJQ?t$NCM$,(B@code{nil}$B$J$i$P!"(B
$BJQ?t(B@code{fortran-column-ruler-fixed}$B$NCM$r7eDj5,$NI=<($K;H$$$^$9!#(B
@code{nil}$B0J30$G$"$l$P!"JQ?t(B
@code{fortran-column-ruler-tab}$B$NFbMF$rI=<($K;H$$$^$9!#(B
$B$3$l$i$NJQ?t$NFbMF$rJQ99$9$l$P!"7eDj5,$NI=<($rJQ99$G$-$^$9!#(B
@c @kindex C-c C-w @r{(Fortran mode)}
@kindex C-c C-w @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-window-create
@c For even more help, use @kbd{C-c C-w} (@code{fortran-window-create}), a
@c command which splits the current window horizontally, making a window 72
@c columns wide. By editing in this window you can immediately see when you
@c make a line too wide to be correct Fortran.
$B$5$i$K7e9g$o$;$r;Y1g$9$k$?$a$K!"(B
@kbd{C-c C-w}$B!J(B@code{fortran-window-create}$B!K$O!"(B
$B8=:_$N%&%#%s%I%&$rI}$,(B72$B7e$K$J$k$h$&$K2#0LCV$GJ,3d$7$^$9!#(B
$B$3$N%&%#%s%I%&$GJT=8$9$l$P!"(B
$B@5$7$$(BFortran$B$N%W%m%0%i%`$H$7$F$OD9$9$.$k9T$rB(:B$KH/8+$G$-$^$9!#(B
@node Fortran Abbrev
@c @subsection Fortran Keyword Abbrevs
@subsection Fortran$B$N%-!<%o!<%I$NN,8l(B
@c Fortran mode provides many built-in abbrevs for common keywords and
@c declarations. These are the same sort of abbrev that you can define
@c yourself. To use them, you must turn on Abbrev mode. @xref{Abbrevs}.
Fortran$B%b!<%I$K$O!"0lHLE*$J%-!<%o!<%I$d@k8@$KBP$9$k(B
$B?tB?$/$NAH$_9~$_N,8l$,$"$j$^$9!#(B
$B$3$l$i$O!"%f!<%6!<<+?H$,Dj5A$G$-$kN,8l$HF1$8<oN`$N$b$N$G$9!#(B
$B$=$l$i$r;H$&$K$O!"N,8l!J(Babbrev$B!K%b!<%I$r%*%s$K$7$^$9!#(B
@xref{Abbrevs}$B!#(B
@c The built-in abbrevs are unusual in one way: they all start with a
@c semicolon. You cannot normally use semicolon in an abbrev, but Fortran
@c mode makes this possible by changing the syntax of semicolon to ``word
@c constituent.''
$BAH$_9~$_N,8l$OB>$NN,8l$H(B1$B$D$NE@$GJQ$o$C$F$$$^$9!#(B
$B$9$Y$F%;%_%3%m%s$G;O$^$j$^$9!#(B
$BDL>o$ON,8l$K$O%;%_%3%m%s$r;H$($^$;$s$,!"(B
Fortran$B%b!<%I$G$O!"%;%_%3%m%s$N9=J8>e$N0UL#$r!XC18l$r9=@.$9$kJ8;z!Y$K(B
$BJQ99$9$k$3$H$G!"$3$l$r2DG=$K$7$F$$$^$9!#(B
@c For example, one built-in Fortran abbrev is @samp{;c} for
@c @samp{continue}. If you insert @samp{;c} and then insert a punctuation
@c character such as a space or a newline, the @samp{;c} expands automatically
@c to @samp{continue}, provided Abbrev mode is enabled.@refill
$B$?$H$($P!"(B@samp{continue}$B$KBP$9$kAH$_9~$_(BFortran$BN,8l$O(B@samp{;c}$B$G$9!#(B
$BN,8l!J(Babbrev$B!K%b!<%I$,%*%s$N$H$-$K!"(B
@samp{;c}$B$rA^F~$7$F$+$i6uGr$d2~9T$H$$$C$?6gFIE@J8;z$rA^F~$9$k$H!"(B
@samp{;c}$B$O<+F0E*$K(B@samp{continue}$B$HE83+$5$l$^$9!#(B
@c Type @samp{;?} or @samp{;C-h} to display a list of all the built-in
@c Fortran abbrevs and what they stand for.
$BAH$_9~$_(BFortran$BN,8l$H$=$NE83+7A$N0lMw$rI=<($9$k$K$O!"(B
@samp{;?}$B$"$k$$$O(B@samp{;C-h}$B$HBG$A$^$9!#(B
@node Fortran Misc
@c @subsection Other Fortran Mode Commands
@subsection Fortran$B%b!<%I$N$=$NB>$N%3%^%s%I(B
@table @kbd
@item C-x n d
@c Narrow to the current Fortran subprogram.
$B8=:_$N(BFortran$B$NI{%W%m%0%i%`$K%J%m%$%s%0$9$k!#(B
@end table
@c @kindex C-x n d @r{(Fortran mode)}
@kindex C-x n d @r{$B!J(BFortran$B%b!<%I!K(B}
@findex fortran-narrow-to-subprogram
@c Fortran mode redefines the key @kbd{C-x n d} to run the command
@c @code{fortran-narrow-to-subprogram}, which is the Fortran analogue
@c of the key's usual definition. It narrows the buffer to the subprogram
@c containing point.
Fortran$B%b!<%I$G$O!"(B
$B%-!<(B@kbd{C-x n d}$B$O%3%^%s%I(B@code{fortran-narrow-to-subprogram}$B$r<B9T$9$k$h$&$K(B
$B:FDj5A$7$F$$$^$9!#(B
$B$3$N%3%^%s%I$O!"%-!<$NDL>o$NDj5A$r(BFrotran$BIw$K$7$?$b$N$G$9!#(B
$B%P%C%U%!$r%]%$%s%H$r4^$`I{%W%m%0%i%`$K%J%m%$%s%0$7$^$9!#(B
@node Asm Mode
@c @section Asm Mode
@section asm$B%b!<%I(B
@c @cindex Asm mode
@cindex asm$B%b!<%I(B
@cindex $B%b!<%I!"(BAsm
@c Asm mode is a major mode for editing files of assembler code. It
@c defines these commands:
asm$B%b!<%I$O!"%"%;%s%V%j%3!<%I$N%U%!%$%k$rJT=8$9$k$?$a$N%a%8%c!<%b!<%I$G$9!#(B
$B$D$.$N%3%^%s%I$,Dj5A$5$l$F$$$^$9!#(B
@table @kbd
@item @key{TAB}
@c @code{tab-to-tab-stop}.
@code{tab-to-tab-stop}$B!#(B
@item C-j
@c Insert a newline and then indent using @code{tab-to-tab-stop}.
$B2~9T$rA^F~$7!"(B@code{tab-to-tab-stop}$B$G;z2<$2$9$k!#(B
@item :
@c Insert a colon and then remove the indentation from before the label
@c preceding colon. Then do @code{tab-to-tab-stop}.
$B%3%m%s$rA^F~$7!"%3%m%s$K@h9T$9$k%i%Y%k$N$^$($N;z2<$2$r<h$j=|$/!#(B
$B$=$7$F!"(B@code{tab-to-tab-stop}$B$r9T$&!#(B
@item ;
@c Insert or align a comment.
$B%3%a%s%H$NA^F~!?0LCVB7$($r9T$&!#(B
@end table
@c The variable @code{asm-comment-char} specifies which character
@c starts comments in assembler syntax.
$BJQ?t(B@code{asm-comment-char}$B$O!"(B
$B%"%;%s%V%i9=J8$G%3%a%s%H$r3+;O$9$kJ8;z$r;XDj$7$^$9!#(B
|