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
|
;;; bindings.el --- define standard key bindings and some variables -*- lexical-binding: t; -*-
;; Copyright (C) 1985-2025 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: internal
;; Package: emacs
;; This file is part of GNU Emacs.
;; GNU Emacs 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 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(defun make-mode-line-mouse-map (mouse function) "\
Return a keymap with single entry for mouse key MOUSE on the mode line.
MOUSE is defined to run function FUNCTION with no args in the buffer
corresponding to the mode line clicked."
(let ((map (make-sparse-keymap)))
(define-key map (vector 'mode-line mouse) function)
map))
(defun mode-line-toggle-read-only (event)
"Like toggling `read-only-mode', for the mode-line."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(read-only-mode 'toggle)))
(defun mode-line-toggle-modified (event)
"Toggle the buffer-modified flag from the mode-line."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(set-buffer-modified-p (not (buffer-modified-p)))
(force-mode-line-update)))
(defun mode-line-widen (event)
"Widen a buffer from the mode-line."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(widen)
(force-mode-line-update)))
(defvar mode-line-input-method-map
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-2]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(toggle-input-method)
(force-mode-line-update))))
(define-key map [mode-line mouse-3]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(describe-current-input-method))))
(purecopy map)))
(defvar mode-line-coding-system-map
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(when (and enable-multibyte-characters
buffer-file-coding-system)
(describe-coding-system buffer-file-coding-system)))))
(define-key map [mode-line mouse-3]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(call-interactively 'set-buffer-file-coding-system))))
(purecopy map))
"Local keymap for the coding-system part of the mode line.")
(defun mode-line-change-eol (event)
"Cycle through the various possible kinds of end-of-line styles."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(let ((eol (coding-system-eol-type buffer-file-coding-system)))
(set-buffer-file-coding-system
(cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix))))))
(defvar mode-line-eol-desc-cache nil)
(defun mode-line-eol-desc ()
(let* ((eol (coding-system-eol-type buffer-file-coding-system))
(mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system))
(desc (assoc eol mode-line-eol-desc-cache)))
(if (and desc (eq (cadr desc) mnemonic))
(cddr desc)
(if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale.
(setq desc
(propertize
mnemonic
'help-echo (format "End-of-line style: %s\nmouse-1: Cycle"
(if (eq eol 0) "Unix-style LF"
(if (eq eol 1) "DOS-style CRLF"
(if (eq eol 2) "Mac-style CR"
"Undecided"))))
'keymap
(eval-when-compile
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1] 'mode-line-change-eol)
map))
'mouse-face 'mode-line-highlight))
(push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache)
desc)))
;;; Mode line contents
(defun mode-line-default-help-echo (window)
"Return default help echo text for WINDOW's mode line."
(let* ((frame (window-frame window))
(line-1a
;; Show text to select window only if the window is not
;; selected.
(not (eq window (frame-selected-window frame))))
(line-1b
;; Show text to drag mode line if either the window is not
;; at the bottom of its frame or the minibuffer window of
;; this frame can be resized. This matches a corresponding
;; check in `mouse-drag-mode-line'.
(or (not (window-at-side-p window 'bottom))
(let ((mini-window (minibuffer-window frame)))
(and (eq frame (window-frame mini-window))
(or (minibuffer-window-active-p mini-window)
(not resize-mini-windows))))))
(line-2
;; Show text make window occupy the whole frame
;; only if it doesn't already do that.
(not (eq window (frame-root-window frame))))
(line-3
;; Show text to delete window only if that's possible.
(not (eq window (frame-root-window frame)))))
(when (or line-1a line-1b line-2 line-3)
(concat
(when (or line-1a line-1b)
(concat
"mouse-1: "
(when line-1a "Select window")
(when line-1b
(if line-1a " (drag to resize)" "Drag to resize"))
(when (or line-2 line-3) "\n")))
(when line-2
(concat
"mouse-2: Make window occupy whole frame"
(when line-3 "\n")))
(when line-3
"mouse-3: Remove window from frame")))))
(defcustom mode-line-default-help-echo #'mode-line-default-help-echo
"Default help text for the mode line.
If the value is a string, it specifies the tooltip or echo area
message to display when the mouse is moved over the mode line.
If the value is a function, call that function with one argument
- the window whose mode line to display. If the text at the
mouse position has a `help-echo' text property, that overrides
this variable."
:type '(choice
(const :tag "No help" :value nil)
function
(string :value "mouse-1: Select (drag to resize)\n\
mouse-2: Make current window occupy the whole frame\n\
mouse-3: Remove current window from display"))
:version "27.1"
:group 'mode-line)
(defvar mode-line-front-space '(:eval (if (display-graphic-p) " " "-"))
"Mode line construct to put at the front of the mode line.
By default, this construct is displayed right at the beginning of
the mode line, except that if there is a \"memory full\" message,
it is displayed first.")
(put 'mode-line-front-space 'risky-local-variable t)
(defun mode-line-mule-info-help-echo (window _object _point)
"Return help text specifying WINDOW's buffer coding system."
(with-current-buffer (window-buffer window)
(if buffer-file-coding-system
(format "Buffer coding system (%s): %s
mouse-1: Describe coding system
mouse-3: Set coding system"
(if enable-multibyte-characters "multi-byte" "unibyte")
(symbol-name buffer-file-coding-system))
"Buffer coding system: none specified")))
(defvar-local mode-line-mule-info
`(""
(current-input-method
(:propertize ("" current-input-method-title)
help-echo (concat
,(purecopy "Current input method: ")
current-input-method
,(purecopy "\n\
mouse-2: Disable input method\n\
mouse-3: Describe current input method"))
local-map ,mode-line-input-method-map
mouse-face mode-line-highlight))
,(propertize
"%z"
'help-echo 'mode-line-mule-info-help-echo
'mouse-face 'mode-line-highlight
'local-map mode-line-coding-system-map)
(:eval (mode-line-eol-desc)))
"Mode line construct to report the multilingual environment.
Normally it displays current input method (if any activated) and
mnemonics of the following coding systems:
coding system for saving or writing the current buffer
coding system for keyboard input (on a text terminal)
coding system for terminal output (on a text terminal)")
;;;###autoload
(put 'mode-line-mule-info 'risky-local-variable t)
(defvar mode-line-client
`(:eval
(if (frame-parameter nil 'client)
,(propertize "@" 'help-echo (purecopy "emacsclient frame"))))
"Mode line construct for identifying emacsclient frames.")
;; Autoload if this file no longer dumped.
;;;###autoload
(put 'mode-line-client 'risky-local-variable t)
(defun mode-line-read-only-help-echo (window _object _point)
"Return help text specifying WINDOW's buffer read-only status."
(format "Buffer is %s\nmouse-1: Toggle"
(if (buffer-local-value 'buffer-read-only (window-buffer window))
"read-only"
"writable")))
(defun mode-line-modified-help-echo (window _object _point)
"Return help text specifying WINDOW's buffer modification status."
(format "Buffer is %smodified\nmouse-1: Toggle modification state"
(if (buffer-modified-p (window-buffer window)) "" "not ")))
(defvar-local mode-line-modified
(list (propertize
"%1*"
'help-echo 'mode-line-read-only-help-echo
'local-map (purecopy (make-mode-line-mouse-map
'mouse-1
#'mode-line-toggle-read-only))
'mouse-face 'mode-line-highlight)
(propertize
"%1+"
'help-echo 'mode-line-modified-help-echo
'local-map (purecopy (make-mode-line-mouse-map
'mouse-1 #'mode-line-toggle-modified))
'mouse-face 'mode-line-highlight))
"Mode line construct for displaying whether current buffer is modified.")
;;;###autoload
(put 'mode-line-modified 'risky-local-variable t)
(defvar-local mode-line-remote
(list (propertize
"%1@"
'mouse-face 'mode-line-highlight
'help-echo (purecopy (lambda (window _object _point)
(format "%s"
(with-selected-window window
(if (stringp default-directory)
(concat
(if (file-remote-p default-directory)
"Current directory is remote: "
"Current directory is local: ")
default-directory)
"Current directory is nil")))))))
"Mode line construct to indicate a remote buffer.")
;;;###autoload
(put 'mode-line-remote 'risky-local-variable t)
;; MSDOS frames have window-system, but want the Fn identification.
(defun mode-line-frame-control ()
"Compute mode line construct for frame identification.
Value is used for `mode-line-frame-identification', which see."
(if (or (null window-system)
(eq window-system 'pc))
" %F "
" "))
;; We need to defer the call to mode-line-frame-control to the time
;; the mode line is actually displayed.
(defvar mode-line-frame-identification '(:eval (mode-line-frame-control))
"Mode line construct to describe the current frame.")
;;;###autoload
(put 'mode-line-frame-identification 'risky-local-variable t)
(defvar mode-line-window-dedicated-keymap
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1] #'toggle-window-dedicated)
(purecopy map)) "\
Keymap for what is displayed by `mode-line-window-dedicated'.")
(defun mode-line-window-control ()
"Compute mode line construct for window dedicated state.
Value is used for `mode-line-window-dedicated', which see."
(cond
((eq (window-dedicated-p) t)
(propertize
"D"
'help-echo "Window strongly dedicated to its buffer\nmouse-1: Toggle"
'local-map mode-line-window-dedicated-keymap
'mouse-face 'mode-line-highlight))
((window-dedicated-p)
(propertize
"d"
'help-echo "Window dedicated to its buffer\nmouse-1: Toggle"
'local-map mode-line-window-dedicated-keymap
'mouse-face 'mode-line-highlight))
(t "")))
(defvar mode-line-window-dedicated '(:eval (mode-line-window-control))
"Mode line construct to describe the current window.")
;;;###autoload
(put 'mode-line-window-dedicated 'risky-local-variable t)
(defvar-local mode-line-process nil
"Mode line construct for displaying info on process status.
Normally nil in most modes, since there is no process to display.")
;;;###autoload
(put 'mode-line-process 'risky-local-variable t)
(defcustom mode-line-right-align-edge 'window
"Where function `mode-line-format-right-align' should align to.
Internally, that function uses `:align-to' in a display property,
so aligns to the left edge of the given area. See info node
`(elisp)Pixel Specification'.
Must be set to a symbol. Acceptable values are:
- `window': align to extreme right of window, regardless of margins
or fringes
- `right-fringe': align to right-fringe
- `right-margin': align to right-margin"
:type '(choice (const right-margin)
(const right-fringe)
(const window))
:group 'mode-line
:version "30.1")
(defun mode--line-format-right-align ()
"Right-align all following mode-line constructs.
When the symbol `mode-line-format-right-align' appears in
`mode-line-format', return a string of one space, with a display
property to make it appear long enough to align anything after
that symbol to the right of the rendered mode line. Exactly how
far to the right is controlled by `mode-line-right-align-edge'.
It is important that the symbol `mode-line-format-right-align' be
included in `mode-line-format' (and not another similar construct
such as `(:eval (mode-line-format-right-align)'). This is because
the symbol `mode-line-format-right-align' is processed by
`format-mode-line' as a variable."
(let* ((rest (cdr (memq 'mode-line-format-right-align
mode-line-format)))
(rest-str (format-mode-line `("" ,@rest)))
(rest-width (progn
(add-face-text-property
0 (length rest-str) 'mode-line t rest-str)
(string-pixel-width rest-str))))
(propertize " " 'display
;; The `right' spec doesn't work on TTY frames
;; when windows are split horizontally (bug#59620)
(if (and (display-graphic-p)
(not (eq mode-line-right-align-edge 'window)))
`(space :align-to (- ,mode-line-right-align-edge
(,rest-width)))
`(space :align-to (,(- (window-pixel-width)
(window-scroll-bar-width)
(window-right-divider-width)
(* (or (car (window-margins)) 0)
(frame-char-width))
;; Manually account for value of
;; `mode-line-right-align-edge' even
;; when display is non-graphical
(pcase mode-line-right-align-edge
('right-margin
(or (cdr (window-margins)) 0))
('right-fringe
;; what here?
(or (cadr (window-fringes)) 0))
(_ 0))
rest-width)))))))
(defvar mode-line-format-right-align '(:eval (mode--line-format-right-align))
"Mode line construct to right align all following constructs.")
;;;###autoload
(put 'mode-line-format-right-align 'risky-local-variable t)
(defun bindings--define-key (map key item)
"Define KEY in keymap MAP according to ITEM from a menu.
This is like `define-key', but it takes the definition from the
specified menu item, and makes pure copies of as much as possible
of the menu's data."
(declare (indent 2))
(define-key map key
(cond
((not (consp item)) item) ;Not sure that could be other than a symbol.
;; Keymaps can't be made pure otherwise users can't remove/add elements
;; from/to them any more.
((keymapp item) item)
((stringp (car item))
(if (keymapp (cdr item))
(cons (purecopy (car item)) (cdr item))
(purecopy item)))
((eq 'menu-item (car item))
(if (keymapp (nth 2 item))
`(menu-item ,(purecopy (nth 1 item)) ,(nth 2 item)
,@(purecopy (nthcdr 3 item)))
(purecopy item)))
(t (message "non-menu-item: %S" item) item))))
(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
Menu of mode operations in the mode line.")
(defun bindings--menu-item-string (item)
"Return the menu-item string for ITEM, or nil if not a menu-item."
(pcase item
(`(menu-item ,name . ,_) (eval name t))
(`(,(and (pred stringp) name) . ,_) name)))
(defun bindings--sort-menu-keymap (map)
"Sort the bindings in MAP in alphabetical order by menu-item string.
The order of bindings in a keymap matters only when it is used as
a menu, so this function is not useful for non-menu keymaps."
(let ((bindings nil)
(prompt (keymap-prompt map)))
(while (keymapp map)
(setq map (map-keymap
(lambda (key item)
;; FIXME: Handle char-ranges here?
(push (cons key item) bindings))
map)))
;; Sort the bindings and make a new keymap from them.
(setq bindings
(sort bindings
(lambda (a b)
(string< (bindings--menu-item-string (cdr-safe a))
(bindings--menu-item-string (cdr-safe b))))))
(nconc (make-sparse-keymap prompt) bindings)))
(defvar mode-line-major-mode-keymap
(let ((map (make-sparse-keymap)))
(bindings--define-key map [mode-line down-mouse-1]
`(menu-item "Menu Bar" ignore
:filter ,(lambda (_) (mouse-menu-major-mode-map))))
(define-key map [mode-line mouse-2] 'describe-mode)
(bindings--define-key map [mode-line down-mouse-3]
`(menu-item "Minor Modes" ,mode-line-mode-menu
:filter bindings--sort-menu-keymap))
map) "\
Keymap to display on major mode.")
(defvar mode-line-minor-mode-keymap
(let ((map (make-sparse-keymap))
(mode-menu-binding
`(menu-item "Menu Bar" ,mode-line-mode-menu
:filter bindings--sort-menu-keymap)))
(define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu)
(define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
(define-key map [mode-line down-mouse-3] mode-menu-binding)
(define-key map [header-line down-mouse-3] mode-menu-binding)
map) "\
Keymap to display on minor modes.")
(defvar mode-line-modes
(let ((recursive-edit-help-echo
"Recursive edit, type C-M-c to get out"))
(list (propertize "%[" 'help-echo recursive-edit-help-echo)
"("
`(:propertize ("" mode-name)
help-echo "Major mode\n\
mouse-1: Display major mode menu\n\
mouse-2: Show help for major mode\n\
mouse-3: Toggle minor modes"
mouse-face mode-line-highlight
local-map ,mode-line-major-mode-keymap)
'("" mode-line-process)
`(:propertize ("" minor-mode-alist)
mouse-face mode-line-highlight
help-echo "Minor mode\n\
mouse-1: Display minor mode menu\n\
mouse-2: Show help for minor mode\n\
mouse-3: Toggle minor modes"
local-map ,mode-line-minor-mode-keymap)
(propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer"
'mouse-face 'mode-line-highlight
'local-map (make-mode-line-mouse-map
'mouse-2 #'mode-line-widen))
")"
(propertize "%]" 'help-echo recursive-edit-help-echo)
" "))
"Mode line construct for displaying major and minor modes.")
(put 'mode-line-modes 'risky-local-variable t)
(defvar mode-line-column-line-number-mode-map
(let ((map (make-sparse-keymap))
(menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
(bindings--define-key menu-map [size-indication-mode]
'(menu-item "Display Size Indication" size-indication-mode
:help "Toggle displaying a size indication in the mode-line"
:button (:toggle . size-indication-mode)))
(bindings--define-key menu-map [line-number-mode]
'(menu-item "Display Line Numbers" line-number-mode
:help "Toggle displaying line numbers in the mode-line"
:button (:toggle . line-number-mode)))
(bindings--define-key menu-map [column-number-mode]
'(menu-item "Display Column Numbers" column-number-mode
:help "Toggle displaying column numbers in the mode-line"
:button (:toggle . column-number-mode)))
(define-key map [mode-line down-mouse-1] menu-map)
map) "\
Keymap to display on column and line numbers.")
(defcustom column-number-indicator-zero-based t
"When non-nil, mode line displays column numbers zero-based.
This variable has effect only when Column Number mode is turned on,
which displays column numbers in the mode line.
If the value is non-nil, the displayed column numbers start from
zero, otherwise they start from one."
:type 'boolean
:group 'mode-line
:version "26.1")
(make-obsolete-variable 'column-number-indicator-zero-based
'mode-line-position-column-format "28.1")
(defcustom mode-line-percent-position '(-3 "%p")
"Specification of \"percentage offset\" of window through buffer.
This option specifies both the field width and the type of offset
displayed in `mode-line-position', a component of the default
`mode-line-format'."
:type '(radio
(const :tag "nil: No offset is displayed" nil)
(const :tag "\"%o\": Proportion of \"travel\" of the window through the buffer"
(-3 "%o"))
(const :tag "\"%p\": Percentage offset of top of window"
(-3 "%p"))
(const :tag "\"%P\": Percentage offset of bottom of window"
(-3 "%P"))
(const :tag "\"%q\": Offsets of both top and bottom of window"
(6 "%q")))
:version "26.1"
:risky t
:group 'mode-line)
(defcustom mode-line-position-line-format '(" L%l")
"Format used to display line numbers in the mode line.
This is used when `line-number-mode' is switched on. The \"%l\"
format spec will be replaced by the line number.
Also see `mode-line-position-column-line-format'."
:type '(list string)
:version "28.1"
:group 'mode-line)
(defcustom mode-line-position-column-format '(" C%c")
"Format used to display column numbers in the mode line.
This is used when `column-number-mode' is switched on. The
\"%c\" format spec is replaced by the zero-based column number,
and \"%C\" is replaced by the one-based column number.
Also see `mode-line-position-column-line-format'."
:type '(list string)
:version "28.1"
:group 'mode-line)
(defcustom mode-line-position-column-line-format '(" (%l,%c)")
"Format used to display combined line/column numbers in the mode line.
This is used when `column-number-mode' and `line-number-mode' are
switched on. The \"%c\" format spec will be replaced by the
column number, which is zero-based if
`column-number-indicator-zero-based' is non-nil, and one-based if
`column-number-indicator-zero-based' is nil."
:type '(list string)
:version "28.1"
:group 'mode-line)
(defconst mode-line-position--column-line-properties
(list 'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number and Column number\n\
mouse-1: Display Line and Column Mode Menu"))
(defvar mode-line-position
`((:propertize
("" mode-line-percent-position)
local-map ,mode-line-column-line-number-mode-map
display (min-width (5.0))
mouse-face mode-line-highlight
;; XXX needs better description
help-echo "Window Scroll Percentage
mouse-1: Display Line and Column Mode Menu")
(size-indication-mode
(8 ,(propertize
" of %I"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
;; XXX needs better description
'help-echo "Size indication mode\n\
mouse-1: Display Line and Column Mode Menu")))
(line-number-mode
(column-number-mode
(column-number-indicator-zero-based
(10
(:propertize
mode-line-position-column-line-format
display (min-width (10.0))
,@mode-line-position--column-line-properties))
(10
(:propertize
(:eval (string-replace
"%c" "%C" (car mode-line-position-column-line-format)))
display (min-width (10.0))
,@mode-line-position--column-line-properties)))
(6
(:propertize
mode-line-position-line-format
display (min-width (6.0))
,@mode-line-position--column-line-properties)))
(column-number-mode
(column-number-indicator-zero-based
(6
(:propertize
mode-line-position-column-format
display (min-width (6.0))
,@mode-line-position--column-line-properties))
(6
(:propertize
(:eval (string-replace
"%c" "%C" (car mode-line-position-column-format)))
display (min-width (6.0))
,@mode-line-position--column-line-properties))))))
"Mode line construct for displaying the position in the buffer.
Normally displays the buffer percentage and, optionally, the
buffer size, the line number and the column number.")
(put 'mode-line-position 'risky-local-variable t)
(defvar mode-line-buffer-identification-keymap
;; Add menu of buffer operations to the buffer identification part
;; of the mode line.or header line.
(let ((map (make-sparse-keymap)))
;; Bind down- events so that the global keymap won't ``shine
;; through''.
(define-key map [mode-line mouse-1] 'mode-line-previous-buffer)
(define-key map [header-line down-mouse-1] 'ignore)
(define-key map [header-line mouse-1] 'mode-line-previous-buffer)
(define-key map [mode-line mouse-3] 'mode-line-next-buffer)
(define-key map [header-line down-mouse-3] 'ignore)
(define-key map [header-line mouse-3] 'mode-line-next-buffer)
map) "\
Keymap for what is displayed by `mode-line-buffer-identification'.")
(defun propertized-buffer-identification (fmt)
"Return a list suitable for `mode-line-buffer-identification'.
FMT is a format specifier such as \"%12b\". This function adds
text properties for face, help-echo, and local-map to it."
(list (propertize fmt
'face 'mode-line-buffer-id
'help-echo
(purecopy "Buffer name
mouse-1: Previous buffer\nmouse-3: Next buffer")
'mouse-face 'mode-line-highlight
'local-map mode-line-buffer-identification-keymap)))
(defvar-local mode-line-buffer-identification
(propertized-buffer-identification "%12b")
"Mode line construct for identifying the buffer being displayed.
Its default value is (\"%12b\") with some text properties added.
Major modes that edit things other than ordinary files may change this
\(e.g. Info, Dired,...)")
;;;###autoload
(put 'mode-line-buffer-identification 'risky-local-variable t)
(defvar mode-line-misc-info
'((global-mode-string ("" global-mode-string)))
"Mode line construct for miscellaneous information.
By default, this shows the information specified by `global-mode-string'.")
(put 'mode-line-misc-info 'risky-local-variable t)
(defvar mode-line-end-spaces '(:eval (unless (display-graphic-p) "-%-"))
"Mode line construct to put at the end of the mode line.")
(put 'mode-line-end-spaces 'risky-local-variable t)
;; Default value of the top-level `mode-line-format' variable:
(let ((standard-mode-line-format
(list "%e"
'mode-line-front-space
(list
:propertize
(list ""
'mode-line-mule-info
'mode-line-client
'mode-line-modified
'mode-line-remote
'mode-line-window-dedicated)
'display '(min-width (6.0)))
'mode-line-frame-identification
'mode-line-buffer-identification
" "
'mode-line-position
'(project-mode-line project-mode-line-format)
'(vc-mode vc-mode)
" "
'mode-line-modes
'mode-line-misc-info
'mode-line-end-spaces)))
(setq-default mode-line-format standard-mode-line-format)
(put 'mode-line-format 'standard-value
(list `(quote ,standard-mode-line-format))))
(defun mode-line-unbury-buffer (event)
"Call `unbury-buffer' in this window."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(unbury-buffer)))
(defun mode-line-bury-buffer (event)
"Like `bury-buffer', but temporarily select EVENT's window."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(bury-buffer)))
(defun mode-line-other-buffer ()
"Switch to the most recently selected buffer other than the current one."
(interactive)
(switch-to-buffer (other-buffer) nil t))
(defun mode-line-next-buffer (event)
"Like `next-buffer', but temporarily select EVENT's window."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(next-buffer)))
(defun mode-line-previous-buffer (event)
"Like `previous-buffer', but temporarily select EVENT's window."
(interactive "e")
(with-selected-window (posn-window (event-start event))
(previous-buffer)))
(defun mode-line-window-selected-p ()
"Return non-nil if we're updating the mode line for the selected window.
This function is meant to be called in `:eval' mode line
constructs to allow altering the look of the mode line depending
on whether the mode line belongs to the currently selected window
or not."
(let ((window (selected-window)))
(or (eq window (old-selected-window))
(and (minibuffer-window-active-p (minibuffer-window))
(with-selected-window (minibuffer-window)
(eq window (minibuffer-selected-window)))))))
(defmacro bound-and-true-p (var)
"Return the value of symbol VAR if it is bound, else nil.
Note that if `lexical-binding' is in effect, this function isn't
meaningful if it refers to a lexically bound variable."
(unless (symbolp var)
(signal 'wrong-type-argument (list 'symbolp var)))
`(and (boundp (quote ,var)) ,var))
;; Use mode-line-mode-menu for local minor-modes only.
;; Global ones can go on the menubar (Options --> Show/Hide).
(bindings--define-key mode-line-mode-menu [overwrite-mode]
'(menu-item "Overwrite (Ovwrt)" overwrite-mode
:help "Overwrite mode: typed characters replace existing text"
:button (:toggle . overwrite-mode)))
(bindings--define-key mode-line-mode-menu [outline-minor-mode]
'(menu-item "Outline (Outl)" outline-minor-mode
;; XXX: This needs a good, brief description.
:help ""
:button (:toggle . (bound-and-true-p outline-minor-mode))))
(bindings--define-key mode-line-mode-menu [highlight-changes-mode]
'(menu-item "Highlight changes (Chg)" highlight-changes-mode
:help "Show changes in the buffer in a distinctive color"
:button (:toggle . (bound-and-true-p highlight-changes-mode))))
(bindings--define-key mode-line-mode-menu [hide-ifdef-mode]
'(menu-item "Hide ifdef (Ifdef)" hide-ifdef-mode
:help "Show/Hide code within #ifdef constructs"
:button (:toggle . (bound-and-true-p hide-ifdef-mode))))
(bindings--define-key mode-line-mode-menu [glasses-mode]
'(menu-item "Glasses (o^o)" glasses-mode
:help "Insert virtual separators to make long identifiers easy to read"
:button (:toggle . (bound-and-true-p glasses-mode))))
(bindings--define-key mode-line-mode-menu [font-lock-mode]
'(menu-item "Font Lock" font-lock-mode
:help "Syntax coloring"
:button (:toggle . font-lock-mode)))
(bindings--define-key mode-line-mode-menu [flyspell-mode]
'(menu-item "Flyspell (Fly)" flyspell-mode
:help "Spell checking on the fly"
:button (:toggle . (bound-and-true-p flyspell-mode))))
(bindings--define-key mode-line-mode-menu [completion-preview-mode]
'(menu-item "Completion Preview (CP)" completion-preview-mode
:help "Show preview of completion suggestions as you type"
:enable completion-at-point-functions
:button (:toggle . (bound-and-true-p completion-preview-mode))))
(bindings--define-key mode-line-mode-menu [auto-revert-tail-mode]
'(menu-item "Auto revert tail (Tail)" auto-revert-tail-mode
:help "Revert the tail of the buffer when the file on disk grows"
:enable (buffer-file-name)
:button (:toggle . (bound-and-true-p auto-revert-tail-mode))))
(bindings--define-key mode-line-mode-menu [auto-revert-mode]
'(menu-item "Auto revert (ARev)" auto-revert-mode
:help "Revert the buffer when the file on disk changes"
:button (:toggle . (bound-and-true-p auto-revert-mode))))
(bindings--define-key mode-line-mode-menu [auto-fill-mode]
'(menu-item "Auto fill (Fill)" auto-fill-mode
:help "Automatically insert new lines"
:button (:toggle . auto-fill-function)))
(bindings--define-key mode-line-mode-menu [abbrev-mode]
'(menu-item "Abbrev (Abbrev)" abbrev-mode
:help "Automatically expand abbreviations"
:button (:toggle . abbrev-mode)))
(defun mode-line-minor-mode-help (event)
"Describe minor mode for EVENT on minor modes area of the mode line."
(interactive "@e")
(let ((indicator (car (nth 4 (car (cdr event))))))
(describe-minor-mode-from-indicator indicator event)))
(defvar mode-line-defining-kbd-macro (propertize " Def" 'face 'font-lock-warning-face)
"String displayed in the mode line in keyboard macro recording mode.")
;;;###autoload
(put 'mode-line-defining-kbd-macro 'risky-local-variable t)
(defvar minor-mode-alist nil "\
Alist saying how to show minor modes in the mode line.
Each element looks like (VARIABLE STRING);
STRING is included in the mode line if VARIABLE's value is non-nil.
Actually, STRING need not be a string; any mode-line construct is
okay. See `mode-line-format'.")
;;;###autoload
(put 'minor-mode-alist 'risky-local-variable t)
;; Don't use purecopy here--some people want to change these strings,
;; also string properties are lost when put into pure space.
(setq minor-mode-alist
'((abbrev-mode " Abbrev")
(overwrite-mode overwrite-mode)
(auto-fill-function " Fill")
;; not really a minor mode...
(defining-kbd-macro mode-line-defining-kbd-macro)))
;; These variables are used by autoloadable packages.
;; They are defined here so that they do not get overridden
;; by the loading of those packages.
;; Names in directory that end in one of these
;; are ignored in completion,
;; making it more likely you will get a unique match.
(setq completion-ignored-extensions
(append
(cond ((memq system-type '(ms-dos windows-nt))
(mapcar 'purecopy
'(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk"
".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386")))
(t
(mapcar 'purecopy
'(".o" "~" ".bin" ".lbin" ".so"
".a" ".ln" ".blg" ".bbl"))))
(mapcar 'purecopy
'(".elc" ".lof"
".glo" ".idx" ".lot"
;; VCS metadata directories
".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/"
;; TeX-related
".fmt" ".tfm"
;; Java compiled
".class"
;; CLISP
".fas" ".lib" ".mem"
;; CMUCL
".x86f" ".sparcf"
;; OpenMCL / Clozure CL
".dfsl" ".pfsl" ".d64fsl" ".p64fsl" ".lx64fsl" ".lx32fsl"
".dx64fsl" ".dx32fsl" ".fx64fsl" ".fx32fsl" ".sx64fsl"
".sx32fsl" ".wx64fsl" ".wx32fsl"
;; Other CL implementations (Allegro, LispWorks)
".fasl" ".ufsl" ".fsl" ".dxl"
;; Libtool
".lo" ".la"
;; Gettext
".gmo" ".mo"
;; Texinfo-related
;; This used to contain .log, but that's commonly used for log
;; files you do want to see, not just TeX stuff. -- fx
".toc" ".aux"
".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs"
;; Python byte-compiled
".pyc" ".pyo"))))
;; Suffixes used for executables.
(setq exec-suffixes
(cond
((memq system-type '(ms-dos windows-nt))
'(".exe" ".com" ".bat" ".cmd" ".btm" ""))
(t
'(""))))
;; Packages should add to this list appropriately when they are
;; loaded, rather than listing everything here.
(setq debug-ignored-errors
;; FIXME: Maybe beginning-of-line, beginning-of-buffer, end-of-line,
;; end-of-buffer, end-of-file, buffer-read-only, and
;; file-supersession should all be user-errors!
'(beginning-of-line beginning-of-buffer end-of-line
end-of-buffer end-of-file buffer-read-only
file-supersession mark-inactive
user-error ;; That's the main one!
))
(make-variable-buffer-local 'indent-tabs-mode)
;; These per-buffer variables are never reset by
;; `kill-all-local-variables', because they have no default value.
;; For consistency, we give them the `permanent-local' property, even
;; though `kill-all-local-variables' does not actually consult it.
;; See init_buffer_once in buffer.c for the origins of this list.
(mapc (lambda (sym) (put sym 'permanent-local t))
'(buffer-file-name default-directory buffer-backed-up
buffer-saved-size buffer-auto-save-file-name
buffer-read-only buffer-undo-list mark-active
point-before-scroll buffer-file-truename
buffer-file-format buffer-auto-save-file-format
buffer-display-count buffer-display-time
enable-multibyte-characters
buffer-file-coding-system truncate-lines))
;; We have base64, md5 and sha1 functions built in now.
(provide 'base64)
(provide 'md5)
(provide 'sha1)
(provide 'overlay '(display syntax-table field))
(provide 'text-properties '(display syntax-table field point-entered))
(define-key esc-map "\t" 'complete-symbol)
(defun complete-symbol (arg)
"Perform completion on the text around point.
The completion method is determined by `completion-at-point-functions'.
With a prefix argument, this command does completion within
the collection of symbols listed in the index of the manual for the
language you are using."
(interactive "P")
(if arg (info-complete-symbol) (completion-at-point)))
;; Reduce total amount of space we must allocate during this function
;; that we will not need to keep permanently.
(garbage-collect)
(setq help-event-list '(help f1 ?\?))
(make-variable-buffer-local 'minor-mode-overriding-map-alist)
;; From frame.c
(global-set-key [switch-frame] 'handle-switch-frame)
(global-set-key [select-window] 'handle-select-window)
;; FIXME: Do those 3 events really ever reach the global-map ?
;; It seems that they can't because they're handled via
;; special-event-map which is used at very low-level. -stef
(global-set-key [delete-frame] 'handle-delete-frame)
(global-set-key [iconify-frame] 'ignore)
(global-set-key [make-frame-visible] 'ignore)
;These commands are defined in editfns.c
;but they are not assigned to keys there.
(put 'narrow-to-region 'disabled t)
;; Moving with arrows in bidi-sensitive direction.
(defcustom visual-order-cursor-movement nil
"If non-nil, moving cursor with arrow keys follows the visual order.
When this is non-nil, \\[right-char] will move to the character that is
to the right of point on display, and \\[left-char] will move to the left,
disregarding the surrounding bidirectional context. Depending on the
bidirectional context of the surrounding characters, this can move point
many buffer positions away.
When the text is entirely left-to-right, logical-order and visual-order
cursor movements produce identical results."
:type '(choice (const :tag "Logical-order cursor movement" nil)
(const :tag "Visual-order cursor movement" t))
:group 'display
:version "24.4")
(defun right-char (&optional n)
"Move point N characters to the right (to the left if N is negative).
On reaching beginning or end of buffer, stop and signal error.
If `visual-order-cursor-movement' is non-nil, this always moves
to the right on display, wherever that is in the buffer.
Otherwise, depending on the bidirectional context, this may move
one position either forward or backward in the buffer. This is
in contrast with \\[forward-char] and \\[backward-char], which
see."
(interactive "^p")
(if visual-order-cursor-movement
(dotimes (_ (if (numberp n) (abs n) 1))
(move-point-visually (if (and (numberp n) (< n 0)) -1 1)))
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(forward-char n)
(backward-char n))))
(defun left-char ( &optional n)
"Move point N characters to the left (to the right if N is negative).
On reaching beginning or end of buffer, stop and signal error.
If `visual-order-cursor-movement' is non-nil, this always moves
to the left on display, wherever that is in the buffer.
Otherwise, depending on the bidirectional context, this may move
one position either backward or forward in the buffer. This is
in contrast with \\[forward-char] and \\[backward-char], which
see."
(interactive "^p")
(if visual-order-cursor-movement
(dotimes (_ (if (numberp n) (abs n) 1))
(move-point-visually (if (and (numberp n) (< n 0)) 1 -1)))
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(backward-char n)
(forward-char n))))
(defun right-word (&optional n)
"Move point N words to the right (to the left if N is negative).
Depending on the bidirectional context, this may move either forward
or backward in the buffer. This is in contrast with \\[forward-word]
and \\[backward-word], which see.
Value is normally t.
The word boundaries are normally determined by the buffer's syntax
table and character script (according to `char-script-table'), but
`find-word-boundary-function-table', such as set up by `subword-mode',
can change that. If a Lisp program needs to move by words determined
strictly by the syntax table, it should use `forward-word-strictly'
instead. See Info node `(elisp) Word Motion' for details.
If an edge of the buffer or a field boundary is reached, point is left there
and the function returns nil. Field boundaries are not noticed
if `inhibit-field-text-motion' is non-nil."
(interactive "^p")
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(forward-word n)
(backward-word n)))
(defun left-word (&optional n)
"Move point N words to the left (to the right if N is negative).
Depending on the bidirectional context, this may move either backward
or forward in the buffer. This is in contrast with \\[backward-word]
and \\[forward-word], which see.
Value is normally t.
The word boundaries are normally determined by the buffer's syntax
table and character script (according to `char-script-table'), but
`find-word-boundary-function-table', such as set up by `subword-mode',
can change that. If a Lisp program needs to move by words determined
strictly by the syntax table, it should use `forward-word-strictly'
instead. See Info node `(elisp) Word Motion' for details.
If an edge of the buffer or a field boundary is reached, point is left there
and the function returns nil. Field boundaries are not noticed
if `inhibit-field-text-motion' is non-nil."
(interactive "^p")
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(backward-word n)
(forward-word n)))
(defvar-keymap narrow-map
:doc "Keymap for narrowing commands."
"n" #'narrow-to-region
"w" #'widen
"g" #'goto-line-relative)
(define-key ctl-x-map "n" narrow-map)
;; Quitting
(define-key global-map "\e\e\e" 'keyboard-escape-quit)
(define-key global-map "\C-g" 'keyboard-quit)
;; Used to be in termdev.el: when using several terminals, make C-z
;; suspend only the relevant terminal.
(substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
(define-key global-map "\C-m" 'newline)
(define-key global-map "\C-o" 'open-line)
(define-key esc-map "\C-o" 'split-line)
(define-key global-map "\C-q" 'quoted-insert)
(define-key esc-map "^" 'delete-indentation)
(define-key esc-map "\\" 'delete-horizontal-space)
(define-key esc-map "m" 'back-to-indentation)
(define-key ctl-x-map "\C-o" 'delete-blank-lines)
(define-key esc-map " " 'cycle-spacing)
(define-key esc-map "z" 'zap-to-char)
(define-key esc-map "=" 'count-words-region)
(define-key ctl-x-map "=" 'what-cursor-position)
(define-key esc-map ":" 'eval-expression)
;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
(define-key esc-map "\M-:" 'eval-expression)
;; Changed from C-x ESC so that function keys work following C-x.
(define-key ctl-x-map "\e\e" 'repeat-complex-command)
;; New binding analogous to M-:.
(define-key ctl-x-map "\M-:" 'repeat-complex-command)
(define-key ctl-x-map "u" 'undo)
(put 'undo :advertised-binding [?\C-x ?u])
;; Many people are used to typing C-/ on GUI frames and getting C-_.
(define-key global-map [?\C-/] 'undo)
(define-key global-map "\C-_" 'undo)
;; Richard said that we should not use C-x <uppercase letter> and I have
;; no idea whereas to bind it. Any suggestion welcome. -stef
;; (define-key ctl-x-map "U" 'undo-only)
(defvar-keymap undo-repeat-map
:doc "Keymap to repeat `undo' commands. Used in `repeat-mode'."
:repeat t
"u" #'undo)
(define-key global-map '[(control ??)] 'undo-redo)
(define-key global-map [?\C-\M-_] 'undo-redo)
(define-key esc-map "!" 'shell-command)
(define-key esc-map "|" 'shell-command-on-region)
(define-key esc-map "&" 'async-shell-command)
(define-key ctl-x-map [right] 'next-buffer)
(define-key ctl-x-map [C-right] 'next-buffer)
(define-key global-map [XF86Forward] 'next-buffer)
(put 'next-buffer :advertised-binding [?\C-x right])
(define-key ctl-x-map [left] 'previous-buffer)
(define-key ctl-x-map [C-left] 'previous-buffer)
(define-key global-map [XF86Back] 'previous-buffer)
(put 'previous-buffer :advertised-binding [?\C-x left])
(defvar-keymap buffer-navigation-repeat-map
:doc "Keymap to repeat `next-buffer' and `previous-buffer'. Used in `repeat-mode'."
:repeat t
"<right>" #'next-buffer
"<left>" #'previous-buffer)
(let ((map minibuffer-local-map))
(define-key map "\en" 'next-history-element)
(define-key map [next] 'next-history-element)
(define-key map [down] 'next-line-or-history-element)
(define-key map [XF86Forward] 'next-history-element)
(define-key map "\ep" 'previous-history-element)
(define-key map [prior] 'previous-history-element)
(define-key map [up] 'previous-line-or-history-element)
(define-key map [XF86Back] 'previous-history-element)
(define-key map "\es" 'next-matching-history-element)
(define-key map "\er" 'previous-matching-history-element)
;; Override the global binding (which calls indent-relative via
;; indent-for-tab-command). The alignment that indent-relative tries to
;; do doesn't make much sense here since the prompt messes it up.
(define-key map "\t" 'self-insert-command)
(define-key map [C-tab] 'file-cache-minibuffer-complete))
(define-key global-map "\C-u" 'universal-argument)
(let ((i ?0))
(while (<= i ?9)
(define-key esc-map (char-to-string i) 'digit-argument)
(setq i (1+ i))))
(define-key esc-map "-" 'negative-argument)
;; Define control-digits.
(let ((i ?0))
(while (<= i ?9)
(define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
(setq i (1+ i))))
(define-key global-map [?\C--] 'negative-argument)
;; Define control-meta-digits.
(let ((i ?0))
(while (<= i ?9)
(define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
(setq i (1+ i))))
(define-key global-map [?\C-\M--] 'negative-argument)
;; Update tutorial--default-keys if you change these.
(define-key global-map "\177" 'delete-backward-char)
;; We explicitly want C-d to use `delete-char' instead of
;; `delete-forward-char' so that it ignores `delete-active-region':
;; Most C-d users are old-timers who don't expect
;; `delete-active-region' here, while newer users who expect
;; `delete-active-region' use C-d much less.
(define-key global-map "\C-d" 'delete-char)
(define-key global-map "\C-k" 'kill-line)
(define-key global-map "\C-w" 'kill-region)
(define-key esc-map "w" 'kill-ring-save)
(define-key esc-map "\C-w" 'append-next-kill)
(define-key global-map "\C-y" 'yank)
(define-key esc-map "y" 'yank-pop)
(define-key global-map "\C-@" 'set-mark-command)
;; Many people are used to typing C-SPC and getting C-@.
(define-key global-map [?\C- ] 'set-mark-command)
(put 'set-mark-command :advertised-binding [?\C- ])
(define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
(define-key ctl-x-map "\C-@" 'pop-global-mark)
(define-key ctl-x-map " " 'rectangle-mark-mode)
(define-key ctl-x-map [?\C- ] 'pop-global-mark)
(define-key global-map "\C-n" 'next-line)
(define-key global-map "\C-p" 'previous-line)
(define-key ctl-x-map "\C-n" 'set-goal-column)
(define-key global-map "\C-a" 'move-beginning-of-line)
(define-key global-map "\C-e" 'move-end-of-line)
(define-key ctl-x-map "`" 'next-error)
(defvar-keymap next-error-repeat-map
:doc "Keymap to repeat `next-error' and `previous-error'. Used in `repeat-mode'."
:repeat t
"n" #'next-error
"M-n" #'next-error
"p" #'previous-error
"M-p" #'previous-error)
(defvar-keymap goto-map
:doc "Keymap for navigation commands."
"c" #'goto-char
"g" #'goto-line
"M-g" #'goto-line
"n" #'next-error
"M-n" #'next-error
"p" #'previous-error
"M-p" #'previous-error
"TAB" #'move-to-column
"i" #'imenu)
(define-key esc-map "g" goto-map)
(defvar-keymap search-map
:doc "Keymap for search related commands."
"o" #'occur
"M-w" #'eww-search-words
"h r" #'highlight-regexp
"h p" #'highlight-phrase
"h l" #'highlight-lines-matching-regexp
"h ." #'highlight-symbol-at-point
"h u" #'unhighlight-regexp
"h f" #'hi-lock-find-patterns
"h w" #'hi-lock-write-interactive-patterns)
(define-key esc-map "s" search-map)
(put 'highlight-regexp :advertised-binding [?\M-s ?h ?r])
(put 'highlight-phrase :advertised-binding [?\M-s ?h ?p])
(put 'highlight-lines-matching-regexp :advertised-binding [?\M-s ?h ?l])
(put 'highlight-symbol-at-point :advertised-binding [?\M-s ?h ?.])
(put 'unhighlight-regexp :advertised-binding [?\M-s ?h ?u])
(put 'hi-lock-find-patterns :advertised-binding [?\M-s ?h ?f])
(put 'hi-lock-write-interactive-patterns :advertised-binding [?\M-s ?h ?w])
;;(defun function-key-error ()
;; (interactive)
;; (error "That function key is not bound to anything"))
(define-key global-map [menu] 'execute-extended-command)
(define-key global-map [find] 'search-forward)
;; Don't do this. We define <delete> in function-key-map instead.
;(define-key global-map [delete] 'backward-delete-char)
;; natural bindings for terminal keycaps --- defined in X keysym order
(define-key global-map
(if (eq system-type 'windows-nt) [scroll] [Scroll_Lock])
#'scroll-lock-mode)
(define-key global-map [C-S-backspace] 'kill-whole-line)
(define-key global-map [home] 'move-beginning-of-line)
(define-key global-map [C-home] 'beginning-of-buffer)
(define-key global-map [M-home] 'beginning-of-buffer-other-window)
(define-key esc-map [home] 'beginning-of-buffer-other-window)
(define-key global-map [left] 'left-char)
(define-key global-map [up] 'previous-line)
(define-key global-map [right] 'right-char)
(define-key global-map [down] 'next-line)
(define-key global-map [prior] 'scroll-down-command)
(define-key global-map [next] 'scroll-up-command)
(define-key global-map [C-up] 'backward-paragraph)
(define-key global-map [C-down] 'forward-paragraph)
(define-key global-map [C-prior] 'scroll-right)
(put 'scroll-left 'disabled t)
(define-key global-map [C-next] 'scroll-left)
(define-key global-map [M-next] 'scroll-other-window)
(define-key esc-map [next] 'scroll-other-window)
(define-key global-map [M-prior] 'scroll-other-window-down)
(define-key esc-map [prior] 'scroll-other-window-down)
(define-key esc-map [?\C-\S-v] 'scroll-other-window-down)
(define-key global-map [end] 'move-end-of-line)
(define-key global-map [C-end] 'end-of-buffer)
(define-key global-map [M-end] 'end-of-buffer-other-window)
(define-key esc-map [end] 'end-of-buffer-other-window)
(define-key global-map [begin] 'beginning-of-buffer)
(define-key global-map [M-begin] 'beginning-of-buffer-other-window)
(define-key esc-map [begin] 'beginning-of-buffer-other-window)
;; (define-key global-map [select] 'function-key-error)
;; (define-key global-map [print] 'function-key-error)
(define-key global-map [execute] 'execute-extended-command)
(define-key global-map [insert] 'overwrite-mode)
(define-key global-map [C-insert] 'kill-ring-save)
(define-key global-map [S-insert] 'yank)
;; `insertchar' is what term.c produces. Should we change term.c
;; to produce `insert' instead?
(define-key global-map [insertchar] 'overwrite-mode)
(define-key global-map [C-insertchar] 'kill-ring-save)
(define-key global-map [S-insertchar] 'yank)
;; The next three keys are used on MS Windows and Android.
(define-key global-map [copy] 'kill-ring-save)
(define-key global-map [paste] 'yank)
(define-key global-map [cut] 'kill-region)
(define-key global-map [undo] 'undo)
(define-key global-map [redo] 'repeat-complex-command)
(define-key global-map [again] 'repeat-complex-command) ; Sun keyboard
(define-key global-map [open] 'find-file) ; Sun
;; The following wouldn't work to interrupt running code since C-g is
;; treated specially in the event loop.
;; (define-key global-map [stop] 'keyboard-quit) ; Sun
;; (define-key global-map [clearline] 'function-key-error)
(define-key global-map [insertline] 'open-line)
(define-key global-map [deleteline] 'kill-line)
(define-key global-map [deletechar] 'delete-forward-char)
;; (define-key global-map [backtab] 'function-key-error)
;; (define-key global-map [f1] 'function-key-error)
;; (define-key global-map [f2] 'function-key-error)
;; (define-key global-map [f3] 'function-key-error)
;; (define-key global-map [f4] 'function-key-error)
;; (define-key global-map [f5] 'function-key-error)
;; (define-key global-map [f6] 'function-key-error)
;; (define-key global-map [f7] 'function-key-error)
;; (define-key global-map [f8] 'function-key-error)
;; (define-key global-map [f9] 'function-key-error)
;; (define-key global-map [f10] 'function-key-error)
;; (define-key global-map [f11] 'function-key-error)
;; (define-key global-map [f12] 'function-key-error)
;; (define-key global-map [f13] 'function-key-error)
;; (define-key global-map [f14] 'function-key-error)
;; (define-key global-map [f15] 'function-key-error)
;; (define-key global-map [f16] 'function-key-error)
;; (define-key global-map [f17] 'function-key-error)
;; (define-key global-map [f18] 'function-key-error)
;; (define-key global-map [f19] 'function-key-error)
;; (define-key global-map [f20] 'function-key-error)
;; (define-key global-map [f21] 'function-key-error)
;; (define-key global-map [f22] 'function-key-error)
;; (define-key global-map [f23] 'function-key-error)
;; (define-key global-map [f24] 'function-key-error)
;; (define-key global-map [f25] 'function-key-error)
;; (define-key global-map [f26] 'function-key-error)
;; (define-key global-map [f27] 'function-key-error)
;; (define-key global-map [f28] 'function-key-error)
;; (define-key global-map [f29] 'function-key-error)
;; (define-key global-map [f30] 'function-key-error)
;; (define-key global-map [f31] 'function-key-error)
;; (define-key global-map [f32] 'function-key-error)
;; (define-key global-map [f33] 'function-key-error)
;; (define-key global-map [f34] 'function-key-error)
;; (define-key global-map [f35] 'function-key-error)
;; (define-key global-map [kp-backtab] 'function-key-error)
;; (define-key global-map [kp-space] 'function-key-error)
;; (define-key global-map [kp-tab] 'function-key-error)
;; (define-key global-map [kp-enter] 'function-key-error)
;; (define-key global-map [kp-f1] 'function-key-error)
;; (define-key global-map [kp-f2] 'function-key-error)
;; (define-key global-map [kp-f3] 'function-key-error)
;; (define-key global-map [kp-f4] 'function-key-error)
;; (define-key global-map [kp-multiply] 'function-key-error)
;; (define-key global-map [kp-add] 'function-key-error)
;; (define-key global-map [kp-separator] 'function-key-error)
;; (define-key global-map [kp-subtract] 'function-key-error)
;; (define-key global-map [kp-decimal] 'function-key-error)
;; (define-key global-map [kp-divide] 'function-key-error)
;; (define-key global-map [kp-0] 'function-key-error)
;; (define-key global-map [kp-1] 'function-key-error)
;; (define-key global-map [kp-2] 'function-key-error)
;; (define-key global-map [kp-3] 'function-key-error)
;; (define-key global-map [kp-4] 'function-key-error)
;; (define-key global-map [kp-5] 'recenter)
;; (define-key global-map [kp-6] 'function-key-error)
;; (define-key global-map [kp-7] 'function-key-error)
;; (define-key global-map [kp-8] 'function-key-error)
;; (define-key global-map [kp-9] 'function-key-error)
;; (define-key global-map [kp-equal] 'function-key-error)
(define-key global-map [touch-end] 'ignore)
;; X11 distinguishes these keys from the non-kp keys.
;; Make them behave like the non-kp keys unless otherwise bound.
;; FIXME: rather than list such mappings for every modifier-combination,
;; we should come up with a way to do it generically, something like
;; (define-key function-key-map [*-kp-home] [*-home])
;; Currently we add keypad key combinations with basic modifiers
;; (to complement plain bindings in "Keypad support" section in simple.el)
;; Until [*-kp-home] is implemented, for more modifiers we could also use:
;; (todo-powerset '(control meta shift hyper super alt)) (Bug#14397)
(let ((modifiers '(nil (control) (meta) (control meta) (shift)
(control shift) (meta shift) (control meta shift)))
(keys '((kp-delete delete) (kp-insert insert)
(kp-end end) (kp-down down) (kp-next next)
(kp-left left) (kp-begin begin) (kp-right right)
(kp-home home) (kp-up up) (kp-prior prior)
(kp-enter enter) (kp-decimal ?.)
(kp-0 ?0) (kp-1 ?1) (kp-2 ?2) (kp-3 ?3) (kp-4 ?4)
(kp-5 ?5) (kp-6 ?6) (kp-7 ?7) (kp-8 ?8) (kp-9 ?9)
(kp-add ?+) (kp-subtract ?-) (kp-multiply ?*) (kp-divide ?/))))
(dolist (pair keys)
(let ((keypad (nth 0 pair))
(normal (nth 1 pair)))
(when (characterp normal)
(put keypad 'ascii-character normal))
(dolist (mod modifiers)
(define-key function-key-map
(vector (append mod (list keypad)))
(vector (append mod (list normal))))))))
(define-key function-key-map [backspace] [?\C-?])
(define-key function-key-map [delete] [?\C-?])
(define-key function-key-map [kp-delete] [?\C-?])
;; Don't bind shifted keypad numeric keys, they reportedly
;; interfere with the feature of some keyboards to produce
;; numbers when NumLock is off.
;(define-key function-key-map [S-kp-1] [S-end])
;(define-key function-key-map [S-kp-2] [S-down])
;(define-key function-key-map [S-kp-3] [S-next])
;(define-key function-key-map [S-kp-4] [S-left])
;(define-key function-key-map [S-kp-6] [S-right])
;(define-key function-key-map [S-kp-7] [S-home])
;(define-key function-key-map [S-kp-8] [S-up])
;(define-key function-key-map [S-kp-9] [S-prior])
;(define-key function-key-map [C-S-kp-1] [C-S-end])
;(define-key function-key-map [C-S-kp-2] [C-S-down])
;(define-key function-key-map [C-S-kp-3] [C-S-next])
;(define-key function-key-map [C-S-kp-4] [C-S-left])
;(define-key function-key-map [C-S-kp-6] [C-S-right])
;(define-key function-key-map [C-S-kp-7] [C-S-home])
;(define-key function-key-map [C-S-kp-8] [C-S-up])
;(define-key function-key-map [C-S-kp-9] [C-S-prior])
;; Hitting C-SPC on text terminals, usually sends the ascii code 0 (aka C-@),
;; so we can't distinguish those two keys, but usually we consider C-SPC
;; (rather than C-@) as the "canonical" binding.
(define-key function-key-map [?\C-@] [?\C-\s])
;; Many keyboards don't have a `backtab' key, so by convention the user
;; can use S-tab instead to access that binding.
(define-key function-key-map [S-tab] [backtab])
(defun ignore-preserving-kill-region (&rest _)
"Like `ignore', but don't overwrite `last-event' if it's `kill-region'."
(declare (completion ignore))
(interactive)
(when (eq last-command 'kill-region)
(setq this-command 'kill-region))
nil)
(define-key global-map [mouse-movement] #'ignore-preserving-kill-region)
(define-key global-map "\C-t" 'transpose-chars)
(define-key esc-map "t" 'transpose-words)
(define-key esc-map "\C-t" 'transpose-sexps)
(define-key ctl-x-map "\C-t" 'transpose-lines)
(define-key esc-map ";" 'comment-dwim)
(define-key esc-map "j" 'default-indent-new-line)
(define-key esc-map "\C-j" 'default-indent-new-line)
(define-key ctl-x-map ";" 'comment-set-column)
(define-key ctl-x-map [?\C-\;] 'comment-line)
(define-key ctl-x-map "f" 'set-fill-column)
(define-key ctl-x-map "$" 'set-selective-display)
(define-key esc-map "@" 'mark-word)
(define-key esc-map "f" 'forward-word)
(define-key esc-map "b" 'backward-word)
(define-key esc-map "d" 'kill-word)
(define-key esc-map "\177" 'backward-kill-word)
(define-key esc-map "<" 'beginning-of-buffer)
(define-key esc-map ">" 'end-of-buffer)
(define-key ctl-x-map "h" 'mark-whole-buffer)
(define-key esc-map "\\" 'delete-horizontal-space)
(defalias 'mode-specific-command-prefix (make-sparse-keymap))
(defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
"Keymap for characters following \\`C-c'.")
(define-key global-map "\C-c" 'mode-specific-command-prefix)
(global-set-key [M-right] 'right-word)
(define-key esc-map [right] 'forward-word)
(global-set-key [M-left] 'left-word)
(define-key esc-map [left] 'backward-word)
;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
(global-set-key [C-right] 'right-word)
(global-set-key [C-left] 'left-word)
;; This is not quite compatible, but at least is analogous
(global-set-key [C-delete] 'kill-word)
(global-set-key [C-backspace] 'backward-kill-word)
;; This is "move to the clipboard", or as close as we come.
(global-set-key [S-delete] 'kill-region)
(global-set-key [C-M-left] 'backward-sexp)
(define-key esc-map [C-left] 'backward-sexp)
(global-set-key [C-M-right] 'forward-sexp)
(define-key esc-map [C-right] 'forward-sexp)
(global-set-key [C-M-up] 'backward-up-list)
(define-key esc-map [C-up] 'backward-up-list)
(global-set-key [C-M-down] 'down-list)
(define-key esc-map [C-down] 'down-list)
(global-set-key [C-M-home] 'beginning-of-defun)
(define-key esc-map [C-home] 'beginning-of-defun)
(global-set-key [C-M-end] 'end-of-defun)
(define-key esc-map [C-end] 'end-of-defun)
(define-key esc-map "\C-f" 'forward-sexp)
(define-key esc-map "\C-b" 'backward-sexp)
(define-key esc-map "\C-u" 'backward-up-list)
(define-key esc-map "\C-@" 'mark-sexp)
(define-key esc-map [?\C-\ ] 'mark-sexp)
(define-key esc-map "\C-d" 'down-list)
(define-key esc-map "\C-k" 'kill-sexp)
(define-key global-map [C-M-delete] 'backward-kill-sexp)
(define-key global-map [C-M-backspace] 'backward-kill-sexp)
(define-key esc-map [C-delete] 'backward-kill-sexp)
(define-key esc-map [C-backspace] 'backward-kill-sexp)
(define-key esc-map "\C-n" 'forward-list)
(define-key esc-map "\C-p" 'backward-list)
(define-key esc-map "\C-a" 'beginning-of-defun)
(define-key esc-map "\C-e" 'end-of-defun)
(define-key esc-map "\C-h" 'mark-defun)
(define-key ctl-x-map "nd" 'narrow-to-defun)
(define-key esc-map "(" 'insert-parentheses)
(define-key esc-map ")" 'move-past-close-and-reindent)
(define-key ctl-x-map "\C-e" 'eval-last-sexp)
(define-key ctl-x-map "m" 'compose-mail)
(define-key ctl-x-4-map "m" 'compose-mail-other-window)
(define-key ctl-x-5-map "m" 'compose-mail-other-frame)
(defvar-keymap ctl-x-r-map
:doc "Keymap for subcommands of \\`C-x r'."
"c" #'clear-rectangle
"k" #'kill-rectangle
"d" #'delete-rectangle
"y" #'yank-rectangle
"o" #'open-rectangle
"t" #'string-rectangle
"N" #'rectangle-number-lines
"M-w" #'copy-rectangle-as-kill
"C-@" #'point-to-register
"C-SPC" #'point-to-register
"SPC" #'point-to-register
"j" #'jump-to-register
"s" #'copy-to-register
"x" #'copy-to-register
"i" #'insert-register
"g" #'insert-register
"r" #'copy-rectangle-to-register
"n" #'number-to-register
"+" #'increment-register
"w" #'window-configuration-to-register
"f" #'frameset-to-register)
(define-key ctl-x-map "r" ctl-x-r-map)
(define-key esc-map "q" 'fill-paragraph)
(define-key ctl-x-map "." 'set-fill-prefix)
(define-key esc-map "{" 'backward-paragraph)
(define-key esc-map "}" 'forward-paragraph)
(define-key esc-map "h" 'mark-paragraph)
(define-key esc-map "a" 'backward-sentence)
(define-key esc-map "e" 'forward-sentence)
(define-key esc-map "k" 'kill-sentence)
(define-key ctl-x-map "\177" 'backward-kill-sentence)
(define-key ctl-x-map "[" 'backward-page)
(define-key ctl-x-map "]" 'forward-page)
(defvar-keymap page-navigation-repeat-map
:doc "Keymap to repeat `forward-page' and `backward-page'. Used in `repeat-mode'."
:repeat t
"]" #'forward-page
"[" #'backward-page)
(define-key ctl-x-map "\C-p" 'mark-page)
(define-key ctl-x-map "l" 'count-lines-page)
(define-key ctl-x-map "np" 'narrow-to-page)
(defvar-keymap abbrev-map
:doc "Keymap for abbrev commands."
"l" #'add-mode-abbrev
"C-a" #'add-mode-abbrev
"g" #'add-global-abbrev
"+" #'add-mode-abbrev
"i g" #'inverse-add-global-abbrev
"i l" #'inverse-add-mode-abbrev
"-" #'inverse-add-global-abbrev
"e" #'expand-abbrev
"'" #'expand-abbrev)
(define-key ctl-x-map "a" abbrev-map)
(define-key esc-map "'" 'abbrev-prefix-mark)
(define-key ctl-x-map "'" 'expand-abbrev)
(define-key ctl-x-map "\C-b" 'list-buffers)
(define-key ctl-x-map "\C-j" 'dired-jump)
(define-key ctl-x-4-map "\C-j" 'dired-jump-other-window)
(define-key ctl-x-map "z" 'repeat)
(defvar-keymap ctl-x-x-map
:doc "Keymap for subcommands of \\`C-x x'."
"f" #'font-lock-update
"g" #'revert-buffer-quick
"r" #'rename-buffer
"u" #'rename-uniquely
"n" #'clone-buffer
"i" #'insert-buffer
"t" #'toggle-truncate-lines)
(define-key ctl-x-map "x" ctl-x-x-map)
(define-key esc-map "\C-l" 'reposition-window)
(define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
(define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
;; Signal handlers
(define-key special-event-map [sigusr1] 'ignore)
(define-key special-event-map [sigusr2] 'ignore)
;; Text conversion
(define-key global-map [text-conversion] 'analyze-text-conversion)
;; Don't look for autoload cookies in this file.
;; Local Variables:
;; no-update-autoloads: t
;; End:
;;; bindings.el ends here
|