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
|
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/windows
@node Windows, Frames, Buffers, Top
@c @chapter Windows
@chapter $B%&%#%s%I%&(B
@c This chapter describes most of the functions and variables related to
@c Emacs windows. See @ref{Display}, for information on how text is
@c displayed in windows.
$BK\>O$G$O!"(BEmacs$B$N%&%#%s%I%&$K4X$7$?$[$H$s$I$N4X?t$HJQ?t$K$D$$$F=R$Y$^$9!#(B
$B%&%#%s%I%&$K$I$N$h$&$K%F%-%9%H$,I=<($5$l$k$+$K4X$7$F$O!"(B
@ref{Display}$B$r;2>H$7$F$/$@$5$$!#(B
@menu
* Basic Windows:: Basic information on using windows.
* Splitting Windows:: Splitting one window into two windows.
* Deleting Windows:: Deleting a window gives its space to other windows.
* Selecting Windows:: The selected window is the one that you edit in.
* Cyclic Window Ordering:: Moving around the existing windows.
* Buffers and Windows:: Each window displays the contents of a buffer.
* Displaying Buffers:: Higher-lever functions for displaying a buffer
and choosing a window for it.
* Choosing Window:: How to choose a window for displaying a buffer.
* Window Point:: Each window has its own location of point.
* Window Start:: The display-start position controls which text
is on-screen in the window.
* Vertical Scrolling:: Moving text up and down in the window.
* Horizontal Scrolling:: Moving text sideways on the window.
* Size of Window:: Accessing the size of a window.
* Resizing Windows:: Changing the size of a window.
* Coordinates and Windows:: Converting coordinates to windows.
* Window Configurations:: Saving and restoring the state of the screen.
* Window Hooks:: Hooks for scrolling, window size changes,
redisplay going past a certain point,
or window configuration changes.
@end menu
@node Basic Windows
@c @section Basic Concepts of Emacs Windows
@section Emacs$B%&%#%s%I%&$N4pK\35G0(B
@c @cindex window
@c @cindex selected window
@cindex $B%&%#%s%I%&(B
@cindex $BA*Br$5$l$F$$$k%&%#%s%I%&(B
@c A @dfn{window} in Emacs is the physical area of the screen in which a
@c buffer is displayed. The term is also used to refer to a Lisp object that
@c represents that screen area in Emacs Lisp. It should be
@c clear from the context which is meant.
Emacs$B$N(B@dfn{$B%&%#%s%I%&(B}$B!J(Bwindow$B!K$O!"(B
$B%P%C%U%!$rI=<($9$k%9%/%j!<%s>e$NJ*M}E*$JNN0h$N$3$H$G$9!#(B
$B$3$NMQ8l$O!"(BEmacs Lisp$B$K$*$$$F!"Ev3:J*M}NN0h$rI=$9(B
Lisp$B%*%V%8%'%/%H$r0UL#$9$k$?$a$K$b;H$$$^$9!#(B
$B$I$A$i$N0UL#$+$OJ8L.$+$iL@$i$+$J$O$:$G$9!#(B
@c Emacs groups windows into frames. A frame represents an area of
@c screen available for Emacs to use. Each frame always contains at least
@c one window, but you can subdivide it vertically or horizontally into
@c multiple nonoverlapping Emacs windows.
Emacs$B$G$O%&%#%s%I%&$r%U%l!<%`$K$^$H$a$F$$$^$9!#(B
$B%U%l!<%`$O!"(BEmacs$B$,;H$($k%9%/%j!<%s$NNN0h$rI=$7$^$9!#(B
$B3F%U%l!<%`$K$O>/$J$/$H$b(B1$B$D$N%&%#%s%I%&$,$D$M$K$"$j$^$9$,!"(B
$B%U%l!<%`$O>e2<$d:81&$K=E$J$j9g$o$J$$J#?t$N(BEmacs$B$N%&%#%s%I%&$KJ,3d$G$-$^$9!#(B
@c In each frame, at any time, one and only one window is designated as
@c @dfn{selected within the frame}. The frame's cursor appears in that
@c window. At any time, one frame is the selected frame; and the window
@c selected within that frame is @dfn{the selected window}. The selected
@c window's buffer is usually the current buffer (except when
@c @code{set-buffer} has been used). @xref{Current Buffer}.
$B$"$k;~E@$G$O!"3F%U%l!<%`$K$O(B@dfn{$B%U%l!<%`$NA*Br$5$l$F$$$k(B}$B%&%#%s%I%&$H(B
$B6hJL$5$l$k%&%#%s%I%&$,$?$C$?(B1$B$D$@$1$"$j$^$9!#(B
$B%U%l!<%`$N%+!<%=%k$O$=$N$h$&$J%&%#%s%I%&$K8=$l$^$9!#(B
$B$"$k;~E@$G$O!"(B1$B$D$N%U%l!<%`$,A*Br$5$l$F$$$k%U%l!<%`$G$"$j!"(B
$BEv3:%U%l!<%`$GA*Br$5$l$F$$$k%&%#%s%I%&$,(B@dfn{$BA*Br$5$l$F$$$k%&%#%s%I%&(B}$B$G$9!#(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$N%P%C%U%!$,!"(B
$B!J(B@code{set-buffer}$B$r;H$C$?>l9g$r=|$$$F!KIaDL$O%+%l%s%H%P%C%U%!$G$9!#(B
@xref{Current Buffer}$B!#(B
@c For practical purposes, a window exists only while it is displayed in
@c a frame. Once removed from the frame, the window is effectively deleted
@c and should not be used, @emph{even though there may still be references
@c to it} from other Lisp objects. Restoring a saved window configuration
@c is the only way for a window no longer on the screen to come back to
@c life. (@xref{Deleting Windows}.)
$B<BMQ>e!"%&%#%s%I%&$O!"$=$l$,%U%l!<%`$KI=<($5$l$F$$$k4|4V$@$1B8:_$7$^$9!#(B
$B%U%l!<%`$+$i$$$C$?$s<h$j$5$k$H!"!J%&%#%s%I%&$X$N;2>H$,;D$C$F$$$k$H$7$F$b!K(B
$B%&%#%s%I%&$O<B<AE*$K$O:o=|$5$l;H$($^$;$s!#(B
$BJ]B8$7$?%&%#%s%I%&9=@.$rI|85$9$k0J30$K!"(B
$B%9%/%j!<%s$+$i>C$($?%&%#%s%I%&$rLa$9J}K!$O$"$j$^$;$s!#(B
$B!J(B@pxref{Deleting Windows}$B!#!K(B
@c Each window has the following attributes:
$B3F%&%#%s%I%&$K$O$D$.$NB0@-$,$"$j$^$9!#(B
@itemize @bullet
@item
@c containing frame
$B%&%#%s%I%&$r4^$s$G$$$k%U%l!<%`(B
@item
@c window height
$B%&%#%s%I%&$N9b$5(B
@item
@c window width
$B%&%#%s%I%&$NI}(B
@item
@c window edges with respect to the screen or frame
$B%9%/%j!<%s$d%U%l!<%`$r4p=`$K$7$?%&%#%s%I%&$N6y(B
@item
@c the buffer it displays
$B%&%#%s%I%&$,I=<($7$F$$$k%P%C%U%!(B
@item
@c position within the buffer at the upper left of the window
$B%&%#%s%I%&$N:8>e6y$KBP1~$9$k%P%C%U%!Fb$N0LCV(B
@item
@c amount of horizontal scrolling, in columns
$B%3%i%`C10L$N?eJ?J}8~$N%9%/%m!<%kNL(B
@item
@c point
$B%]%$%s%H(B
@item
@c the mark
$B%^!<%/(B
@item
@c how recently the window was selected
$B$I$NDxEY:G6a$K%&%#%s%I%&$,A*Br$5$l$?$+(B
@end itemize
@c @cindex multiple windows
@cindex $BJ#?t$N%&%#%s%I%&(B
@c Users create multiple windows so they can look at several buffers at
@c once. Lisp libraries use multiple windows for a variety of reasons, but
@c most often to display related information. In Rmail, for example, you
@c can move through a summary buffer in one window while the other window
@c shows messages one at a time as they are reached.
$BJ#?t$N%P%C%U%!$rF1;~$K8+$i$l$k$h$&$K%f!<%6!<$OJ#?t$N%&%#%s%I%&$r:n$j$^$9!#(B
$B$5$^$6$^$JM}M3$G(BLisp$B%i%$%V%i%j$OJ#?t$N%&%#%s%I%&$r;H$$$^$9$,!"(B
$B$=$N$[$H$s$I$O!"4XO"$9$k>pJs$rI=<($9$k$?$a$G$9!#(B
$B$?$H$($P!"(Brmail$B$G$O!"$"$k%&%#%s%I%&$N%5%^%j%P%C%U%!$G0\F0$9$k$H!"(B
$BJL$N%&%#%s%I%&$G$OBP1~$9$k%a%C%;!<%8$rI=<($7$^$9!#(B
@c The meaning of ``window'' in Emacs is similar to what it means in the
@c context of general-purpose window systems such as X, but not identical.
@c The X Window System places X windows on the screen; Emacs uses one or
@c more X windows as frames, and subdivides them into
@c Emacs windows. When you use Emacs on a character-only terminal, Emacs
@c treats the whole terminal screen as one frame.
Emacs$B$K$*$1$k!X%&%#%s%I%&!Y$N0UL#$O!"(B
X$B$N$h$&$JHFMQL\E*$N%&%#%s%I%&%7%9%F%`$K$*$1$k0UL#$K;w$F$$$^$9$,!"(B
$BF10l$G$O$"$j$^$;$s!#(B
X$B%&%#%s%I%&%7%9%F%`$O!"%9%/%j!<%s>e$K(BX$B$N%&%#%s%I%&$rG[CV$7$^$9!#(B
Emacs$B$O!"(B1$B$D$+J#?t$N(BX$B$N%&%#%s%I%&$r%U%l!<%`$H$7$F;H$$!"(B
$B$=$l$i$r(BEmacs$B$N%&%#%s%I%&$KJ,3d$7$^$9!#(B
$BJ8;zC<Kv$G(BEmacs$B$r;H$&$H!"(B
Emacs$B$OC<Kv$N%/%j!<%sA4BN$r(B1$B$D$N%U%l!<%`$H$7$F07$$$^$9!#(B
@c @cindex terminal screen
@c @cindex screen of terminal
@c @cindex tiled windows
@cindex $BC<Kv%9%/%j!<%s(B
@cindex $B%9%/%j!<%s!"C<Kv(B
@cindex $B%?%$%k7?%&%#%s%I%&(B
@c Most window systems support arbitrarily located overlapping windows.
@c In contrast, Emacs windows are @dfn{tiled}; they never overlap, and
@c together they fill the whole screen or frame. Because of the way in
@c which Emacs creates new windows and resizes them, not all conceivable
@c tilings of windows on an Emacs frame are actually possible.
@c @xref{Splitting Windows}, and @ref{Size of Window}.
$B$[$H$s$I$N%&%#%s%I%&%7%9%F%`$O!"G$0U$K=E$M9g$o$5$C$?%&%#%s%I%&$r07$($^$9!#(B
$BBP>HE*$K!"(BEmacs$B$N%&%#%s%I%&$O(B@dfn{$B%?%$%k7?(B}$B$G$9!#(B
$B$D$^$j!"8_$$$K=E$J$j9g$&$3$H$O$J$/!"(B
$B%9%/%j!<%s$d%U%l!<%`$NA4LL$KI_$-5M$a$i$l$^$9!#(B
Emacs$B$,?7$?$J%&%#%s%I%&$r:n@.$9$kJ}K!$d(B
$B%&%#%s%I%&%5%$%:$NJQ99J}K!$K5/0x$9$k$N$G$9$,!"(B
Emacs$B$N%U%l!<%`$rG$0U$N7A$K%&%#%s%I%&$GI_$-5M$a$k$3$H$O!"(B
$B<B:]$K$OI,$:$7$b2DG=$G$"$k$H$O8B$j$^$;$s!#(B
@ref{Splitting Windows}$B$H(B@xref{Size of Window}$B!#(B
@c @xref{Display}, for information on how the contents of the
@c window's buffer are displayed in the window.
$B%&%#%s%I%&$N%P%C%U%!$NFbMF$,$I$N$h$&$K%&%#%s%I%&$KI=<($5$l$k$+$K$D$$$F$O!"(B
@xref{Display}$B!#(B
@defun windowp object
@c This function returns @code{t} if @var{object} is a window.
$B$3$N4X?t$O!"(B@var{object}$B$,%&%#%s%I%&$G$"$l$P(B@code{t}$B$rJV$9!#(B
@end defun
@node Splitting Windows
@c @section Splitting Windows
@section $B%&%#%s%I%&$NJ,3d(B
@c @cindex splitting windows
@c @cindex window splitting
@cindex $B%&%#%s%I%&$NJ,3d(B
@cindex $BJ,3d!"%&%#%s%I%&(B
@c The functions described here are the primitives used to split a window
@c into two windows. Two higher level functions sometimes split a window,
@c but not always: @code{pop-to-buffer} and @code{display-buffer}
@c (@pxref{Displaying Buffers}).
$B$3$3$G=R$Y$k4X?t$O!"%&%#%s%I%&$r(B2$B$D$KJ,3d$9$k$?$a$N4pK\4X?t$G$9!#(B
$B>e0L%l%Y%k$N(B2$B$D$N4X?t!"(B@code{pop-to-buffer}$B$H(B@code{display-buffer}$B$b(B
$B%&%#%s%I%&$rJ,3d$7$^$9$,!"(B
$B$D$M$KJ,3d$9$k$H$O8B$j$^$;$s!J(B@pxref{Displaying Buffers}$B!K!#(B
@c The functions described here do not accept a buffer as an argument.
@c The two ``halves'' of the split window initially display the same buffer
@c previously visible in the window that was split.
$B$3$3$K=R$Y$k4X?t$O!"0z?t$K$O%P%C%U%!$r<u$1IU$1$^$;$s!#(B
$BJ,3d$5$l$?%&%#%s%I%&$N(B2$B$D$N!XItJ,!Y$K$O!"J,3dA0$KI=<($5$l$F$$$?$N$H(B
$BF1$8%P%C%U%!$,;O$a$OI=<($5$l$^$9!#(B
@c @deffn Command split-window &optional window size horizontal
@deffn $B%3%^%s%I(B split-window &optional window size horizontal
@c This function splits @var{window} into two windows. The original
@c window @var{window} remains the selected window, but occupies only
@c part of its former screen area. The rest is occupied by a newly created
@c window which is returned as the value of this function.
$B$3$N4X?t$O(B@var{window}$B$r(B2$B$D$N%&%#%s%I%&$KJ,3d$9$k!#(B
$B$b$H$N%&%#%s%I%&(B@var{window}$B$O!"A*Br$5$l$F$$$k%&%#%s%I%&$G$"$jB3$1$k$,!"(B
$B0JA0$N%9%/%j!<%sNN0h$N0lIt$r@j$a$k$@$1$G$"$k!#(B
$B;D$j$NItJ,$O?7$?$K:n@.$5$l$?%&%#%s%I%&$,@j$a!"(B
$B$=$N%&%#%s%I%&$,$3$N4X?t$NCM$H$7$FJV$5$l$k!#(B
@c If @var{horizontal} is non-@code{nil}, then @var{window} splits into
@c two side by side windows. The original window @var{window} keeps the
@c leftmost @var{size} columns, and gives the rest of the columns to the
@c new window. Otherwise, it splits into windows one above the other, and
@c @var{window} keeps the upper @var{size} lines and gives the rest of the
@c lines to the new window. The original window is therefore the
@c left-hand or upper of the two, and the new window is the right-hand or
@c lower.
@var{horizontal}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B@var{window}$B$O:81&$KJ,$+$l$k!#(B
$B$b$H$N%&%#%s%I%&(B@var{window}$B$O:8C<$N(B@var{size}$B%3%i%`$KN1$^$j!"(B
$B;D$j$N%3%i%`$O?7$?$J%&%#%s%I%&$KM?$($i$l$k!#(B
$B$5$b$J$1$l$P!"%&%#%s%I%&$O>e2<$KJ,$+$l!"(B
@var{window}$B$O>eB&$N(B@var{size}$B9T$KN1$^$j!"(B
$B;D$j$N9T$O?7$?$J%&%#%s%I%&$KM?$($i$l$k!#(B
$B$7$?$,$C$F!"$b$H$N%&%#%s%I%&$O:8B&$+>eB&$K$"$j!"(B
$B?7$?$J%&%#%s%I%&$O1&B&$+2<B&$K$"$k!#(B
@c If @var{window} is omitted or @code{nil}, then the selected window is
@c split. If @var{size} is omitted or @code{nil}, then @var{window} is
@c divided evenly into two parts. (If there is an odd line, it is
@c allocated to the new window.) When @code{split-window} is called
@c interactively, all its arguments are @code{nil}.
@var{window}$B$r>JN,$7$?$j(B@code{nil}$B$G$"$k$H!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$rJ,3d$9$k!#(B
@var{size}$B$r>JN,$7$?$j(B@code{nil}$B$G$"$k$H!"(B
@var{window}$B$r6QEy$KJ,$1$k!#(B
$B!JM>J,$J9T$O?7$?$J%&%#%s%I%&$KM?$($k!#!K(B
@code{split-window}$B$,BPOCE*$K8F$S=P$5$l$k$H!"(B
$B$9$Y$F$N0z?t$O(B@code{nil}$B$G$"$k!#(B
@c The following example starts with one window on a screen that is 50
@c lines high by 80 columns wide; then the window is split.
$B$D$.$NNc$G$O!"(B50$B9T!_(B80$B%3%i%`$N%9%/%j!<%s>e$N(B1$B$D$N%&%#%s%I%&$rJ,3d$9$k!#(B
@smallexample
@group
(setq w (selected-window))
@result{} #<window 8 on windows.texi>
@c (window-edges) ; @r{Edges in order:}
@c @result{} (0 0 80 50) ; @r{left--top--right--bottom}
(window-edges) ; @r{$B=g$K(B}
@result{} (0 0 80 50) ; @r{$B:8C<(B--$B>eC<(B--$B1&C<(B--$B2<C<(B}
@end group
@group
@c ;; @r{Returns window created}
;; @r{$B:n@.$7$?%&%#%s%I%&$rJV$9(B}
(setq w2 (split-window w 15))
@result{} #<window 28 on windows.texi>
@end group
@group
(window-edges w2)
@c @result{} (0 15 80 50) ; @r{Bottom window;}
@c ; @r{top is line 15}
@result{} (0 15 80 50) ; @r{$B2<B&$N%&%#%s%I%&$N>eC<$O(B15$B9TL\(B}
@end group
@group
(window-edges w)
@c @result{} (0 0 80 15) ; @r{Top window}
@result{} (0 0 80 15) ; @r{$B>eB&$N%&%#%s%I%&(B}
@end group
@end smallexample
@c The screen looks like this:
$B%9%/%j!<%s$O$D$.$N$h$&$K$J$k!#(B
@smallexample
@group
@c __________
@c | | line 0
@c | w |
@c |__________|
@c | | line 15
@c | w2 |
@c |__________|
@c line 50
@c column 0 column 80
$B!!!!!!(#(!(!(!(!(!(!($(B
$B!!!!!!("!!!!!!!!!!!!("(B 0$B9TL\(B
$B!!!!!!("!!!!!!#w!!!!("(B
$B!!!!!!("!!!!!!!!!!!!("(B
$B!!!!!!('(!(!(!(!(!(!()(B
$B!!!!!!("!!!!!!!!!!!!("(B15$B9TL\(B
$B!!!!!!("!!!!!!#w#2!!("(B
$B!!!!!!("!!!!!!!!!!!!("(B
$B!!!!!!(&(!(!(!(!(!(!(%(B
$B!!!!!!!!!!!!!!!!!!!!!!(B50$B9TL\(B
$B%3%i%`(B0 $B%3%i%`(B80
@end group
@end smallexample
@c Next, the top window is split horizontally:
$B$D$.$K>eB&$N%&%#%s%I%&$r:81&$KJ,3d$9$k!#(B
@smallexample
@group
(setq w3 (split-window w 35 t))
@result{} #<window 32 on windows.texi>
@end group
@group
(window-edges w3)
@c @result{} (35 0 80 15) ; @r{Left edge at column 35}
@result{} (35 0 80 15) ; @r{$B:8C<$O(B35$B%3%i%`L\(B}
@end group
@group
(window-edges w)
@c @result{} (0 0 35 15) ; @r{Right edge at column 35}
@result{} (0 0 35 15) ; @r{$B1&C<$O(B35$B%3%i%`L\(B}
@end group
@group
(window-edges w2)
@c @result{} (0 15 80 50) ; @r{Bottom window unchanged}
@result{} (0 15 80 50) ; @r{$B2<B&$N%&%#%s%I%&$OL$JQ99(B}
@end group
@end smallexample
@need 3000
@c Now, the screen looks like this:
$B%9%/%j!<%s$O$D$.$N$h$&$K$J$k!#(B
@smallexample
@group
@c column 35
@c __________
@c | | | line 0
@c | w | w3 |
@c |___|______|
@c | | line 15
@c | w2 |
@c |__________|
@c line 50
@c column 0 column 80
$B%3%i%`(B35
$B!!!!!!(#(!(((!(!(!(!($(B
$B!!!!!!("!!("!!!!!!!!("(B 0$B9TL\(B
$B!!!!!!("#w("!!#w#3!!("(B
$B!!!!!!("!!("!!!!!!!!("(B
$B!!!!!!('(!(*(!(!(!(!()(B
$B!!!!!!("!!!!!!!!!!!!("(B15$B9TL\(B
$B!!!!!!("!!!!!!#w#2!!("(B
$B!!!!!!("!!!!!!!!!!!!("(B
$B!!!!!!(&(!(!(!(!(!(!(%(B
$B!!!!!!!!!!!!!!!!!!!!!!(B50$B9TL\(B
$B%3%i%`(B0 $B%3%i%`(B80
@end group
@end smallexample
@c Normally, Emacs indicates the border between two side-by-side windows
@c with a scroll bar (@pxref{Window Frame Parameters,Scroll Bars}) or @samp{|}
@c characters. The display table can specify alternative border
@c characters; see @ref{Display Tables}.
$BDL>o!"(BEmacs$B$O:81&$KJB$s$@%&%#%s%I%&$N6-3&$r(B
$B%9%/%m!<%k%P!<!J(B@pxref{Window Frame Parameters,Scroll Bars}$B!K$+(B
$BJ8;z(B@samp{|}$B$GI=$9!#(B
$BI=<(%F!<%V%k$G6-3&$KJL$NJ8;z$r;XDj$G$-$k!#(B
@ref{Display Tables}$B$r;2>H!#(B
@end deffn
@c @deffn Command split-window-vertically size
@deffn $B%3%^%s%I(B split-window-vertically size
@c This function splits the selected window into two windows, one above the
@c other, leaving the upper of the two windows selected, with @var{size}
@c lines. (If @var{size} is negative, then the lower of the two windows
@c gets @minus{} @var{size} lines and the upper window gets the rest, but
@c the upper window is still the one selected.)
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r>e2<$K(B2$B$D$KJ,3d$9$k!#(B
$B>eB&$,A*Br$5$l$F$$$k%&%#%s%I%&$N$^$^$G!"(B@var{size}$B9T$NBg$-$5$K$J$k!#(B
$B!J(B@var{size}$B$,Ii$G$"$k$H!"2<B&$N%&%#%s%I%&$,(B@minus{} @var{size}$B9T$K$J$j!"(B
$B>eB&$N%&%#%s%I%&$O;D$j$K$J$k!#(B
$B$7$+$7!"$=$l$G$b>eB&$,A*Br$5$l$F$$$k%&%#%s%I%&$G$"$k!#!K(B
@c This function is simply an interface to @code{split-window}.
@c Here is the complete function definition for it:
$B$3$N4X?t$O(B@code{split-window}$B$NC1$J$k%$%s%?!<%U%'%$%9$G$"$k!#(B
$B$=$N40A4$J4X?tDj5A$O$D$.$N$H$*$j$G$"$k!#(B
@smallexample
@group
(defun split-window-vertically (&optional arg)
"Split current window into two windows, @dots{}"
(interactive "P")
(split-window nil (and arg (prefix-numeric-value arg))))
@end group
@end smallexample
@end deffn
@c @deffn Command split-window-horizontally size
@deffn $B%3%^%s%I(B split-window-horizontally size
@c This function splits the selected window into two windows
@c side-by-side, leaving the selected window with @var{size} columns.
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r:81&$K(B2$B$D$KJ,3d$7!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$K$O(B@var{size}$B%3%i%`;D$9!#(B
@c This function is simply an interface to @code{split-window}. Here is
@c the complete definition for @code{split-window-horizontally} (except for
@c part of the documentation string):
$B$3$N4X?t$O(B@code{split-window}$B$NC1$J$k%$%s%?!<%U%'%$%9$G$"$k!#(B
@code{split-window-horizontally}$B$N40A4$J4X?tDj5A$O(B
$B!J@bL@J8;zNs$r=|$1$P!K$D$.$N$H$*$j$G$"$k!#(B
@smallexample
@group
(defun split-window-horizontally (&optional arg)
"Split selected window into two windows, side by side..."
(interactive "P")
(split-window nil (and arg (prefix-numeric-value arg)) t))
@end group
@end smallexample
@end deffn
@defun one-window-p &optional no-mini all-frames
@c This function returns non-@code{nil} if there is only one window. The
@c argument @var{no-mini}, if non-@code{nil}, means don't count the
@c minibuffer even if it is active; otherwise, the minibuffer window is
@c included, if active, in the total number of windows, which is compared
@c against one.
$B$3$N4X?t$O!"%&%#%s%I%&$,$?$C$?(B1$B$D$7$+$J$1$l$P(B@code{nil}$B0J30$rJV$9!#(B
$B0z?t(B@var{no-mini}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%_%K%P%C%U%!$,3h@-$G$"$C$F$b$=$l$r?t$($J$$$3$H$r0UL#$9$k!#(B
$B$5$b$J$1$l$P!"%_%K%P%C%U%!$,3h@-$G$"$l$P$=$l$bAm%&%#%s%I%&8D?t$K?t$($F(B
1$B$HHf3S$9$k!#(B
@c The argument @var{all-frames} specifies which frames to consider. Here
@c are the possible values and their meanings:
$B0z?t(B@var{all-frames}$B$O!"$I$N%U%l!<%`$rBP>]$K$9$k$+$r;XDj$9$k!#(B
$B;XDj$G$-$kCM$H$=$N0UL#$O$D$.$N$H$*$j$G$"$k!#(B
@table @asis
@item @code{nil}
@c Count the windows in the selected frame, plus the minibuffer used
@c by that frame even if it lies in some other frame.
$BA*Br$5$l$F$$$k%U%l!<%`$N%&%#%s%I%&$K2C$($F!"(B
$B%_%K%P%C%U%!$,$I$3$KCV$+$l$F$$$h$&$H(B
$BEv3:%U%l!<%`$,;H$C$F$$$k%_%K%P%C%U%!$r?t$($k!#(B
@item @code{t}
@c Count all windows in all existing frames.
$B4{B8$N$9$Y$F$N%U%l!<%`$N%&%#%s%I%&$r?t$($k!#(B
@item @code{visible}
@c Count all windows in all visible frames.
$B$9$Y$F$N2D;k%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$r?t$($k!#(B
@item 0
@c Count all windows in all visible or iconified frames.
$B$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`$N(B
$B$9$Y$F$N%&%#%s%I%&$r?t$($k!#(B
@c @item anything else
@item $B$=$NB>(B
@c Count precisely the windows in the selected frame, and no others.
$BA*Br$5$l$F$$$k%U%l!<%`$@$1$G%&%#%s%I%&$r@53N$K?t$($k!#(B
@end table
@end defun
@node Deleting Windows
@c @section Deleting Windows
@section $B%&%#%s%I%&$N:o=|(B
@c @cindex deleting windows
@cindex $B%&%#%s%I%&$N:o=|(B
@c A window remains visible on its frame unless you @dfn{delete} it by
@c calling certain functions that delete windows. A deleted window cannot
@c appear on the screen, but continues to exist as a Lisp object until
@c there are no references to it. There is no way to cancel the deletion
@c of a window aside from restoring a saved window configuration
@c (@pxref{Window Configurations}). Restoring a window configuration also
@c deletes any windows that aren't part of that configuration.
$B%&%#%s%I%&$r:o=|$9$k$"$k<o$N4X?t$r8F$S=P$7$F(B
$B%&%#%s%I%&$r(B@dfn{$B:o=|(B}$B$7$J$$8B$j!"(B
$B%&%#%s%I%&$O$=$N%U%l!<%`$KI=<($5$lB3$1$^$9!#(B
$B:o=|$5$l$?%&%#%s%I%&$,%9%/%j!<%s$K8=$l$k$3$H$O$"$j$^$;$s$,!"(B
$B$=$l$r;2>H$9$k$b$N$,$"$k8B$j(BLisp$B%*%V%8%'%/%H$H$H$7$F$O(B
$BB8:_$7B3$1$^$9!#(B
$BJ]B8$7$?%&%#%s%I%&9=@.!J(B@pxref{Window Configurations}$B!K$rI|85$9$k0J30$K$O!"(B
$B%&%#%s%I%&$N:o=|$O<h$j>C$;$^$;$s!#(B
$B%&%#%s%I%&9=@.$rI|85$9$k$H!"(B
$B$=$N9=@.$K4^$^$l$J$$%&%#%s%I%&$O$9$Y$F:o=|$5$l$^$9!#(B
@c When you delete a window, the space it took up is given to one
@c adjacent sibling.
$B%&%#%s%I%&$r:o=|$9$k$H!"$=$l$,;H$C$F$$$?>l=j$O(B
$B6a@\$9$k7;Do%&%#%s%I%&$N(B1$B$D$KM?$($i$l$^$9!#(B
@c Emacs 19 feature
@defun window-live-p window
@c This function returns @code{nil} if @var{window} is deleted, and
@c @code{t} otherwise.
$B$3$N4X?t$O!"(B@var{window}$B$,:o=|$5$l$F$$$k$H(B@code{nil}$B$rJV$7!"(B
$B$5$b$J$1$l$P(B@code{t}$B$rJV$9!#(B
@c @strong{Warning:} Erroneous information or fatal errors may result from
@c using a deleted window as if it were live.
@strong{$B7Y9p!'(B}@code{ }
$B:o=|$5$l$?%&%#%s%I%&$r@5$7$$$b$N$H$7$F;H$&$H!"(B
$B8m$C$?>pJs$d=EBg$J%(%i!<$r0z$-5/$3$9!#(B
@end defun
@c @deffn Command delete-window &optional window
@deffn $B%3%^%s%I(B delete-window &optional window
@c This function removes @var{window} from display, and returns @code{nil}.
@c If @var{window} is omitted, then the selected window is deleted. An
@c error is signaled if there is only one window when @code{delete-window}
@c is called.
$B$3$N4X?t$O!"%G%#%9%W%l%$$+$i(B@var{window}$B$r<h$j$5$j!"(B@code{nil}$B$rJV$9!#(B
@var{window}$B$r>JN,$9$k$H!"A*Br$5$l$F$$$k%&%#%s%I%&$r:o=|$9$k!#(B
@code{delete-window}$B$r8F$S=P$7$?$H$-$K$?$C$?(B1$B$D$N%&%#%s%I%&$7$+$J$$$H(B
$B%(%i!<$rDLCN$9$k!#(B
@end deffn
@c @deffn Command delete-other-windows &optional window
@deffn $B%3%^%s%I(B delete-other-windows &optional window
@c This function makes @var{window} the only window on its frame, by
@c deleting the other windows in that frame. If @var{window} is omitted or
@c @code{nil}, then the selected window is used by default.
$B$3$N4X?t$O!"(B@var{window}$B$N%U%l!<%`$K$"$kB>$N%&%#%s%I%&$r:o=|$7$F(B
@var{window}$B$rEv3:%U%l!<%`$GM#0l$N%&%#%s%I%&$K$9$k!#(B
@var{window}$B$r>JN,$7$?$j(B@code{nil}$B$G$"$k$H!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$r%G%U%)%k%H$G;H$&!#(B
@c The return value is @code{nil}.
$B$3$l$O(B@code{nil}$B$rJV$9!#(B
@end deffn
@c @deffn Command delete-windows-on buffer &optional frame
@deffn $B%3%^%s%I(B delete-windows-on buffer &optional frame
@c This function deletes all windows showing @var{buffer}. If there are
@c no windows showing @var{buffer}, it does nothing.
$B$3$N4X?t$O!"(B@var{buffer}$B$rI=<($7$F$$$k$9$Y$F$N%&%#%s%I%&$r:o=|$9$k!#(B
@var{buffer}$B$rI=<($7$F$$$k%&%#%s%I%&$,$J$1$l$P$J$K$b$7$J$$!#(B
@c @code{delete-windows-on} operates frame by frame. If a frame has
@c several windows showing different buffers, then those showing
@c @var{buffer} are removed, and the others expand to fill the space. If
@c all windows in some frame are showing @var{buffer} (including the case
@c where there is only one window), then the frame reverts to having a
@c single window showing another buffer chosen with @code{other-buffer}.
@c @xref{The Buffer List}.
@code{delete-windows-on}$B$O%U%l!<%`$r(B1$B$D(B1$B$D=hM}$9$k!#(B
$B%U%l!<%`$K0[$J$k%P%C%U%!$rI=<($7$F$$$k%&%#%s%I%&$,J#?t$"$k>l9g!"(B
$B$=$l$i$N$&$A$G(B@var{buffer}$B$rI=<($7$F$$$k$b$N$r:o=|$7!"(B
$BB>$N$b$N$O6u$$$?NN0h$rKd$a$k$?$a$K3HD%$5$l$k!#(B
$B$"$k%U%l!<%`$N$9$Y$F$N%&%#%s%I%&!J$?$C$?(B1$B$D$N%&%#%s%I%&$G$"$k>l9g$b4^$`!K(B
$B$,(B@var{buffer}$B$rI=<($7$F$$$k>l9g!"Ev3:%U%l!<%`$O!"(B
@code{other-buffer}$B$GA*$P$l$kJL$N%P%C%U%!$rI=<($9$k(B
1$B$D$N%&%#%s%I%&$@$1$K$J$k!#(B
@pxref{The Buffer List}$B!#(B
@c The argument @var{frame} controls which frames to operate on. This
@c function does not use it in quite the same way as the other functions
@c which scan all windows; specifically, the values @code{t} and @code{nil}
@c have the opposite of their meanings in other functions. Here are the
@c full details:
$B0z?t(B@var{frame}$B$O!"$I$N%U%l!<%`$rBP>]$K$9$k$+$r;XDj$9$k!#(B
$B$3$N4X?t$O!"$9$Y$F$N%&%#%s%I%&$rAv::$9$kB>$N4X?t$HF1$8$h$&$K$O(B
@var{frame}$B$r;H$o$J$$!#(B
$BFC$K!"(B@code{t}$B$H(B@code{nil}$B$NCM$N0UL#$OB>$N4X?t$H$O5U$G$"$k!#(B
$B0J2<$K>\:Y$r<($9!#(B
@itemize @bullet
@item
@c If it is @code{nil}, operate on all frames.
@code{nil}$B$G$"$k$H!"$9$Y$F$N%U%l!<%`$rBP>]$K$9$k!#(B
@item
@c If it is @code{t}, operate on the selected frame.
@code{t}$B$G$"$k$H!"A*Br$5$l$F$$$k%U%l!<%`$rBP>]$K$9$k!#(B
@item
@c If it is @code{visible}, operate on all visible frames.
@code{visible}$B$G$"$k$H!"$9$Y$F$N2D;k%U%l!<%`$rBP>]$K$9$k!#(B
@item
@c If it is 0, operate on all visible or iconified frames.
0$B$G$"$k$H!"$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`$rBP>]$K$9$k!#(B
@item
@c If it is a frame, operate on that frame.
$B%U%l!<%`$G$"$k$H!"Ev3:%U%l!<%`$rBP>]$K$9$k!#(B
@end itemize
@c This function always returns @code{nil}.
$B$3$N4X?t$O$D$M$K(B@code{nil}$B$rJV$9!#(B
@end deffn
@node Selecting Windows
@c @section Selecting Windows
@section $B%&%#%s%I%&$NA*Br(B
@c @cindex selecting windows
@cindex $B%&%#%s%I%&$NA*Br(B
@c When a window is selected, the buffer in the window becomes the current
@c buffer, and the cursor will appear in it.
$B%&%#%s%I%&$rA*Br$9$k$H!"Ev3:%&%#%s%I%&$N%P%C%U%!$,%+%l%s%H%P%C%U%!$K$J$j!"(B
$B%+!<%=%k$,$=$N%&%#%s%I%&$K8=$l$^$9!#(B
@defun selected-window
@c This function returns the selected window. This is the window in
@c which the cursor appears and to which many commands apply.
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$rJV$9!#(B
$B%+!<%=%k$,I=<($5$lB?$/$N%3%^%s%I$,:nMQ$9$k%&%#%s%I%&$,$=$l$G$"$k!#(B
@end defun
@defun select-window window
@c This function makes @var{window} the selected window. The cursor then
@c appears in @var{window} (on redisplay). The buffer being displayed in
@c @var{window} is immediately designated the current buffer.
$B$3$N4X?t$O!"(B@var{window}$B$rA*Br$5$l$F$$$k%&%#%s%I%&$K$9$k!#(B
$B$9$k$H!"%+!<%=%k$O!J:FI=<($9$k$H!K(B@var{window}$B$K8=$l$k!#(B
@var{window}$B$KI=<($5$l$F$$$k%P%C%U%!$,$?$@$A$K%+%l%s%H%P%C%U%!$K$J$k!#(B
@c The return value is @var{window}.
$BLa$jCM$O(B@var{window}$B$G$"$k!#(B
@example
@group
(setq w (next-window))
(select-window w)
@result{} #<window 65 on windows.texi>
@end group
@end example
@end defun
@defmac save-selected-window forms@dots{}
@c This macro records the selected window, executes @var{forms}
@c in sequence, then restores the earlier selected window.
$B$3$N%^%/%m$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r5-O?$7$F!"(B
@var{forms}$B$r=g$K<B9T$7!"(B
$B$b$H$NA*Br$5$l$F$$$k%&%#%s%I%&$KLa$9!#(B
@c This macro does not save or restore anything about the sizes, arrangement
@c or contents of windows; therefore, if the @var{forms} change them,
@c the change persists.
$B$3$N%^%/%m$O!"%&%#%s%I%&%5%$%:!"G[CV!"FbMF$K4X$7$F(B
$B$$$C$5$$$J$K$bJ]B8$7$?$jI|85$7$J$$$N$G!"(B
@var{forms}$B$,$=$l$i$rJQ99$9$k$H$=$NJQ99$O;}B3$9$k!#(B
@c Each frame, at any time, has a window selected within the frame. This
@c macro saves only @emph{the} selected window; it does not save anything
@c about other frames. If the @var{forms} select some other frame and
@c alter the window selected within it, the change persists.
$B$"$k;~E@$G!"3F%U%l!<%`$K$O%U%l!<%`$NA*Br$5$l$F$$$k%&%#%s%I%&$,$"$k!#(B
$B$3$N%^%/%m$O!"A*Br$5$l$F$$$k%&%#%s%I%&(B@emph{$B$@$1(B}$B$rJ]B8$7!"(B
$BB>$N%U%l!<%`$K$D$$$F$O$J$K$bJ]B8$7$J$$!#(B
@var{forms}$B$,JL$N%U%l!<%`$rA*Br$7$F(B
$B$=$N%U%l!<%`$NA*Br$5$l$F$$$k%&%#%s%I%&$rJQ99$9$k$H!"$=$NJQ99$O;}B3$9$k!#(B
@end defmac
@c @cindex finding windows
@cindex $B%&%#%s%I%&$rC5$9(B
@c The following functions choose one of the windows on the screen,
@c offering various criteria for the choice.
$B0J2<$N4X?t$O!"$5$^$6$^>r7o$G%9%/%j!<%s>e$N%&%#%s%I%&$N(B1$B$D$rA*$S$^$9!#(B
@defun get-lru-window &optional frame
@c This function returns the window least recently ``used'' (that is,
@c selected). The selected window is always the most recently used window.
$B$3$N4X?t$O!"$b$C$H$b@N$K!X;H$o$l$?!Y(B
$B!J$D$^$jA*Br$5$l$F$$$?!K%&%#%s%I%&$rJV$9!#(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$O$D$M$K$b$C$H$b:G6a$K;H$o$l$?%&%#%s%I%&$G$"$k!#(B
@c The selected window can be the least recently used window if it is the
@c only window. A newly created window becomes the least recently used
@c window until it is selected. A minibuffer window is never a candidate.
$B%&%#%s%I%&$,$?$C$?(B1$B$D$G$"$k$H!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$,(B
$B$b$C$H$b@N$K;H$o$l$?%&%#%s%I%&$G$"$k$3$H$b$"$j$&$k!#(B
$B?7$?$K:n@.$5$l$?%&%#%s%I%&$O!"A*Br$5$l$k$^$G$O$b$C$H$b@N$K(B
$B;H$o$l$?%&%#%s%I%&$K$J$k!#(B
$B%_%K%P%C%U%!MQ%&%#%s%I%&$O8uJd$K$O$J$i$J$$!#(B
@c The argument @var{frame} controls which windows are considered.
$B0z?t(B@var{frame}$B$O!"$I$N%&%#%s%I%&$rBP>]$H$9$k$+$r@)8f$9$k!#(B
@itemize @bullet
@item
@c If it is @code{nil}, consider windows on the selected frame.
@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{t}, consider windows on all frames.
@code{t}$B$G$"$k$H!"$9$Y$F$N%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{visible}, consider windows on all visible frames.
@code{visible}$B$G$"$k$H!"(B
$B$9$Y$F$N2D;k%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is 0, consider windows on all visible or iconified frames.
0$B$G$"$k$H!"$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`(B
$B$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is a frame, consider windows on that frame.
$B%U%l!<%`$G$"$k$H!"Ev3:%U%l!<%`$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@end itemize
@end defun
@defun get-largest-window &optional frame
@c This function returns the window with the largest area (height times
@c width). If there are no side-by-side windows, then this is the window
@c with the most lines. A minibuffer window is never a candidate.
$B$3$N4X?t$O!"$b$C$H$bBg$-$JNN0h!J9b$5!_I}!K$N%&%#%s%I%&$rJV$9!#(B
$B:81&$KJB$s$@%&%#%s%I%&$,$J$1$l$P!"(B
$B$3$l$,$b$C$H$b9T?t$r;}$D%&%#%s%I%&$G$"$k!#(B
$B%_%K%P%C%U%!MQ%&%#%s%I%&$O8uJd$K$O$J$i$J$$!#(B
@c If there are two windows of the same size, then the function returns
@c the window that is first in the cyclic ordering of windows (see
@c following section), starting from the selected window.
$BF1$8Bg$-$5$N%&%#%s%I%&$,(B2$B$D$"$k>l9g!"(B
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$+$i;O$a$F(B
$B%&%#%s%I%&$N=d2s=g=x!J<!@a;2>H!K$G:G=i$N%&%#%s%I%&$rJV$9!#(B
@c The argument @var{frame} controls which set of windows to
@c consider. See @code{get-lru-window}, above.
$B0z?t(B@var{frame}$B$O!"%&%#%s%I%&$N$I$N$h$&$J=8$^$j$rBP>]$K$9$k$+$r;XDj$9$k!#(B
$B$&$($N(B@code{get-lru-window}$B$r;2>H!#(B
@end defun
@node Cyclic Window Ordering
@comment node-name, next, previous, up
@c @section Cyclic Ordering of Windows
@section $B%&%#%s%I%&$N=d2s=g=x(B
@c @cindex cyclic ordering of windows
@c @cindex ordering of windows, cyclic
@c @cindex window ordering, cyclic
@cindex $B%&%#%s%I%&$N=d2s=g=x(B
@cindex $B=g=x!"%&%#%s%I%&(B
@cindex $B=d2s=g=x!"%&%#%s%I%&(B
@c When you use the command @kbd{C-x o} (@code{other-window}) to select
@c the next window, it moves through all the windows on the screen in a
@c specific cyclic order. For any given configuration of windows, this
@c order never varies. It is called the @dfn{cyclic ordering of windows}.
$B$D$.$N%&%#%s%I%&$rA*Br$9$k$?$a$K%3%^%s%I(B@kbd{C-x o}$B!J(B@code{other-window}$B!K$r(B
$B;H$&$H!"%9%/%j!<%s>e$N$9$Y$F$N%&%#%s%I%&$r$"$k=d2s=g=x$G=d$j$^$9!#(B
$B%&%#%s%I%&$N$"$k9=@.$K$*$$$F!"$3$N=g=x$OJQ$o$j$^$;$s!#(B
$B$3$l$r(B@dfn{$B%&%#%s%I%&$N=d2s=g=x(B}$B!J(Bcyclic ordering of windows$B!K$H8F$S$^$9!#(B
@c This ordering generally goes from top to bottom, and from left to
@c right. But it may go down first or go right first, depending on the
@c order in which the windows were split.
$B$3$N=gHV$O0lHL$K>e$+$i2<!":8$+$i1&$K$J$j$^$9!#(B
$B$7$+$7!"%&%#%s%I%&$rJ,3d$7$?=gHV$K0MB8$7$F!"(B
$B2<$d1&$,:G=i$K$J$k$3$H$b$"$j$^$9!#(B
@c If the first split was vertical (into windows one above each other),
@c and then the subwindows were split horizontally, then the ordering is
@c left to right in the top of the frame, and then left to right in the
@c next lower part of the frame, and so on. If the first split was
@c horizontal, the ordering is top to bottom in the left part, and so on.
@c In general, within each set of siblings at any level in the window tree,
@c the order is left to right, or top to bottom.
$B:G=i$K>e2<$KJ,3d$7$F$D$.$K:81&$KJ,3d$9$k$H!"(B
$B=gHV$O!"%U%l!<%`$N>eB&$G:8$+$i1&!"%U%l!<%`$N$=$N2<$G$O:8$+$i1&(B
$B$H$$$C$?6q9g$K$J$j$^$9!#(B
$B:G=i$K:81&$KJ,3d$9$k$H!"(B
$B=gHV$O!"%U%l!<%`$N:8B&$G>e$+$i2<$H$$$C$?6q9g$K$J$j$^$9!#(B
$B0lHL$K!"%&%#%s%I%&LZ$N$"$k%l%Y%k$GJ,3d$5$l$?3F7;Do$NCf$G$O!"(B
$B=gHV$O!":8$+$i1&!"$"$k$$$O!">e$+$i2<$K$J$j$^$9!#(B
@defun next-window &optional window minibuf all-frames
@c @cindex minibuffer window
@cindex $B%_%K%P%C%U%!MQ%&%#%s%I%&(B
@c This function returns the window following @var{window} in the cyclic
@c ordering of windows. This is the window that @kbd{C-x o} would select
@c if typed when @var{window} is selected. If @var{window} is the only
@c window visible, then this function returns @var{window}. If omitted,
@c @var{window} defaults to the selected window.
$B$3$N4X?t$O!"%&%#%s%I%&$N=d2s=g=x$K$*$$$F(B@var{window}$B$N$D$.$N(B
$B%&%#%s%I%&$rJV$9!#(B
$B$3$l$O!"(B@var{window}$B$,A*Br$5$l$F$$$k$H$-$K(B
@kbd{C-x o}$B$,A*Br$9$k$G$"$m$&%&%#%s%I%&$G$"$k!#(B
@var{window}$B$,M#0l$N2D;k%&%#%s%I%&$G$"$k$H!"(B
$B$3$N4X?t$O(B@var{window}$B$rJV$9!#(B
@var{window}$B$r>JN,$9$k$H!"%G%U%)%k%H$OA*Br$5$l$F$$$k%&%#%s%I%&$G$"$k!#(B
@c The value of the argument @var{minibuf} determines whether the
@c minibuffer is included in the window order. Normally, when
@c @var{minibuf} is @code{nil}, the minibuffer is included if it is
@c currently active; this is the behavior of @kbd{C-x o}. (The minibuffer
@c window is active while the minibuffer is in use. @xref{Minibuffers}.)
$B0z?t(B@var{minibuf}$B$NCM$O!"%_%K%P%C%U%!$r(B
$B%&%#%s%I%&$N=g=x$K4^$a$k$+$I$&$+$r7hDj$9$k!#(B
@var{minibuf}$B$,(B@code{nil}$B$G$"$k$H!"(B
$B%_%K%P%C%U%!$,3h@-$G$"$k$H$-$K$O%_%K%P%C%U%!$r4^$a$k!#(B
$B$3$l$O(B@kbd{C-x o}$B$N$U$k$^$$$G$"$k!#(B
$B!J%_%K%P%C%U%!$,;H$o$l$F$$$k$"$$$@$O!"(B
$B%_%K%P%C%U%!MQ%&%#%s%I%&$O3h@-$G$"$k!#(B
@pxref{Minibuffers}$B!#!K(B
@c If @var{minibuf} is @code{t}, then the cyclic ordering includes the
@c minibuffer window even if it is not active.
@var{minibuf}$B$,(B@code{t}$B$G$"$k$H!"(B
$B%_%K%P%C%U%!$,3h@-$G$J$/$F$b=d2s=g=x$K%_%K%P%C%U%!MQ%&%#%s%I%&$r4^$a$k!#(B
@c If @var{minibuf} is neither @code{t} nor @code{nil}, then the minibuffer
@c window is not included even if it is active.
@var{minibuf}$B$,(B@code{t}$B$G$b(B@code{nil}$B$G$b$J$$$H!"(B
$B3h@-$G$"$C$F$b%_%K%P%C%U%!MQ%&%#%s%I%&$r4^$a$J$$!#(B
@c The argument @var{all-frames} specifies which frames to consider. Here
@c are the possible values and their meanings:
$B0z?t(B@var{all-frames}$B$O!"$I$N%U%l!<%`$rBP>]$K$9$k$+$r;XDj$9$k!#(B
$B2DG=$JCM$H$=$N0UL#$r0J2<$K<($9!#(B
@table @asis
@item @code{nil}
@c Consider all the windows in @var{window}'s frame, plus the minibuffer
@c used by that frame even if it lies in some other frame.
@var{window}$B$N%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$K2C$($F!"(B
$B%_%K%P%C%U%!$,$I$3$KCV$+$l$F$$$h$&$H(B
$BEv3:%U%l!<%`$,;H$C$F$$$k%_%K%P%C%U%!$rBP>]$K$9$k!#(B
@item @code{t}
@c Consider all windows in all existing frames.
$B4{B8$N$9$Y$F$N%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item @code{visible}
@c Consider all windows in all visible frames. (To get useful results, you
@c must ensure @var{window} is in a visible frame.)
$B$9$Y$F$N2D;k%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$rBP>]$K$9$k!#(B
$B!J7k2L$,M-MQ$G$"$k$?$a$K$O!"2D;k%U%l!<%`$K(B@var{window}$B$,$"$k$3$H!K(B
@item 0
@c Consider all windows in all visible or iconified frames.
$B$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`$N(B
$B$9$Y$F$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@c @item anything else
@item $B$=$NB>(B
@c Consider precisely the windows in @var{window}'s frame, and no others.
@var{window}$B$N%U%l!<%`$@$1$N%&%#%s%I%&$r@53N$KBP>]$K$9$k!#(B
@end table
@c This example assumes there are two windows, both displaying the
@c buffer @samp{windows.texi}:
$B$D$.$NNc$G$O!"(B2$B$D$N%&%#%s%I%&$,$"$j!"(B
$B$I$A$i$b%P%C%U%!(B@samp{windows.texi}$B$rI=<($7$F$$$k$H2>Dj$9$k!#(B
@example
@group
(selected-window)
@result{} #<window 56 on windows.texi>
@end group
@group
(next-window (selected-window))
@result{} #<window 52 on windows.texi>
@end group
@group
(next-window (next-window (selected-window)))
@result{} #<window 56 on windows.texi>
@end group
@end example
@end defun
@defun previous-window &optional window minibuf all-frames
@c This function returns the window preceding @var{window} in the cyclic
@c ordering of windows. The other arguments specify which windows to
@c include in the cycle, as in @code{next-window}.
$B$3$N4X?t$O!"%&%#%s%I%&$N=d2s=g=x$K$*$$$F(B@var{window}$B$N$^$($N(B
$B%&%#%s%I%&$rJV$9!#(B
$BB>$N0z?t$O!"(B@code{next-window}$B$HF1MM$K!"(B
$B$I$N$h$&$J%&%#%s%I%&$r=d2s$K4^$a$k$+$r;XDj$9$k!#(B
@end defun
@c @deffn Command other-window count
@deffn $B%3%^%s%I(B other-window count
@c This function selects the @var{count}th following window in the cyclic
@c order. If count is negative, then it moves back @minus{}@var{count}
@c windows in the cycle, rather than forward. It returns @code{nil}.
$B$3$N4X?t$O!"%&%#%s%I%&$N=d2s=g=x$K$*$$$F(B@var{count}$BHVL\$&$7$m$N(B
$B%&%#%s%I%&$rA*Br$9$k!#(B
@var{count}$B$,Ii$G$"$k$H!"=d2s=g=x$K$*$$$F(B
@minus{}@var{count}$BHVL\$^$($N%&%#%s%I%&$KLa$k!#(B
$B$3$N4X?t$O(B@code{nil}$B$rJV$9!#(B
@c In an interactive call, @var{count} is the numeric prefix argument.
$BBPOCE*$K8F$S=P$9$H!"(B@var{count}$B$O?tCMA0CV0z?t$G$"$k!#(B
@end deffn
@c Emacs 19 feature
@defun walk-windows proc &optional minibuf all-frames
@c This function cycles through all windows, calling @code{proc}
@c = $B8m?"!)(B @var{proc}
@c once for each window with the window as its sole argument.
$B$3$N4X?t$O!"3F%&%#%s%I%&$4$H$KEv3:%&%#%s%I%&$rM#0l$N0z?t$H$7$F(B
@var{proc}$B$r8F$S=P$7$F$9$Y$F$N%&%#%s%I%&$r=d$k!#(B
@c The optional arguments @var{minibuf} and @var{all-frames} specify the
@c set of windows to include in the scan. See @code{next-window}, above,
@c for details.
$B>JN,2DG=$J0z?t(B@var{minibuf}$B$H(B@var{all-frames}$B$O!"(B
$BAv::$9$k%&%#%s%I%&$N=8$^$j$r;XDj$9$k!#(B
$B>\$7$/$O>e5-$N(B@code{next-window}$B$r;2>H!#(B
@end defun
@node Buffers and Windows
@c @section Buffers and Windows
@section $B%P%C%U%!$H%&%#%s%I%&(B
@c @cindex examining windows
@c @cindex windows, controlling precisely
@c @cindex buffers, controlled in windows
@cindex $B%&%#%s%I%&$rD4$Y$k(B
@cindex $B%&%#%s%I%&!"@53N$K@)8f$9$k(B
@cindex $B%P%C%U%!!"%&%#%s%I%&$G@)8f$5$l$k(B
@c This section describes low-level functions to examine windows or to
@c display buffers in windows in a precisely controlled fashion.
$BK\@a$G$O!"%&%#%s%I%&$rD4$Y$?$j!"(B
$B@53N$K@)8f$7$F%&%#%s%I%&$K%P%C%U%!$rI=<($9$kDc%l%Y%k$N4X?t$K$D$$$F=R$Y$^$9!#(B
$B;HMQ$9$k%&%#%s%I%&$rC5$7$?$j$=$l$K%P%C%U%!$r;XDj$9$k4XO"$9$k4X?t$K$D$$$F$O!"(B
@iftex
@c See the following section for
$B<!@a$r;2>H$7$F$/$@$5$$!#(B
@end iftex
@ifinfo
@c @xref{Displaying Buffers}, for
@xref{Displaying Buffers}$B!#(B
@end ifinfo
@c related functions that find a window to use and specify a buffer for it.
@c The functions described there are easier to use than these, but they
@c employ heuristics in choosing or creating a window; use these functions
@c when you need complete control.
$B$=$3$K=R$Y$?4X?t$OK\@a$N4X?t$h$j4JC1$K;H$($^$9$,!"(B
$B$=$l$i$O%&%#%s%I%&$rA*$s$@$j:n$C$?$j$9$k$H$-$KH/8+E*<jK!$r;H$$$^$9!#(B
$B40A4$K@)8f$9$kI,MW$,$"$k$H$-$K$O!"K\@a$N4X?t$r;H$$$^$9!#(B
@defun set-window-buffer window buffer-or-name
@c This function makes @var{window} display @var{buffer-or-name} as its
@c contents. It returns @code{nil}. This is the fundamental primitive
@c for changing which buffer is displayed in a window, and all ways
@c of doing that call this function.
$B$3$N4X?t$O!"(B@var{window}$B$NFbMF$H$7$F(B@var{buffer-or-name}$B$rI=<($9$k$h$&$K$9$k!#(B
$B$3$N4X?t$O(B@code{nil}$B$rJV$9!#(B
$B$3$l$O!"%&%#%s%I%&$KI=<($9$k%P%C%U%!$r@Z$jBX$($k(B
$B$b$C$H$b4pK\$N4pK\4X?t$G$"$j!"(B
$BB>$N@Z$jBX$(4X?t$O$3$N4X?t$r8F$S=P$9!#(B
@example
@group
(set-window-buffer (selected-window) "foo")
@result{} nil
@end group
@end example
@end defun
@defun window-buffer &optional window
@c This function returns the buffer that @var{window} is displaying. If
@c @var{window} is omitted, this function returns the buffer for the
@c selected window.
$B$3$N4X?t$O!"(B@var{window}$B$KI=<($7$F$$$k%P%C%U%!$rJV$9!#(B
@var{window}$B$r>JN,$9$k$H!"$3$N4X?t$OA*Br$5$l$F$$$k%&%#%s%I%&$N%P%C%U%!$rJV$9!#(B
@example
@group
(window-buffer)
@result{} #<buffer windows.texi>
@end group
@end example
@end defun
@defun get-buffer-window buffer-or-name &optional all-frames
@c This function returns a window currently displaying
@c @var{buffer-or-name}, or @code{nil} if there is none. If there are
@c several such windows, then the function returns the first one in the
@c cyclic ordering of windows, starting from the selected window.
@c @xref{Cyclic Window Ordering}.
$B$3$N4X?t$O!"8=:_(B@var{buffer-or-name}$B$rI=<($7$F$$$k%&%#%s%I%&$rJV$9!#(B
$B$=$N$h$&$J%&%#%s%I%&$,$J$1$l$P(B@code{nil}$B$rJV$9!#(B
$B$=$N$h$&$J%&%#%s%I%&$,J#?t$"$k>l9g!"(B
$B%&%#%s%I%&$N=d2s=g=x$K$*$$$FA*Br$5$l$F$$$k%&%#%s%I%&$+$i;O$a$F(B
$B:G=i$K$_$D$+$C$?%&%#%s%I%&$rJV$9!#(B
@pxref{Cyclic Window Ordering}$B!#(B
@c The argument @var{all-frames} controls which windows to consider.
$B0z?t(B@var{all-frames}$B$O!"$I$N%&%#%s%I%&$rBP>]$H$9$k$+$r@)8f$9$k!#(B
@itemize @bullet
@item
@c If it is @code{nil}, consider windows on the selected frame.
@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{t}, consider windows on all frames.
@code{t}$B$G$"$k$H!"$9$Y$F$N%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{visible}, consider windows on all visible frames.
@code{visible}$B$G$"$k$H!"(B
$B$9$Y$F$N2D;k%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is 0, consider windows on all visible or iconified frames.
0$B$G$"$k$H!"$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`(B
$B$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is a frame, consider windows on that frame.
$B%U%l!<%`$G$"$k$H!"Ev3:%U%l!<%`$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@end itemize
@end defun
@defun get-buffer-window-list buffer-or-name &optional minibuf all-frames
@c This function returns a list of all the windows currently displaying
@c @var{buffer-or-name}.
$B$3$N4X?t$O!"8=:_(B@var{buffer-or-name}$B$rI=<($7$F$$$k(B
$B$9$Y$F$N%&%#%s%I%&$N%j%9%H$rJV$9!#(B
@c The two optional arguments work like the optional arguments of
@c @code{next-window} (@pxref{Cyclic Window Ordering}); they are @emph{not}
@c like the single optional argument of @code{get-buffer-window}. Perhaps
@c we should change @code{get-buffer-window} in the future to make it
@c compatible with the other functions.
$B>JN,2DG=$J(B2$B$D$N0z?t$O!"(B@code{next-window}$B!J(B@pxref{Cyclic Window Ordering}$B!K$N(B
$B>JN,2DG=$J0z?t$HF1MM$KF/$-!"(B
@code{get-buffer-window}$B$N>JN,2DG=$JC10l$N0z?t$HF1$8$G$O(B@emph{$B$J$$(B}$B!#(B
@code{get-buffer-window}$B$rB>$N4X?t$H8_49@-$,$"$k$h$&$K(B
$B>-MhJQ99$9$Y$-$J$N$G$"$m$&!#(B
@c The argument @var{all-frames} controls which windows to consider.
$B0z?t(B@var{all-frames}$B$O!"$I$N%&%#%s%I%&$rBP>]$H$9$k$+$r@)8f$9$k!#(B
@itemize @bullet
@item
@c If it is @code{nil}, consider windows on the selected frame.
@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{t}, consider windows on all frames.
@code{t}$B$G$"$k$H!"$9$Y$F$N%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{visible}, consider windows on all visible frames.
@code{visible}$B$G$"$k$H!"(B
$B$9$Y$F$N2D;k%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is 0, consider windows on all visible or iconified frames.
0$B$G$"$k$H!"$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`(B
$B$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is a frame, consider windows on that frame.
$B%U%l!<%`$G$"$k$H!"Ev3:%U%l!<%`$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@end itemize
@end defun
@defvar buffer-display-time
@tindex buffer-display-time
@c This variable records the time at which a buffer was last made visible
@c in a window. It is always local in each buffer; each time
@c @code{set-window-buffer} is called, it sets this variable to
@c @code{(current-time)} in the specified buffer (@pxref{Time of Day}).
@c When a buffer is first created, @code{buffer-display-time} starts out
@c with the value @code{nil}.
$B$3$NJQ?t$O!"%P%C%U%!$,%&%#%s%I%&$G8+$($k$h$&$K$J$C$?:G8e$N;~9o$r5-O?$9$k!#(B
$B$3$NJQ?t$O3F%P%C%U%!$G$D$M$K%P%C%U%!%m!<%+%k$G$"$j!"(B
@code{set-window-buffer}$B$O!"8F$P$l$k$?$S$K(B
$B;XDj$5$l$?%P%C%U%!$N$3$NJQ?t$K(B@code{(current-time)}$B$r@_Dj$9$k(B
$B!J(B@pxref{Time of Day}$B!K!#(B
$B%P%C%U%!$,=i$a$F:n$i$l$k$H!"(B@code{buffer-display-time}$B$OCM(B@code{nil}$B$G;O$^$k!#(B
@end defvar
@node Displaying Buffers
@c @section Displaying Buffers in Windows
@section $B%&%#%s%I%&$X$N%P%C%U%!$NI=<((B
@c @cindex switching to a buffer
@c @cindex displaying a buffer
@cindex $B%P%C%U%!$N@Z$jBX$((B
@cindex $B%P%C%U%!$NI=<((B
@c In this section we describe convenient functions that choose a window
@c automatically and use it to display a specified buffer. These functions
@c can also split an existing window in certain circumstances. We also
@c describe variables that parameterize the heuristics used for choosing a
@c window.
$BK\@a$G$O!"%&%#%s%I%&$r<+F0E*$KA*$S$=$l$K;XDj$7$?%P%C%U%!$rI=<($9$k(B
$BJXMx$J4X?t$K$D$$$F=R$Y$^$9!#(B
$B$3$l$i$N4X?t$O!"$"$k>u67$G$O!"4{B8$N%&%#%s%I%&$rJ,3d$7$^$9!#(B
$B%&%#%s%I%&$rA*$V:]$NH/8+E*<jK!$r@)8f$9$kJQ?t$K$D$$$F$b=R$Y$^$9!#(B
$B$h$j@53N$K@)8f$9$k$?$a$NDc%l%Y%k$N4X?t$K$D$$$F$O!"(B
@iftex
@c See the preceding section for
$BA0@a$r;2>H$7$F$/$@$5$$!#(B
@end iftex
@ifinfo
@c @xref{Buffers and Windows}, for
@xref{Buffers and Windows}$B!#(B
@end ifinfo
@c low-level functions that give you more precise control. All of these
@c functions work by calling @code{set-window-buffer}.
$B$3$l$i$N4X?t$O$9$Y$F(B@code{set-window-buffer}$B$r8F$S=P$7$FF0:n$7$^$9!#(B
@c Do not use the functions in this section in order to make a buffer
@c current so that a Lisp program can access or modify it; they are too
@c drastic for that purpose, since they change the display of buffers in
@c windows, which would be gratuitous and surprise the user. Instead, use
@c @code{set-buffer} and @code{save-current-buffer} (@pxref{Current
@c Buffer}), which designate buffers as current for programmed access
@c without affecting the display of buffers in windows.
$B%P%C%U%!$r%+%l%s%H%P%C%U%!$K$7$F(BLisp$B%W%m%0%i%`$G;2>H$7$?$jJQ99$G$-$k$h$&$K(B
$B$9$k$?$a$K$O!"K\@a$N4X?t$r;H$o$J$$$G$/$@$5$$!#(B
$B$3$l$i$O$=$NL\E*$K$O6/NO$9$.$^$9!#(B
$B%&%#%s%I%&$N%P%C%U%!$NI=<($r%f!<%6!<$K$H$C$F$OLBOG$G6C$/$h$&$J$b$N$K(B
$BJQ99$7$F$7$^$&$+$i$G$9!#(B
$B$=$N$+$o$j$K!"%&%#%s%I%&$N%P%C%U%!$NI=<($K$O1F6A$;$:$K(B
$B%P%C%U%!$r%W%m%0%i%`$+$i;2>H$9$k$?$a$K%+%l%s%H%P%C%U%!$K$9$k(B
@code{set-buffer}$B$H(B@code{save-current-buffer}$B!J(B@pxref{Current Buffer}$B!K$r(B
$B;H$$$^$9!#(B
@c @deffn Command switch-to-buffer buffer-or-name &optional norecord
@deffn $B%3%^%s%I(B switch-to-buffer buffer-or-name &optional norecord
@c This function makes @var{buffer-or-name} the current buffer, and also
@c displays the buffer in the selected window. This means that a human can
@c see the buffer and subsequent keyboard commands will apply to it.
@c Contrast this with @code{set-buffer}, which makes @var{buffer-or-name}
@c the current buffer but does not display it in the selected window.
@c @xref{Current Buffer}.
$B$3$N4X?t$O!"(B@var{buffer-or-name}$B$r%+%l%s%H%P%C%U%!$K$7!"(B
$B$5$i$K!"A*Br$5$l$F$$$k%&%#%s%I%&$KEv3:%P%C%U%!$rI=<($9$k!#(B
$B$D$^$j!"?M4V$,Ev3:%P%C%U%!$r8+$k$3$H$,$G$-$k$h$&$K$J$j!"(B
$B0J9_$N%-!<%\!<%I%3%^%s%I$OEv3:%P%C%U%!$KE,MQ$5$l$k!#(B
@var{buffer-or-name}$B$r%+%l%s%H%P%C%U%!$K$9$k$,(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$K$OI=<($7$J$$(B@code{set-buffer}$B$HHf3S$7$F$[$7$$!#(B
@pxref{Current Buffer}$B!#(B
@c If @var{buffer-or-name} does not identify an existing buffer, then a new
@c buffer by that name is created. The major mode for the new buffer is
@c set according to the variable @code{default-major-mode}. @xref{Auto
@c Major Mode}.
@var{buffer-or-name}$B$,4{B8$N%P%C%U%!$r;XDj$7$J$1$l$P!"(B
$B$=$NL>A0$N?7$?$J%P%C%U%!$,:n@.$5$l$k!#(B
$B?7$?$J%P%C%U%!$N%a%8%c!<%b!<%I$OJQ?t(B@code{default-major-mode}$B$K(B
$B=>$C$F@_Dj$5$l$k!#(B
@pxref{Auto Major Mode}$B!#(B
@c Normally the specified buffer is put at the front of the buffer list
@c (both the selected frame's buffer list and the frame-independent buffer
@c list). This affects the operation of @code{other-buffer}. However, if
@c @var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer
@c List}.
$BDL>o!";XDj$7$?%P%C%U%!$O%P%C%U%!%j%9%H(B
$B!JA*Br$5$l$F$$$k%U%l!<%`$N%P%C%U%!%j%9%H$H%U%l!<%`FHN)$N%P%C%U%!%j%9%H$N(B
$BN>J}!K$N@hF,$KCV$+$l$k!#(B
$B$3$l$O!"(B@code{other-buffer}$B$NF0:n$K1F6A$9$k!#(B
$B$7$+$7!"(B@var{norecord}$B$,(B@code{nil}$B0J30$G$"$k$H!"$3$l$r9T$o$J$$!#(B
@pxref{The Buffer List}$B!#(B
@c The @code{switch-to-buffer} function is often used interactively, as
@c the binding of @kbd{C-x b}. It is also used frequently in programs. It
@c always returns @code{nil}.
$B4X?t(B@code{switch-to-buffer}$B$O!"$7$P$7$P!"(B
@kbd{C-x b}$B$K%P%$%s%I$5$l$FBPOCE*$K;H$o$l$k!#(B
$B%W%m%0%i%`$G$bB?MQ$5$l$k!#(B
$B$D$M$K(B@code{nil}$B$rJV$9!#(B
@end deffn
@c @deffn Command switch-to-buffer-other-window buffer-or-name &optional norecord
@deffn $B%3%^%s%I(B switch-to-buffer-other-window buffer-or-name &optional norecord
@c This function makes @var{buffer-or-name} the current buffer and
@c displays it in a window not currently selected. It then selects that
@c window. The handling of the buffer is the same as in
@c @code{switch-to-buffer}.
$B$3$N4X?t$O!"(B@var{buffer-or-name}$B$r%+%l%s%H%P%C%U%!$K$7!"(B
$B8=:_A*Br$5$l$F$$$J$$%&%#%s%I%&$KEv3:%P%C%U%!$rI=<($9$k!#(B
$B$=$7$FEv3:%&%#%s%I%&$rA*Br$9$k!#(B
$B%P%C%U%!$N07$$J}$O(B@code{switch-to-buffer}$B$HF1$8$G$"$k!#(B
@c The currently selected window is absolutely never used to do the job.
@c If it is the only window, then it is split to make a distinct window for
@c this purpose. If the selected window is already displaying the buffer,
@c then it continues to do so, but another window is nonetheless found to
@c display it in as well.
$B8=:_A*Br$5$l$F$$$k%&%#%s%I%&$O!"$3$N=hM}$K$O@dBP$K;H$o$J$$!#(B
$B$=$l$,M#0l$N%&%#%s%I%&$G$"$k>l9g$K$O!"$3$NL\E*$N$?$a$K(B
$B%&%#%s%I%&$rJ,3d$7$FJL$N%&%#%s%I%&$r:n$k!#(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$,$9$G$KEv3:%P%C%U%!$rI=<($7$F$$$k>l9g$K$O!"(B
$BEv3:%&%#%s%I%&$O$=$N$^$^I=<($7B3$1$k$,!"$=$l$K$b4X$o$i$:!"(B
$BI=<($9$k$?$a$KJL$N%&%#%s%I%&$rC5$9!#(B
@c This function updates the buffer list just like @code{switch-to-buffer}
@c unless @var{norecord} is non-@code{nil}.
$B$3$N4X?t$O!"(B@var{norecord}$B$,(B@code{nil}$B$G$"$k$H!"(B
@code{switch-to-buffer}$B$N$h$&$K%P%C%U%!%j%9%H$r99?7$9$k!#(B
@end deffn
@defun pop-to-buffer buffer-or-name &optional other-window norecord
@c This function makes @var{buffer-or-name} the current buffer and
@c switches to it in some window, preferably not the window previously
@c selected. The ``popped-to'' window becomes the selected window within
@c its frame.
$B$3$N4X?t$O!"(B@var{buffer-or-name}$B$r%+%l%s%H%P%C%U%!$K$7!"(B
$B0JA0$K$OA*Br$5$l$F$$$J$$JL$N%&%#%s%I%&$GEv3:%P%C%U%!$K@Z$jBX$($k!#(B
$B$=$N%&%#%s%I%&$,$=$N%U%l!<%`$NA*Br$5$l$F$$$k%&%#%s%I%&$K$J$k!#(B
@c If the variable @code{pop-up-frames} is non-@code{nil},
@c @code{pop-to-buffer} looks for a window in any visible frame already
@c displaying the buffer; if there is one, it returns that window and makes
@c it be selected within its frame. If there is none, it creates a new
@c frame and displays the buffer in it.
$BJQ?t(B@code{pop-up-frames}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
@code{pop-to-buffer}$B$O!"2D;k%U%l!<%`$+$i(B
$BEv3:%P%C%U%!$r$9$G$KI=<($7$F$$$k%&%#%s%I%&$rC5$9!#(B
$B$=$N$h$&$J%&%#%s%I%&$,$"$l$P!"$=$N%&%#%s%I%&$rJV$9$H$H$b$K!"(B
$B$=$N%&%#%s%I%&$r$=$N%U%l!<%`$NA*Br$5$l$F$$$k%&%#%s%I%&$K$9$k!#(B
$B$=$N$h$&$J%&%#%s%I%&$,$J$1$l$P!"?7$?$J%U%l!<%`$r:n@.$7(B
$B$=$l$K%P%C%U%!$rI=<($9$k!#(B
@c If @code{pop-up-frames} is @code{nil}, then @code{pop-to-buffer}
@c operates entirely within the selected frame. (If the selected frame has
@c just a minibuffer, @code{pop-to-buffer} operates within the most
@c recently selected frame that was not just a minibuffer.)
@code{pop-up-frames}$B$,(B@code{nil}$B$G$"$k$H!"(B
@code{pop-to-buffer}$B$OA*Br$5$l$F$$$k%U%l!<%`Fb$@$1$G=hM}$r9T$&!#(B
$B!JA*Br$5$l$F$$$k%U%l!<%`$,%_%K%P%C%U%!$N$_$G$"$k$H$-$K$O!"(B
@code{pop-to-buffer}$B$O!"%_%K%P%C%U%!$N$_$G$J$$(B
$B$b$C$H$b:G6a$KA*Br$5$l$?%U%l!<%`Fb$G=hM}$9$k!#!K(B
@c If the variable @code{pop-up-windows} is non-@code{nil}, windows may
@c be split to create a new window that is different from the original
@c window. For details, see @ref{Choosing Window}.
$BJQ?t(B@code{pop-up-windows}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B$b$H$N%&%#%s%I%&$H$O0[$J$k?7$?$J%&%#%s%I%&$r:n@.$9$k$?$a$K(B
$B%&%#%s%I%&$rJ,3d$9$k$3$H$,$"$k!#(B
$B>\$7$/$O!"(B@ref{Choosing Window}$B$r;2>H!#(B
@c If @var{other-window} is non-@code{nil}, @code{pop-to-buffer} finds or
@c creates another window even if @var{buffer-or-name} is already visible
@c in the selected window. Thus @var{buffer-or-name} could end up
@c displayed in two windows. On the other hand, if @var{buffer-or-name} is
@c already displayed in the selected window and @var{other-window} is
@c @code{nil}, then the selected window is considered sufficient display
@c for @var{buffer-or-name}, so that nothing needs to be done.
@var{other-window}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$K(B@var{buffer-or-name}$B$,$9$G$KI=<($5$l$F$$$F$b!"(B
@code{pop-to-buffer}$B$OJL$N%&%#%s%I%&$rC5$7$?$j:n@.$9$k!#(B
$B$=$N$?$a!"(B@var{buffer-or-name}$B$O(B2$B$D$N%&%#%s%I%&$KI=<($5$l$k$3$H$K$J$k!#(B
$B0lJ}$G!"(B@var{buffer-or-name}$B$,A*Br$5$l$F$$$k%&%#%s%I%&$K(B
$B$9$G$KI=<($5$l$F$$$F!"$+$D!"(B@var{other-window}$B$,(B@code{nil}$B$G$"$k$H!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$O(B@var{buffer-or-name}$B$NI=<($K$O==J,$G$"$k$H$_$J$7!"(B
$B$J$K$b9T$o$J$$!#(B
@c All the variables that affect @code{display-buffer} affect
@c @code{pop-to-buffer} as well. @xref{Choosing Window}.
@code{display-buffer}$B$K1F6A$9$k$9$Y$F$NJQ?t$O!"(B
@code{pop-to-buffer}$B$K$b1F6A$9$k!#(B
@pxref{Choosing Window}$B!#(B
@c If @var{buffer-or-name} is a string that does not name an existing
@c buffer, a buffer by that name is created. The major mode for the new
@c buffer is set according to the variable @code{default-major-mode}.
@c @xref{Auto Major Mode}.
@var{buffer-or-name}$B$,J8;zNs$G$"$j4{B8$N%P%C%U%!$r;XDj$7$J$$>l9g!"(B
$B$=$NL>A0$N%P%C%U%!$r:n@.$9$k!#(B
$B?7$?$J%P%C%U%!$N%a%8%c!<%b!<%I$OJQ?t(B@code{default-major-mode}$B$K(B
$B=>$C$F@_Dj$5$l$k!#(B
@pxref{Auto Major Mode}$B!#(B
@c This function updates the buffer list just like @code{switch-to-buffer}
@c unless @var{norecord} is non-@code{nil}.
$B$3$N4X?t$O!"(B@var{norecord}$B$,(B@code{nil}$B$G$"$k$H!"(B
@code{switch-to-buffer}$B$N$h$&$K%P%C%U%!%j%9%H$r99?7$9$k!#(B
@end defun
@c @deffn Command replace-buffer-in-windows buffer
@deffn $B%3%^%s%I(B replace-buffer-in-windows buffer
@c This function replaces @var{buffer} with some other buffer in all
@c windows displaying it. The other buffer used is chosen with
@c @code{other-buffer}. In the usual applications of this function, you
@c don't care which other buffer is used; you just want to make sure that
@c @var{buffer} is no longer displayed.
$B$3$N4X?t$O!"(B@var{buffer}$B$rI=<($7$F$$$k$9$Y$F$N%&%#%s%I%&$K$*$$$F(B
@var{buffer}$B$rJL$N%P%C%U%!$K@Z$jBX$($k!#(B
$BJL$N%P%C%U%!$O(B@code{other-buffer}$B$GA*$V!#(B
$B$3$N4X?t$NIaDL$NMQES$O!"JL$N%P%C%U%!$,$I$l$K$J$k$+5$$K$7$J$$>l9g$G$"$k!#(B
$B$D$^$j!"(B@var{buffer}$B$,I=<($5$l$F$$$J$$$3$H$rJ]>Z$7$?$$>l9g$G$"$k!#(B
@c This function returns @code{nil}.
$B$3$N4X?t$O(B@code{nil}$B$rJV$9!#(B
@end deffn
@node Choosing Window
@c @section Choosing a Window for Display
@section $BI=<(%&%#%s%I%&$rA*$V(B
@c This section describes the basic facility that chooses a window to
@c display a buffer in---@code{display-buffer}. All the higher-level
@c functions and commands use this subroutine. Here we describe how to use
@c @code{display-buffer} and how to customize it.
$BK\@a$G$O!"%P%C%U%!$rI=<($9$k$?$a$N%&%#%s%I%&$rA*$V$?$a$N4pK\E*$J5!G=!"(B
@code{display-buffer}$B$K$D$$$F=R$Y$^$9!#(B
$B>e0L%l%Y%k$N4X?t$d%3%^%s%I$O$9$Y$F$3$N%5%V%k!<%F%#%s$r;H$$$^$9!#(B
$B$3$3$G$O!"(B@code{display-buffer}$B$N;H$$J}$H%+%9%?%^%$%:J}K!$r@bL@$7$^$9!#(B
@c @deffn Command display-buffer buffer-or-name &optional not-this-window frame
@deffn $B%3%^%s%I(B display-buffer buffer-or-name &optional not-this-window frame
@c This command makes @var{buffer-or-name} appear in some window, like
@c @code{pop-to-buffer}, but it does not select that window and does not
@c make the buffer current. The identity of the selected window is
@c unaltered by this function.
$B$3$N%3%^%s%I$O!"(B@code{pop-to-buffer}$B$N$h$&$K!"(B
@var{buffer-or-name}$B$r$"$k%&%#%s%I%&$KI=<($9$k$,!"(B
$B$=$N%&%#%s%I%&$rA*Br$7$J$$$N$GEv3:%P%C%U%!$b%+%l%s%H%P%C%U%!$K$J$i$J$$!#(B
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$rJQ$($J$$!#(B
@c If @var{not-this-window} is non-@code{nil}, it means to display the
@c specified buffer in a window other than the selected one, even if it is
@c already on display in the selected window. This can cause the buffer to
@c appear in two windows at once. Otherwise, if @var{buffer-or-name} is
@c already being displayed in any window, that is good enough, so this
@c function does nothing.
@var{not-this-window}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B;XDj$7$?%P%C%U%!$,A*Br$5$l$F$$$k%&%#%s%I%&$K$9$G$KI=<($5$l$F$$$F$b!"(B
$BJL$N%&%#%s%I%&$KEv3:%P%C%U%!$rI=<($9$k$3$H$r0UL#$9$k!#(B
$B$3$l$K$h$j!"Ev3:%P%C%U%!$,F1;~$K(B2$B$D$N%&%#%s%I%&$KI=<($5$l$k!#(B
$B$5$b$J$1$l$P!"(B@var{buffer-or-name}$B$,%&%#%s%I%&$K$9$G$KI=<($5$l$F$$$k$H!"(B
$B$=$l$G==J,$H$_$J$7$3$N4X?t$O$J$K$b$7$J$$!#(B
@c @code{display-buffer} returns the window chosen to display
@c @var{buffer-or-name}.
@code{display-buffer}$B$O!"(B@var{buffer-or-name}$B$rI=<($9$k$?$a$K(B
$BA*$s$@%&%#%s%I%&$rJV$9!#(B
@c If the argument @var{frame} is non-@code{nil}, it specifies which frames
@c to check when deciding whether the buffer is already displayed. If the
@c buffer is already displayed in some window on one of these frames,
@c @code{display-buffer} simply returns that window. Here are the possible
@c values of @var{frame}:
$B0z?t(B@var{frame}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%P%C%U%!$,$9$G$KI=<($5$l$F$$$k$+$I$&$+$r8!::$9$k$H$-$K(B
$B$I$N%U%l!<%`$rBP>]$H$9$k$+$r;XDj$9$k!#(B
$B$=$l$i$N%U%l!<%`$N$I$l$+$N%&%#%s%I%&$KEv3:%P%C%U%!$,$9$G$KI=<($5$l$F$$$k$H!"(B
@code{display-buffer}$B$OC1$K$=$N%&%#%s%I%&$rJV$9!#(B
@var{frame}$B$N2DG=$JCM$O$D$.$N$H$*$j$G$"$k!#(B
@itemize @bullet
@item
@c If it is @code{nil}, consider windows on the selected frame.
@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{t}, consider windows on all frames.
@code{t}$B$G$"$k$H!"$9$Y$F$N%U%l!<%`$N%&%#%s%I%&$rBP>]$H$9$k!#(B
@item
@c If it is @code{visible}, consider windows on all visible frames.
@code{visible}$B$G$"$k$H!"(B
$B$9$Y$F$N2D;k%U%l!<%`$N$9$Y$F$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is 0, consider windows on all visible or iconified frames.
0$B$G$"$k$H!"$9$Y$F$N2D;k%U%l!<%`$d%"%$%3%s$K$J$C$F$$$k%U%l!<%`(B
$B$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@item
@c If it is a frame, consider windows on that frame.
$B%U%l!<%`$G$"$k$H!"Ev3:%U%l!<%`$N%&%#%s%I%&$rBP>]$K$9$k!#(B
@end itemize
@c Precisely how @code{display-buffer} finds or creates a window depends on
@c the variables described below.
@code{display-buffer}$B$,%&%#%s%I%&$r:n@.$7$?$jC5$9>\$7$$<j=g$O!"(B
$B0J2<$K=R$Y$kJQ?t$K0MB8$9$k!#(B
@end deffn
@defopt pop-up-windows
@c This variable controls whether @code{display-buffer} makes new windows.
@c If it is non-@code{nil} and there is only one window, then that window
@c is split. If it is @code{nil}, then @code{display-buffer} does not
@c split the single window, but uses it whole.
$B$3$NJQ?t$O!"(B@code{display-buffer}$B$,?7$?$K%&%#%s%I%&$r:n$k$+$I$&$+$r@)8f$9$k!#(B
@code{nil}$B0J30$G$"$j!"$+$D!"%&%#%s%I%&$,$?$C$?(B1$B$D$G$"$k>l9g!"(B
$B$=$N%&%#%s%I%&$rJ,3d$9$k!#(B
@code{nil}$B$G$"$k$H!"(B@code{display-buffer}$B$O(B
$BC10l$N%&%#%s%I%&$rJ,3d$;$:$K$=$lA4BN$r;H$&!#(B
@end defopt
@defopt split-height-threshold
@c This variable determines when @code{display-buffer} may split a window,
@c if there are multiple windows. @code{display-buffer} always splits the
@c largest window if it has at least this many lines. If the largest
@c window is not this tall, it is split only if it is the sole window and
@c @code{pop-up-windows} is non-@code{nil}.
$B$3$NJQ?t$O!"%&%#%s%I%&$,J#?t$"$k>l9g$K(B
@code{display-buffer}$B$,$I$N;~E@$G%&%#%s%I%&$rJ,3d$9$k$+$r7hDj$9$k!#(B
@code{display-buffer}$B$O!":GBg%&%#%s%I%&$N9T?t$,(B
$B$3$NJQ?t$K$h$k;XDj9T?t$h$jBg$-$1$l$P!":GBg%&%#%s%I%&$r$D$M$KJ,3d$9$k!#(B
$B:GBg%&%#%s%I%&$,$3$l$@$1Bg$-$/$J$$>l9g$K$O!"(B
$B$=$l$,M#0l$N%&%#%s%I%&$G$"$j!"$+$D!"(B@code{pop-up-windows}$B$,(B@code{nil}$B0J30(B
$B$N>l9g$K$N$_:GBg%&%#%s%I%&$rJ,3d$9$k!#(B
@end defopt
@c Emacs 19 feature
@defopt pop-up-frames
@c This variable controls whether @code{display-buffer} makes new frames.
@c If it is non-@code{nil}, @code{display-buffer} looks for an existing
@c window already displaying the desired buffer, on any visible frame. If
@c it finds one, it returns that window. Otherwise it makes a new frame.
@c The variables @code{pop-up-windows} and @code{split-height-threshold} do
@c not matter if @code{pop-up-frames} is non-@code{nil}.
$B$3$NJQ?t$O!"(B@code{display-buffer}$B$,?7$?$J%U%l!<%`$r:n$k$+$I$&$+$r@)8f$9$k!#(B
@code{nil}$B0J30$G$"$k$H!"(B@code{display-buffer}$B$O!"(B
$B$9$Y$F$N2D;k%U%l!<%`$+$i;XDj$5$l$?%P%C%U%!$r$9$G$KI=<($7$F$$$k(B
$B4{B8$N%&%#%s%I%&$rC5$9!#(B
$B$=$N$h$&$J%&%#%s%I%&$,$"$l$P!"$=$N%&%#%s%I%&$rJV$9!#(B
$B$5$b$J$1$l$P!"?7$?$J%U%l!<%`$r:n$k!#(B
$BJQ?t(B@code{pop-up-frames}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$BJQ?t(B@code{pop-up-windows}$B$H(B@code{split-height-threshold}$B$O1F6A$7$J$$!#(B
@c If @code{pop-up-frames} is @code{nil}, then @code{display-buffer} either
@c splits a window or reuses one.
@code{pop-up-frames}$B$,(B@code{nil}$B$G$"$k$H!"(B
@code{display-buffer}$B$O%&%#%s%I%&$rJ,3d$9$k$+:FMxMQ$9$k!#(B
@c @xref{Frames}, for more information.
$B>\$7$/$O!"(B@pxref{Frames}$B!#(B
@end defopt
@c Emacs 19 feature
@defvar pop-up-frame-function
@c This variable specifies how to make a new frame if @code{pop-up-frames}
@c is non-@code{nil}.
$B$3$NJQ?t$O!"(B@code{pop-up-frames}$B$,(B@code{nil}$B0J30$G$"$k$H$-$K(B
$B$I$N$h$&$K?7$?$J%U%l!<%`$r:n$k$+$r;XDj$9$k!#(B
@c Its value should be a function of no arguments. When
@c @code{display-buffer} makes a new frame, it does so by calling that
@c function, which should return a frame. The default value of the
@c variable is a function that creates a frame using parameters from
@c @code{pop-up-frame-alist}.
$B$=$NCM$O0z?t$J$7$N4X?t$G$"$k$3$H!#(B
@code{display-buffer}$B$,?7$?$K%U%l!<%`$r:n$k$H$-!"(B
$B%U%l!<%`$rJV$9$3$N4X?t$r8F$S=P$9!#(B
$B$3$NJQ?t$N%G%U%)%k%HCM$O!"(B
@code{pop-up-frame-alist}$B$N%Q%i%a!<%?$r;H$C$F?7$?$J%U%l!<%`$r:n$k4X?t$G$"$k!#(B
@end defvar
@defvar pop-up-frame-alist
@c This variable holds an alist specifying frame parameters used when
@c @code{display-buffer} makes a new frame. @xref{Frame Parameters}, for
@c more information about frame parameters.
$B$3$NJQ?t$O!"(B@code{display-buffer}$B$,?7$?$K%U%l!<%`$r:n$k$H$-$K(B
$B;HMQ$9$k%U%l!<%`%Q%i%a!<%?$r;XDj$9$kO"A[%j%9%H$rJ];}$9$k!#(B
$B%U%l!<%`%Q%i%a!<%?$K4X$7$F>\$7$/$O!"(B
@pxref{Frame Parameters}$B!#(B
@end defvar
@defopt special-display-buffer-names
@c A list of buffer names for buffers that should be displayed specially.
@c If the buffer's name is in this list, @code{display-buffer} handles the
@c buffer specially.
$BFCJL$KI=<($9$Y$-%P%C%U%!$N%P%C%U%!L>$N%j%9%H!#(B
$B%P%C%U%!L>$,$3$N%j%9%H$K$"$k$H!"(B
@code{display-buffer}$B$OEv3:%P%C%U%!$rFCJL$K07$&!#(B
@c By default, special display means to give the buffer a dedicated frame.
$B%G%U%)%k%H$G$O!"FCJL$KI=<($9$k$H$O!"(B
$B@lMQ$N%U%l!<%`$K%P%C%U%!$rI=<($9$k$3$H$G$"$k!#(B
@c If an element is a list, instead of a string, then the @sc{car} of the
@c list is the buffer name, and the rest of the list says how to create the
@c frame. There are two possibilities for the rest of the list. It can be
@c an alist, specifying frame parameters, or it can contain a function and
@c arguments to give to it. (The function's first argument is always the
@c buffer to be displayed; the arguments from the list come after that.)
$B%j%9%H$NMWAG$,J8;zNs$G$J$/%j%9%H$G$"$k$H!"(B
$B%j%9%H$N(B@sc{car}$B$,%P%C%U%!L>$G$"$j!"(B
$B%j%9%H$N;D$j$O%U%l!<%`$N:n@.J}K!$r;XDj$9$k!#(B
$B$=$l$O!"%U%l!<%`%Q%i%a!<%?$r;XDj$9$kO"A[%j%9%H$G$"$k$+!"(B
$B4X?t$H$=$l$KEO$90z?t$G$"$k!#(B
$B!J4X?t$NBh(B1$B0z?t$O$D$M$KI=<($9$Y$-%P%C%U%!$G$"$k!#(B
$B$=$N$"$H$K%j%9%HFb$N0z?t$,B3$/!#!K(B
@end defopt
@defopt special-display-regexps
@c A list of regular expressions that specify buffers that should be
@c displayed specially. If the buffer's name matches any of the regular
@c expressions in this list, @code{display-buffer} handles the buffer
@c specially.
$BFCJL$KI=<($9$Y$-%P%C%U%!$r;XDj$9$k@55,I=8=$N%j%9%H!#(B
$B%P%C%U%!L>$,$3$N%j%9%H$N$$$:$l$+$N@55,I=8=$K0lCW$9$k$H!"(B
@code{display-buffer}$B$OEv3:%P%C%U%!$rFCJL$K07$&!#(B
@c By default, special display means to give the buffer a dedicated frame.
$B%G%U%)%k%H$G$O!"FCJL$KI=<($9$k$H$O!"(B
$B@lMQ$N%U%l!<%`$K%P%C%U%!$rI=<($9$k$3$H$G$"$k!#(B
@c If an element is a list, instead of a string, then the @sc{car} of the
@c list is the regular expression, and the rest of the list says how to
@c create the frame. See above, under @code{special-display-buffer-names}.
$B%j%9%H$NMWAG$,J8;zNs$G$J$/%j%9%H$G$"$k$H!"(B
$B%j%9%H$N(B@sc{car}$B$,@55,I=8=$G$"$j!"(B
$B%j%9%H$N;D$j$O%U%l!<%`$N:n@.J}K!$r;XDj$9$k!#(B
$B>e5-$N(B@code{special-display-buffer-names}$B$r;2>H!#(B
@end defopt
@defvar special-display-function
@c This variable holds the function to call to display a buffer specially.
@c It receives the buffer as an argument, and should return the window in
@c which it is displayed.
$B$3$NJQ?t$O!"%P%C%U%!$rFCJL$KI=<($9$k$?$a$K8F$S=P$94X?t$rJ];}$9$k!#(B
$B0z?t$H$7$F%P%C%U%!$r<u$1<h$j!"(B
$BEv3:%P%C%U%!$rI=<($7$?%&%#%s%I%&$rJV$9$3$H!#(B
@c The default value of this variable is
@c @code{special-display-popup-frame}.
$B$3$N4X?t$N%G%U%)%k%HCM$O(B@code{special-display-popup-frame}$B$G$"$k!#(B
@end defvar
@defun special-display-popup-frame buffer
@c This function makes @var{buffer} visible in a frame of its own. If
@c @var{buffer} is already displayed in a window in some frame, it makes
@c the frame visible and raises it, to use that window. Otherwise, it
@c creates a frame that will be dedicated to @var{buffer}.
$B$3$N4X?t$O!"(B@var{buffer}$B$r$=$l@lMQ$N%U%l!<%`$KI=<($9$k!#(B
$B$"$k%U%l!<%`$N%&%#%s%I%&$K(B@var{buffer}$B$,$9$G$KI=<($5$l$F$$$k>l9g!"(B
$BEv3:%&%#%s%I%&$r;H$&$?$a$KEv3:%U%l!<%`$r2D;k$K$7<jA0$K;}$C$F$/$k!#(B
$B$5$b$J$1$l$P!"(B@var{buffer}$BMQ$K%U%l!<%`$r:n@.$9$k!#(B
@c This function uses an existing window displaying @var{buffer} whether or
@c not it is in a frame of its own; but if you set up the above variables
@c in your init file, before @var{buffer} was created, then presumably the
@c window was previously made by this function.
$B$3$N4X?t$O!"(B@var{buffer}$B$rI=<($7$F$$$k4{B8$N%&%#%s%I%&$N%U%l!<%`$G(B
$BEv3:%P%C%U%!$@$1$rI=<($7$F$$$k$+$I$&$+$K4X$o$i$:!"(B
$B4{B8$NEv3:%&%#%s%I%&$r;H$&!#(B
$B$7$+$7!"(B@var{buffer}$B$r:n$k$^$($KFI<T$N=i4|2=%U%!%$%k$G>e5-$NJQ?t$K@_Dj(B
$B$7$F$$$k$H$-$K$O!"Ev3:%&%#%s%I%&$O0JA0$K$3$N4X?t$,:n@.$7$?$b$N$G$"$m$&!#(B
@end defun
@defopt special-display-frame-alist
@c This variable holds frame parameters for
@c @code{special-display-popup-frame} to use when it creates a frame.
$B$3$NJQ?t$O!"(B@code{special-display-popup-frame}$B$,%U%l!<%`$r:n$k$H$-$K(B
$B;HMQ$9$k%U%l!<%`%Q%i%a!<%?$rJ];}$9$k!#(B
@end defopt
@defopt same-window-buffer-names
@c A list of buffer names for buffers that should be displayed in the
@c selected window. If the buffer's name is in this list,
@c @code{display-buffer} handles the buffer by switching to it in the
@c selected window.
$BA*Br$5$l$F$$$k%&%#%s%I%&$KI=<($9$Y$-%P%C%U%!$N%P%C%U%!L>$N%j%9%H!#(B
$B%P%C%U%!L>$,$3$N%j%9%H$K$"$k$H!"(B
@code{display-buffer}$B$OA*Br$5$l$F$$$k%&%#%s%I%&$GEv3:%P%C%U%!$K@Z$jBX$($k!#(B
@end defopt
@defopt same-window-regexps
@c A list of regular expressions that specify buffers that should be
@c displayed in the selected window. If the buffer's name matches any of
@c the regular expressions in this list, @code{display-buffer} handles the
@c buffer by switching to it in the selected window.
$BA*Br$5$l$F$$$k%&%#%s%I%&$KI=<($9$Y$-%P%C%U%!$r;XDj$9$k@55,I=8=$N%j%9%H!#(B
$B%P%C%U%!L>$,$3$N%j%9%H$N$$$:$l$+$N@55,I=8=$K0lCW$9$k$H!"(B
@code{display-buffer}$B$OA*Br$5$l$F$$$k%&%#%s%I%&$GEv3:%P%C%U%!$K@Z$jBX$($k!#(B
@end defopt
@c Emacs 19 feature
@defvar display-buffer-function
@c This variable is the most flexible way to customize the behavior of
@c @code{display-buffer}. If it is non-@code{nil}, it should be a function
@c that @code{display-buffer} calls to do the work. The function should
@c accept two arguments, the same two arguments that @code{display-buffer}
@c received. It should choose or create a window, display the specified
@c buffer, and then return the window.
$B$3$NJQ?t$O!"(B@code{display-buffer}$B$N$U$k$^$$$r%+%9%?%^%$%:$9$k(B
$B$b$C$H$b=@Fp$JJ}K!$G$"$k!#(B
@code{nil}$B0J30$G$"$k$H!"(B@code{display-buffer}$B$,=hM}$r0MMj$9$k$?$a$K(B
$B8F$S=P$94X?t$G$"$k$3$H!#(B
$B$=$N4X?t$O!"(B@code{display-buffer}$B$,<u$1<h$k$N$HF1$8(B2$B$D$N0z?t$r<u$1IU$1$k$3$H!#(B
$B$=$N4X?t$O!"%&%#%s%I%&$rA*$V$+:n@.$7!";XDj$5$l$?%P%C%U%!$rI=<($7!"(B
$BEv3:%&%#%s%I%&$rJV$9$3$H!#(B
@c This hook takes precedence over all the other options and hooks
@c described above.
$B$3$N%U%C%/$O!">e$K=R$Y$?B>$N%*%W%7%g%s$d%U%C%/$9$Y$F$KM%@h$9$k!#(B
@end defvar
@c @c Emacs 19 feature
@c @cindex dedicated window
@cindex $B@lMQ%&%#%s%I%&(B
@c A window can be marked as ``dedicated'' to its buffer. Then
@c @code{display-buffer} will not try to use that window to display any
@c other buffer.
$B%&%#%s%I%&$K$O$=$N%P%C%U%!!X@lMQ!Y$H0u$rIU$1$i$l$^$9!#(B
$B$=$&$9$k$H!"(B@code{display-buffer}$B$OB>$N%P%C%U%!$rI=<($9$k$?$a$K(B
$BEv3:%&%#%s%I%&$r;H$o$J$$$h$&$K$7$^$9!#(B
@defun window-dedicated-p window
@c This function returns @code{t} if @var{window} is marked as dedicated;
@c otherwise @code{nil}.
$B$3$N4X?t$O!"(B@var{window}$B$K@lMQ$H0u$,IU$$$F$$$l$P(B@code{t}$B$rJV$7!"(B
$B$5$b$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@end defun
@defun set-window-dedicated-p window flag
@c This function marks @var{window} as dedicated if @var{flag} is
@c non-@code{nil}, and nondedicated otherwise.
$B$3$N4X?t$O!"(B@var{flag}$B$,(B@code{nil}$B0J30$G$"$k$H(B@var{window}$B$K@lMQ$N0u$rIU$1!"(B
$B$5$b$J$1$l$P@lMQ$N0u$r>C$9!#(B
@end defun
@node Window Point
@c @section Windows and Point
@section $B%&%#%s%I%&$H%]%$%s%H(B
@c @cindex window position
@c @cindex window point
@c @cindex position in window
@c @cindex point in window
@cindex $B%&%#%s%I%&Fb0LCV(B
@cindex $B%&%#%s%I%&$N%]%$%s%H(B
@cindex $B0LCV!"%&%#%s%I%&Fb(B
@cindex $B%]%$%s%H!"%&%#%s%I%&(B
@c Each window has its own value of point, independent of the value of
@c point in other windows displaying the same buffer. This makes it useful
@c to have multiple windows showing one buffer.
$B3F%&%#%s%I%&$K$O!"F1$8%P%C%U%!$rI=<($7$F$$$k(B
$BJL$N%&%#%s%I%&$N%]%$%s%H$NCM$H$OFHN)$JFH<+$N%]%$%s%H$NCM$,$"$j$^$9!#(B
$B$3$l$K$h$j!"$"$k%P%C%U%!$rJ#?t$N%&%#%s%I%&$KI=<($7$F$bM-MQ$J$N$G$9!#(B
@itemize @bullet
@item
@c The window point is established when a window is first created; it is
@c initialized from the buffer's point, or from the window point of another
@c window opened on the buffer if such a window exists.
$B%&%#%s%I%&$N%]%$%s%H$O!"%&%#%s%I%&$r:G=i$K:n@.$7$?$H$-$K3NN)$5$l$k!#(B
$B%P%C%U%!$N%]%$%s%H$+!"%P%C%U%!$r$9$G$KI=<($7$F$$$k%&%#%s%I%&$,$"$l$P(B
$B$=$N%&%#%s%I%&$N%]%$%s%H$G=i4|2=$5$l$k!#(B
@item
@c Selecting a window sets the value of point in its buffer from the
@c window's value of point. Conversely, deselecting a window sets the
@c window's value of point from that of the buffer. Thus, when you switch
@c between windows that display a given buffer, the point value for the
@c selected window is in effect in the buffer, while the point values for
@c the other windows are stored in those windows.
$B%&%#%s%I%&$rA*Br$9$k$H!"%&%#%s%I%&$N%]%$%s%HCM$,(B
$B$=$N%P%C%U%!$N%]%$%s%HCM$K$J$k!#(B
$B5U$K!"%&%#%s%I%&$NA*Br$r$d$a$k$H!"(B
$B%P%C%U%!$N%]%$%s%HCM$,%&%#%s%I%&$N%]%$%s%HCM$K$J$k!#(B
$B$7$?$,$C$F!"F1$8%P%C%U%!$rI=<($7$F$$$kJ#?t$N%&%#%s%I%&$N$"$$$@$G(B
$B@Z$jBX$($k$H!"A*Br$5$l$F$$$k%&%#%s%I%&$G$O%&%#%s%I%&$N%]%$%s%HCM$,(B
$BEv3:%P%C%U%!$GM-8z$K$J$j!"(B
$BA*Br$5$l$F$$$J$$B>$N%&%#%s%I%&$N3F%]%$%s%HCM$O!"(B
$B$=$l$>$l$N%&%#%s%I%&$KJ];}$5$l$k!#(B
@item
@c As long as the selected window displays the current buffer, the window's
@c point and the buffer's point always move together; they remain equal.
$BA*Br$5$l$F$$$k%&%#%s%I%&$,%+%l%s%H%P%C%U%!$rI=<($7B3$1$k8B$j!"(B
$B%&%#%s%I%&$N%]%$%s%H$H%P%C%U%!$N%]%$%s%H$O$H$b$KF0$$$F!"(B
$BN><T$OF1$8$G$"$jB3$1$k!#(B
@item
@c @xref{Positions}, for more details on buffer positions.
$B%P%C%U%!Fb0LCV$K$D$$$F>\$7$/$O!"(B@pxref{Positions}$B!#(B
@end itemize
@c As far as the user is concerned, point is where the cursor is, and
@c when the user switches to another buffer, the cursor jumps to the
@c position of point in that buffer.
$B%f!<%6!<$K$H$C$F$O!"%]%$%s%H$H$O%+!<%=%k$,CV$+$l$?2U=j$G$"$j!"(B
$BJL$N%P%C%U%!$K@Z$jBX$($k$H$=$N%P%C%U%!$N%]%$%s%H0LCV$K(B
$B%+!<%=%k$,0\F0$7$^$9!#(B
@defun window-point window
@c This function returns the current position of point in @var{window}.
@c For a nonselected window, this is the value point would have (in that
@c window's buffer) if that window were selected.
$B$3$N4X?t$O!"(B@var{window}$B$N8=:_$N%]%$%s%H0LCV$rJV$9!#(B
$BA*Br$5$l$F$$$J$$%&%#%s%I%&$G$O!"(B
$BEv3:%&%#%s%I%&$rA*Br$7$?$H$-$K$J$k$G$"$m$&(B
$B!J%&%#%s%I%&$N%P%C%U%!$N!K%]%$%s%HCM$G$"$k!#(B
@c When @var{window} is the selected window and its buffer is also the
@c current buffer, the value returned is the same as point in that buffer.
@var{window}$B$,A*Br$5$l$F$$$k%&%#%s%I%&$G$"$j!"$+$D!"(B
$B$=$N%P%C%U%!$,%+%l%s%H%P%C%U%!$G$"$l$P!"(B
$BLa$jCM$OEv3:%P%C%U%!$N%]%$%s%H$HF1$8$G$"$k!#(B
@c Strictly speaking, it would be more correct to return the
@c ``top-level'' value of point, outside of any @code{save-excursion}
@c forms. But that value is hard to find.
$B87L)$K$$$($P!"$9$Y$F$N%U%)!<%`(B@code{save-excursion}$B$N30B&$G$N(B
$B!X%H%C%W%l%Y%k!Y$N%]%$%s%H$NCM$rJV$9$[$&$,$h$j@53N$G$"$k!#(B
$B$7$+$7!"$=$N$h$&$JCM$rC5$9$N$O:$Fq$G$"$k!#(B
@end defun
@defun set-window-point window position
@c This function positions point in @var{window} at position
@c @var{position} in @var{window}'s buffer.
$B$3$N4X?t$O!"(B@var{window}$B$N%P%C%U%!Fb$N0LCV(B@var{position}$B$r(B
@var{window}$B$N%]%$%s%H0LCV$H$9$k!#(B
@end defun
@node Window Start
@c @section The Window Start Position
@section $B%&%#%s%I%&$N3+;O0LCV(B
@c Each window contains a marker used to keep track of a buffer position
@c that specifies where in the buffer display should start. This position
@c is called the @dfn{display-start} position of the window (or just the
@c @dfn{start}). The character after this position is the one that appears
@c at the upper left corner of the window. It is usually, but not
@c inevitably, at the beginning of a text line.
$B3F%&%#%s%I%&$K$O!"%P%C%U%!$N$I$N2U=j$+$iI=<($r;O$a$k$+$r;XDj$9$k(B
$B%P%C%U%!Fb0LCV$rDI@W$9$k$?$a$K;H$&%^!<%+$,$"$j$^$9!#(B
$B$3$N0LCV$r%&%#%s%I%&$N(B@dfn{$BI=<(3+;O(B}$B!J(Bdisplay-start$B!K0LCV(B
$B!J$"$k$$$OC1$K(B@dfn{$B3+;O(B}$B!J(Bstart$B!K0LCV!K$H8F$S$^$9!#(B
$B$3$N0LCV$ND>8e$K$"$kJ8;z$,!"%&%#%s%I%&$N:8>e6y$K8=$l$^$9!#(B
$B$3$N0LCV$O!"DL>o!"%F%-%9%H9T$N@hF,$K$"$j$^$9$,!"I,?\$G$O$"$j$^$;$s!#(B
@defun window-start &optional window
@c @cindex window top line
@cindex $B%&%#%s%I%&$N@hF,9T(B
@c This function returns the display-start position of window
@c @var{window}. If @var{window} is @code{nil}, the selected window is
@c used. For example,
$B$3$N4X?t$O!"%&%#%s%I%&(B@var{window}$B$NI=<(3+;O0LCV$rJV$9!#(B
@var{window}$B$,(B@code{nil}$B$G$"$k$H!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$r;H$&!#(B
$B$?$H$($P$D$.$N$H$*$j$G$"$k!#(B
@example
@group
(window-start)
@result{} 7058
@end group
@end example
@c When you create a window, or display a different buffer in it, the
@c display-start position is set to a display-start position recently used
@c for the same buffer, or 1 if the buffer doesn't have any.
$B?7$?$K%&%#%s%I%&$r:n@.$7$?$j0[$J$k%P%C%U%!$r%&%#%s%I%&$KI=<($9$k$H!"(B
$BI=<(3+;O0LCV$O!"Ev3:%P%C%U%!$N:G6a$K;H$o$l$?I=<(3+;O0LCV$K$J$k$+!"(B
$B%P%C%U%!$KI=<(3+;O0LCV$,$J$1$l$P(B1$B$K$J$k!#(B
@c Redisplay updates the window-start position (if you have not specified
@c it explicitly since the previous redisplay) so that point appears on the
@c screen. Nothing except redisplay automatically changes the window-start
@c position; if you move point, do not expect the window-start position to
@c change in response until after the next redisplay.
$B:FI=<($9$k$H%&%#%s%I%&3+;O0LCV$O(B
$B!J$=$l0JA0$N:FI=<($GL@<(E*$K0LCV$r;XDj$7$F$$$J$1$l$P!K!"(B
$B%]%$%s%H$,%9%/%j!<%s$K8=$l$k$h$&$K99?7$5$l$k!#(B
$B:FI=<(0J30$K$O!"%&%#%s%I%&3+;O0LCV$r<+F0E*$KJQ99$7$J$$!#(B
$B%]%$%s%H$r0\F0$7$F$b!"$D$.$N:FI=<($^$G$O!"(B
$BO"F0$7$F%&%#%s%I%&3+;O0LCV$,JQ99$5$l$k$H4|BT$7$J$$$3$H!#(B
@c For a realistic example of using @code{window-start}, see the
@c description of @code{count-lines} in @ref{Text Lines}.
@code{window-start}$B$r;H$C$?<B:]E*$JNc$O!"(B
@ref{Text Lines}$B$N(B@code{count-lines}$B$N5-=R$r;2>H!#(B
@end defun
@defun window-end &optional window update
@c This function returns the position of the end of the display in window
@c @var{window}. If @var{window} is @code{nil}, the selected window is
@c used.
$B$3$N4X?t$O!"%&%#%s%I%&(B@var{window}$B$NI=<($NKvHx$N0LCV$rJV$9!#(B
@var{window}$B$,(B@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%&%#%s%I%&$r;H$&!#(B
@c Simply changing the buffer text or moving point does not update the
@c value that @code{window-end} returns. The value is updated only when
@c Emacs redisplays and redisplay completes without being preempted.
$B%P%C%U%!$N%F%-%9%H$rJQ99$7$?$j%]%$%s%H$r0\F0$7$?$@$1$G$O!"(B
@code{window-end}$B$,JV$9CM$O99?7$5$l$J$$!#(B
$B$3$NCM$O!"(BEmacs$B$,:FI=<($r<B9T$7ESCf$G;_$a$k$3$H$J$/(B
$B:G8e$^$G=*N;$7$?>l9g$K$N$_99?7$5$l$k!#(B
@c If the last redisplay of @var{window} was preempted, and did not finish,
@c Emacs does not know the position of the end of display in that window.
@c In that case, this function returns @code{nil}.
@var{window}$B$N:G8e$N:FI=<($,ESCf$G;_$a$i$l$F40N;$7$F$$$J$$$H!"(B
$BEv3:%&%#%s%I%&$NI=<($NKvHx$N0LCV$O(BEmacs$B$K$O$o$+$i$J$$!#(B
@c If @var{update} is non-@code{nil}, @code{window-end} always returns
@c an up-to-date value for where the window ends. If the saved value is
@c valid, @code{window-end} returns that; otherwise it computes the correct
@c value by scanning the buffer text.
@var{update}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
@code{window-end}$B$O%&%#%s%I%&$NKvHx$N99?7CM$r$D$M$KJV$9!#(B
$BJ]B8$7$F$*$$$?CM$,@5$7$1$l$P(B@code{window-end}$B$O$=$l$rJV$9!#(B
$B$5$b$J$1$l$P!"%P%C%U%!$N%F%-%9%H$rAv::$7$F@5$7$$CM$r7W;;$9$k!#(B
@end defun
@defun set-window-start window position &optional noforce
@c This function sets the display-start position of @var{window} to
@c @var{position} in @var{window}'s buffer. It returns @var{position}.
$B$3$N4X?t$O!"(B@var{window}$B$NI=<(3+;O0LCV$r(B
@var{window}$B$N%P%C%U%!Fb$N0LCV(B@var{position}$B$H$9$k!#(B
$B$3$l$O(B@var{position}$B$rJV$9!#(B
@c The display routines insist that the position of point be visible when a
@c buffer is displayed. Normally, they change the display-start position
@c (that is, scroll the window) whenever necessary to make point visible.
@c However, if you specify the start position with this function using
@c @code{nil} for @var{noforce}, it means you want display to start at
@c @var{position} even if that would put the location of point off the
@c screen. If this does place point off screen, the display routines move
@c point to the left margin on the middle line in the window.
$BI=<(%k!<%F%#%s$O!"%P%C%U%!$rI=<($9$k$H$-$K$O(B
$B%]%$%s%H0LCV$,2D;k$G$"$k$3$H$r6/MW$9$k!#(B
$BDL>o!"I=<(%k!<%F%#%s$O!"%]%$%s%H$r2D;k$K$9$k$?$a$KI,MW$J$H$-$K$O(B
$BI=<(3+;O0LCV$r!J$D$^$j%&%#%s%I%&$r%9%/%m!<%k$7$F!KJQ99$9$k!#(B
$B$7$+$7!"(B@var{noforce}$B$K(B@code{nil}$B$r;XDj$7$F$3$N4X?t$G3+;O0LCV$r;XDj$9$k$H!"(B
$B%]%$%s%H0LCV$,%9%/%j!<%s$+$i$O$_=P$7$?$H$7$F$b!"(B
$BI=<(3+;O0LCV$r(B@var{position}$B$H$9$k$3$H$r0UL#$9$k!#(B
$B%]%$%s%H$,%9%/%j!<%s$+$i$O$_=P$9>l9g$K$O!"(B
$BI=<(%k!<%F%#%s$O%&%#%s%I%&$NCf1{9T$N:8C<$K%]%$%s%H$r0\F0$9$k!#(B
@c For example, if point @w{is 1} and you set the start of the window @w{to
@c 2}, then point would be ``above'' the top of the window. The display
@c routines will automatically move point if it is still 1 when redisplay
@c occurs. Here is an example:
$B$?$H$($P!"%]%$%s%H$,(B@w{1$B$K$"$k(B}$B$H$-$K(B
$B%&%#%s%I%&$N3+;O0LCV$r(B@w{2$B$K(B}$B$7$?$H$9$k$H!"(B
$B%]%$%s%H$O%&%#%s%I%&$N>eC<$h$j!X>e!Y$K$J$k!#(B
$BI=<(%k!<%F%#%s$O!":FI=<(;~$K%]%$%s%H$,(B1$B$N$^$^$G$"$k$H(B
$B<+F0E*$K%]%$%s%H$r0\F0$9$k!#(B
$B0J2<$KNc$r<($9!#(B
@example
@group
@c ;; @r{Here is what @samp{foo} looks like before executing}
@c ;; @r{the @code{set-window-start} expression.}
;; @r{$B<0(B@code{set-window-start}$B$r<B9T$9$k$^$($N(B}
;; @r{@samp{foo}$B$N8+$(J}(B}
@end group
@group
---------- Buffer: foo ----------
@point{}This is the contents of buffer foo.
2
3
4
5
6
---------- Buffer: foo ----------
@end group
@group
(set-window-start
(selected-window)
(1+ (window-start)))
@result{} 2
@end group
@group
@c ;; @r{Here is what @samp{foo} looks like after executing}
@c ;; @r{the @code{set-window-start} expression.}
;; @r{$B<0(B@code{set-window-start}$B$r<B9T$7$?$"$H$N(B}
;; @r{@samp{foo}$B$N8+$(J}(B}
---------- Buffer: foo ----------
his is the contents of buffer foo.
2
3
@point{}4
5
6
---------- Buffer: foo ----------
@end group
@end example
@c If @var{noforce} is non-@code{nil}, and @var{position} would place point
@c off screen at the next redisplay, then redisplay computes a new window-start
@c position that works well with point, and thus @var{position} is not used.
@var{noforce}$B$,(B@code{nil}$B0J30$G$"$C$F(B
@var{position}$B$K$9$k$H$D$.$N:FI=<(;~$K%]%$%s%H$,%9%/%j!<%s$+$i$O$_=P$9(B
$B>l9g$K$O!":FI=<($G$O%]%$%s%H$,<}$^$k$h$&$K?7$?$J%&%#%s%I%&3+;O0LCV$r(B
$B7W;;$7!"(B@var{position}$B$r;H$o$J$$!#(B
@end defun
@defun pos-visible-in-window-p &optional position window
@c This function returns @code{t} if @var{position} is within the range
@c of text currently visible on the screen in @var{window}. It returns
@c @code{nil} if @var{position} is scrolled vertically out of view. The
@c argument @var{position} defaults to the current position of point;
@c @var{window}, to the selected window. Here is an example:
$B$3$N4X?t$O!"(B@var{window}$BFb$N(B@var{position}$B$,%9%/%j!<%s>e$G(B
$B8=:_2D;k$J%F%-%9%H$NHO0OFb$K$"$l$P(B@code{t}$B$rJV$9!#(B
@var{position}$B$,%9%/%j!<%s$N>e2<C<$+$i$O$_=P$9>l9g$K$O(B@code{nil}$B$rJV$9!#(B
$B0z?t(B@var{position}$B$N%G%U%)%k%H$O%]%$%s%H$N8=:_0LCV$G$"$j!"(B
@var{window}$B$N%G%U%)%k%H$OA*Br$5$l$F$$$k%&%#%s%I%&$G$"$k!#(B
$BNc$r<($9!#(B
@example
@group
(or (pos-visible-in-window-p
(point) (selected-window))
(recenter 0))
@end group
@end example
@c The @code{pos-visible-in-window-p} function considers only vertical
@c scrolling. If @var{position} is out of view only because @var{window}
@c has been scrolled horizontally, @code{pos-visible-in-window-p} returns
@c @code{t}. @xref{Horizontal Scrolling}.
$B4X?t(B@code{pos-visible-in-window-p}$B$O!"?bD>J}8~$N%9%/%m!<%k$@$1$r9MN8$9$k!#(B
@var{window}$B$r?eJ?J}8~$K%9%/%m!<%k$7$?$?$a$K(B
@var{position}$B$,$O$_=P$7$F$$$k>l9g$K$O!"(B
@code{pos-visible-in-window-p}$B$O(B@code{t}$B$rJV$9!#(B
@pxref{Horizontal Scrolling}$B!#(B
@end defun
@node Vertical Scrolling
@c @section Vertical Scrolling
@section $B?bD>%9%/%m!<%k(B
@c @cindex vertical scrolling
@c @cindex scrolling vertically
@cindex $B?bD>%9%/%m!<%k(B
@cindex $B%9%/%m!<%k!"?bD>(B
@c Vertical scrolling means moving the text up or down in a window. It
@c works by changing the value of the window's display-start location. It
@c may also change the value of @code{window-point} to keep it on the
@c screen.
$B?bD>%9%/%m!<%k$H$O!"%&%#%s%I%&Fb$N%F%-%9%H$r>e8~$-$d2<8~$-$KF0$+$9$3$H$G$9!#(B
$B%&%#%s%I%&$NI=<(3+;O0LCV$NCM$rJQ99$9$k$3$H$GF0:n$7$^$9!#(B
$B%]%$%s%H$,%9%/%j!<%sFb$KN1$^$k$h$&$K(B@code{window-point}$B$N(B
$BCM$rJQ99$9$k$3$H$b$"$j$^$9!#(B
@c In the commands @code{scroll-up} and @code{scroll-down}, the directions
@c ``up'' and ``down'' refer to the motion of the text in the buffer at which
@c you are looking through the window. Imagine that the text is
@c written on a long roll of paper and that the scrolling commands move the
@c paper up and down. Thus, if you are looking at text in the middle of a
@c buffer and repeatedly call @code{scroll-down}, you will eventually see
@c the beginning of the buffer.
$B%3%^%s%I(B@code{scroll-up}$B$d(B@code{scroll-down}$B$N(B
$BJ}8~$r<($9!X(Bup$B!Y!J>e8~$-!K$H!X(Bdown$B!Y!J2<8~$-!K$O!"(B
$B%&%#%s%I%&$r8+$F$$$k$H$-$N%P%C%U%!Fb$N%F%-%9%H$N0\F0J}8~$rI=$7$^$9!#(B
$B%F%-%9%H$O=D$KD9$$;f$K!J2#=q$-$G!K=q$$$F$"$j!"(B
$B%9%/%m!<%k%3%^%s%I$O$=$N;f$r>e2<$KF0$+$9$HA[A|$7$F$/$@$5$$!#(B
$B$7$?$,$C$F!"%P%C%U%!$NCf$[$I$N%F%-%9%H$r8+$F$$$k$H$-$K(B
@code{scroll-down}$B$r7+$jJV$78F$S=P$9$H!"(B
$B:G=*E*$K$O%P%C%U%!$N@hF,$r8+$k$3$H$K$J$j$^$9!#(B
@c Some people have urged that the opposite convention be used: they
@c imagine that the window moves over text that remains in place. Then
@c ``down'' commands would take you to the end of the buffer. This view is
@c more consistent with the actual relationship between windows and the
@c text in the buffer, but it is less like what the user sees. The
@c position of a window on the terminal does not move, and short scrolling
@c commands clearly move the text up or down on the screen. We have chosen
@c names that fit the user's point of view.
$B5U$N47=,$NL>A0$r;H$&$Y$-$@$H<gD%$9$k?M!9$b$$$^$9!#(B
$BH`$i$O!"8GDj$5$l$?%F%-%9%H$N$&$($r%&%#%s%I%&$,F0$$$F$$$k$HA[A|$9$k$N$G$9!#(B
$B$9$k$H!"!X2<8~$-!Y$N%3%^%s%I$O%P%C%U%!$NKvHx$K0\F0$9$k$3$H$K$J$j$^$9!#(B
$B$3$N8+J}$O!"%&%#%s%I%&$H%P%C%U%!Fb$N%F%-%9%H$H$N<B:]$N4X78$K(B
$B$h$/E,9g$7$F$$$k$N$G$9$,!"%f!<%6!<$O$=$N$h$&$K9M$($J$$$h$&$G$9!#(B
$BC<Kv>e$G$O%&%#%s%I%&$OF0$-$^$;$s$7!"%9%/%m!<%k%3%^%s%I$O(B
$BL@$i$+$K%F%-%9%H$r%9%/%j!<%s>e$G>e2<$KF0$+$7$F$$$^$9!#(B
$B%f!<%6!<$N;kE@$K9g$&L>>N$rA*$s$@$N$G$9!#(B
@c The scrolling functions (aside from @code{scroll-other-window}) have
@c unpredictable results if the current buffer is different from the buffer
@c that is displayed in the selected window. @xref{Current Buffer}.
$B%+%l%s%H%P%C%U%!$HA*Br$5$l$F$$$k%&%#%s%I%&$K(B
$BI=<($5$l$F$$$k%P%C%U%!$H$,0[$J$k>l9g$K$O!"(B
$B!J(B@code{scroll-other-window}$B0J30$N!K%9%/%m!<%k4X?t$N7k2L$OM=B,$G$-$^$;$s!#(B
@xref{Current Buffer}$B!#(B
@c @deffn Command scroll-up &optional count
@deffn $B%3%^%s%I(B scroll-up &optional count
@c This function scrolls the text in the selected window upward
@c @var{count} lines. If @var{count} is negative, scrolling is actually
@c downward.
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$N%F%-%9%H$r(B
$B>e8~$-$K(B@var{count}$B9T$@$1%9%/%m!<%k$9$k!#(B
@var{count}$B$,Ii$G$"$k$H!"<B:]$N%9%/%m!<%kJ}8~$O2<8~$-$G$"$k!#(B
@c If @var{count} is @code{nil} (or omitted), then the length of scroll
@c is @code{next-screen-context-lines} lines less than the usable height of
@c the window (not counting its mode line).
@var{count}$B$,(B@code{nil}$B!J$"$k$$$O>JN,!K$G$"$k$H!"(B
$B%9%/%m!<%kNL$O!"%&%#%s%I%&$N!J%b!<%I9T$r?t$($J$$!KMxMQ2DG=$J9b$5$h$j(B
@code{next-screen-context-lines}$B$@$1>/$J$/$J$k!#(B
@c @code{scroll-up} returns @code{nil}.
@code{scroll-up}$B$O(B@code{nil}$B$rJV$9!#(B
@end deffn
@c @deffn Command scroll-down &optional count
@deffn $B%3%^%s%I(B scroll-down &optional count
@c This function scrolls the text in the selected window downward
@c @var{count} lines. If @var{count} is negative, scrolling is actually
@c upward.
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$N%F%-%9%H$r(B
$B2<8~$-$K(B@var{count}$B9T$@$1%9%/%m!<%k$9$k!#(B
@var{count}$B$,Ii$G$"$k$H!"<B:]$N%9%/%m!<%kJ}8~$O>e8~$-$G$"$k!#(B
@c If @var{count} is omitted or @code{nil}, then the length of the scroll
@c is @code{next-screen-context-lines} lines less than the usable height of
@c the window (not counting its mode line).
@var{count}$B$,(B@code{nil}$B!J$"$k$$$O>JN,!K$G$"$k$H!"(B
$B%9%/%m!<%kNL$O!"%&%#%s%I%&$N!J%b!<%I9T$r?t$($J$$!KMxMQ2DG=$J9b$5$h$j(B
@code{next-screen-context-lines}$B$@$1>/$J$/$J$k!#(B
@c @code{scroll-down} returns @code{nil}.
@code{scroll-down}$B$O(B@code{nil}$B$rJV$9!#(B
@end deffn
@c @deffn Command scroll-other-window &optional count
@deffn $B%3%^%s%I(B scroll-other-window &optional count
@c This function scrolls the text in another window upward @var{count}
@c lines. Negative values of @var{count}, or @code{nil}, are handled
@c as in @code{scroll-up}.
$B$3$N4X?t$O!"JL$N%&%#%s%I%&$N%F%-%9%H$r>e8~$-$K(B
@var{count}$B9T$@$1%9%/%m!<%k$9$k!#(B
@var{count}$B$NCM$,Ii$G$"$C$?$j(B@code{nil}$B$G$"$k$H!"(B
@code{scroll-up}$B$HF1MM$K07$&!#(B
@c You can specify a buffer to scroll with the variable
@c @code{other-window-scroll-buffer}. When the selected window is the
@c minibuffer, the next window is normally the one at the top left corner.
@c You can specify a different window to scroll with the variable
@c @code{minibuffer-scroll-window}. This variable has no effect when any
@c other window is selected. @xref{Minibuffer Misc}.
$BJQ?t(B@code{other-window-scroll-buffer}$B$G!"%9%/%m!<%k$9$k%P%C%U%!$r;XDj$G$-$k!#(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$,%_%K%P%C%U%!MQ$G$"$k$H$-$K$O!"(B
$B$D$.$N%&%#%s%I%&$O!"DL>o!"$b$C$H$b:8>e6y$K$"$k%&%#%s%I%&$G$"$k!#(B
$BJQ?t(B@code{minibuffer-scroll-window}$B$G!"(B
$B%9%/%m!<%k$9$kJL$N%&%#%s%I%&$r;XDj$G$-$k!#(B
$BJL$N%&%#%s%I%&$,A*Br$5$l$F$$$k>l9g$K$O!"$3$NJQ?t$N8z2L$O$J$$!#(B
@pxref{Minibuffer Misc}$B!#(B
@c When the minibuffer is active, it is the next window if the selected
@c window is the one at the bottom right corner. In this case,
@c @code{scroll-other-window} attempts to scroll the minibuffer. If the
@c minibuffer contains just one line, it has nowhere to scroll to, so the
@c line reappears after the echo area momentarily displays the message
@c ``Beginning of buffer''.
$B%_%K%P%C%U%!$,3h@-$G$"$k$H!"(B
$B1&2<6y$N%&%#%s%I%&$,A*Br$5$l$F$$$k%&%#%s%I%&$G$"$k$H$-$K$O!"(B
$B$D$.$N%&%#%s%I%&$O%_%K%P%C%U%!MQ%&%#%s%I%&$G$"$k!#(B
$B$3$N>l9g!"(B@code{scroll-other-window}$B$O%_%K%P%C%U%!$r%9%/%m!<%k$7$h$&$H$9$k!#(B
$B%_%K%P%C%U%!$K$?$C$?(B1$B9T$7$+F~$C$F$$$J$1$l$P%9%/%m!<%k$G$-$:!"(B
$B%(%3!<NN0h$K!X(BBeginning of buffer$B!Y$HC;;~4VI=<($5$l$?$"$H$G!"(B
$B%_%K%P%C%U%!$N9T$,:FEY8=$l$k!#(B
@end deffn
@c Emacs 19 feature
@defvar other-window-scroll-buffer
@c If this variable is non-@code{nil}, it tells @code{scroll-other-window}
@c which buffer to scroll.
$B$3$NJQ?t$,(B@code{nil}$B0J30$G$"$k$H!"(B
@code{scroll-other-window}$B$,%9%/%m!<%k$9$k%P%C%U%!$r;XDj$9$k!#(B
@end defvar
@tindex scroll-margin
@defopt scroll-margin
@c This option specifies the size of the scroll margin---a minimum number
@c of lines between point and the top or bottom of a window. Whenever
@c point gets within this many lines of the top or bottom of the window,
@c the window scrolls automatically (if possible) to move point out of the
@c margin, closer to the center of the window.
$B$3$N%*%W%7%g%s$O!"%9%/%m!<%k;~$NM>Gr$NBg$-$5!"(B
$B$D$^$j!"%]%$%s%H$H%&%#%s%I%&$N>eC<$d2<C<$H$N$"$$$@$K$"$k:GDc9T?t$r;XDj$9$k!#(B
$B%&%#%s%I%&$N>eC<$d2<C<$+$i$3$N9T?t0JFb$K%]%$%s%H$,0\F0$9$k$?$S$K!"(B
$B!J2DG=$J$i$P!K%&%#%s%I%&$r<+F0E*$K%9%/%m!<%k$7$F!"(B
$B%]%$%s%H$rM>Gr$N30B&$G%&%#%s%I%&$NCf1{6a$/$K0\F0$9$k!#(B
@end defopt
@tindex scroll-conservatively
@defopt scroll-conservatively
@c This variable controls how scrolling is done automatically when point
@c moves off the screen (or into the scroll margin). If the value is zero,
@c then redisplay scrolls the text to center point vertically in the
@c window. If the value is a positive integer @var{n}, then redisplay
@c scrolls the window up to @var{n} lines in either direction, if that will
@c bring point back into view. Otherwise, it centers point. The default
@c value is zero.
$B$3$NJQ?t$O!"%]%$%s%H$,%9%/%j!<%s$+$i$O$_=P$7$?$H$-(B
$B!J$"$k$$$O%9%/%m!<%k;~$NM>Gr$KF~$C$?$H$-!K$K(B
$B$I$N$h$&$K<+F0E*$K%9%/%m!<%k$9$k$+$r@)8f$9$k!#(B
$BCM$,(B0$B$G$"$k$H!"%&%#%s%I%&$N=DJ}8~$G%]%$%s%H$,Cf1{$K$/$k$h$&$K(B
$B%F%-%9%H$r%9%/%m!<%k$7$F:FI=<($9$k!#(B
$BCM$,@5$N@0?t(B@var{n}$B$G$"$k$H!"(B
$B%&%#%s%I%&$r$I$A$i$+$NJ}8~$K:GBg(B@var{n}$B9T$@$1%9%/%m!<%k$9$k$H(B
$B%]%$%s%H$,8+$($k$h$&$K$J$k$H$-$K$O!"$=$N$h$&$K%9%/%m!<%k$7$F:FI=<($9$k!#(B
$B$5$b$J$1$l$P!"%]%$%s%H$,Cf1{$K$/$k$h$&$K$9$k!#(B
$B%G%U%)%k%HCM$O(B0$B$G$"$k!#(B
@end defopt
@defopt scroll-step
@c This variable is an older variant of @code{scroll-conservatively}. The
@c difference is that it if its value is @var{n}, that permits scrolling
@c only by precisely @var{n} lines, not a smaller number. This feature
@c does not work with @code{scroll-margin}. The default value is zero.
$B$3$NJQ?t$O!"(B@code{scroll-conservatively}$B$N8E$$JQ<o$G$"$k!#(B
$B0c$$$O!"CM$,(B@var{n}$B$G$"$k$H@53N$K(B@var{n}$B9T$@$1$N%9%/%m!<%k$r5v$9$3$H$G$"$k!#(B
$B$3$N5!G=$O(B@code{scroll-margin}$B$G$OF/$+$J$$!#(B
$B%G%U%)%k%HCM$O(B0$B$G$"$k!#(B
@end defopt
@tindex scroll-preserve-screen-position
@defopt scroll-preserve-screen-position
@c If this option is non-@code{nil}, the scroll functions move point so
@c that the vertical position of the cursor is unchanged, when that is
@c possible.
$B$3$N%*%W%7%g%s$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%9%/%m!<%k4X?t$O!"2DG=$J$i$P%+!<%=%k$N?bD>J}8~$N0LCV$r(B
$BJQ$($J$$$h$&$K%]%$%s%H$r0\F0$9$k!#(B
@end defopt
@defopt next-screen-context-lines
@c The value of this variable is the number of lines of continuity to
@c retain when scrolling by full screens. For example, @code{scroll-up}
@c with an argument of @code{nil} scrolls so that this many lines at the
@c bottom of the window appear instead at the top. The default value is
@c @code{2}.
$B$3$NJQ?t$NCM$O!"(B1$B2hLLJ,%9%/%m!<%k$7$?$H$-$KO"B3$7$F;D$C$F$$$k9T?t$G$"$k!#(B
$B$?$H$($P!"0z?t(B@code{nil}$B$N(B@code{scroll-up}$B$O!"(B
$B%&%#%s%I%&$N2<C<$K$"$k$3$N9T?t$@$1$N9T$,>eC<$K$/$k$h$&$K%9%/%m!<%k$9$k!#(B
$B%G%U%)%k%HCM$O(B@code{2}$B$G$"$k!#(B
@end defopt
@c @deffn Command recenter &optional count
@deffn $B%3%^%s%I(B recenter &optional count
@c @cindex centering point
@cindex $B%]%$%s%H$rCf1{$KB7$($k(B
@c This function scrolls the selected window to put the text where point
@c is located at a specified vertical position within the window.
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r%9%/%m!<%k$7$F(B
$B%]%$%s%H0LCV$K$"$k%F%-%9%H$,%&%#%s%I%&Fb$N?bD>J}8~$N;XDj0LCV$K$/$k$h$&$K$9$k!#(B
@c If @var{count} is a nonnegative number, it puts the line containing
@c point @var{count} lines down from the top of the window. If @var{count}
@c is a negative number, then it counts upward from the bottom of the
@c window, so that @minus{}1 stands for the last usable line in the window.
@c If @var{count} is a non-@code{nil} list, then it stands for the line in
@c the middle of the window.
@var{count}$B$,HsIi$N?t$G$"$k$H!"%]%$%s%H0LCV$K$"$k9T$r(B
$B%&%#%s%I%&$N>eC<$+$i(B@var{count}$B9T2<$K$/$k$h$&$K$9$k!#(B
@var{count}$B$,Ii$N?t$G$"$k$H!"%&%#%s%I%&$N2<C<$+$i?t$(!"(B
@minus{}1$B$O%&%#%s%I%&$N;HMQ2DG=$J:G8e$N9T$rI=$9!#(B
@var{count}$B$,(B@code{nil}$B0J30$N%j%9%H$G$"$k$H!"(B
$B%&%#%s%I%&$NCf1{$N9T$rI=$9!#(B
@c If @var{count} is @code{nil}, @code{recenter} puts the line containing
@c point in the middle of the window, then clears and redisplays the entire
@c selected frame.
@var{count}$B$,(B@code{nil}$B$G$"$k$H!"(B@code{recenter}$B$O!"(B
$B%]%$%s%H0LCV$K$"$k9T$,%&%#%s%I%&$NCf1{$K$/$k$h$&$K$7$F!"(B
$BA*Br$5$l$F$$$k%U%l!<%`A4BN$r%/%j%"$7$F:FI=<($9$k!#(B
@c When @code{recenter} is called interactively, @var{count} is the raw
@c prefix argument. Thus, typing @kbd{C-u} as the prefix sets the
@c @var{count} to a non-@code{nil} list, while typing @kbd{C-u 4} sets
@c @var{count} to 4, which positions the current line four lines from the
@c top.
@code{recenter}$B$,BPOCE*$K8F$S=P$5$l$k$H!"(B@var{count}$B$O@8$NA0CV0z?t$G$"$k!#(B
$B$7$?$,$C$F!"A0CV0z?t$H$7$F(B@kbd{C-u}$B$HBG$D$H(B
@var{count}$B$O(B@code{nil}$B0J30$N%j%9%H$K$J$j!"(B
@kbd{C-u 4}$B$HBG$D$H(B@var{count}$B$O(B4$B$K$J$C$F>eC<$+$i(B4$B9TL\$K8=:_9T$,$/$k!#(B
@c With an argument of zero, @code{recenter} positions the current line at
@c the top of the window. This action is so handy that some people make a
@c separate key binding to do this. For example,
$B0z?t$,(B0$B$G$"$k$H!"(B
@code{recenter}$B$O%&%#%s%I%&$N>eC<$K8=:_9T$,$/$k$h$&$K$9$k!#(B
$B$3$NF0:n$O!"$3$N$?$a$N@lMQ$N%-!<%P%$%s%G%#%s%0$r$9$k?M$,$$$k$/$i$$JXMx$G$"$k!#(B
$B$?$H$($P$D$.$N$h$&$K$9$k!#(B
@example
@group
(defun line-to-top-of-window ()
"Scroll current line to top of window.
Replaces three keystroke sequence C-u 0 C-l."
(interactive)
(recenter 0))
(global-set-key [kp-multiply] 'line-to-top-of-window)
@end group
@end example
@end deffn
@node Horizontal Scrolling
@c @section Horizontal Scrolling
@section $B?eJ?%9%/%m!<%k(B
@c @cindex horizontal scrolling
@cindex $B?eJ?%9%/%m!<%k(B
@c Because we read English from left to right in the ``inner loop'', and
@c from top to bottom in the ``outer loop'', horizontal scrolling is not
@c like vertical scrolling. Vertical scrolling involves selection of a
@c contiguous portion of text to display, but horizontal scrolling causes
@c part of each line to go off screen. The amount of horizontal scrolling
@c is therefore specified as a number of columns rather than as a position
@c in the buffer. It has nothing to do with the display-start position
@c returned by @code{window-start}.
$B1QJ8$O!XFbB&$N%k!<%W!Y$G$O:8$+$i1&$X!X30B&$N%k!<%W!Y$G$O>e$+$i2<$X$HFI$`$N$G!"(B
$B?eJ?%9%/%m!<%k$O?bD>%9%/%m!<%k$K$O;w$F$$$^$;$s!#(B
$B?bD>%9%/%m!<%k$G$OI=<($9$k%F%-%9%H$NO"B3ItJ,$rA*$S$^$9$,!"(B
$B?eJ?%9%/%m!<%k$G$O3F9T$N0lIt$,%9%/%j!<%s$+$i$O$_=P$9$3$H$K$J$j$^$9!#(B
$B$=$N$?$a!"?eJ?%9%/%m!<%k$NNL$O!"%P%C%U%!Fb$N0LCV$G$O$J$/!"(B
$B%3%i%`?t$G;XDj$7$^$9!#(B
$B$3$l$O!"(B@code{window-start}$B$,JV$9I=<(3+;O0LCV$H$O$J$s$N4X78$b$"$j$^$;$s!#(B
@c Usually, no horizontal scrolling is in effect; then the leftmost
@c column is at the left edge of the window. In this state, scrolling to
@c the right is meaningless, since there is no data to the left of the
@c screen to be revealed by it; so this is not allowed. Scrolling to the
@c left is allowed; it scrolls the first columns of text off the edge of
@c the window and can reveal additional columns on the right that were
@c truncated before. Once a window has a nonzero amount of leftward
@c horizontal scrolling, you can scroll it back to the right, but only so
@c far as to reduce the net horizontal scroll to zero. There is no limit
@c to how far left you can scroll, but eventually all the text will
@c disappear off the left edge.
$BDL>o!"?eJ?%9%/%m!<%k$O9T$o$l$^$;$s!#(B
$B$D$^$j!":8C<$N%3%i%`$O%&%#%s%I%&$N:8C<$K$"$j$^$9!#(B
$B$3$N>uBV$G1&8~$-$K%9%/%m!<%k$7$F$b!"(B
$B$=$l$K$h$C$F8+$($F$/$k%9%/%j!<%s$N:8B&$K$O$J$K$b$J$$$N$G0UL#$,$"$j$^$;$s!#(B
$B$G$9$+$i!"$3$l$O6X;_$5$l$^$9!#(B
$B:88~$-$X$N%9%/%m!<%k$O5v$5$l$F!"(B
$B%F%-%9%H$N@hF,%3%i%`$O%&%#%s%I%&$NC<$+$i$O$_=P$7!"(B
$B$=$l$^$G@Z$j5M$a$i$l$F$$$?1&B&$N%3%i%`$,8+$($k$h$&$K$J$j$^$9!#(B
$B:88~$-$N?eJ?%9%/%m!<%kNL$,(B0$B$G$J$1$l$P!"(B
$B1&8~$-$X%9%/%m!<%k$7$FLa$;$^$9$,!"(B
$B$3$l$OA4BN$H$7$F$N?eJ?%9%/%m!<%kNL$,(B0$B$K$J$k$^$G$G$9!#(B
$B:88~$-%9%/%m!<%k$N8B3&$O$"$j$^$;$s$,!"(B
$B:G=*E*$K$O%F%-%9%H$9$Y$F$,:8C<$+$i$O$_=P$7$F$7$^$$$^$9!#(B
@c @deffn Command scroll-left count
@deffn $B%3%^%s%I(B scroll-left count
@c This function scrolls the selected window @var{count} columns to the
@c left (or to the right if @var{count} is negative). The return value is
@c the total amount of leftward horizontal scrolling in effect after the
@c change---just like the value returned by @code{window-hscroll} (below).
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r(B@var{count}$B%3%i%`$@$1(B
$B:88~$-$K!J(B@var{count}$B$,Ii$J$i$P1&8~$-$K!K%9%/%m!<%k$9$k!#(B
$BLa$jCM$O!"JQ998e$N:88~$-?eJ?%9%/%m!<%kNL$NAmNL$G$"$j!"(B
@code{window-hscroll}$B!J2<5-;2>H!K$,JV$9CM$HF1$8$G$"$k!#(B
@end deffn
@c @deffn Command scroll-right count
@deffn $B%3%^%s%I(B scroll-right count
@c This function scrolls the selected window @var{count} columns to the
@c right (or to the left if @var{count} is negative). The return value is
@c the total amount of leftward horizontal scrolling in effect after the
@c change---just like the value returned by @code{window-hscroll} (below).
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r(B@var{count}$B%3%i%`$@$1(B
$B1&8~$-$K!J(B@var{count}$B$,Ii$J$i$P:88~$-$K!K%9%/%m!<%k$9$k!#(B
$BLa$jCM$O!"JQ998e$N:88~$-?eJ?%9%/%m!<%kNL$NAmNL$G$"$j!"(B
@code{window-hscroll}$B!J2<5-;2>H!K$,JV$9CM$HF1$8$G$"$k!#(B
@c Once you scroll a window as far right as it can go, back to its normal
@c position where the total leftward scrolling is zero, attempts to scroll
@c any farther right have no effect.
$B2DG=$J$@$1%&%#%s%I%&$r1&8~$-$K%9%/%m!<%k$7$F$7$^$&$H!"(B
$BDL>o$N>uBV!"$D$^$j!":88~$-?eJ?%9%/%m!<%kNL$,(B0$B$K$J$j!"(B
$B$=$l0J9_!"1&8~$-%9%/%m!<%k$O8z2L$,$J$/$J$k!#(B
@end deffn
@defun window-hscroll &optional window
@c This function returns the total leftward horizontal scrolling of
@c @var{window}---the number of columns by which the text in @var{window}
@c is scrolled left past the left margin.
$B$3$N4X?t$O!"(B@var{window}$B$N:88~$-?eJ?%9%/%m!<%kNL$NAmNL!"(B
$B$D$^$j!"(B@var{window}$B$N%F%-%9%H$,:8C<$rD6$($F%9%/%m!<%k$5$l$?%3%i%`?t$rJV$9!#(B
@c The value is never negative. It is zero when no horizontal scrolling
@c has been done in @var{window} (which is usually the case).
$BCM$O$1$C$7$FIi$K$O$J$i$J$$!#(B
@var{window}$B$,?eJ?J}8~$K%9%/%m!<%k$5$l$F$$$J$1$l$P(B
$B!J$3$l$,DL>o$N>uBV!K(B0$B$G$"$k!#(B
@c If @var{window} is @code{nil}, the selected window is used.
@var{window}$B$,(B@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%&%#%s%I%&$r;H$&!#(B
@example
@group
(window-hscroll)
@result{} 0
@end group
@group
(scroll-left 5)
@result{} 5
@end group
@group
(window-hscroll)
@result{} 5
@end group
@end example
@end defun
@defun set-window-hscroll window columns
@c This function sets the number of columns from the left margin that
@c @var{window} is scrolled from the value of @var{columns}. The argument
@c @var{columns} should be zero or positive; if not, it is taken as zero.
$B$3$N4X?t$O!"(B@var{window}$B$N%9%/%m!<%k$5$l$F$$$k:8C<$+$i$N%3%i%`?t$r(B
@var{columns}$B$NCM$H$9$k!#(B
$B0z?t(B@var{columns}$B$O(B0$B$+@5$G$"$k$3$H!#(B
$B$5$b$J$$$H(B0$B$H2>Dj$9$k!#(B
@c The value returned is @var{columns}.
$BLa$jCM$O(B@var{columns}$B$G$"$k!#(B
@example
@group
(set-window-hscroll (selected-window) 10)
@result{} 10
@end group
@end example
@end defun
@c Here is how you can determine whether a given position @var{position}
@c is off the screen due to horizontal scrolling:
$B?eJ?%9%/%m!<%k$N$?$a$K;XDj0LCV(B@var{position}$B$,(B
$B%9%/%j!<%s$+$i$O$_=P$7$F$$$k$+$I$&$+$rD4$Y$kJ}K!$r$D$.$K<($7$^$9!#(B
@example
@group
(defun hscroll-on-screen (window position)
(save-excursion
(goto-char position)
(and
(>= (- (current-column) (window-hscroll window)) 0)
(< (- (current-column) (window-hscroll window))
(window-width window)))))
@end group
@end example
@node Size of Window
@c @section The Size of a Window
@section $B%&%#%s%I%&%5%$%:(B
@c @cindex window size
@c @cindex size of window
@cindex $B%&%#%s%I%&%5%$%:(B
@cindex $BBg$-$5!"%&%#%s%I%&(B
@cindex $B%5%$%:!"%&%#%s%I%&(B
@c An Emacs window is rectangular, and its size information consists of
@c the height (the number of lines) and the width (the number of character
@c positions in each line). The mode line is included in the height. But
@c the width does not count the scroll bar or the column of @samp{|}
@c characters that separates side-by-side windows.
Emacs$B$N%&%#%s%I%&$O6k7A$G$"$j!"$=$N%5%$%:>pJs$O(B
$B9b$5!J9T?t!K$HI}!J3F9T$NJ8;z?t!K$+$i@.$j$^$9!#(B
$B%b!<%I9T$O9b$5$K4^$_$^$9!#(B
$B$7$+$7!"%9%/%m!<%k%P!<$d:81&$N%&%#%s%I%&$r3V$F$kJ8;z(B@samp{|}$B$N%3%i%`$O(B
$BI}$K$O4^$_$^$;$s!#(B
@c The following three functions return size information about a window:
$B$D$.$N(B3$B$D$N4X?t$O!"%&%#%s%I%&$N%5%$%:>pJs$rJV$7$^$9!#(B
@defun window-height &optional window
@c This function returns the number of lines in @var{window}, including its
@c mode line. If @var{window} fills its entire frame, this is typically
@c one less than the value of @code{frame-height} on that frame (since the
@c last line is always reserved for the minibuffer).
$B$3$N4X?t$O!"%b!<%I9T$r4^$`(B@var{window}$B$N9T?t$rJV$9!#(B
@var{window}$B$,%U%l!<%`A4BN$r@j$a$k>l9g!"$3$NCM$OE57?E*$K$O!"(B
$BEv3:%U%l!<%`$K$*$1$k(B@code{frame-height}$B$NCM$h$j(B1$B>.$5$$(B
$B!J:G8e$N9T$O%_%K%P%C%U%!MQ$K$D$M$K3NJ]$7$F$"$k$?$a!K!#(B
@c If @var{window} is @code{nil}, the function uses the selected window.
@var{window}$B$,(B@code{nil}$B$G$"$k$H!"$3$N4X?t$OA*Br$5$l$F$$$k%&%#%s%I%&$r;H$&!#(B
@example
@group
(window-height)
@result{} 23
@end group
@group
(split-window-vertically)
@result{} #<window 4 on windows.texi>
@end group
@group
(window-height)
@result{} 11
@end group
@end example
@end defun
@defun window-width &optional window
@c This function returns the number of columns in @var{window}. If
@c @var{window} fills its entire frame, this is the same as the value of
@c @code{frame-width} on that frame. The width does not include the
@c window's scroll bar or the column of @samp{|} characters that separates
@c side-by-side windows.
$B$3$N4X?t$O!"(B@var{window}$B$N%3%i%`?t$rJV$9!#(B
@var{window}$B$,%U%l!<%`A4BN$r@j$a$k>l9g!"$3$NCM$O!"(B
$BEv3:%U%l!<%`$K$*$1$k(B@code{frame-width}$B$NCM$HF1$8$G$"$k!#(B
$B$3$NI}$K$O!"%&%#%s%I%&$N%9%/%m!<%k%P!<$d(B
$B:81&$N%&%#%s%I%&$r3V$F$kJ8;z(B@samp{|}$B$N%3%i%`$O4^$^$J$$!#(B
@c If @var{window} is @code{nil}, the function uses the selected window.
@var{window}$B$,(B@code{nil}$B$G$"$k$H!"$3$N4X?t$OA*Br$5$l$F$$$k%&%#%s%I%&$r;H$&!#(B
@example
@group
(window-width)
@result{} 80
@end group
@end example
@end defun
@defun window-edges &optional window
@c This function returns a list of the edge coordinates of @var{window}.
@c If @var{window} is @code{nil}, the selected window is used.
$B$3$N4X?t$O!"(B@var{window}$B$N;M6y$N:BI8$+$i@.$k%j%9%H$rJV$9!#(B
@var{window}$B$,(B@code{nil}$B$G$"$k$H!"A*Br$5$l$F$$$k%&%#%s%I%&$r;H$&!#(B
@c The order of the list is @code{(@var{left} @var{top} @var{right}
@c @var{bottom})}, all elements relative to 0, 0 at the top left corner of
@c the frame. The element @var{right} of the value is one more than the
@c rightmost column used by @var{window}, and @var{bottom} is one more than
@c the bottommost row used by @var{window} and its mode-line.
list$BFb$N=gHV$O(B@code{(@var{left} @var{top} @var{right} @var{bottom})}
$B!J$D$^$j!":8C<!">eC<!"1&C<!"2<C<!K$G$"$j!"(B
$B%U%l!<%`$N:8>e6y$r(B0$B$H$7$F$9$Y$F$NMWAG$O(B0$B$r4p=`$H$9$k!#(B
$BMWAG(B@var{right}$B$O(B@var{window}$B$,;HMQ$9$k1&C<$N%3%i%`$h$j(B1$BBg$-$/!"(B
@var{bottom}$B$O(B@var{window}$B$,;HMQ$9$k2<C<$h$j(B1$BBg$-$/(B
$B%b!<%I9T$HF1$8$G$"$k!#(B
@c When you have side-by-side windows, the right edge value for a window
@c with a neighbor on the right includes the width of the separator between
@c the window and that neighbor. This separator may be a column of
@c @samp{|} characters or it may be a scroll bar. Since the width of the
@c window does not include this separator, the width does not equal the
@c difference between the right and left edges in this case.
$B:81&$KNY$j9g$C$?%&%#%s%I%&$,$"$k>l9g!"(B
$B1&NY$K%&%#%s%I%&$,$"$k%&%#%s%I%&$N1&C<$NCM$K$O!"(B
$B%&%#%s%I%&$r3V$F$k6h@Z$j$NI}$,4^$^$l$k!#(B
$B$3$N6h@Z$j$O!"J8;z(B@samp{|}$B$N%3%i%`$G$"$k$+%9%/%m!<%k%P!<$G$"$k!#(B
$B%&%#%s%I%&$NI}$K$O$3$N6h@Z$j$O4^$^$J$$$?$a!"(B
$B$3$N>l9g!":8C<$H1&C<$N:9$OI}$KEy$7$/$J$$!#(B
@c Here is the result obtained on a typical 24-line terminal with just one
@c window:
$BE57?E*$J(B24$B9T$NC<Kv$G%&%#%s%I%&$,(B1$B$D$N>l9g$KF@$i$l$k7k2L$r<($9!#(B
@example
@group
(window-edges (selected-window))
@result{} (0 0 80 23)
@end group
@end example
@noindent
@c The bottom edge is at line 23 because the last line is the echo area.
$B2<C<$,(B23$B9TL\$G$"$k$N$O!":G2<9T$O%(%3!<NN0h$@$+$i$G$"$k!#(B
@c If @var{window} is at the upper left corner of its frame, then
@c @var{bottom} is the same as the value of @code{(window-height)},
@c @var{right} is almost the same as the value of
@c @code{(window-width)}@footnote{They are not exactly equal because
@c @var{right} includes the vertical separator line or scroll bar, while
@c @code{(window-width)} does not.}, and @var{top} and @var{left} are zero.
@c For example, the edges of the following window are @w{@samp{0 0 5 8}}.
@c Assuming that the frame has more than 8 columns, the last column of the
@c window (column 7) holds a border rather than text. The last row (row 4)
@c holds the mode line, shown here with @samp{xxxxxxxxx}.
@var{window}$B$,%U%l!<%`$N:8>e6y$K$"$k$H!"(B
@var{bottom}$B$O(B@code{(window-height)}$B$NCM$KEy$7$/!"(B
@var{right}$B$O(B@code{(window-width)}$B$NCM$K$[$\Ey$7$/(B
@footnote{@var{right}$B$O?bD>$N6h@Z$j9T$d%9%/%m!<%k%P!<$r4^$`$,!"(B
@code{(window-width)}$B$O$=$l$i$r4^$^$J$$$?$a!"(B
$B40A4$KEy$7$/$O$J$$!#(B}$B!"(B
@var{top}$B$H(B@var{left}$B$O(B0$B$G$"$k!#(B
$B$?$H$($P!"$D$.$N%&%#%s%I%&$O(B@w{@samp{0 0 5 8}}$B$G$"$k!#(B
$BEv3:%U%l!<%`$K$O(B8$B%3%i%`$h$jB?$/$"$j!"(B
$B%&%#%s%I%&$N:G=*%3%i%`!J(B7$B%3%i%`L\!K$O%F%-%9%H$G$O$J$/6-3&$G$"$k$H2>Dj$9$k!#(B
$B:G8e$N9T!J(B4$B9TL\!K$O%b!<%I9T$G$"$j!"$3$3$G$O(B@samp{xxxxxxxxx}$B$G<($7$?!#(B
@example
@group
0
_______
0 | |
| |
| |
| |
xxxxxxxxx 4
7
@end group
@end example
@c When there are side-by-side windows, any window not at the right edge of
@c its frame has a separator in its last column or columns. The separator
@c counts as one or two columns in the width of the window. A window never
@c includes a separator on its left, since that belongs to the window to
@c the left.
$B:81&$KNY$j9g$C$?%&%#%s%I%&$,$"$k$H$-$K$O!"(B
$B%U%l!<%`$N1&C<$K$J$$%&%#%s%I%&$N:G8e$N%3%i%`$O6h@Z$j$G$"$k!#(B
$B6h@Z$j$O!"%&%#%s%I%&$NI}$G$O(B1$B%3%i%`$+(B2$B%3%i%`@j$a$k!#(B
$B:8B&$N6h@Z$j$O:8NY$N%&%#%s%I%&$KB0$9$k$N$G!"(B
$B%&%#%s%I%&$K$O:8B&$N6h@Z$j$O4^$^$l$J$$!#(B
@c In the following example, let's suppose that the frame is 7
@c columns wide. Then the edges of the left window are @w{@samp{0 0 4 3}}
@c and the edges of the right window are @w{@samp{4 0 7 3}}.
$B$D$.$NNc$G$O!"%U%l!<%`$O(B7$B%3%i%`I}$G$"$k$H$9$k!#(B
$B$9$k$H!":8B&$N%&%#%s%I%&$N;M6y$O(B@w{@samp{0 0 4 3}}$B$G$"$j!"(B
$B1&B&$N%&%#%s%I%&$N;M6y$O(B@w{@samp{4 0 7 3}}$B$G$"$k!#(B
@example
@group
___ ___
| | |
| | |
xxxxxxxxx
0 34 7
@end group
@end example
@end defun
@node Resizing Windows
@c @section Changing the Size of a Window
@section $B%&%#%s%I%&%5%$%:$NJQ99(B
@c @cindex window resizing
@c @cindex changing window size
@c @cindex window size, changing
@cindex $B%&%#%s%I%&$N%j%5%$%:(B
@cindex $B%&%#%s%I%&%5%$%:$NJQ99(B
@cindex $BJQ99!"%&%#%s%I%&%5%$%:(B
@c The window size functions fall into two classes: high-level commands
@c that change the size of windows and low-level functions that access
@c window size. Emacs does not permit overlapping windows or gaps between
@c windows, so resizing one window affects other windows.
$B%&%#%s%I%&%5%$%:4X?t$O(B2$B$D$KBgJL$G$-$^$9!#(B
$B%&%#%s%I%&%5%$%:$rJQ$($k>e0L%l%Y%k$N%3%^%s%I$H(B
$B%&%#%s%I%&%5%$%:$rD4$Y$k2<0L%l%Y%k$N4X?t$G$9!#(B
Emacs$B$G$O=E$J$j9g$C$?%&%#%s%I%&$d%&%#%s%I%&$N$"$$$@$K7d4V$r5v$5$J$$$N$G!"(B
1$B$D$N%&%#%s%I%&$NBg$-$5$rJQ$($k$HJL$N%&%#%s%I%&$K$b1F6A$7$^$9!#(B
@c @deffn Command enlarge-window size &optional horizontal
@deffn $B%3%^%s%I(B enlarge-window size &optional horizontal
@c This function makes the selected window @var{size} lines taller,
@c stealing lines from neighboring windows. It takes the lines from one
@c window at a time until that window is used up, then takes from another.
@c If a window from which lines are stolen shrinks below
@c @code{window-min-height} lines, that window disappears.
$B$3$N4X?t$O!"NY$j9g$&%&%#%s%I%&$+$i>l=j$rC%$C$F!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$r(B@var{size}$B9T9b$/$9$k!#(B
1$B$D$N%&%#%s%I%&$+$i>l=j$rC%$$<h$j!"C%$$?T$/$9$HJL$N%&%#%s%I%&$+$i<h$k!#(B
$B>l=j$rC%$o$l$?%&%#%s%I%&$,(B@code{window-min-height}$B9TL$K~$K$J$k$H!"(B
$B$=$N%&%#%s%I%&$O>C$($k!#(B
@c If @var{horizontal} is non-@code{nil}, this function makes
@c @var{window} wider by @var{size} columns, stealing columns instead of
@c lines. If a window from which columns are stolen shrinks below
@c @code{window-min-width} columns, that window disappears.
@var{horizontal}$B$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B$3$N4X?t$O!"NY$j9g$&%&%#%s%I%&$+$i>l=j$rC%$C$F!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$r(B@var{size}$B%3%i%`9-$/$9$k!#(B
$B>l=j$rC%$o$l$?%&%#%s%I%&$,(B@code{window-min-width}$B%3%i%`L$K~$K$J$k$H!"(B
$B$=$N%&%#%s%I%&$O>C$($k!#(B
@c If the requested size would exceed that of the window's frame, then the
@c function makes the window occupy the entire height (or width) of the
@c frame.
$B;XDj$7$?Bg$-$5$,%&%#%s%I%&$N%U%l!<%`$NBg$-$5$rD6$($k>l9g!"(B
$B$3$N4X?t$O!"%&%#%s%I%&$,%U%l!<%`$N9b$5!J$"$k$$$OI}!KA4BN$r@j$a$k$h$&$K$9$k!#(B
@c If @var{size} is negative, this function shrinks the window by
@c @minus{}@var{size} lines or columns. If that makes the window smaller
@c than the minimum size (@code{window-min-height} and
@c @code{window-min-width}), @code{enlarge-window} deletes the window.
@var{size}$B$,Ii$G$"$k$H!"$3$N4X?t$O(B@minus{}@var{size}$B9T!?%3%i%`$@$1(B
$B%&%#%s%I%&$r=L$a$k!#(B
$B%&%#%s%I%&$,!J(B@code{window-min-height}$B$H(B@code{window-min-width}$B$N!K(B
$B:G>.%5%$%:$h$j>.$5$/$J$k$H!"(B@code{enlarge-window}$B$O(B
$BEv3:%&%#%s%I%&$r:o=|$9$k!#(B
@c @code{enlarge-window} returns @code{nil}.
@code{enlarge-window}$B$O(B@code{nil}$B$rJV$9!#(B
@end deffn
@c @deffn Command enlarge-window-horizontally columns
@deffn $B%3%^%s%I(B enlarge-window-horizontally columns
@c This function makes the selected window @var{columns} wider.
@c It could be defined as follows:
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r(B@var{columns}$B%3%i%`9-$/$9$k!#(B
@example
@group
(defun enlarge-window-horizontally (columns)
(enlarge-window columns t))
@end group
@end example
@end deffn
@c @deffn Command shrink-window size &optional horizontal
@deffn $B%3%^%s%I(B shrink-window size &optional horizontal
@c This function is like @code{enlarge-window} but negates the argument
@c @var{size}, making the selected window smaller by giving lines (or
@c columns) to the other windows. If the window shrinks below
@c @code{window-min-height} or @code{window-min-width}, then it disappears.
$B$3$N4X?t$O(B@code{enlarge-window}$B$K;w$F$$$k$,0z?t(B@var{size}$B$NId9f$rJQ$($F!"(B
$BA*Br$5$l$F$$$k%&%#%s%I%&$r=L$a$F;XDj9T?t!J%3%i%`?t!K$r(B
$BB>$N%&%#%s%I%&$KM?$($k!#(B
$B%&%#%s%I%&$,(B@code{window-min-height}$B$d(B@code{window-min-width}$BL$K~$K=L$`$H!"(B
$B$=$N%&%#%s%I%&$O>C$($k!#(B
@c If @var{size} is negative, the window is enlarged by @minus{}@var{size}
@c lines or columns.
@var{size}$B$,Ii$G$"$k$H!"%&%#%s%I%&$O(B
@minus{}@var{size}$B9T!?%3%i%`$@$1?-$S$k!#(B
@end deffn
@c @deffn Command shrink-window-horizontally columns
@deffn $B%3%^%s%I(B shrink-window-horizontally columns
@c This function makes the selected window @var{columns} narrower.
@c It could be defined as follows:
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%&%#%s%I%&$r(B@var{columns}$B%3%i%`69$/$9$k!#(B
$B$D$.$N$h$&$KDj5A$G$-$k!#(B
@example
@group
(defun shrink-window-horizontally (columns)
(shrink-window columns t))
@end group
@end example
@end deffn
@c @deffn Command shrink-window-if-larger-than-buffer window
@deffn $B%3%^%s%I(B shrink-window-if-larger-than-buffer window
@c This command shrinks @var{window} to be as small as possible while still
@c showing the full contents of its buffer---but not less than
@c @code{window-min-height} lines.
$B$3$N%3%^%s%I$O!"%P%C%U%!$NA4FbMF$rI=<($9$k$K==J,$J$@$1$NBg$-$5$K(B
@var{window}$B$r=L$a$k$,!"(B@code{window-min-height}$B9TL$K~$K$O$7$J$$!#(B
@c However, the command does nothing if the window is already too small to
@c display the whole text of the buffer, or if part of the contents are
@c currently scrolled off screen, or if the window is not the full width of
@c its frame, or if the window is the only window in its frame.
$B$7$+$7!"%P%C%U%!$NA4%F%-%9%H$rI=<($9$k$K$O%&%#%s%I%&$,>.$5$9$.$k>l9g$d!"(B
$BFbMF$N0lIt$,%9%/%m!<%k$G%9%/%j!<%s$+$i$O$_=P$7$F$$$k>l9g$d!"(B
$B%&%#%s%I%&$NI}$,%U%l!<%`$NI}$HF1$8$G$J$$>l9g$d!"(B
$B%&%#%s%I%&$,%U%l!<%`$NM#0l$N%&%#%s%I%&$G$"$k>l9g$K$O!"(B
$B$3$N%3%^%s%I$O$J$K$b$7$J$$!#(B
@end deffn
@c @cindex minimum window size
@cindex $B%&%#%s%I%&$N:G>.%5%$%:(B
@c The following two variables constrain the window-size-changing
@c functions to a minimum height and width.
$B$D$.$N(B2$B$D$NJQ?t$O!"%&%#%s%I%&%5%$%:$rJQ$($k4X?t$K:G>.$N9b$5$HI}$r2]$7$^$9!#(B
@defopt window-min-height
@c The value of this variable determines how short a window may become
@c before it is automatically deleted. Making a window smaller than
@c @code{window-min-height} automatically deletes it, and no window may be
@c created shorter than this. The absolute minimum height is two (allowing
@c one line for the mode line, and one line for the buffer display).
@c Actions that change window sizes reset this variable to two if it is
@c less than two. The default value is 4.
$B$3$NJQ?t$NCM$O!"%&%#%s%I%&$,<+F0E*$K:o=|$5$l$k$^$G$K(B
$B$I$NDxEY$^$G%&%#%s%I%&$,C;$/$J$j$&$k$+$r7hDj$9$k!#(B
$B%&%#%s%I%&$r(B@code{window-min-height}$B9TL$K~$K>.$5$/$9$k$H<+F0E*$K:o=|$5$l!"(B
$B$3$l$h$jC;$$%&%#%s%I%&$O:n@.$G$-$J$$!#(B
$B@dBPE*$J:G>.$N9b$5$O(B2$B9T!J%b!<%I9T$K(B1$B9T!"%P%C%U%!$NI=<($K(B1$B9T!K$G$"$k!#(B
$B%&%#%s%I%&%5%$%:$rJQ$($k=hM}$G$O!"$3$NJQ?t$,(B2$BL$K~$G$"$k$H(B2$B$K@_Dj$7D>$9!#(B
$B%G%U%)%k%HCM$O(B4$B$G$"$k!#(B
@end defopt
@defopt window-min-width
@c The value of this variable determines how narrow a window may become
@c before it is automatically deleted. Making a window smaller than
@c @code{window-min-width} automatically deletes it, and no window may be
@c created narrower than this. The absolute minimum width is one; any
@c value below that is ignored. The default value is 10.
$B$3$NJQ?t$NCM$O!"%&%#%s%I%&$,<+F0E*$K:o=|$5$l$k$^$G$K(B
$B$I$NDxEY$^$G%&%#%s%I%&$,69$/$J$j$&$k$+$r7hDj$9$k!#(B
$B%&%#%s%I%&$r(B@code{window-min-width}$B%3%i%`L$K~$K>.$5$/$9$k$H<+F0E*$K:o=|$5$l!"(B
$B$3$l$h$j69$$%&%#%s%I%&$O:n@.$G$-$J$$!#(B
$B@dBPE*$J:G>.$NI}$O(B1$B$G$"$j!"$=$lL$K~$OL5;k$9$k!#(B
$B%G%U%)%k%HCM$O(B10$B$G$"$k!#(B
@end defopt
@node Coordinates and Windows
@c @section Coordinates and Windows
@section $B:BI8$H%&%#%s%I%&(B
@c This section describes how to relate screen coordinates to windows.
$BK\@a$G$O!"%9%/%j!<%s:BI8$r%&%#%s%I%&$K4XO"IU$1$kJ}K!$r=R$Y$^$9!#(B
@defun window-at x y &optional frame
@c This function returns the window containing the specified cursor
@c position in the frame @var{frame}. The coordinates @var{x} and @var{y}
@c are measured in characters and count from the top left corner of the
@c frame. If they are out of range, @code{window-at} returns @code{nil}.
$B$3$N4X?t$O!"%U%l!<%`(B@var{frame}$B$K$*$$$F;XDj$7$?%+!<%=%k0LCV$r4^$s$G$$$k(B
$B%&%#%s%I%&$rJV$9!#(B
$B:BI8(B@var{x}$B$H(B@var{y}$B$O!"%U%l!<%`$N:8>e6y$+$iJ8;zC10L$G?t$($k!#(B
$B:BI8$,HO0O30$G$"$k$H(B@code{window-at}$B$O(B@code{nil}$B$rJV$9!#(B
@c If you omit @var{frame}, the selected frame is used.
@var{frame}$B$r>JN,$9$k$H!"A*Br$5$l$F$$$k%U%l!<%`$r;H$&!#(B
@end defun
@defun coordinates-in-window-p coordinates window
@c This function checks whether a particular frame position falls within
@c the window @var{window}.
$B$3$N4X?t$O!";XDj$7$?%U%l!<%`0LCV$,%&%#%s%I%&(B@var{window}$B$NCf$K(B
$BF~$k$+$I$&$+$r8!::$9$k!#(B
@c The argument @var{coordinates} is a cons cell of the form @code{(@var{x}
@c . @var{y})}. The coordinates @var{x} and @var{y} are measured in
@c characters, and count from the top left corner of the screen or frame.
$B0z?t(B@var{coordinates}$B$O!"(B@code{(@var{x} . @var{y})}$B$N7A$N%3%s%9%;%k$G$"$k!#(B
$B:BI8(B@var{x}$B$H(B@var{y}$B$O!"%9%/%j!<%s$d%U%l!<%`$N:8>e6y$+$iJ8;zC10L$G?t$($k!#(B
@c The value returned by @code{coordinates-in-window-p} is non-@code{nil}
@c if the coordinates are inside @var{window}. The value also indicates
@c what part of the window the position is in, as follows:
@code{coordinates-in-window-p}$B$,JV$9CM$,(B@code{nil}$B0J30$G$"$k$H!"(B
$BEv3::BI8$O(B@var{window}$B$NFbB&$K$"$k!#(B
$B$D$.$N$h$&$K!"$3$NCM$O%&%#%s%I%&Fb$G$N0LCV$bI=$9!#(B
@table @code
@item (@var{relx} . @var{rely})
@c The coordinates are inside @var{window}. The numbers @var{relx} and
@c @var{rely} are the equivalent window-relative coordinates for the
@c specified position, counting from 0 at the top left corner of the
@c window.
$BEv3::BI8$O(B@var{window}$B$NFbB&$G$"$k!#(B
$B?t(B@var{relx}$B$H(B@var{rely}$B$O!";XDj0LCV$KBP1~$9$k%&%#%s%I%&AjBP$N:BI8$G$"$j!"(B
$B%&%#%s%I%&$N:8>e6y$r(B0$B$H$7$F?t$($?$b$N$G$"$k!#(B
@item mode-line
@c The coordinates are in the mode line of @var{window}.
$BEv3::BI8$O(B@var{window}$B$N%b!<%I9T$NFbB&$G$"$k!#(B
@item vertical-split
@c The coordinates are in the vertical line between @var{window} and its
@c neighbor to the right. This value occurs only if the window doesn't
@c have a scroll bar; positions in a scroll bar are considered outside the
@c window.
$BEv3::BI8$O(B@var{window}$B$H1&NY$N%&%#%s%I%&$N$"$$$@$N?bD>9T$G$"$k!#(B
$B%&%#%s%I%&$K%9%/%m!<%k%P!<$,$J$$>l9g$K8B$C$F!"$3$NCM$K$J$k!#(B
$B%9%/%m!<%k%P!<$O%&%#%s%I%&$N30B&$G$"$k$H$_$J$9!#(B
@item nil
@c The coordinates are not in any part of @var{window}.
$BEv3::BI8$O(B@var{window}$B$N$I$3$G$b$J$$!#(B
@end table
@c The function @code{coordinates-in-window-p} does not require a frame as
@c argument because it always uses the frame that @var{window} is on.
$B4X?t(B@code{coordinates-in-window-p}$B$O!"(B
@var{window}$B$N%U%l!<%`$r$D$M$K;H$&$?$a!"0z?t$K%U%l!<%`$rI,MW$H$7$J$$!#(B
@end defun
@node Window Configurations
@c @section Window Configurations
@section $B%&%#%s%I%&9=@.(B
@c @cindex window configurations
@c @cindex saving window information
@cindex $B%&%#%s%I%&9=@.(B
@cindex $B%&%#%s%I%&>pJs$NJ]B8(B
@cindex $BJ]B8!"%&%#%s%I%&>pJs(B
@c A @dfn{window configuration} records the entire layout of one
@c frame---all windows, their sizes, which buffers they contain, what part
@c of each buffer is displayed, and the values of point and the mark. You
@c can bring back an entire previous layout by restoring a window
@c configuration previously saved.
@dfn{$B%&%#%s%I%&9=@.(B}$B!J(Bwindow configuration$B!K$O!"(B
1$B$D$N%U%l!<%`$NA4BN$NG[CV!"$D$^$j!"(B
$B$9$Y$F$N%&%#%s%I%&!"$=$l$i$NBg$-$5!"I=<($7$F$$$k%P%C%U%!!"(B
$B3F%P%C%U%!$NI=<(0LCV!"%]%$%s%H$H%^!<%/$NCM$r5-O?$7$^$9!#(B
$BJ]B8$7$F$*$$$?%&%#%s%I%&9=@.$rI|85$9$l$P!"(B
$B$^$($H$^$C$?$/F1$8G[CV$KLa$;$^$9!#(B
@c If you want to record all frames instead of just one, use a frame
@c configuration instead of a window configuration. @xref{Frame
@c Configurations}.
1$B$D$N%U%l!<%`$G$O$J$/$9$Y$F$N%U%l!<%`$r5-O?$9$k$K$O!"(B
$B%&%#%s%I%&9=@.$N$+$o$j$K%U%l!<%`9=@.$r;H$$$^$9!#(B
@xref{Frame Configurations}$B!#(B
@defun current-window-configuration
@c This function returns a new object representing the selected frame's
@c current window configuration, including the number of windows, their
@c sizes and current buffers, which window is the selected window, and for
@c each window the displayed buffer, the display-start position, and the
@c positions of point and the mark. It also includes the values of
@c @code{window-min-height}, @code{window-min-width} and
@c @code{minibuffer-scroll-window}. An exception is made for point in the
@c current buffer, whose value is not saved.
$B$3$N4X?t$O!"A*Br$5$l$F$$$k%U%l!<%`$N8=:_$N%&%#%s%I%&9=@.$rI=$9(B
$B?7$?$J%*%V%8%'%/%H$rJV$9!#(B
$B%&%#%s%I%&9=@.$K$O!"%&%#%s%I%&$N8D?t!"$=$l$i$NBg$-$5$H%+%l%s%H%P%C%U%!!"(B
$B$I$N%&%#%s%I%&$,A*Br$5$l$F$$$k%&%#%s%I%&$G$"$k$+!"(B
$B3F%&%#%s%I%&$,I=<($7$F$$$k%P%C%U%!!"I=<(3+;O0LCV!"(B
$B%]%$%s%H$H%^!<%/$N0LCV$,4^$^$l$k!#(B
@code{window-min-height}$B!"(B@code{window-min-width}$B!"(B
@code{minibuffer-scroll-window}$B$NCM$b4^$`!#(B
$BNc30$O%+%l%s%H%P%C%U%!$N%]%$%s%H$G$"$j!"$=$NCM$OJ]B8$5$l$J$$!#(B
@end defun
@defun set-window-configuration configuration
@c This function restores the configuration of windows and buffers as
@c specified by @var{configuration}. The argument @var{configuration} must
@c be a value that was previously returned by
@c @code{current-window-configuration}. This configuration is restored in
@c the frame from which @var{configuration} was made, whether that frame is
@c selected or not. This always counts as a window size change and
@c triggers execution of the @code{window-size-change-functions}
@c (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't
@c know how to tell whether the new configuration actually differs from the
@c old one.
$B$3$N4X?t$O!"(B@var{configuration}$B$G;XDj$5$l$k(B
$B%&%#%s%I%&$H%P%C%U%!$N9=@.$KI|85$9$k!#(B
$B0z?t(B@var{configuration}$B$O!"(B
@code{current-window-configuration}$B$,JV$7$?CM$G$"$k$3$H!#(B
@var{configuration}$B$r:n@.$7$?%U%l!<%`$K$*$$$F!"(B
$B$=$N%U%l!<%`$,A*Br$5$l$F$$$k$+$I$&$+$K4X$o$i$:!"$3$N9=@.$rI|85$9$k!#(B
@code{set-window-configuration}$B$O!"?7$?$J9=@.$,8E$$$b$N$H(B
$B<B:]$K0[$J$k$N$+$I$&$+<1JL$9$kJ}K!$rCN$i$J$$$?$a!"(B
$B%&%#%s%I%&%5%$%:$NJQ99$H$D$M$K$_$J$7$F(B
@code{window-size-change-functions}$B!J(B@pxref{Window Hooks}$B!K$N(B
$B<B9T$r0z$-5/$3$9!#(B
@c If the frame which @var{configuration} was saved from is dead, all this
@c function does is restore the three variables @code{window-min-height},
@c @code{window-min-width} and @code{minibuffer-scroll-window}.
@var{configuration}$B$rJ]B8$7$?%U%l!<%`$,$J$/$J$C$F$$$k$H!"(B
$B$3$N4X?t$O!"(B3$B$D$NJQ?t!"(B@code{window-min-height}$B!"(B
@code{window-min-width}$B!"(B@code{minibuffer-scroll-window}$B$r(B
$BI|85$9$k$@$1$G$"$k!#(B
@c Here is a way of using this function to get the same effect
@c as @code{save-window-excursion}:
@code{save-window-excursion}$B$HF1$88z2L$rF@$k$?$a$N(B
$B$3$N4X?t$N;H$$J}$r$D$.$K<($9!#(B
@example
@group
(let ((config (current-window-configuration)))
(unwind-protect
(progn (split-window-vertically nil)
@dots{})
(set-window-configuration config)))
@end group
@end example
@end defun
@defspec save-window-excursion forms@dots{}
@c This special form records the window configuration, executes @var{forms}
@c in sequence, then restores the earlier window configuration. The window
@c configuration includes the value of point and the portion of the buffer
@c that is visible. It also includes the choice of selected window.
@c However, it does not include the value of point in the current buffer;
@c use @code{save-excursion} also, if you wish to preserve that.
$B$3$N%9%Z%7%c%k%U%)!<%`$O!"%&%#%s%I%&9=@.$r5-O?$7!"(B
@var{forms}$B$r=g$KI>2A$7!"$b$H$N%&%#%s%I%&9=@.$KI|85$9$k!#(B
$B%&%#%s%I%&9=@.$K$O!"%]%$%s%H$NCM$H2D;k$J%P%C%U%!$NItJ,$,4^$^$l$k!#(B
$B$^$?!"A*Br$5$l$F$$$k%&%#%s%I%&$b4^$`!#(B
$B$7$+$7!"$3$l$K$O%+%l%s%H%P%C%U%!$N%]%$%s%HCM$O4^$^$l$J$$$?$a!"(B
$B%]%$%s%H0LCV$rJ]B8$7$?$$>l9g$K$O(B@code{save-excursion}$B$b;H$&!#(B
@c Don't use this construct when @code{save-selected-window} is all you need.
@code{save-selected-window}$B$G==J,$J$H$-$K$O!"$3$N9=J8$r;H$o$J$$$3$H!#(B
@c Exit from @code{save-window-excursion} always triggers execution of the
@c @code{window-size-change-functions}. (It doesn't know how to tell
@c whether the restored configuration actually differs from the one in
@c effect at the end of the @var{forms}.)
@code{save-window-excursion}$B$+$iH4$1$k$H!"(B
@code{window-size-change-functions}$B$N<B9T$r$D$M$K0z$-5/$3$9!#(B
$B!JI|85$7$?9=@.$H(B@var{forms}$B$N=*$j$G$N9=@.$,<B:]$K0[$J$k$+$I$&$+$r(B
$B<1JL$9$kJ}K!$rCN$i$J$$!#!K(B
@c The return value is the value of the final form in @var{forms}.
@c For example:
$BLa$jCM$O!"(B@var{forms}$B$N:G8e$N%U%)!<%`$NCM$G$"$k!#(B
$BNc$r<($9!#(B
@example
@group
(split-window)
@result{} #<window 25 on control.texi>
@end group
@group
(setq w (selected-window))
@result{} #<window 19 on control.texi>
@end group
@group
(save-window-excursion
(delete-other-windows w)
(switch-to-buffer "foo")
'do-something)
@result{} do-something
@c ;; @r{The screen is now split again.}
;; @r{$B%9%/%j!<%s$O$3$3$G$U$?$?$SJ,3d$5$l$k(B}
@end group
@end example
@end defspec
@defun window-configuration-p object
@c This function returns @code{t} if @var{object} is a window configuration.
$B$3$N4X?t$O!"(B@var{object}$B$,%&%#%s%I%&9=@.$G$"$l$P(B@code{t}$B$rJV$9!#(B
@end defun
@defun compare-window-configurations config1 config2
@c This function compares two window configurations as regards the
@c structure of windows, but ignores the values of point and mark and the
@c saved scrolling positions---it can return @code{t} even if those
@c aspects differ.
$B$3$N4X?t$O!"%&%#%s%I%&$N9=B$$r4p$K(B2$B$D$N%&%#%s%I%&9=@.$rHf3S$9$k!#(B
$B%]%$%s%H$H%^!<%/$NCM!"J]B8$5$l$?%9%/%m!<%k0LCV$OL5;k$9$k$N$G!"(B
$B$=$l$i$,0[$J$C$F$$$F$b(B@code{t}$B$rJV$9!#(B
@c The function @code{equal} can also compare two window configurations; it
@c regards configurations as unequal if they differ in any respect, even a
@c saved point or mark.
$B4X?t(B@code{equal}$B$G$b(B2$B$D$N%&%#%s%I%&9=@.$rHf3S$G$-$k$,!"(B
$BJ]B8$5$l$?%]%$%s%H$d%^!<%/$,0c$&$@$1$G$"$C$F$b0[$J$kItJ,$,$"$k$H!"(B
$BEy$7$/$J$$9=@.$H$_$J$9!#(B
@end defun
@c Primitives to look inside of window configurations would make sense,
@c but none are implemented. It is not clear they are useful enough to be
@c worth implementing.
$B%&%#%s%I%&9=@.$NFbIt$rD4$Y$k4pK\4X?t$K$O0UL#$,$"$k$G$7$g$&$,!"(B
$B<BAu$7$F$"$j$^$;$s!#(B
$B<BAu$9$k$@$1$N2ACM$,$"$k$[$IM-MQ$J$N$+$O$C$-$j$7$J$$$N$G$9!#(B
@node Window Hooks
@c @section Hooks for Window Scrolling and Changes
@section $B%&%#%s%I%&$N%9%/%m!<%k$H%5%$%:JQ998~$1$N%U%C%/(B
@c This section describes how a Lisp program can take action whenever a
@c window displays a different part of its buffer or a different buffer.
@c There are three actions that can change this: scrolling the window,
@c switching buffers in the window, and changing the size of the window.
@c The first two actions run @code{window-scroll-functions}; the last runs
@c @code{window-size-change-functions}. The paradigmatic use of these
@c hooks is in the implementation of Lazy Lock mode; see @ref{Support
@c Modes, Lazy Lock, Font Lock Support Modes, emacs, The GNU Emacs Manual}.
$BK\@a$G$O!"%&%#%s%I%&$K%P%C%U%!$NJL$NItJ,$rI=<($7$?$j(B
$BJL$N%P%C%U%!$rI=<($9$k$?$S$K!"(B
Lisp$B%W%m%0%i%`$,F0:n$9$kJ}K!$r=R$Y$^$9!#(B
$BJQ99$G$-$kF0:n$O(B3$B<oN`!"%&%#%s%I%&$r%9%/%m!<%k$9$k$H$-!"(B
$B%&%#%s%I%&$G%P%C%U%!$r@Z$jBX$($k$H$-!"(B
$B%&%#%s%I%&%5%$%:$rJQ$($k$H$-$G$9!#(B
$B:G=i$N(B2$B$D$NF0:n$G$O(B@code{window-scroll-functions}$B$r<B9T$7!"(B
3$B$DL\$O(B@code{window-size-change-functions}$B$r<B9T$7$^$9!#(B
$B$3$l$i$N%U%C%/$NLOHOE*$J;HMQNc$OCY1d%m%C%/!J(Blazy-lock$B!K%b!<%I$N(B
$B<BAu$NCf$K$"$j$^$9!#(B
@ref{Support Modes,, $B%U%)%s%H%m%C%/$N%b!<%I(B, emacs,
GNU Emacs $B%^%K%e%"%k(B}$B$r;2>H$7$F$/$@$5$$!#(B
@defvar window-scroll-functions
@c This variable holds a list of functions that Emacs should call before
@c redisplaying a window with scrolling. It is not a normal hook, because
@c each function is called with two arguments: the window, and its new
@c display-start position.
$B$3$NJQ?t$O!"%9%/%m!<%k$K$h$j%&%#%s%I%&$r:FI=<($9$k$^$($K(B
Emacs$B$,8F$S=P$9$Y$-4X?t$N%j%9%H$rJ];}$9$k!#(B
$B3F4X?t$O%&%#%s%I%&$H?7$?$JI=<(3+;O0LCV$N(B2$B$D$N0z?t$G8F$P$l$k$?$a!"(B
$B$3$l$O%N!<%^%k%U%C%/$G$O$J$$!#(B
@c Displaying a different buffer in the window also runs these functions.
$B%&%#%s%I%&$KJL$N%P%C%U%!$rI=<($9$k>l9g$G$b(B
$B$3$l$i$N4X?t$,<B9T$5$l$k!#(B
@c These functions must be careful in using @code{window-end}
@c (@pxref{Window Start}); if you need an up-to-date value, you must use
@c the @var{update} argument to ensure you get it.
$B$3$l$i$N4X?t$G(B@code{window-end}$B!J(B@pxref{Window Start}$B!K$r;H$&$K$O(B
$BCm0U$,I,MW$G$"$k!#(B
$B99?7$5$l$?CM$,I,MW$J$H$-$K$O!"3N<B$K99?7CM$rF@$k$?$a$K(B
$B0z?t(B@var{update}$B$r;H$&I,MW$,$"$k!#(B
@end defvar
@defvar window-size-change-functions
@c This variable holds a list of functions to be called if the size of any
@c window changes for any reason. The functions are called just once per
@c redisplay, and just once for each frame on which size changes have
@c occurred.
$B$3$NJQ?t$O!"$$$+$J$kM}M3$G$"$l%&%#%s%I%&%5%$%:$,JQ$o$k$H$-$K(B
$B8F$S=P$5$l$k4X?t$N%j%9%H$rJ];}$9$k!#(B
$B4X?t$O!":FI=<($N$?$S$K%5%$%:JQ99$,5/$-$?%U%l!<%`$4$H$K8F$P$l$k!#(B
@c Each function receives the frame as its sole argument. There is no
@c direct way to find out which windows on that frame have changed size, or
@c precisely how. However, if a size-change function records, at each
@c call, the existing windows and their sizes, it can also compare the
@c present sizes and the previous sizes.
$B3F4X?t$O%U%l!<%`$rM#0l$N0z?t$H$7$F<u$1<h$k!#(B
$BEv3:%U%l!<%`$GBg$-$5$,JQ99$5$l$?%&%#%s%I%&$rC5$9D>@\E*$JJ}K!$d(B
$B@53N$JJ}K!$O$J$$!#(B
$B$7$+$7!"%5%$%:JQ994X?t$,8F$P$l$k$?$S$K(B
$B4{B8$N%&%#%s%I%&$H$=$l$i$NBg$-$5$r5-O?$9$l$P!"(B
$B8=:_$NBg$-$5$H0JA0$NBg$-$5$rHf3S$G$-$k!#(B
@c Creating or deleting windows counts as a size change, and therefore
@c causes these functions to be called. Changing the frame size also
@c counts, because it changes the sizes of the existing windows.
$B%&%#%s%I%&$r:n@.$7$?$j:o=|$7$F$b%5%$%:JQ99$H$_$J$9$N$G!"(B
$B$3$l$i$N4X?t$,8F$S=P$5$l$k!#(B
$B%U%l!<%`$NBg$-$5$,JQ$o$k$H4{B8$N%&%#%s%I%&$NBg$-$5$bJQ$o$k$N$G!"(B
$B$3$l$b%5%$%:JQ99$H$_$J$9!#(B
@c It is not a good idea to use @code{save-window-excursion} (@pxref{Window
@c Configurations}) in these functions, because that always counts as a
@c size change, and it would cause these functions to be called over and
@c over. In most cases, @code{save-selected-window} (@pxref{Selecting
@c Windows}) is what you need here.
$B$3$l$i$N4X?t$G(B@code{save-window-excursion}
$B!J(B@pxref{Window Configurations}$B!K$r;H$&$N$O$h$/$J$$!#(B
$B$3$N4X?t$O$D$M$K%5%$%:JQ99$H$_$J$7$3$l$i$N4X?t$r8F$S=P$7!"(B
$B$3$l$,7+$jJV$5$l$F$7$^$&$+$i$G$"$k!#(B
$BB?$/$N>l9g!"$3$3$GI,MW$J$N$O(B@code{save-selected-window}
$B!J(B@pxref{Selecting Windows}$B!K$G$"$k!#(B
@end defvar
@defvar redisplay-end-trigger-functions
@tindex redisplay-end-trigger-functions
@c This abnormal hook is run whenever redisplay in a window uses text that
@c extends past a specified end trigger position. You set the end trigger
@c position with the function @code{set-window-redisplay-end-trigger}. The
@c functions are called with two arguments: the window, and the end trigger
@c position. Storing @code{nil} for the end trigger position turns off the
@c feature, and the trigger value is automatically reset to @code{nil} just
@c after the hook is run.
$B$3$N%"%V%N!<%^%k%U%C%/$O!"%&%#%s%I%&$N:FI=<($K$*$$$F!"(B
$B;XDj$5$l$?=*N;%H%j%,0LCV$rD6$($F?-$S$k%F%-%9%H$r;H$&$?$S$K<B9T$5$l$k!#(B
$B=*N;%H%j%,0LCV$O4X?t(B@code{set-window-redisplay-end-trigger}$B$G@_Dj$9$k!#(B
$B%U%C%/4X?t$O(B2$B$D$N0z?t!"%&%#%s%I%&$H=*N;%H%j%,0LCV$G8F$P$l$k!#(B
$B=*N;%H%j%,0LCV$H$7$F(B@code{nil}$B$rJ]B8$9$k$H$3$N5!G=$r%*%U$K$7!"(B
$B%U%C%/$r<B9TD>8e$K%H%j%,CM$O<+F0E*$K(B@code{nil}$B$K:F@_Dj$5$l$k!#(B
@end defvar
@defun set-window-redisplay-end-trigger window position
@tindex set-window-redisplay-end-trigger
@c This function sets @var{window}'s end trigger position at
@c @var{position}.
$B$3$N4X?t$O!"(B@var{window}$B$N=*N;%H%j%,0LCV$r(B@var{position}$B$H$9$k!#(B
@end defun
@defun window-redisplay-end-trigger window
@tindex window-redisplay-end-trigger
@c This function returns @var{window}'s current end trigger position.
$B$3$N4X?t$O!"(B@var{window}$B$N8=:_$N=*N;%H%j%,0LCV$rJV$9!#(B
@end defun
@defvar window-configuration-change-hook
@tindex window-configuration-change-hook
@c A normal hook that is run every time you change the window configuration
@c of an existing frame. This includes splitting or deleting windows,
@c changing the sizes of windows, or displaying a different buffer in a
@c window. The frame whose window configuration has changed is the
@c selected frame when this hook runs.
$B$3$N%N!<%^%k%U%C%/$O!"(B
$B4{B8$N%U%l!<%`$N%&%#%s%I%&$N9=@.$rJQ99$9$k$?$S$K8F$S=P$5$l$k!#(B
$B$3$l$K$O!"%&%#%s%I%&$NJ,3d$d:o=|!"%&%#%s%I%&%5%$%:$NJQ99!"(B
$B%&%#%s%I%&$KJL$N%P%C%U%!$rI=<($9$k$3$H$,4^$^$l$k!#(B
$B$3$N%U%C%/$r<B9T$9$k$H$-$K$O!"(B
$B%&%#%s%I%&$N9=@.$,JQ99$5$l$?%U%l!<%`$,A*Br$5$l$F$$$k%U%l!<%`$G$"$k!#(B
@end defvar
|