/usr/share/emacs/site-lisp/elscreen/elscreen.el is in elscreen 1.4.6-5.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | ;; -*- Mode: Emacs-Lisp -*-
;;
;; elscreen.el
;;
(defconst elscreen-version "1.4.6 (December 30, 2007)")
;;
;; Author: Naoto Morishima <naoto@morishima.net>
;; Based on: screens.el
;; by Heikki T. Suopanki <suopanki@stekt1.oulu.fi>
;; Created: June 22, 1996
;; Revised: December 30, 2007
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
(provide 'elscreen)
(require 'alist)
(eval-when-compile
(require 'static))
(static-defconst elscreen-on-xemacs (featurep 'xemacs))
(static-defconst elscreen-on-emacs (and (not elscreen-on-xemacs)
(>= emacs-major-version 21)))
(defun elscreen-booleanp (value)
"Return t if VALUE is boolean.
This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs.
This function may be removed when Emacs 21 is no longer supported."
(or (equal value t) (equal value nil)))
;;; User Customizable Variables:
(defgroup elscreen nil
"ElScreen -- Screen Manager for Emacsen"
:tag "ElScreen"
:group 'environment)
(defcustom elscreen-prefix-key "\C-z"
"*Prefix key for ElScreen commands."
:tag "Prefix Key of ElScreen"
:type '(string :size 10)
:set (lambda (symbol value)
(when (boundp 'elscreen-map)
(elscreen-set-prefix-key value))
(custom-set-default symbol value))
:group 'elscreen)
(defcustom elscreen-default-buffer-name "*scratch*"
"*Name of a buffer in new screen."
:tag "Name of Default Buffer"
:type '(string :size 24)
:group 'elscreen)
(defcustom elscreen-default-buffer-initial-major-mode initial-major-mode
"*Major mode command symbol to use for the default buffer."
:tag "Major Mode for Default Buffer"
:type 'function
:group 'elscreen)
(defcustom elscreen-default-buffer-initial-message initial-scratch-message
"*Initial message displayed in default buffer.
If this is nil, no message will be displayed."
:tag "Message to Display in the Default Buffer"
:type '(choice (text :tag "Message")
(const :tag "none" nil))
:group 'elscreen)
(defcustom elscreen-mode-to-nickname-alist
'(("^dired-mode$" .
(lambda ()
(format "Dired(%s)" dired-directory)))
("^Info-mode$" .
(lambda ()
(format "Info(%s)" (file-name-nondirectory Info-current-file))))
("^mew-draft-mode$" .
(lambda ()
(format "Mew(%s)" (buffer-name (current-buffer)))))
("^mew-" . "Mew")
("^irchat-" . "IRChat")
("^liece-" . "Liece")
("^lookup-" . "Lookup"))
"*Alist composed of the pair of name of major-mode and corresponding screen-name."
:tag "Alist to Derive Screen Names from Major Modes"
:type '(alist :key-type string :value-type (choice string function))
:set (lambda (symbol value)
(custom-set-default symbol value)
(when (fboundp 'elscreen-rebuild-mode-to-nickname-alist)
(elscreen-rebuild-mode-to-nickname-alist)))
:group 'elscreen)
(defcustom elscreen-buffer-to-nickname-alist
'(("[Ss]hell" . "shell")
("compilation" . "compile")
("-telnet" . "telnet")
("dict" . "OnlineDict")
("*WL:Message*" . "Wanderlust"))
"*Alist composed of the pair of regular expression of
buffer-name and corresponding screen-name."
:tag "Alist to Derive Screen Names from Major Modes"
:type '(alist :key-type string :value-type (choice string function))
:set (lambda (symbol value)
(custom-set-default symbol value)
(when (fboundp 'elscreen-rebuild-buffer-to-nickname-alist)
(elscreen-rebuild-buffer-to-nickname-alist)))
:group 'elscreen)
(defcustom elscreen-startup-command-line-processing t
"*If non-nil, ElScreen processes command line when Emacsen
starts up, and opens files with new screen if needed."
:type 'boolean
:tag "Enable/Disable ElScreen to Process Command Line Arguments"
:group 'elscreen)
(defcustom elscreen-display-screen-number t
"*Non-nil to display the number of current screen in the mode line."
:tag "Show/Hide Screen Number on the mode-line"
:type 'boolean
:group 'elscreen)
(defcustom elscreen-display-tab t
"*Specify how the tabs at the top of frame should be displayed.
t means to display tabs whose width should be calculated automatically.
A value of integer means to display tabs with fixed width of this value.
nil means don't display tabs."
:tag "Specify how the tabs at the top of frame should be displayed"
:type '(choice (const :tag "Show (automatic width tab)" t)
(integer :tag "Show (fixed width tab)" :size 4 :value 16)
(const :tag "Hide" nil))
:set (lambda (symbol value)
(when (or (elscreen-booleanp value)
(and (numberp value)
(> value 0)))
(custom-set-default symbol value)
(static-cond
(elscreen-on-emacs
(when (fboundp 'elscreen-e21-tab-update)
(elscreen-e21-tab-update t)))
(elscreen-on-xemacs
(when (fboundp 'elscreen-xmas-tab-update)
(elscreen-xmas-tab-update t))))))
:group 'elscreen)
(static-when elscreen-on-emacs ;; GNU Emacs 21
(make-obsolete-variable 'elscreen-tab-display-create-screen
'elscreen-tab-display-control)
(defcustom elscreen-tab-display-control t
"*Non-nil to display control tab at the most left side."
:tag "Show/Hide the Control Tab"
:type 'boolean
:set (lambda (symbol value)
(custom-set-default symbol value)
(when (fboundp 'elscreen-e21-tab-update)
(elscreen-e21-tab-update t)))
:group 'elscreen)
(defcustom elscreen-tab-display-kill-screen 'left
"*Location of the icons to kill a screen on each tab. Possible values are 'left, 'right, or nil (to hide them)."
:tag "Location of Buttons to Kill Screen on Each Tab"
:type '(choice (const :tag "Left" left)
(const :tag "Right" right)
(const :tag "None" nil))
:set (lambda (symbol value)
(custom-set-default symbol value)
(when (fboundp 'elscreen-e21-tab-update)
(elscreen-e21-tab-update t)))
:group 'elscreen)
(defface elscreen-tab-background-face
'((((type x w32 mac) (class color))
:background "Gray50")
(((class color))
(:background "black")))
"Face to fontify background of tab line."
:group 'elscreen)
(defface elscreen-tab-control-face
'((((type x w32 mac) (class color))
(:background "white" :foreground "black" :underline "Gray50"))
(((class color))
(:background "white" :foreground "black" :underline t))
(t (:underline t)))
"Face for control tab."
:group 'elscreen)
(defface elscreen-tab-current-screen-face
'((((class color))
(:background "white" :foreground "black"))
(t (:underline t)))
"Face for current screen tab."
:group 'elscreen)
(defface elscreen-tab-other-screen-face
'((((type x w32 mac) (class color))
:background "Gray85" :foreground "Gray50")
(((class color))
(:background "blue" :foreground "black" :underline t)))
"Face for tabs other than current screen one."
:group 'elscreen))
;;; Key & Menu bindings:
(defvar elscreen-map (make-sparse-keymap)
"Keymap for ElScreen.")
(define-key elscreen-map "\C-c" 'elscreen-create)
(define-key elscreen-map "c" 'elscreen-create)
(define-key elscreen-map "C" 'elscreen-clone)
(define-key elscreen-map "\C-k" 'elscreen-kill)
(define-key elscreen-map "k" 'elscreen-kill)
(define-key elscreen-map "\M-k" 'elscreen-kill-screen-and-buffers)
(define-key elscreen-map "K" 'elscreen-kill-others)
(define-key elscreen-map "\C-p" 'elscreen-previous)
(define-key elscreen-map "p" 'elscreen-previous)
(define-key elscreen-map "\C-n" 'elscreen-next)
(define-key elscreen-map "n" 'elscreen-next)
(define-key elscreen-map "\C-a" 'elscreen-toggle)
(define-key elscreen-map "a" 'elscreen-toggle)
(define-key elscreen-map "'" 'elscreen-goto)
(define-key elscreen-map "\"" 'elscreen-select-and-goto)
(define-key elscreen-map "0" 'elscreen-jump-0)
(define-key elscreen-map "1" 'elscreen-jump)
(define-key elscreen-map "2" 'elscreen-jump)
(define-key elscreen-map "3" 'elscreen-jump)
(define-key elscreen-map "4" 'elscreen-jump)
(define-key elscreen-map "5" 'elscreen-jump)
(define-key elscreen-map "6" 'elscreen-jump)
(define-key elscreen-map "7" 'elscreen-jump)
(define-key elscreen-map "8" 'elscreen-jump)
(define-key elscreen-map "9" 'elscreen-jump-9)
(define-key elscreen-map "\C-s" 'elscreen-swap)
(define-key elscreen-map "\C-w" 'elscreen-display-screen-name-list)
(define-key elscreen-map "w" 'elscreen-display-screen-name-list)
(define-key elscreen-map "\C-m" 'elscreen-display-last-message)
(define-key elscreen-map "m" 'elscreen-display-last-message)
(define-key elscreen-map "\C-t" 'elscreen-display-time)
(define-key elscreen-map "t" 'elscreen-display-time)
(define-key elscreen-map "A" 'elscreen-screen-nickname)
(define-key elscreen-map "b" 'elscreen-find-and-goto-by-buffer)
(define-key elscreen-map "\C-f" 'elscreen-find-file)
(define-key elscreen-map "\C-r" 'elscreen-find-file-read-only)
(define-key elscreen-map "d" 'elscreen-dired)
(define-key elscreen-map "\M-x" 'elscreen-execute-extended-command)
(define-key elscreen-map "i" 'elscreen-toggle-display-screen-number)
(define-key elscreen-map "T" 'elscreen-toggle-display-tab)
(define-key elscreen-map "?" 'elscreen-help)
(define-key elscreen-map "v" 'elscreen-display-version)
(define-key elscreen-map "j" 'elscreen-link)
(define-key elscreen-map "s" 'elscreen-split)
(defun elscreen-set-prefix-key (prefix-key)
(when (not (eq elscreen-prefix-key prefix-key))
(when elscreen-prefix-key
(global-set-key elscreen-prefix-key
(get 'elscreen-prefix-key
'global-map-original-definition))
(define-key minibuffer-local-map elscreen-prefix-key
(get 'elscreen-prefix-key 'minibuffer-local-map-original-definition)))
(put 'elscreen-prefix-key 'global-map-original-definition
(lookup-key global-map prefix-key))
(put 'elscreen-prefix-key 'minibuffer-local-map-original-definition
(lookup-key minibuffer-local-map prefix-key)))
(global-set-key prefix-key elscreen-map)
(define-key minibuffer-local-map prefix-key 'undefined)
(setq elscreen-prefix-key prefix-key))
(defvar elscreen-help "ElScreen keys:
\\[elscreen-create] Create a new screen and switch to it
\\[elscreen-clone] Create a new screen with the window-configuration of current screen
\\[elscreen-kill] Kill current screen
\\[elscreen-kill-screen-and-buffers] Kill current screen and buffers
\\[elscreen-kill-others] Kill other screens
\\[elscreen-next] Switch to the \"next\" screen in a cyclic order
\\[elscreen-previous] Switch to the \"previous\" screen in a cyclic order
\\[elscreen-toggle] Toggle to the screen selected previously
\\[elscreen-select-and-goto] Jump to the specified screen
\\[elscreen-jump-0]
: Jump to the screen #
\\[elscreen-jump-9]
\\[elscreen-swap] Swap current screen with previous one
\\[elscreen-display-screen-name-list] Show list of screens
\\[elscreen-screen-nickname] Name current screen
\\[elscreen-display-last-message] Show last message
\\[elscreen-display-time] Show time
\\[elscreen-find-and-goto-by-buffer] Switch to the screen in which specified buffer is displayed
\\[elscreen-find-file] Create new screen and open file
\\[elscreen-find-file-read-only] Create new screen and open file but don't allow changes
\\[elscreen-dired] Create new screen and run dired
\\[elscreen-execute-extended-command] Read function name, then call it with new screen
\\[elscreen-toggle-display-screen-number] Show/hide the screen number in the mode line
\\[elscreen-toggle-display-tab] Show/hide the tab at the top of screen
\\[elscreen-display-version] Show ElScreen version
\\[elscreen-help] Show this help"
"Help shown by elscreen-help-mode")
;;; Internal Functions:
(defun elscreen-last-command-char ()
(if (featurep 'xemacs)
(event-to-character last-command-event)
last-command-event))
(defvar elscreen-frame-confs nil
"Alist that contains the information about screen configurations.")
(defun elscreen-current-window-configuration ()
(list (current-window-configuration) (point-marker)))
(defun elscreen-default-window-configuration ()
(let ((default-buffer (get-buffer elscreen-default-buffer-name)))
(save-window-excursion
(set-window-dedicated-p (selected-window) nil)
(delete-other-windows)
(if default-buffer
(switch-to-buffer default-buffer)
(switch-to-buffer (get-buffer-create elscreen-default-buffer-name))
(funcall elscreen-default-buffer-initial-major-mode)
(insert elscreen-default-buffer-initial-message)
(set-buffer-modified-p nil))
(elscreen-current-window-configuration))))
(defun elscreen-apply-window-configuration (elscreen-window-configuration)
(let ((window-configuration (car elscreen-window-configuration))
(marker (cadr elscreen-window-configuration)))
(set-window-configuration window-configuration)
(when (marker-buffer marker)
(goto-char marker))))
(defun get-alist (key alist)
(cdr (assoc key alist)))
(defsubst elscreen-copy-tree (tree)
(if (fboundp 'copy-tree)
(copy-tree tree)
(elscreen-copy-tree-1 tree)))
(defun elscreen-copy-tree-1 (tree)
(let (clone)
(while (consp tree)
(setq clone (cons (or (and (consp (car tree))
(elscreen-copy-tree-1 (car tree)))
(car tree))
clone))
(setq tree (cdr tree)))
(nconc (nreverse clone) tree)))
(defmacro elscreen-save-screen-excursion (&rest body)
"Execute BODY, preserving ElScreen meta data.
Return the value of the last form in BODY."
`(let ((original-buffer-list (buffer-list))
(original-buffer-live-p nil)
(original-elscreen-window-configuration
(elscreen-current-window-configuration))
(original-frame-confs (elscreen-copy-tree elscreen-frame-confs)))
(unwind-protect
(save-window-excursion ,@body)
(setq elscreen-frame-confs original-frame-confs)
(elscreen-apply-window-configuration
original-elscreen-window-configuration)
(mapcar
(lambda (buffer)
(when (buffer-live-p buffer)
(bury-buffer buffer)
(setq original-buffer-live-p t)))
original-buffer-list)
(when original-buffer-live-p
(while (not (memq (car (buffer-list)) original-buffer-list))
(bury-buffer (car (buffer-list))))))))
(defsubst elscreen-get-frame-confs (frame)
(get-alist frame elscreen-frame-confs))
(defun elscreen-make-frame-confs (frame &optional keep-window-configuration)
(when (null (elscreen-get-frame-confs frame))
(let ((selected-frame (selected-frame))
elscreen-window-configuration)
(save-current-buffer
(select-frame frame)
(setq elscreen-window-configuration
(if keep-window-configuration
(elscreen-current-window-configuration)
(elscreen-default-window-configuration)))
(set-alist 'elscreen-frame-confs frame
(list
(cons 'screen-property
(list
(cons 0 (list
(cons 'window-configuration
elscreen-window-configuration)))))
(cons 'screen-history (list 0))
(cons 'modified-inquirer nil)
(cons 'screen-to-name-alist-cache nil)))
(elscreen-apply-window-configuration elscreen-window-configuration)
(elscreen-notify-screen-modification 'force-immediately)
(select-frame selected-frame)))))
(defun elscreen-delete-frame-confs (frame)
(remove-alist 'elscreen-frame-confs frame))
(static-cond
((boundp 'after-make-frame-functions) ;; GNU Emacs 21
(add-hook 'after-make-frame-functions 'elscreen-make-frame-confs))
(t ;; XEmacs
(add-hook 'create-frame-hook 'elscreen-make-frame-confs)))
(static-cond
((boundp 'delete-frame-functions) ;; GNU Emacs 22?
(add-hook 'delete-frame-functions 'elscreen-delete-frame-confs))
(t ;; XEmacs
(add-hook 'delete-frame-hook 'elscreen-delete-frame-confs)))
(defsubst elscreen-get-conf-list (type)
(get-alist type (elscreen-get-frame-confs (selected-frame))))
(defsubst elscreen-set-conf-list (type conf-list)
(let ((frame-conf (elscreen-get-frame-confs (selected-frame))))
(set-alist 'frame-conf type conf-list)))
(defun elscreen-get-screen-property (screen)
(let ((screen-property-list (elscreen-get-conf-list 'screen-property)))
(get-alist screen screen-property-list)))
(defun elscreen-set-screen-property (screen property)
(let ((screen-property-list (elscreen-get-conf-list 'screen-property)))
(set-alist 'screen-property-list screen property)
(elscreen-set-conf-list 'screen-property screen-property-list)))
(defun elscreen-delete-screen-property (screen)
(let ((screen-property-list (elscreen-get-conf-list 'screen-property)))
(remove-alist 'screen-property-list screen)
(elscreen-set-conf-list 'screen-property screen-property-list)))
(defun elscreen-get-number-of-screens ()
"Return total number of screens."
(length (elscreen-get-conf-list 'screen-property)))
(defun elscreen-one-screen-p ()
"Return t if there is only one screen."
(= (elscreen-get-number-of-screens) 1))
(defun elscreen-get-screen-list ()
"Return a list of screen numbers."
(mapcar 'car (elscreen-get-conf-list 'screen-property)))
(defun elscreen-screen-live-p (screen)
"Return t when SCREEN is alive."
(not (null (elscreen-get-screen-property screen))))
(defun elscreen-get-window-configuration (screen)
"Return pair of window-configuration and marker of SCREEN
from `elscreen-frame-confs', a cons cell."
(let ((screen-property (elscreen-get-screen-property screen)))
(get-alist 'window-configuration screen-property)))
(defun elscreen-set-window-configuration (screen winconf)
"Set pair of window-configuration and marker of SCREEN to WINCONF."
(let ((screen-property (elscreen-get-screen-property screen)))
(set-alist 'screen-property 'window-configuration winconf)
(elscreen-set-screen-property screen screen-property)))
(defun elscreen-get-screen-nickname (screen)
"Return nickname of SCREEN from `elscreen-frame-confs', a string."
(let ((screen-property (elscreen-get-screen-property screen)))
(get-alist 'nickname screen-property)))
(defun elscreen-set-screen-nickname (screen nickname)
"Set nickname of SCREEN to NICKNAME."
(let ((screen-property (elscreen-get-screen-property screen)))
(set-alist 'screen-property 'nickname nickname)
(elscreen-set-screen-property screen screen-property)))
(defun elscreen-delete-screen-nickname (screen)
"Remove nickname of SCREEN from `elscreen-frame-confs'."
(let ((screen-property (elscreen-get-screen-property screen)))
(remove-alist 'screen-property 'nickname)
(elscreen-set-screen-property screen screen-property)))
(defun elscreen-append-screen-to-history (screen)
(let ((screen-history (elscreen-get-conf-list 'screen-history)))
(setcdr (last screen-history) (list screen))))
(defun elscreen-delete-screen-from-history (screen)
(let ((screen-history (elscreen-get-conf-list 'screen-history)))
(setq screen-history (delq screen screen-history))
(elscreen-set-conf-list 'screen-history screen-history)))
(defun elscreen-set-current-screen (screen)
(let ((screen-history (elscreen-get-conf-list 'screen-history)))
(setq screen-history (cons screen (delq screen screen-history)))
(elscreen-set-conf-list 'screen-history screen-history)))
(defun elscreen-get-current-screen ()
(car (elscreen-get-conf-list 'screen-history)))
(defun elscreen-get-previous-screen ()
(cadr (elscreen-get-conf-list 'screen-history)))
(defun elscreen-status-label (screen &optional default)
(let ((default (or default " "))
(current-screen (elscreen-get-current-screen))
(previous-screen (elscreen-get-previous-screen)))
(cond
((eq screen current-screen) "+")
((eq screen previous-screen) "-")
(t default))))
(defvar elscreen-notify-screen-modification-suppress-flag nil)
(defmacro elscreen-notify-screen-modification-suppress (&rest body)
`(let ((elscreen-notify-screen-modification-suppress-flag t))
,@body))
(defvar elscreen-screen-update-hook nil)
(defun elscreen-run-screen-update-hook ()
(when elscreen-frame-confs
(elscreen-notify-screen-modification-suppress
(run-hooks 'elscreen-screen-update-hook)))
(remove-hook 'post-command-hook 'elscreen-run-screen-update-hook))
(defun elscreen-screen-modified-p (inquirer)
(let* ((inquirer-list (elscreen-get-conf-list 'modified-inquirer))
(modified (null (memq inquirer inquirer-list))))
(add-to-list 'inquirer-list inquirer)
(elscreen-set-conf-list 'modified-inquirer inquirer-list)
modified))
(defun elscreen-set-screen-modified ()
(elscreen-set-conf-list 'modified-inquirer nil)
(add-hook 'post-command-hook 'elscreen-run-screen-update-hook))
(cond
((fboundp 'compare-window-configurations)) ;; GNU Emacs
((fboundp 'window-configuration-equal) ;; XEmacs 21.5
(defalias 'compare-window-configurations 'window-configuration-equal)))
(defvar elscreen-screen-modified-hook-pwc nil)
(defun elscreen-notify-screen-modification (&optional mode)
(when (and (not (window-minibuffer-p))
(not elscreen-notify-screen-modification-suppress-flag)
(or (eq mode 'force)
(eq mode 'force-immediately)
(null elscreen-screen-modified-hook-pwc)
(not (fboundp 'compare-window-configurations))
(not (compare-window-configurations
(current-window-configuration)
elscreen-screen-modified-hook-pwc))))
(setq elscreen-screen-modified-hook-pwc
(current-window-configuration))
(elscreen-set-screen-modified)
(when (eq mode 'force-immediately)
(elscreen-run-screen-update-hook))))
(defmacro elscreen-screen-modified-hook-setup (&rest hooks-and-functions)
(cons
'progn
(mapcar
(lambda (hook-or-function)
(let ((mode ''normal))
(when (listp hook-or-function)
(setq mode (nth 1 hook-or-function))
(setq hook-or-function (nth 0 hook-or-function)))
(cond
((string-match "-\\(hooks?\\|functions\\)$"
(symbol-name hook-or-function))
`(add-hook (quote ,hook-or-function)
(lambda (&rest ignore)
(elscreen-notify-screen-modification ,mode))))
(t ;; Assume hook-or-function is function
`(defadvice ,hook-or-function (around
elscreen-screen-modified-advice
activate)
ad-do-it
(elscreen-notify-screen-modification ,mode))))))
hooks-and-functions)))
(elscreen-screen-modified-hook-setup
(recenter 'force) (change-major-mode-hook 'force)
other-window
window-configuration-change-hook window-size-change-functions
(handle-switch-frame 'force) ;; GNU Emacs 21
(select-frame-hook 'force) ;; XEmacs
(delete-frame 'force)
(Info-find-node-2 'force))
(defun elscreen-get-screen-to-name-alist-cache ()
(elscreen-get-conf-list 'screen-to-name-alist-cache))
(defun elscreen-set-screen-to-name-alist-cache (alist)
(elscreen-set-conf-list 'screen-to-name-alist-cache alist))
(defvar elscreen-mode-to-nickname-alist-symbol-list nil)
(defvar elscreen-mode-to-nickname-alist-internal nil)
(defun elscreen-rebuild-mode-to-nickname-alist ()
(setq elscreen-mode-to-nickname-alist-internal
(apply 'append
(mapcar 'symbol-value
elscreen-mode-to-nickname-alist-symbol-list)))
(elscreen-notify-screen-modification 'force-immediately))
(defun elscreen-set-mode-to-nickname-alist (mode-to-nickname-alist-symbol)
(add-to-list 'elscreen-mode-to-nickname-alist-symbol-list
mode-to-nickname-alist-symbol)
(elscreen-rebuild-mode-to-nickname-alist))
(elscreen-set-mode-to-nickname-alist 'elscreen-mode-to-nickname-alist)
(defvar elscreen-buffer-to-nickname-alist-symbol-list nil)
(defvar elscreen-buffer-to-nickname-alist-internal nil)
(defun elscreen-rebuild-buffer-to-nickname-alist ()
(setq elscreen-buffer-to-nickname-alist-internal
(apply 'append
(mapcar 'symbol-value
elscreen-buffer-to-nickname-alist-symbol-list)))
(elscreen-notify-screen-modification 'force-immediately))
(defun elscreen-set-buffer-to-nickname-alist (buffer-to-nickname-alist-symbol)
(add-to-list 'elscreen-buffer-to-nickname-alist-symbol-list
buffer-to-nickname-alist-symbol)
(elscreen-rebuild-buffer-to-nickname-alist))
(elscreen-set-buffer-to-nickname-alist 'elscreen-buffer-to-nickname-alist)
(defsubst elscreen-get-alist-to-nickname (alist op mode-or-buffer-name)
(catch 'found
(progn
(mapcar
(lambda (map)
(let ((nickname nil)
(condition-data (car map))
(string-or-function (cdr map)))
(when (funcall op condition-data mode-or-buffer-name)
(cond
((functionp string-or-function)
(setq nickname
(condition-case nil
(funcall string-or-function)
(wrong-number-of-arguments
(funcall string-or-function (current-buffer))))))
(t
(setq nickname string-or-function)))
(throw 'found (cons 'nickname nickname)))))
alist)
nil)))
(defun elscreen-get-screen-to-name-alist (&optional truncate-length padding)
(when (elscreen-screen-modified-p 'elscreen-get-screen-to-name-alist)
(elscreen-notify-screen-modification-suppress
(elscreen-set-window-configuration (elscreen-get-current-screen)
(elscreen-current-window-configuration))
(let* ((screen-list (sort (elscreen-get-screen-list) '<))
screen-name screen-to-name-alist nickname-type-map)
(elscreen-save-screen-excursion
(mapcar
(lambda (screen)
;; If nickname exists, use it.
(setq screen-name (elscreen-get-screen-nickname screen))
;; Nickname does not exist, so examine major-mode and buffer-name.
(when (null screen-name)
(elscreen-goto-internal screen)
(setq nickname-type-map
(mapcar
(lambda (window)
(with-current-buffer (window-buffer window)
(or (elscreen-get-alist-to-nickname
elscreen-mode-to-nickname-alist-internal
'string-match (symbol-name major-mode))
(elscreen-get-alist-to-nickname
elscreen-buffer-to-nickname-alist-internal
'string-match (buffer-name))
(cons 'buffer-name (buffer-name)))))
(window-list)))
(let (nickname-list)
(while (> (length nickname-type-map) 0)
(let ((type (caar nickname-type-map))
(name (cdar nickname-type-map)))
(when name
(setq nickname-list (cons name nickname-list)))
(setq nickname-type-map
(if (eq type 'nickname)
(delete (car nickname-type-map) nickname-type-map)
(cdr nickname-type-map)))))
(setq screen-name
(mapconcat 'identity (reverse nickname-list) ":"))))
(set-alist 'screen-to-name-alist screen screen-name))
screen-list))
(elscreen-set-screen-to-name-alist-cache screen-to-name-alist))))
;; Arguments of truncate-length and padding are deprecated.
(if truncate-length
(let ((screen-to-name-alist
(copy-alist (elscreen-get-screen-to-name-alist-cache))))
(elscreen-message "Arguments for `elscreen-get-screen-to-name-alist' are deprecated. Use elscreen-truncate-screen-name for each screen-name.")
(mapc
(lambda (screen-to-name)
(setcdr screen-to-name
(elscreen-truncate-screen-name (cdr screen-to-name)
truncate-length padding)))
screen-to-name-alist)
screen-to-name-alist)
(elscreen-get-screen-to-name-alist-cache)))
(defun elscreen-truncate-screen-name (screen-name truncate-length &optional padding)
(let ((truncate-length (max truncate-length 4)))
(cond
((> (string-width screen-name) truncate-length)
(concat (truncate-string-to-width screen-name (- truncate-length 3)
nil ?.)
"..."))
(padding
(truncate-string-to-width screen-name truncate-length nil ?\ ))
(t
screen-name))))
(defun elscreen-goto-internal (screen)
"Set the configuration of windows, buffers and markers previousuly
stored as SCREEN."
(let ((elscreen-window-configuration
(elscreen-get-window-configuration screen)))
(elscreen-apply-window-configuration elscreen-window-configuration)))
(defvar elscreen-create-hook nil)
(defun elscreen-create-internal (&optional noerror)
"Create a new screen.
If NOERROR is not nil, no message is displayed in mini buffer
when error is occurred."
(cond
((>= (elscreen-get-number-of-screens) 10)
(unless noerror
(elscreen-message "No more screens."))
nil)
(t
(let ((screen-list (sort (elscreen-get-screen-list) '<))
(screen 0))
(elscreen-set-window-configuration
(elscreen-get-current-screen)
(elscreen-current-window-configuration))
(while (eq (nth screen screen-list) screen)
(setq screen (+ screen 1)))
(elscreen-set-window-configuration
screen (elscreen-default-window-configuration))
(elscreen-append-screen-to-history screen)
(elscreen-notify-screen-modification 'force)
(run-hooks 'elscreen-create-hook)
screen))))
(defun elscreen-kill-internal (screen)
(elscreen-delete-screen-property screen)
(elscreen-delete-screen-from-history screen)
screen)
(defun elscreen-find-screens (condition)
(let ((screen-list (sort (elscreen-get-screen-list) '<))
result)
(save-current-buffer
(elscreen-set-window-configuration
(elscreen-get-current-screen)
(elscreen-current-window-configuration))
(elscreen-notify-screen-modification-suppress
(elscreen-save-screen-excursion
(mapc
(lambda (screen)
(when (funcall condition screen)
(setq result (cons screen result))))
screen-list))
result))))
(defun elscreen-find-screen (condition)
(catch 'elscreen-find-screen
(elscreen-find-screens `(lambda (screen)
(when (funcall ,condition screen)
(throw 'elscreen-find-screen screen))))))
(defun elscreen-find-screen-by-buffer (buffer &optional create)
(let* ((buffer (if (bufferp buffer) buffer (get-buffer buffer)))
(screen (when buffer
(elscreen-find-screen
`(lambda (screen)
(elscreen-goto-internal screen)
(not (null (get-buffer-window ,buffer))))))))
(when (and buffer (null screen) create)
(cond
((setq screen (elscreen-create-internal 'noerror))
(save-window-excursion
(elscreen-goto-internal screen)
(switch-to-buffer buffer t)
(elscreen-set-window-configuration
screen (elscreen-current-window-configuration))))
(t
(setq screen (elscreen-get-current-screen))
(elscreen-goto-internal screen)
(save-selected-window
(select-window (split-window))
(switch-to-buffer buffer t)))))
screen))
(defun elscreen-find-screen-by-major-mode (major-mode-or-re)
(let ((major-mode-re (cond
((stringp major-mode-or-re)
major-mode-or-re)
((symbolp major-mode-or-re)
(format "^%s$" (regexp-quote
(symbol-name major-mode-or-re))))
(t nil))))
(when major-mode-re
(elscreen-find-screen
(lambda (screen)
(elscreen-goto-internal screen)
(save-selected-window
(catch 'found
(mapcar
(lambda (window)
(select-window window)
(when (string-match major-mode-re (symbol-name major-mode))
(throw 'found t)))
(window-list))
nil)))))))
(defvar elscreen-last-message "Welcome to ElScreen!"
"Last shown message.")
(defun elscreen-message (message &optional sec)
"Display MESSAGE in mini-buffer for SEC seconds.
Default value for SEC is 3."
(when message
(setq elscreen-last-message message)
(message "%s" message)
(sit-for (or sec 3)))
(message nil))
;;; User Interfaces:
(defun elscreen-create ()
"Create a new screen and switch to it."
(interactive)
(let ((screen (elscreen-create-internal)))
(if screen
(elscreen-goto screen))))
(defun elscreen-clone (&optional screen)
"Create a new screen with the window-configuration of SCREEN.
If SCREEN is ommitted, current-screen is used."
(interactive)
(let ((screen (or screen (elscreen-get-current-screen)))
clone elscreen-window-configuration)
(cond
((not (elscreen-screen-live-p screen))
(elscreen-message "There is no such screen, cannot clone"))
((setq clone (elscreen-create-internal))
(save-window-excursion
(elscreen-goto-internal screen)
(setq elscreen-window-configuration
(elscreen-current-window-configuration)))
(elscreen-set-window-configuration clone elscreen-window-configuration)
(elscreen-goto clone)))))
(defvar elscreen-kill-hook nil)
(defun elscreen-kill (&optional screen)
"Kill SCREEN. If optional argument SCREEN is
ommitted, current-screen is killed."
(interactive "P")
(let ((screen (or (and (numberp screen) screen)
(elscreen-get-current-screen))))
(cond
((not (elscreen-screen-live-p screen))
(elscreen-message "There is no such screen, cannot kill")
nil)
((elscreen-one-screen-p)
(elscreen-message "There is only one screen, cannot kill")
nil)
(t
(elscreen-kill-internal screen)
(elscreen-goto-internal (elscreen-get-current-screen))
(elscreen-notify-screen-modification 'force)
(run-hooks 'elscreen-kill-hook)
screen))))
(defun elscreen-kill-screen-and-buffers (&optional screen)
"Kill buffers on SCREEN and SCREEN itself. If optional
argument SCREEN is omitted, current screen is killed."
(interactive)
(let* ((screen (or screen (elscreen-get-current-screen)))
(elscreen-window-configuration
(elscreen-get-window-configuration screen)))
(when (elscreen-kill screen)
(save-window-excursion
(elscreen-apply-window-configuration elscreen-window-configuration)
(mapc
(lambda (buffer)
(when (buffer-live-p buffer)
(kill-buffer buffer)))
(mapcar 'window-buffer (window-list))))
screen)))
(defun elscreen-kill-others (&optional screen)
"Kill screens other than SCREEN. If optional argument SCREEN
is ommitted, current screen will survive."
(interactive)
(let* ((screen (or screen (elscreen-get-current-screen)))
(screen-list (when (elscreen-screen-live-p screen)
(delq screen (sort (elscreen-get-screen-list) '<))))
screen-list-string)
(cond
((not (elscreen-screen-live-p screen)) ;; XXX
(when (interactive-p)
(elscreen-message "There is no such screen")))
((null screen-list)
(when (interactive-p)
(elscreen-message "There is only one screen, cannot kill")))
((or
(not (interactive-p))
(yes-or-no-p (format "Really kill screens other than %d? " screen)))
(setq screen-list-string (mapconcat
(lambda (screen)
(elscreen-kill-internal screen)
(number-to-string screen))
screen-list ","))
(elscreen-goto-internal screen)
(elscreen-notify-screen-modification 'force-immediately)
(when (interactive-p)
(elscreen-message (format "screen %s killed" screen-list-string)))))
screen-list))
(defvar elscreen-goto-hook nil)
(defun elscreen-goto (screen)
"Switch to screen SCREEN."
(interactive "NGoto screen number: ")
(cond
((eq (elscreen-get-current-screen) screen))
((elscreen-screen-live-p screen)
(elscreen-set-window-configuration
(elscreen-get-current-screen)
(elscreen-current-window-configuration))
(elscreen-set-current-screen screen)
(elscreen-goto-internal screen)
(static-when (and elscreen-on-emacs (= emacs-major-version 21))
(when window-system
(redraw-frame (selected-frame))))
(elscreen-notify-screen-modification 'force)
(run-hooks 'elscreen-goto-hook)
screen)
(t
(elscreen-message (format "No screen %d" screen))
nil)))
(defun elscreen-next ()
"Switch to the next screen."
(interactive)
(cond
((elscreen-one-screen-p)
(elscreen-message
(format "You cannot escape from screen %d!"
(elscreen-get-current-screen))))
(t
(let* ((screen-list (sort (elscreen-get-screen-list) '<))
(next-screen
(or (nth 1 (memq (elscreen-get-current-screen) screen-list))
(car screen-list))))
(elscreen-goto next-screen)))))
(defun elscreen-previous ()
"Switch to the previous screen."
(interactive)
(cond
((elscreen-one-screen-p)
(elscreen-message
(format "You cannot escape from screen %d!"
(elscreen-get-current-screen))))
(t
(let* ((screen-list (sort (elscreen-get-screen-list) '>))
(previous-screen
(or (nth 1 (memq (elscreen-get-current-screen) screen-list))
(car screen-list))))
(elscreen-goto previous-screen)))))
(defun elscreen-toggle ()
"Toggle to the screen selected previously."
(interactive)
(cond
((elscreen-one-screen-p)
(elscreen-message
(format "You cannot escape from screen %d!"
(elscreen-get-current-screen))))
(t
(elscreen-goto (elscreen-get-previous-screen)))))
(defun elscreen-jump ()
"Switch to specified screen."
(interactive)
(let ((next-screen (string-to-number (string (elscreen-last-command-char)))))
(if (and (<= 0 next-screen) (<= next-screen 9))
(elscreen-goto next-screen))))
(defalias 'elscreen-jump-0 'elscreen-jump)
(defalias 'elscreen-jump-9 'elscreen-jump)
(defun elscreen-swap ()
"Interchange screens selected currently and previously."
(interactive)
(cond
((elscreen-one-screen-p)
(elscreen-message "There is only one screen, cannot swap"))
(t
(let* ((current-screen (elscreen-get-current-screen))
(previous-screen (elscreen-get-previous-screen))
(current-screen-property
(elscreen-get-screen-property current-screen))
(previous-screen-property
(elscreen-get-screen-property previous-screen)))
(elscreen-set-screen-property current-screen previous-screen-property)
(elscreen-set-screen-property previous-screen current-screen-property)
(elscreen-goto-internal (elscreen-get-current-screen))))))
(defun elscreen-screen-nickname (nickname)
"Set nickname for current screen to NICKNAME."
(interactive "sSet window title to: ")
(cond
((zerop (length nickname))
(elscreen-delete-screen-nickname (elscreen-get-current-screen)))
(t
(elscreen-set-screen-nickname (elscreen-get-current-screen) nickname)))
(elscreen-notify-screen-modification 'force))
(defun elscreen-display-screen-name-list ()
"Display the list of screens in mini-buffer."
(interactive)
(let ((screen-list (sort (elscreen-get-screen-list) '<))
(screen-to-name-alist (elscreen-get-screen-to-name-alist)))
(elscreen-message
(mapconcat
(lambda (screen)
(let ((screen-name (get-alist screen screen-to-name-alist)))
(format "%d%s %s" screen
(elscreen-status-label screen "")
screen-name)))
screen-list " "))))
;;; Help
(defvar elscreen-help-symbol-list nil)
(defun elscreen-set-help (help-symbol)
(add-to-list 'elscreen-help-symbol-list help-symbol t))
(elscreen-set-help 'elscreen-help)
(defun elscreen-help ()
"Show key bindings of ElScreen and Add-On softwares."
(interactive)
(with-output-to-temp-buffer "*ElScreen Help*"
(princ (substitute-command-keys
(mapconcat 'symbol-value
elscreen-help-symbol-list "\n\n")))
(print-help-return-message)))
;;; Utility Functions
(defun elscreen-display-version ()
"Display ElScreen version."
(interactive)
(elscreen-message (concat "ElScreen version " elscreen-version)))
(defun elscreen-toggle-display-screen-number ()
"Toggle the screen number in the mode line."
(interactive)
(setq elscreen-display-screen-number (null elscreen-display-screen-number))
(elscreen-notify-screen-modification 'force))
(defun elscreen-toggle-display-tab ()
"Toggle the tab on the top of screen."
(interactive)
(setq elscreen-display-tab (null elscreen-display-tab))
(elscreen-notify-screen-modification 'force))
(defun elscreen-display-last-message ()
"Repeat the last message displayed in the mini-buffer."
(interactive)
(elscreen-message elscreen-last-message 5))
(defun elscreen-display-time ()
"Show system information."
(interactive)
(elscreen-message
(format "%s %s / %s"
(current-time-string)
(nth 1 (current-time-zone))
(mapconcat
(lambda (load)
(format "%.2f" (/ load 100.0)))
(load-average) " "))))
(defun elscreen-select-and-goto ()
(interactive)
(let* ((screen-list (sort (elscreen-get-screen-list) '<))
(screen-to-name-alist (elscreen-get-screen-to-name-alist))
(command-list '(("c" . elscreen-create)
("n" . elscreen-next)
("p" . elscreen-previous)
("t" . elscreen-toggle)))
(truncate-length (- (frame-width) 6))
(candidate-window-height (max (+ (elscreen-get-number-of-screens) 4)
window-min-height))
(candidate-buffer (get-buffer-create
(format " *ElScreen-select:%s*"
(prin1-to-string (selected-frame)))))
(candidate (concat
"Current screen list: \n\n"
(mapconcat
(lambda (screen)
(format " %d%s %s\n" screen
(elscreen-status-label screen)
(elscreen-truncate-screen-name
(get-alist screen screen-to-name-alist)
truncate-length)))
screen-list nil)))
(prompt "Select screen or (c)reate, (n)ext, (p)revious, (t)oggle: ")
(minibuffer-map (copy-keymap minibuffer-local-map))
window frame-last-window command-or-target-screen mini-hist)
;; prepare window to show candidates
(save-window-excursion
(setq frame-last-window (previous-window (static-if elscreen-on-xemacs
(frame-highest-window)
(frame-first-window))))
(while (minibuffer-window-active-p frame-last-window)
(setq frame-last-window (previous-window frame-last-window)))
(while (and (not (one-window-p))
(or (< (window-width frame-last-window)
(frame-width))
(< (window-height frame-last-window)
(+ candidate-window-height window-min-height))))
(setq window frame-last-window)
(setq frame-last-window (previous-window window))
(delete-window window))
(select-window (split-window frame-last-window))
(shrink-window (- (window-height) candidate-window-height))
;; now switch to the buffer for candidates and fill it
(switch-to-buffer candidate-buffer)
(let ((buffer-read-only nil))
(erase-buffer)
(insert candidate)
(goto-char (point-min))
(save-excursion
(while (not (eobp))
(when (looking-at "^ \\([0-9]\\)\\(.\\) \\(.*\\)$")
(put-text-property
(match-beginning 1) (match-end 1) 'face 'bold)
(cond
((string= (match-string 2) "+")
(put-text-property
(match-beginning 3) (match-end 3) 'face 'bold))))
(forward-line 1)))
(setq buffer-read-only t)
(set-buffer-modified-p nil))
;; make keymap for minibuffer
(suppress-keymap minibuffer-map t)
(define-key minibuffer-map "\C-g" 'abort-recursive-edit)
(define-key minibuffer-map "\C-m" 'exit-recursive-edit)
(define-key minibuffer-map "q" 'exit-recursive-edit)
(define-key minibuffer-map " " 'exit-recursive-edit)
(mapcar
(lambda (command)
(define-key minibuffer-map (car command) 'self-insert-and-exit))
command-list)
(mapcar
(lambda (screen)
(define-key minibuffer-map (number-to-string screen)
'self-insert-and-exit))
screen-list)
;; read key from minibuffer
(unwind-protect
(setq command-or-target-screen
(read-from-minibuffer prompt nil minibuffer-map
nil 'mini-hist))
(kill-buffer candidate-buffer)))
(cond
((string= command-or-target-screen ""))
((get-alist command-or-target-screen command-list)
(funcall (get-alist command-or-target-screen command-list)))
(t
(elscreen-goto (string-to-number command-or-target-screen))))))
(defun elscreen-find-and-goto-by-buffer (&optional buffer create noselect)
"Go to the screen that has the window with buffer BUFFER,
creating one if none already exists."
(interactive)
(let* ((prompt "Go to the screen with specified buffer: ")
(create (or create (interactive-p)))
(buffer-name (or (and (bufferp buffer) (buffer-name buffer))
(and (stringp buffer) buffer)
(and (featurep 'iswitchb)
(iswitchb-read-buffer prompt))
(read-buffer prompt)))
(target-screen (elscreen-find-screen-by-buffer
(get-buffer-create buffer-name) create)))
(when target-screen
(elscreen-goto target-screen)
(unless noselect
(select-window (get-buffer-window buffer-name))))
target-screen))
(defun elscreen-find-file (filename)
"Edit file FILENAME.
Switch to a screen visiting file FILENAME,
creating one if none already exists."
(interactive "FFind file in new screen: ")
(elscreen-find-and-goto-by-buffer (find-file-noselect filename) 'create))
(defun elscreen-find-file-read-only (filename)
"Edit file FILENAME with new screen but don't allow changes.
Like \\[elscreen-find-file] but marks buffer as read-only.
Use \\[toggle-read-only] to permit editing."
(interactive "FFind file read-only in new screen: ")
(elscreen-find-file filename)
(toggle-read-only 1))
(defun elscreen-dired (dirname &optional switches)
(interactive (progn
(or (featurep 'dired) (require 'dired))
(dired-read-dir-and-switches "in new screen ")))
(elscreen-find-and-goto-by-buffer (dired-noselect dirname switches) 'create))
(defun elscreen-execute-extended-command (prefix-arg)
(interactive "P")
(let ((prefix-arg prefix-arg)
(prefix-key (key-description elscreen-prefix-key))
target-screen)
(setq this-command (intern (completing-read
;; Note: this has the hard-wired
;; "C-u" and "M-x" string bug in common
;; with all Emacs's.
;; (i.e. it prints C-u and M-x regardless of
;; whether some other keys were actually bound
;; to `execute-extended-command' and
;; `universal-argument'.
(cond ((eq prefix-arg '-)
(format "- %s M-x " prefix-key))
((equal prefix-arg '(4))
(format "C-u %s M-x " prefix-key))
((integerp prefix-arg)
(format "%d %s M-x "
prefix-arg prefix-key))
((and (consp prefix-arg)
(integerp (car prefix-arg)))
(format "%d %s M-x "
(car prefix-arg) prefix-key))
(t
(format "%s M-x " prefix-key)))
obarray 'commandp t nil
(static-if elscreen-on-xemacs
'read-command-history
'extended-command-history))))
(if (setq target-screen (elscreen-create-internal 'noerror))
(elscreen-goto target-screen)
(select-window (split-window)))
(command-execute this-command t)))
;;; Mode Line & Menu & Tab
;; GNU Emacs
(static-when elscreen-on-emacs
;; Mode Line
(defvar elscreen-e21-mode-line-string "[0]")
(defun elscreen-e21-mode-line-update ()
(when (elscreen-screen-modified-p 'elscreen-e21-mode-line-update)
(setq elscreen-e21-mode-line-string
(format "[%d]" (elscreen-get-current-screen)))
(force-mode-line-update)))
(let ((point (or
;; GNU Emacs 21.3.50 or later
(memq 'mode-line-position mode-line-format)
;; GNU Emacs 21.3.1
(memq 'mode-line-buffer-identification mode-line-format)))
(elscreen-mode-line-elm '(elscreen-display-screen-number
(" " elscreen-e21-mode-line-string))))
(when (null (member elscreen-mode-line-elm mode-line-format))
(setcdr point (cons elscreen-mode-line-elm (cdr point)))))
(add-hook 'elscreen-screen-update-hook 'elscreen-e21-mode-line-update)
;; Menu
(define-key-after (lookup-key global-map [menu-bar]) [elscreen]
(cons "ElScreen" (make-sparse-keymap "ElScreen")) 'buffer)
(defvar elscreen-e21-menu-bar-command-entries
(list (list 'elscreen-command-separator
'menu-item
"--")
(list 'elscreen-create
'menu-item
"Create Screen"
'elscreen-create
:help "Create a new screen and switch to it")
(list 'elscreen-clone
'menu-item
"Clone Screen"
'elscreen-clone
:help "Create a new screen with the window-configuration of current screen")
(list 'elscreen-kill
'menu-item
"Kill Screen"
'elscreen-kill
:help "Kill current screen")
(list 'elscreen-kill-screen-and-buffers
'menu-item
"Kill Screen and Buffers"
'elscreen-kill-screen-and-buffers
:help "Kill current screen and buffers")
(list 'elscreen-kill-others
'menu-item
"Kill Other Screens"
'elscreen-kill-others
:help "Kill other screens")
(list 'elscreen-next
'menu-item
"Next Screen"
'elscreen-next
:help "Switch to the \"next\" screen in a cyclic order")
(list 'elscreen-previous
'menu-item
"Previous Screen"
'elscreen-previous
:help "Switch to the \"previous\" screen in a cyclic order")
(list 'elscreen-toggle
'menu-item
"Toggle Screen"
'elscreen-toggle
:help "Toggle to the screen selected previously")
(list 'elscreen-command-separator
'menu-item
"--")
(list 'elscreen-toggle-display-screen-number
'menu-item
"Display Screen Number"
'elscreen-toggle-display-screen-number
:help "Display screen number on the mode line"
:button '(:toggle . elscreen-display-screen-number))
(list 'elscreen-toggle-display-tab
'menu-item
"Display Tab"
'elscreen-toggle-display-tab
:help "Display tab on the top of screen"
:button '(:toggle . elscreen-display-tab))))
(defun elscreen-e21-menu-bar-update (&optional force)
(when (and (lookup-key (current-global-map) [menu-bar elscreen])
(or force
(elscreen-screen-modified-p 'elscreen-menu-bar-update)))
(let ((screen-list (sort (elscreen-get-screen-list) '<))
(screen-to-name-alist (elscreen-get-screen-to-name-alist))
(elscreen-menu nil))
(setq elscreen-menu
(mapcar
(lambda (screen)
(list (string-to-char (number-to-string screen))
'menu-item
(format "%d%s %s" screen
(elscreen-status-label screen)
(elscreen-truncate-screen-name
(get-alist screen screen-to-name-alist) 25))
'elscreen-jump
:keys (format "%s %d"
(key-description elscreen-prefix-key)
screen)))
screen-list))
(setq elscreen-menu
(nconc elscreen-menu elscreen-e21-menu-bar-command-entries))
(setq elscreen-menu
(cons 'keymap (cons "Select Screen" elscreen-menu)))
(define-key (current-global-map) [menu-bar elscreen]
(cons (copy-sequence "ElScreen") elscreen-menu)))))
(add-hook 'elscreen-screen-update-hook 'elscreen-e21-menu-bar-update)
;; Tab
(defvar elscreen-e21-tab-format nil)
(make-variable-buffer-local 'elscreen-e21-tab-format)
(defsubst elscreen-e21-tab-create-keymap (&rest definitions)
(let ((keymap (make-sparse-keymap))
(key-function-pairs
(eval-when-compile
(mapcar
(lambda (key)
(cons key 'ignore))
(list 'mouse-1 'mouse-2 'mouse-3
'down-mouse-1 'down-mouse-2 'down-mouse-3
'drag-mouse-1 'drag-mouse-2 'drag-mouse-3)))))
(while definitions
(set-alist 'key-function-pairs (car definitions) (cadr definitions))
(setq definitions (cddr definitions)))
(mapc
(lambda (key-function-pair)
(let ((key (car key-function-pair))
(function (cdr key-function-pair)))
(define-key keymap (vector 'header-line key) function)))
key-function-pairs)
keymap))
(defsubst elscreen-e21-tab-width ()
(if (numberp elscreen-display-tab)
elscreen-display-tab
(let* ((number-of-screens (elscreen-get-number-of-screens))
(available-width
(- (frame-width) (if elscreen-tab-display-control 4 0)))
(tab-width
(round (- (/ available-width number-of-screens)
(if elscreen-tab-display-kill-screen 5.5 1.5)))))
(max (min tab-width 16) 1))))
(defun elscreen-e21-tab-escape-% (string)
(if (string-match "%" string)
(let ((retval "")
start (end 0) substring)
(while (setq start end)
(setq end (next-property-change start string))
(setq substring (replace-regexp-in-string
"%" "%%" (substring string start end)))
(set-text-properties 0 (length substring)
(text-properties-at start string) substring)
(setq retval (concat retval substring)))
retval)
string))
(defun elscreen-e21-tab-update (&optional force)
(when (and (not (window-minibuffer-p))
(or (elscreen-screen-modified-p 'elscreen-tab-update) force))
(walk-windows
(lambda (window)
(with-current-buffer (window-buffer window)
(when (and (boundp 'elscreen-e21-tab-format)
(equal header-line-format elscreen-e21-tab-format)
(or (not (eq (window-buffer window)
(window-buffer (frame-first-window))))
(not elscreen-display-tab)))
(kill-local-variable 'elscreen-e21-tab-format)
(setq header-line-format nil))))
'other 'other)
(when elscreen-display-tab
(let ((screen-list (sort (elscreen-get-screen-list) '<))
(screen-to-name-alist (elscreen-get-screen-to-name-alist))
(current-screen (elscreen-get-current-screen))
(half-space (eval-when-compile
(propertize
" "
'display '(space :width 0.5))))
(tab-separator (eval-when-compile
(propertize
" "
'face 'elscreen-tab-background-face
'display '(space :width 0.5))))
(control-tab (eval-when-compile
(propertize
"<->"
'face 'elscreen-tab-control-face
'local-map (elscreen-e21-tab-create-keymap
'mouse-1 'elscreen-previous
'mouse-2 'elscreen-create
'mouse-3 'elscreen-next)
'help-echo "mouse-1: previous screen, mouse-2: create new screen, mouse-3: next screen"))))
(with-current-buffer (window-buffer (frame-first-window))
(kill-local-variable 'elscreen-e21-tab-format)
(when elscreen-tab-display-control
(setq elscreen-e21-tab-format
(nconc
elscreen-e21-tab-format
(list
control-tab
tab-separator))))
(mapcar
(lambda (screen)
(let ((kill-screen
(propertize
"[X]"
'local-map (elscreen-e21-tab-create-keymap
'mouse-1 `(lambda (e)
(interactive "e")
(elscreen-kill ,screen))
'M-mouse-1 `(lambda (e)
(interactive "e")
(elscreen-kill-screen-and-buffers ,screen)))
'help-echo (format "mouse-1: kill screen %d, M-mouse-1: kill screen %d and buffers on it" screen screen))))
(setq elscreen-e21-tab-format
(nconc
elscreen-e21-tab-format
(list
(propertize
(concat
(when (or (eq elscreen-tab-display-kill-screen 'left)
(eq elscreen-tab-display-kill-screen t))
kill-screen)
half-space
(propertize
(format "%d%s%s%s"
screen
(elscreen-status-label screen)
half-space
(elscreen-e21-tab-escape-%
(elscreen-truncate-screen-name
(get-alist screen screen-to-name-alist)
(elscreen-e21-tab-width) t)))
'help-echo (get-alist screen screen-to-name-alist)
'local-map (elscreen-e21-tab-create-keymap
'mouse-1 `(lambda (e)
(interactive "e")
(elscreen-goto ,screen))))
(when (eq elscreen-tab-display-kill-screen 'right)
(concat half-space kill-screen)))
'face (if (eq current-screen screen)
'elscreen-tab-current-screen-face
'elscreen-tab-other-screen-face))
tab-separator)))))
screen-list)
(setq elscreen-e21-tab-format
(nconc
elscreen-e21-tab-format
(list
(propertize
(make-string (window-width) ?\ )
'face 'elscreen-tab-background-face
'local-map (elscreen-e21-tab-create-keymap)))))
(setq header-line-format elscreen-e21-tab-format))))))
(add-hook 'elscreen-screen-update-hook 'elscreen-e21-tab-update))
;; XEmacs
(static-when elscreen-on-xemacs
;; Mode Line
(defvar elscreen-xmas-mode-line-string "[0]")
(defun elscreen-xmas-mode-line-update ()
(when (elscreen-screen-modified-p 'elscreen-xmas-mode-line-update)
(setq elscreen-xmas-mode-line-string
(format "[%d]" (elscreen-get-current-screen)))
(force-mode-line-update)))
(let ((point (memq 'global-mode-string mode-line-format))
(elscreen-mode-line-elm '(elscreen-display-screen-number
(" " elscreen-xmas-mode-line-string))))
(if (null (member elscreen-mode-line-elm mode-line-format))
(setcdr point (cons elscreen-mode-line-elm (cdr point)))))
(add-hook 'elscreen-screen-update-hook 'elscreen-xmas-mode-line-update)
;; Menu
(defvar elscreen-xmas-menu-bar-command-entries
'("%_ElScreen"
:filter elscreen-xmas-menu-bar-filter
"----"
["%_Create Screen" elscreen-create]
["%_Clone Screen" elscreen-clone]
["%_Kill Screen" elscreen-kill]
["%_Kill Screen and Buffers" elscreen-kill-screen-and-buffers]
["%_Kill Other Screens" elscreen-kill-others]
["%_Next Screen" elscreen-next]
["%_Previous Screen" elscreen-previous]
["%_Toggle Screen" elscreen-toggle]
"----"
["%_Display Screen Number" elscreen-toggle-display-screen-number
:style toggle :selected elscreen-display-screen-number]
["%_Display Tab" elscreen-toggle-display-tab
:style toggle :selected elscreen-display-tab]))
(defconst elscreen-xmas-menubar (copy-sequence default-menubar))
(let ((menubar elscreen-xmas-menubar))
(catch 'buffers-menu-search
(while (car menubar)
(when (equal (car (car menubar)) "%_Buffers")
(throw 'buffers-menu-search menubar))
(setq menubar (cdr menubar))))
(setcdr menubar
(cons elscreen-xmas-menu-bar-command-entries (cdr menubar))))
(set-menubar elscreen-xmas-menubar)
(set-menubar-dirty-flag)
(defun elscreen-xmas-menu-bar-filter (menu)
(let ((screen-list (sort (elscreen-get-screen-list) '<))
(screen-to-name-alist (elscreen-get-screen-to-name-alist))
(elscreen-menu nil))
(setq elscreen-menu
(mapcar
(lambda (screen)
(vector (format "%d%s %s" screen
(elscreen-status-label screen)
(elscreen-truncate-screen-name
(get-alist screen screen-to-name-alist) 25))
`(elscreen-goto ,screen)
:active t
:keys (format "%s %d"
(key-description elscreen-prefix-key)
screen)))
screen-list))
(append elscreen-menu menu)))
;; Tab
(defsubst elscreen-xmas-tab-width ()
(if (numberp elscreen-display-tab) elscreen-display-tab 16))
(defvar elscreen-xmas-tab-glyph (make-glyph))
(let* ((gutter-string (copy-sequence "\n"))
(gutter-elscreen-tab-extent (make-extent 0 1 gutter-string)))
(set-extent-begin-glyph gutter-elscreen-tab-extent elscreen-xmas-tab-glyph)
(mapcar
(lambda (console-type)
(when (valid-image-instantiator-format-p 'tab-control console-type)
(set-specifier top-gutter-border-width 0 'global console-type)
(set-gutter-element top-gutter 'elscreen-tab
gutter-string 'global console-type)))
(console-type-list)))
(defun elscreen-xmas-tab-update (&optional force)
(if (or (not elscreen-display-tab)
(window-dedicated-p (selected-window)))
(set-gutter-element-visible-p default-gutter-visible-p
'elscreen-tab nil)
(when (and (not (window-minibuffer-p))
(or (elscreen-screen-modified-p 'elscreen-tab-update) force))
(set-gutter-element-visible-p default-gutter-visible-p
'elscreen-tab t)
(when (valid-image-instantiator-format-p 'tab-control)
(let* ((screen-list (sort (elscreen-get-screen-list) '<))
(screen-to-name-alist (elscreen-get-screen-to-name-alist))
(current-screen (elscreen-get-current-screen))
(tab-items
(mapcar
(lambda (screen)
(vector
(format "%d%s %s" screen
(elscreen-status-label screen)
(elscreen-truncate-screen-name
(get-alist screen screen-to-name-alist)
(elscreen-xmas-tab-width) t))
`(elscreen-goto ,screen)
:selected (eq screen current-screen)))
screen-list)))
(set-glyph-image
elscreen-xmas-tab-glyph
(vector 'tab-control
:descriptor "ElScreen"
:face 'default
:orientation 'top
:pixel-width '(gutter-pixel-width)
:items tab-items)
(selected-frame)))
(set-gutter-dirty-p 'top)))))
(add-hook 'elscreen-screen-update-hook 'elscreen-xmas-tab-update))
;;; Command-line processing at startup time
(defun elscreen-command-line-funcall (switch-string)
(let ((argval (intern (car command-line-args-left)))
screen elscreen-window-configuration)
(setq command-line-args-left (cdr command-line-args-left))
(save-window-excursion
(elscreen-apply-window-configuration
(elscreen-default-window-configuration))
(if (commandp argval)
(command-execute argval)
(funcall argval))
(setq elscreen-window-configuration
(elscreen-current-window-configuration)))
(setq file-count (1+ file-count))
(cond
((= file-count 1)
(elscreen-apply-window-configuration elscreen-window-configuration))
((setq screen (elscreen-create-internal 'noerror))
(elscreen-set-window-configuration screen
elscreen-window-configuration)))))
(defun elscreen-command-line-find-file (file file-count &optional line column)
(let ((line (or line 0))
(column (or column 0)))
(cond
((= file-count 1)
(find-file file))
((> file-count 10)
(find-file-noselect file))
(t
(elscreen-find-screen-by-buffer (find-file-noselect file) 'create)))
(or (zerop line)
(goto-line line))
(unless (< column 1)
(move-to-column (1- column)))))
(when elscreen-startup-command-line-processing
(setq command-switch-alist
(append command-switch-alist
'(("-elscreen-funcall" . elscreen-command-line-funcall)
("-e" . elscreen-command-line-funcall))))
(static-when elscreen-on-emacs
(if (string-match "^\\(19\\|2[0-2]\\)" emacs-version) ; emacs22 or prior-to
(progn
(defun elscreen-e21-command-line ()
(when (string-match "\\`-" argi)
(error "Unknown option `%s'" argi))
(setq file-count (1+ file-count))
(setq inhibit-startup-buffer-menu t)
(let* ((file
(expand-file-name
(command-line-normalize-file-name orig-argi)
dir)))
(elscreen-command-line-find-file file file-count line column))
(setq line 0)
(setq column 0)
t)
(add-hook 'after-init-hook (lambda ()
(add-to-list 'command-line-functions
'elscreen-e21-command-line t))))
; else
(progn
(defun elscreen-e23-command-line ()
(when (string-match "\\`-" argi)
(error "Unknown option `%s'" argi))
(setq file-count (1+ file-count))
(setq inhibit-startup-buffer-menu t)
(let* ((file
(expand-file-name
(command-line-normalize-file-name orig-argi)
cl1-dir)))
(elscreen-command-line-find-file file file-count cl1-line cl1-column))
(setq cl1-line 0)
(setq cl1-column 0)
t) ; defun
(add-hook 'after-init-hook (lambda ()
(add-to-list 'command-line-functions
'elscreen-e23-command-line t))))
); endif
)
(static-when elscreen-on-xemacs
(defadvice command-line-1 (around elscreen-xmas-command-line-1 activate)
(cond
((null command-line-args-left)
ad-do-it)
(t
(let ((dir command-line-default-directory)
(file-count 0)
(line nil)
(end-of-options nil)
file-p arg tem)
(while command-line-args-left
(setq arg (pop command-line-args-left))
(cond
(end-of-options
(setq file-p t))
((setq tem (when (eq (aref arg 0) ?-)
(or (assoc arg command-switch-alist)
(assoc (substring arg 1)
command-switch-alist))))
(funcall (cdr tem) arg))
((string-match "\\`\\+[0-9]+\\'" arg)
(setq line (string-to-int arg)))
((or (string= arg "-") (string= arg "--"))
(setq end-of-options t))
(t
(setq file-p t)))
(when file-p
(setq file-p nil)
(incf file-count)
(elscreen-command-line-find-file
(expand-file-name arg dir) file-count line)
(setq line nil)))))))))
;;; Unsupported Functions...
(defun elscreen-link ()
(interactive)
(cond
((null (one-window-p))
(elscreen-message "current screen must not have two or more window!"))
((or (null (elscreen-get-previous-screen))
(elscreen-one-screen-p))
(elscreen-message "must specify previous screen!"))
((and (elscreen-goto (elscreen-get-previous-screen))
(null (one-window-p)))
(elscreen-goto (elscreen-get-previous-screen))
(elscreen-message "previous screen must not have two or more window!"))
(t
(let ((elscreen-link-buffer (current-buffer)))
(elscreen-kill)
(switch-to-buffer-other-window elscreen-link-buffer)))))
(defun elscreen-split ()
(interactive)
(if (and (null (one-window-p))
(< (elscreen-get-number-of-screens) 10))
(let ((elscreen-split-buffer (current-buffer)))
(delete-window)
(elscreen-create)
(switch-to-buffer elscreen-split-buffer)
(elscreen-goto (elscreen-get-previous-screen)))
(elscreen-message "cannot split screen!")))
;;; Start ElScreen!
(defun elscreen-start ()
(mapcar
(lambda (frame)
(elscreen-make-frame-confs frame 'keep))
(frame-list))
(let ((prefix-key elscreen-prefix-key)
(elscreen-prefix-key nil))
(elscreen-set-prefix-key prefix-key)))
(elscreen-start)
|