(Emulation): Mention TPU.
[emacs.git] / lisp / bindings.el
blobe8b92b54e88d3370ef7a3eb14d2f953f9e0fb86a
1 ;;; bindings.el --- define standard key bindings and some variables.
3 ;; Copyright (C) 1985,86,87,92,93,94,95,96,99,2000
4 ;; Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: internal
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Commentary:
28 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 ;;; Special formatting conventions are used in this file!
30 ;;;
31 ;;; a backslash-newline is used at the beginning of a documentation string
32 ;;; when that string should be stored in the file etc/DOCnnn, not in core.
33 ;;;
34 ;;; Such strings read into Lisp as numbers (during the pure-loading phase).
35 ;;;
36 ;;; But you must obey certain rules to make sure the string is understood
37 ;;; and goes into etc/DOCnnn properly.
38 ;;;
39 ;;; The doc string must appear in the standard place in a call to
40 ;;; defun, autoload, defvar or defconst. No Lisp macros are recognized.
41 ;;; The open-paren starting the definition must appear in column 0.
42 ;;;
43 ;;; In defvar and defconst, there is an additional rule:
44 ;;; The double-quote that starts the string must be on the same
45 ;;; line as the defvar or defconst.
46 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
48 ;;; Code:
50 (defun make-mode-line-mouse2-map (f) "\
51 Return a keymap with single entry for mouse-2 on mode line.
52 This is defined to run function F with no args in the buffer
53 corresponding to the mode line clicked."
54 (let ((map (make-sparse-keymap)))
55 (define-key map [mode-line mouse-2]
56 `(lambda (e)
57 (interactive "e")
58 (save-selected-window
59 (select-window
60 (posn-window (event-start e)))
61 (,f)
62 (force-mode-line-update))))
63 map))
65 (defvar mode-line-input-method-map
66 (let ((map (make-sparse-keymap)))
67 (define-key map [mode-line mouse-2]
68 (lambda (e)
69 (interactive "e")
70 (save-selected-window
71 (select-window
72 (posn-window (event-start e)))
73 (toggle-input-method)
74 (force-mode-line-update))))
75 (define-key map [mode-line mouse-3]
76 (lambda (e)
77 (interactive "e")
78 (save-selected-window
79 (select-window
80 (posn-window (event-start e)))
81 (describe-current-input-method))))
82 (purecopy map)))
84 (defvar mode-line-mule-info
85 `(""
86 (current-input-method
87 (:eval
88 (propertize current-input-method-title
89 'help-echo (concat ,(purecopy "Input method: ")
90 current-input-method
91 ,(purecopy ". mouse-2 disables, \
92 mouse-3 describes"))
93 'local-map mode-line-input-method-map)))
94 ,(propertize "%Z"
95 'help-echo (purecopy "Coding system information: \
96 see M-x describe-coding-system")))
97 "Mode-line control for displaying information of multilingual environment.
98 Normally it displays current input method (if any activated) and
99 mnemonics of the following coding systems:
100 coding system for saving or writing the current buffer
101 coding system for keyboard input (if Emacs is running on terminal)
102 coding system for terminal output (if Emacs is running on terminal)"
103 ;; Currently not:
104 ;;; coding system for decoding output of buffer process (if any)
105 ;;; coding system for encoding text to send to buffer process (if any)."
108 (make-variable-buffer-local 'mode-line-mule-info)
110 (defvar mode-line-buffer-identification (purecopy '("%12b")) "\
111 Mode-line control for identifying the buffer being displayed.
112 Its default value is (\"%12b\").
113 Major modes that edit things other than ordinary files may change this
114 \(e.g. Info, Dired,...)")
116 (make-variable-buffer-local 'mode-line-buffer-identification)
118 (defvar mode-line-frame-identification '("-%F "))
120 (defvar mode-line-process nil "\
121 Mode-line control for displaying info on process status.
122 Normally nil in most modes, since there is no process to display.")
124 (make-variable-buffer-local 'mode-line-process)
126 (defvar mode-line-modified
127 (list (propertize
128 "%1*%1+"
129 'help-echo (purecopy "Read-only status: mouse-2 toggles it")
130 'local-map (purecopy (make-mode-line-mouse2-map #'toggle-read-only))))
131 "Mode-line control for displaying whether current buffer is modified.")
133 (make-variable-buffer-local 'mode-line-modified)
135 (setq-default mode-line-format
136 (let* ((help-echo
137 ;; The multi-line message doesn't work terribly well on the
138 ;; bottom mode line... Better ideas?
139 ;;; "\
140 ;;; mouse-1: select window, mouse-2: delete others, mouse-3: delete,
141 ;;; drag-mouse-1: resize, C-mouse-2: split horizontally"
142 "mouse-1: select window, mouse-2: delete others, mouse-3: delete ...")
143 (dashes (propertize "--" 'help-echo help-echo)))
144 (list
145 (propertize "-" 'help-echo help-echo)
146 'mode-line-mule-info
147 'mode-line-modified
148 'mode-line-frame-identification
149 'mode-line-buffer-identification
150 (propertize " " 'help-echo help-echo)
151 'global-mode-string
152 (propertize " %[(" 'help-echo help-echo)
153 '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist
154 (propertize "%n" 'help-echo "mouse-2: widen"
155 'local-map (make-mode-line-mouse2-map #'widen))
156 (propertize ")%]--" 'help-echo help-echo)
157 `(which-func-mode ("" which-func-format ,dashes))
158 `(line-number-mode ("L%l" ,dashes))
159 `(column-number-mode ("C%c" ,dashes))
160 (purecopy '(-3 . "%p"))
161 (propertize "-%-" 'help-echo help-echo))))
163 (defvar minor-mode-alist nil "\
164 Alist saying how to show minor modes in the mode line.
165 Each element looks like (VARIABLE STRING);
166 STRING is included in the mode line iff VARIABLE's value is non-nil.
168 Actually, STRING need not be a string; any possible mode-line element
169 is okay. See `mode-line-format'.")
170 ;; Don't use purecopy here--some people want to change these strings.
171 (setq minor-mode-alist
172 (list
173 (list 'abbrev-mode
174 (propertize " Abbrev"
175 'help-echo (purecopy
176 "mouse-2: turn off Abbrev mode")
177 'local-map (purecopy (make-mode-line-mouse2-map
178 #'abbrev-mode))))
179 '(overwrite-mode overwrite-mode)
180 (list 'auto-fill-function
181 (propertize " Fill"
182 'help-echo (purecopy
183 "mouse-2: turn off Autofill mode")
184 'local-map (purecopy (make-mode-line-mouse2-map
185 #'auto-fill-mode))))
186 ;; not really a minor mode...
187 '(defining-kbd-macro " Def")))
189 (defvar mode-line-buffer-identification-keymap nil "\
190 Keymap for what is displayed by `mode-line-buffer-identification'.")
192 (defvar mode-line-minor-mode-keymap nil "\
193 Keymap for what is displayed by `mode-line-mode-name'.")
195 (defvar mode-line-mode-menu-keymap nil "\
196 Keymap for mode operations menu in the mode line.")
198 (defun mode-line-unbury-buffer () "\
199 Switch to the last buffer in the buffer list that is not hidden."
200 (interactive)
201 (let ((list (reverse (buffer-list))))
202 (while (eq (aref (buffer-name (car list)) 0) ? )
203 (setq list (cdr list)))
204 (switch-to-buffer (car list))))
206 (defun mode-line-other-buffer () "\
207 Switch to the most recently selected buffer other than the current one."
208 (interactive)
209 (switch-to-buffer (other-buffer)))
211 (defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
212 Menu of mode operations in the mode line.")
214 (defun mode-line-mode-menu-1 (event)
215 (interactive "e")
216 (save-selected-window
217 (select-window (posn-window (event-start event)))
218 (let* ((selection (mode-line-mode-menu event))
219 (binding (and selection (lookup-key mode-line-mode-menu
220 (vector (car selection))))))
221 (if binding
222 (call-interactively binding)))))
224 (defun mode-line-mode-name () "\
225 Return a string to display in the mode line for the current mode name."
226 (let (length (result mode-name))
227 (let ((local-map (get-text-property 0 'local-map result))
228 (help-echo (get-text-property 0 'help-echo result)))
229 (setq result (copy-sequence result))
230 ;; Add `local-map' property if there isn't already one.
231 (when (and (null local-map)
232 (null (next-single-property-change 0 'local-map result)))
233 (put-text-property 0 (length result)
234 'local-map mode-line-minor-mode-keymap result))
235 ;; Add `help-echo' property if there isn't already one.
236 (when (and (null help-echo)
237 (null (next-single-property-change 0 'help-echo result)))
238 (put-text-property 0 (length result)
239 'help-echo "mouse-3: minor mode menu" result)))
240 result))
242 (defmacro bound-and-true-p (var)
243 "Return the value of symbol VAR if it is bound, else nil."
244 `(and (boundp (quote ,var)) ,var))
246 (define-key mode-line-mode-menu [abbrev-mode]
247 `(menu-item ,(purecopy "Abbrev") abbrev-mode
248 :button (:toggle . abbrev-mode)))
249 (define-key mode-line-mode-menu [auto-revert-mode]
250 `(menu-item ,(purecopy "Auto revert") auto-revert-mode
251 :button (:toggle . auto-revert-mode)))
252 (define-key mode-line-mode-menu [auto-fill-mode]
253 `(menu-item ,(purecopy "Auto-fill") auto-fill-mode
254 :button (:toggle . auto-fill-function)))
255 (define-key mode-line-mode-menu [column-number-mode]
256 `(menu-item ,(purecopy "Column number") column-number-mode
257 :button (:toggle . column-number-mode)))
258 (define-key mode-line-mode-menu [flyspell-mode]
259 `(menu-item ,(purecopy "Flyspell") flyspell-mode
260 :button (:toggle . (bound-and-true-p flyspell-mode))))
261 (define-key mode-line-mode-menu [font-lock-mode]
262 `(menu-item ,(purecopy "Font-lock") font-lock-mode
263 :button (:toggle . font-lock-mode)))
264 (define-key mode-line-mode-menu [hide-ifdef-mode]
265 `(menu-item ,(purecopy "Hide ifdef") hide-ifdef-mode
266 :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
267 (define-key mode-line-mode-menu [highlight-changes-mode]
268 `(menu-item ,(purecopy "Highlight changes") highlight-changes-mode
269 :button (:toggle . highlight-changes-mode)))
270 (define-key mode-line-mode-menu [line-number-mode]
271 `(menu-item ,(purecopy "Line number") line-number-mode
272 :button (:toggle . line-number-mode)))
273 (define-key mode-line-mode-menu [outline-minor-mode]
274 `(menu-item ,(purecopy "Outline") outline-minor-mode
275 :button (:toggle . (bound-and-true-p outline-minor-mode))))
276 (define-key mode-line-mode-menu [overwrite-mode]
277 `(menu-item ,(purecopy "Overwrite") overwrite-mode
278 :button (:toggle . overwrite-mode)))
280 (defun mode-line-mode-menu (event)
281 (interactive "@e")
282 (x-popup-menu event mode-line-mode-menu))
284 ;; Add menu of buffer operations to the buffer identification part
285 ;; of the mode line.
286 (let ((map (make-sparse-keymap)))
287 (define-key map [mode-line mouse-1] 'mode-line-other-buffer)
288 (define-key map [header-line mouse-1] 'mode-line-other-buffer)
289 (define-key map [mode-line M-mouse-2] 'mode-line-unbury-buffer)
290 (define-key map [header-line M-mouse-2] 'mode-line-unbury-buffer)
291 (define-key map [mode-line mouse-2] 'bury-buffer)
292 (define-key map [header-line mouse-2] 'bury-buffer)
293 (define-key map [mode-line down-mouse-3] 'mouse-buffer-menu)
294 (define-key map [header-line down-mouse-3] 'mouse-buffer-menu)
295 (setq mode-line-buffer-identification-keymap map))
297 (defun propertized-buffer-identification (fmt)
298 "Return a list suitable for `mode-line-buffer-identification'.
299 FMT is a format specifier such as \"%12b\". This function adds
300 text properties for face, help-echo, and local-map to it."
301 (list (propertize fmt
302 'face '(:weight bold)
303 'help-echo (purecopy "mouse-1: other \
304 buffer, mouse-2: prev, M-mouse-2: next, mouse-3: buffer menu")
305 'local-map mode-line-buffer-identification-keymap)))
307 (setq-default mode-line-buffer-identification
308 (propertized-buffer-identification "%12b"))
310 ;; Menu of minor modes.
311 (let ((map (make-sparse-keymap)))
312 (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
313 (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1)
314 (setq mode-line-minor-mode-keymap map))
316 ;; These variables are used by autoloadable packages.
317 ;; They are defined here so that they do not get overridden
318 ;; by the loading of those packages.
320 ;; Names in directory that end in one of these
321 ;; are ignored in completion,
322 ;; making it more likely you will get a unique match.
323 (setq completion-ignored-extensions
324 (append
325 (cond ((or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
326 '(".o" "~" ".bin" ".bak" ".obj" ".map"
327 ".a" ".ln" ".blg" ".bbl"))
328 ((eq system-type 'vax-vms)
329 '(".obj" ".exe" ".bin" ".lbin" ".sbin"
330 ".brn" ".rnt" ".mem" ".lni" ".lis"
331 ".olb" ".tlb" ".mlb" ".hlb"))
333 '(".o" "~" ".bin" ".lbin" ".fasl" ".ufsl"
334 ".a" ".ln" ".blg" ".bbl")))
335 '(".elc" ".lof"
336 ".glo" ".idx" ".lot"
337 ;; TeX-related
338 ".dvi" ".fmt" ".tfm" ".pdf"
339 ;; Java compiled
340 ".class"
341 ;; Clisp
342 ".fas" ".lib"
343 ;; CMUCL
344 ".x86f" ".sparcf"
345 ;; Texinfo-related
346 ".toc" ".log" ".aux"
347 ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
348 ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs")))
350 ;; Packages should add to this list appropriately when they are
351 ;; loaded, rather than listing everything here.
352 (setq debug-ignored-errors
353 '(beginning-of-line beginning-of-buffer end-of-line
354 end-of-buffer end-of-file buffer-read-only
355 file-supersession
356 "^Previous command was not a yank$"
357 "^Minibuffer window is not active$"
358 "^End of history; no next item$"
359 "^Beginning of history; no preceding item$"
360 "^No recursive edit is in progress$"
361 "^Changes to be undone are outside visible portion of buffer$"
362 "^No undo information in this buffer$"
363 "^No further undo information$"
364 "^Save not confirmed$"
365 "^Recover-file cancelled\\.$"
366 "^Cannot switch buffers in a dedicated window$"
368 ;; comint
369 "^Not at command line$"
370 "^Empty input ring$"
371 "^No history$"
372 "^Not found$";; To common?
373 "^Current buffer has no process$"
375 ;; dabbrev
376 "^No dynamic expansion for .* found$"
377 "^No further dynamic expansion for .* found$"
378 "^No possible abbreviation preceding point$"
380 ;; Completion
381 "^To complete, the point must be after a symbol at least [0-9]* character long\\.$"
382 "^The string \".*\" is too short to be saved as a completion\\.$"
384 ;; Compile
385 "^No more errors\\( yet\\|\\)$"
387 ;; Gnus
388 "^NNTP: Connection closed\\.$"
390 ;; info
391 "^Node has no Previous$"
392 "^No menu in this node$"
393 "^Node has no Next$"
394 "^No \".*\" in index$"
396 ;; imenu
397 "^No items suitable for an index found in this buffer\\.$"
398 "^This buffer cannot use `imenu-default-create-index-function'$"
399 "^The mode `.*' does not support Imenu$"
401 ;; ispell
402 "^No word found to check!$"
404 ;; mh-e
405 "^Cursor not pointing to message$"
406 "^There is no other window$"
408 ;; man
409 "^No manpage [0-9]* found$"
410 "^Can't find the .* manpage$"
412 ;; etags
413 "^No tags table in use; use .* to select one$"
414 "^There is no default tag$"
415 "^No previous tag locations$"
416 "^File .* is not a valid tags table$"
417 "^No \\(more \\|\\)tags \\(matching\\|containing\\) "
418 "^Rerun etags: `.*' not found in "
419 "^All files processed$"
420 "^No .* or .* in progress$"
421 "^File .* not in current tags tables$"
422 "^No tags table loaded"
423 "^Nothing to complete$"
425 ;; ediff
426 "^Errors in diff output. Diff output is in "
427 "^Hmm... I don't see an Ediff command around here...$"
428 "^Undocumented command! Type `G' in Ediff Control Panel to drop a note to the Ediff maintainer$"
429 ": This command runs in Ediff Control Buffer only!$"
430 ": Invalid op in ediff-check-version$"
431 "^ediff-shrink-window-C can be used only for merging jobs$"
432 "^Lost difference info on these directories$"
433 "^This command is inapplicable in the present context$"
434 "^This session group has no parent$"
435 "^Can't hide active session, $"
436 "^Ediff: something wrong--no multiple diffs buffer$"
437 "^Can't make context diff for Session $"
438 "^The patch buffer wasn't found$"
439 "^Aborted$"
440 "^This Ediff session is not part of a session group$"
441 "^No active Ediff sessions or corrupted session registry$"
442 "^No session info in this line$"
443 "^`.*' is not an ordinary file$"
444 "^Patch appears to have failed$"
445 "^Recomputation of differences cancelled$"
446 "^No fine differences in this mode$"
447 "^Lost connection to ancestor buffer...sorry$"
448 "^Not merging with ancestor$"
449 "^Don't know how to toggle read-only in buffer "
450 "Emacs is not running as a window application$"
451 "^This command makes sense only when merging with an ancestor$"
452 "^At end of the difference list$"
453 "^At beginning of the difference list$"
454 "^Nothing saved for diff .* in buffer "
455 "^Buffer is out of sync for file "
456 "^Buffer out of sync for file "
457 "^Output from `diff' not found$"
458 "^You forgot to specify a region in buffer "
459 "^All right. Make up your mind and come back...$"
460 "^Current buffer is not visiting any file$"
461 "^Failed to retrieve revision: $"
462 "^Can't determine display width.$"
463 "^File `.*' does not exist or is not readable$"
464 "^File `.*' is a directory$"
465 "^Buffer .* doesn't exist$"
466 "^Directories . and . are the same: "
467 "^Directory merge aborted$"
468 "^Merge of directory revisions aborted$"
469 "^Buffer .* doesn't exist$"
470 "^There is no file to merge$"
471 "^Version control package .*.el not found. Use vc.el instead$"
473 ;; cus-edit
474 "^No user options have changed defaults in recent Emacs versions$"
476 ;; BBDB
477 "^no previous record$"
478 "^no next record$"))
481 (make-variable-buffer-local 'indent-tabs-mode)
483 ;; We have base64 functions built in now.
484 (add-to-list 'features 'base64)
486 (define-key esc-map "\t" 'complete-symbol)
488 (defun complete-symbol (arg) "\
489 Perform tags completion on the text around point.
490 Completes to the set of names listed in the current tags table.
491 The string to complete is chosen in the same way as the default
492 for \\[find-tag] (which see).
494 With a prefix argument, this command does completion within
495 the collection of symbols listed in the index of the manual for the
496 language you are using."
497 (interactive "P")
498 (if arg
499 (info-complete-symbol)
500 (if (fboundp 'complete-tag)
501 (complete-tag)
502 ;; Don't autoload etags if we have no tags table.
503 (error (substitute-command-keys
504 "No tags table loaded; use \\[visit-tags-table] to load one")))))
506 ;; Reduce total amount of space we must allocate during this function
507 ;; that we will not need to keep permanently.
508 (garbage-collect)
510 ;; Make all multibyte characters self-insert.
511 (let ((l (generic-character-list))
512 (table (nth 1 global-map)))
513 (while l
514 (set-char-table-default table (car l) 'self-insert-command)
515 (setq l (cdr l))))
517 (setq help-event-list '(help f1))
519 (make-variable-buffer-local 'minor-mode-overriding-map-alist)
521 ;These commands are defined in editfns.c
522 ;but they are not assigned to keys there.
523 (put 'narrow-to-region 'disabled t)
524 (define-key ctl-x-map "nn" 'narrow-to-region)
525 (define-key ctl-x-map "nw" 'widen)
526 ;; (define-key ctl-x-map "n" 'narrow-to-region)
527 ;; (define-key ctl-x-map "w" 'widen)
529 (define-key global-map "\C-j" 'newline-and-indent)
530 (define-key global-map "\C-m" 'newline)
531 (define-key global-map "\C-o" 'open-line)
532 (define-key esc-map "\C-o" 'split-line)
533 (define-key global-map "\C-q" 'quoted-insert)
534 (define-key esc-map "^" 'delete-indentation)
535 (define-key esc-map "\\" 'delete-horizontal-space)
536 (define-key esc-map "m" 'back-to-indentation)
537 (define-key ctl-x-map "\C-o" 'delete-blank-lines)
538 (define-key esc-map " " 'just-one-space)
539 (define-key esc-map "z" 'zap-to-char)
540 (define-key esc-map "=" 'count-lines-region)
541 (define-key ctl-x-map "=" 'what-cursor-position)
542 (define-key esc-map ":" 'eval-expression)
543 ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
544 (define-key esc-map "\M-:" 'eval-expression)
545 ;; Changed from C-x ESC so that function keys work following C-x.
546 (define-key ctl-x-map "\e\e" 'repeat-complex-command)
547 ;; New binding analogous to M-:.
548 (define-key ctl-x-map "\M-:" 'repeat-complex-command)
549 (define-key ctl-x-map "u" 'advertised-undo)
550 ;; Many people are used to typing C-/ on X terminals and getting C-_.
551 (define-key global-map [?\C-/] 'undo)
552 (define-key global-map "\C-_" 'undo)
553 (define-key esc-map "!" 'shell-command)
554 (define-key esc-map "|" 'shell-command-on-region)
556 ;; This is an experiment--make up and down arrows do history.
557 (define-key minibuffer-local-map [up] 'previous-history-element)
558 (define-key minibuffer-local-map [down] 'next-history-element)
559 (define-key minibuffer-local-ns-map [up] 'previous-history-element)
560 (define-key minibuffer-local-ns-map [down] 'next-history-element)
561 (define-key minibuffer-local-completion-map [up] 'previous-history-element)
562 (define-key minibuffer-local-completion-map [down] 'next-history-element)
563 (define-key minibuffer-local-must-match-map [up] 'previous-history-element)
564 (define-key minibuffer-local-must-match-map [down] 'next-history-element)
566 (define-key global-map "\C-u" 'universal-argument)
567 (let ((i ?0))
568 (while (<= i ?9)
569 (define-key esc-map (char-to-string i) 'digit-argument)
570 (setq i (1+ i))))
571 (define-key esc-map "-" 'negative-argument)
572 ;; Define control-digits.
573 (let ((i ?0))
574 (while (<= i ?9)
575 (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
576 (setq i (1+ i))))
577 (define-key global-map [?\C--] 'negative-argument)
578 ;; Define control-meta-digits.
579 (let ((i ?0))
580 (while (<= i ?9)
581 (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
582 (setq i (1+ i))))
583 (define-key global-map [?\C-\M--] 'negative-argument)
585 (define-key global-map "\C-k" 'kill-line)
586 (define-key global-map "\C-w" 'kill-region)
587 (define-key esc-map "w" 'kill-ring-save)
588 (define-key esc-map "\C-w" 'append-next-kill)
589 (define-key global-map "\C-y" 'yank)
590 (define-key esc-map "y" 'yank-pop)
592 ;; (define-key ctl-x-map "a" 'append-to-buffer)
594 (define-key global-map "\C-@" 'set-mark-command)
595 ;; Many people are used to typing C-SPC and getting C-@.
596 (define-key global-map [?\C- ] 'set-mark-command)
597 (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
598 (define-key ctl-x-map "\C-@" 'pop-global-mark)
599 (define-key ctl-x-map [?\C- ] 'pop-global-mark)
601 (define-key global-map "\C-n" 'next-line)
602 (define-key global-map "\C-p" 'previous-line)
603 (define-key ctl-x-map "\C-n" 'set-goal-column)
605 ;;(defun function-key-error ()
606 ;; (interactive)
607 ;; (error "That function key is not bound to anything."))
609 (define-key global-map [menu] 'execute-extended-command)
610 (define-key global-map [find] 'search-forward)
612 ;; natural bindings for terminal keycaps --- defined in X keysym order
613 (define-key global-map [home] 'beginning-of-buffer)
614 (define-key global-map [M-home] 'beginning-of-buffer-other-window)
615 (define-key global-map [left] 'backward-char)
616 (define-key global-map [up] 'previous-line)
617 (define-key global-map [right] 'forward-char)
618 (define-key global-map [down] 'next-line)
619 (define-key global-map [prior] 'scroll-down)
620 (define-key global-map [next] 'scroll-up)
621 (define-key global-map [C-up] 'backward-paragraph)
622 (define-key global-map [C-down] 'forward-paragraph)
623 (define-key global-map [C-prior] 'scroll-right)
624 (define-key global-map [C-next] 'scroll-left)
625 (define-key global-map [M-next] 'scroll-other-window)
626 (define-key global-map [M-prior] 'scroll-other-window-down)
627 (define-key global-map [end] 'end-of-buffer)
628 (define-key global-map [M-end] 'end-of-buffer-other-window)
629 (define-key global-map [begin] 'beginning-of-buffer)
630 (define-key global-map [M-begin] 'beginning-of-buffer-other-window)
631 ;; (define-key global-map [select] 'function-key-error)
632 ;; (define-key global-map [print] 'function-key-error)
633 (define-key global-map [execute] 'execute-extended-command)
634 (define-key global-map [insert] 'overwrite-mode)
635 (define-key global-map [C-insert] 'kill-ring-save)
636 (define-key global-map [S-insert] 'yank)
637 (define-key global-map [undo] 'undo)
638 (define-key global-map [redo] 'repeat-complex-command)
639 ;; (define-key global-map [clearline] 'function-key-error)
640 (define-key global-map [insertline] 'open-line)
641 (define-key global-map [deleteline] 'kill-line)
642 ;; (define-key global-map [insertchar] 'function-key-error)
643 (define-key global-map [deletechar] 'delete-char)
644 ;; (define-key global-map [backtab] 'function-key-error)
645 ;; (define-key global-map [f1] 'function-key-error)
646 ;; (define-key global-map [f2] 'function-key-error)
647 ;; (define-key global-map [f3] 'function-key-error)
648 ;; (define-key global-map [f4] 'function-key-error)
649 ;; (define-key global-map [f5] 'function-key-error)
650 ;; (define-key global-map [f6] 'function-key-error)
651 ;; (define-key global-map [f7] 'function-key-error)
652 ;; (define-key global-map [f8] 'function-key-error)
653 ;; (define-key global-map [f9] 'function-key-error)
654 ;; (define-key global-map [f10] 'function-key-error)
655 ;; (define-key global-map [f11] 'function-key-error)
656 ;; (define-key global-map [f12] 'function-key-error)
657 ;; (define-key global-map [f13] 'function-key-error)
658 ;; (define-key global-map [f14] 'function-key-error)
659 ;; (define-key global-map [f15] 'function-key-error)
660 ;; (define-key global-map [f16] 'function-key-error)
661 ;; (define-key global-map [f17] 'function-key-error)
662 ;; (define-key global-map [f18] 'function-key-error)
663 ;; (define-key global-map [f19] 'function-key-error)
664 ;; (define-key global-map [f20] 'function-key-error)
665 ;; (define-key global-map [f21] 'function-key-error)
666 ;; (define-key global-map [f22] 'function-key-error)
667 ;; (define-key global-map [f23] 'function-key-error)
668 ;; (define-key global-map [f24] 'function-key-error)
669 ;; (define-key global-map [f25] 'function-key-error)
670 ;; (define-key global-map [f26] 'function-key-error)
671 ;; (define-key global-map [f27] 'function-key-error)
672 ;; (define-key global-map [f28] 'function-key-error)
673 ;; (define-key global-map [f29] 'function-key-error)
674 ;; (define-key global-map [f30] 'function-key-error)
675 ;; (define-key global-map [f31] 'function-key-error)
676 ;; (define-key global-map [f32] 'function-key-error)
677 ;; (define-key global-map [f33] 'function-key-error)
678 ;; (define-key global-map [f34] 'function-key-error)
679 ;; (define-key global-map [f35] 'function-key-error)
680 ;; (define-key global-map [kp-backtab] 'function-key-error)
681 ;; (define-key global-map [kp-space] 'function-key-error)
682 ;; (define-key global-map [kp-tab] 'function-key-error)
683 ;; (define-key global-map [kp-enter] 'function-key-error)
684 ;; (define-key global-map [kp-f1] 'function-key-error)
685 ;; (define-key global-map [kp-f2] 'function-key-error)
686 ;; (define-key global-map [kp-f3] 'function-key-error)
687 ;; (define-key global-map [kp-f4] 'function-key-error)
688 ;; (define-key global-map [kp-multiply] 'function-key-error)
689 ;; (define-key global-map [kp-add] 'function-key-error)
690 ;; (define-key global-map [kp-separator] 'function-key-error)
691 ;; (define-key global-map [kp-subtract] 'function-key-error)
692 ;; (define-key global-map [kp-decimal] 'function-key-error)
693 ;; (define-key global-map [kp-divide] 'function-key-error)
694 ;; (define-key global-map [kp-0] 'function-key-error)
695 ;; (define-key global-map [kp-1] 'function-key-error)
696 ;; (define-key global-map [kp-2] 'function-key-error)
697 ;; (define-key global-map [kp-3] 'function-key-error)
698 ;; (define-key global-map [kp-4] 'function-key-error)
699 ;; (define-key global-map [kp-5] 'recenter)
700 ;; (define-key global-map [kp-6] 'function-key-error)
701 ;; (define-key global-map [kp-7] 'function-key-error)
702 ;; (define-key global-map [kp-8] 'function-key-error)
703 ;; (define-key global-map [kp-9] 'function-key-error)
704 ;; (define-key global-map [kp-equal] 'function-key-error)
706 ;; X11R6 distinguishes these keys from the non-kp keys.
707 ;; Make them behave like the non-kp keys unless otherwise bound.
708 (define-key function-key-map [kp-home] [home])
709 (define-key function-key-map [kp-left] [left])
710 (define-key function-key-map [kp-up] [up])
711 (define-key function-key-map [kp-right] [right])
712 (define-key function-key-map [kp-down] [down])
713 (define-key function-key-map [kp-prior] [prior])
714 (define-key function-key-map [kp-next] [next])
715 (define-key function-key-map [M-kp-next] [M-next])
716 (define-key function-key-map [kp-end] [end])
717 (define-key function-key-map [kp-begin] [begin])
718 (define-key function-key-map [kp-insert] [insert])
719 (define-key function-key-map [kp-delete] [delete])
721 (define-key global-map [mouse-movement] 'ignore)
723 (define-key global-map "\C-t" 'transpose-chars)
724 (define-key esc-map "t" 'transpose-words)
725 (define-key esc-map "\C-t" 'transpose-sexps)
726 (define-key ctl-x-map "\C-t" 'transpose-lines)
728 (define-key esc-map ";" 'indent-for-comment)
729 (define-key esc-map "j" 'indent-new-comment-line)
730 (define-key esc-map "\C-j" 'indent-new-comment-line)
731 (define-key ctl-x-map ";" 'set-comment-column)
732 (define-key ctl-x-map "f" 'set-fill-column)
733 (define-key ctl-x-map "$" 'set-selective-display)
735 (define-key esc-map "@" 'mark-word)
736 (define-key esc-map "f" 'forward-word)
737 (define-key esc-map "b" 'backward-word)
738 (define-key esc-map "d" 'kill-word)
739 (define-key esc-map "\177" 'backward-kill-word)
741 (define-key esc-map "<" 'beginning-of-buffer)
742 (define-key esc-map ">" 'end-of-buffer)
743 (define-key ctl-x-map "h" 'mark-whole-buffer)
744 (define-key esc-map "\\" 'delete-horizontal-space)
746 (defalias 'mode-specific-command-prefix (make-sparse-keymap))
747 (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
748 "Keymap for characters following C-c.")
749 (define-key global-map "\C-c" 'mode-specific-command-prefix)
751 (global-set-key [M-right] 'forward-word)
752 (global-set-key [M-left] 'backward-word)
753 ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
754 (global-set-key [C-right] 'forward-word)
755 (global-set-key [C-left] 'backward-word)
756 ;; This is not quite compatible, but at least is analogous
757 (global-set-key [C-delete] 'backward-kill-word)
758 ;; This is "move to the clipboard", or as close as we come.
759 (global-set-key [S-delete] 'kill-region)
761 (define-key esc-map "\C-f" 'forward-sexp)
762 (define-key esc-map "\C-b" 'backward-sexp)
763 (define-key esc-map "\C-u" 'backward-up-list)
764 (define-key esc-map "\C-@" 'mark-sexp)
765 (define-key esc-map [?\C-\ ] 'mark-sexp)
766 (define-key esc-map "\C-d" 'down-list)
767 (define-key esc-map "\C-k" 'kill-sexp)
768 (define-key global-map [C-M-delete] 'backward-kill-sexp)
769 (define-key global-map [C-M-backspace] 'backward-kill-sexp)
770 (define-key esc-map "\C-n" 'forward-list)
771 (define-key esc-map "\C-p" 'backward-list)
772 (define-key esc-map "\C-a" 'beginning-of-defun)
773 (define-key esc-map "\C-e" 'end-of-defun)
774 (define-key esc-map "\C-h" 'mark-defun)
775 (define-key ctl-x-map "nd" 'narrow-to-defun)
776 (define-key esc-map "(" 'insert-parentheses)
777 (define-key esc-map ")" 'move-past-close-and-reindent)
779 (define-key ctl-x-map "\C-e" 'eval-last-sexp)
781 (define-key ctl-x-map "m" 'compose-mail)
782 (define-key ctl-x-4-map "m" 'compose-mail-other-window)
783 (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
785 (define-key ctl-x-map "r\C-@" 'point-to-register)
786 (define-key ctl-x-map [?r ?\C-\ ] 'point-to-register)
787 (define-key ctl-x-map "r " 'point-to-register)
788 (define-key ctl-x-map "rj" 'jump-to-register)
789 (define-key ctl-x-map "rs" 'copy-to-register)
790 (define-key ctl-x-map "rx" 'copy-to-register)
791 (define-key ctl-x-map "ri" 'insert-register)
792 (define-key ctl-x-map "rg" 'insert-register)
793 (define-key ctl-x-map "rr" 'copy-rectangle-to-register)
794 (define-key ctl-x-map "rn" 'number-to-register)
795 (define-key ctl-x-map "r+" 'increment-register)
796 (define-key ctl-x-map "rc" 'clear-rectangle)
797 (define-key ctl-x-map "rk" 'kill-rectangle)
798 (define-key ctl-x-map "rd" 'delete-rectangle)
799 (define-key ctl-x-map "ry" 'yank-rectangle)
800 (define-key ctl-x-map "ro" 'open-rectangle)
801 (define-key ctl-x-map "rt" 'string-rectangle)
802 (define-key ctl-x-map "rw" 'window-configuration-to-register)
803 (define-key ctl-x-map "rf" 'frame-configuration-to-register)
805 ;; These key bindings are deprecated; use the above C-x r map instead.
806 ;; We use these aliases so \[...] will show the C-x r bindings instead.
807 (defalias 'point-to-register-compatibility-binding 'point-to-register)
808 (defalias 'jump-to-register-compatibility-binding 'jump-to-register)
809 (defalias 'copy-to-register-compatibility-binding 'copy-to-register)
810 (defalias 'insert-register-compatibility-binding 'insert-register)
811 (define-key ctl-x-map "/" 'point-to-register-compatibility-binding)
812 (define-key ctl-x-map "j" 'jump-to-register-compatibility-binding)
813 (define-key ctl-x-map "x" 'copy-to-register-compatibility-binding)
814 (define-key ctl-x-map "g" 'insert-register-compatibility-binding)
815 ;; (define-key ctl-x-map "r" 'copy-rectangle-to-register)
817 (define-key esc-map "q" 'fill-paragraph)
818 ;; (define-key esc-map "g" 'fill-region)
819 (define-key ctl-x-map "." 'set-fill-prefix)
821 (define-key esc-map "{" 'backward-paragraph)
822 (define-key esc-map "}" 'forward-paragraph)
823 (define-key esc-map "h" 'mark-paragraph)
824 (define-key esc-map "a" 'backward-sentence)
825 (define-key esc-map "e" 'forward-sentence)
826 (define-key esc-map "k" 'kill-sentence)
827 (define-key ctl-x-map "\177" 'backward-kill-sentence)
829 (define-key ctl-x-map "[" 'backward-page)
830 (define-key ctl-x-map "]" 'forward-page)
831 (define-key ctl-x-map "\C-p" 'mark-page)
832 (define-key ctl-x-map "l" 'count-lines-page)
833 (define-key ctl-x-map "np" 'narrow-to-page)
834 ;; (define-key ctl-x-map "p" 'narrow-to-page)
836 (define-key ctl-x-map "al" 'add-mode-abbrev)
837 (define-key ctl-x-map "a\C-a" 'add-mode-abbrev)
838 (define-key ctl-x-map "ag" 'add-global-abbrev)
839 (define-key ctl-x-map "a+" 'add-mode-abbrev)
840 (define-key ctl-x-map "aig" 'inverse-add-global-abbrev)
841 (define-key ctl-x-map "ail" 'inverse-add-mode-abbrev)
842 ;; (define-key ctl-x-map "a\C-h" 'inverse-add-global-abbrev)
843 (define-key ctl-x-map "a-" 'inverse-add-global-abbrev)
844 (define-key ctl-x-map "ae" 'expand-abbrev)
845 (define-key ctl-x-map "a'" 'expand-abbrev)
846 ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
847 ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
848 ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
849 ;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev)
850 (define-key esc-map "'" 'abbrev-prefix-mark)
851 (define-key ctl-x-map "'" 'expand-abbrev)
853 (define-key ctl-x-map "z" 'repeat)
855 ;;; Don't compile this file; it contains no large function definitions.
856 ;;; Don't look for autoload cookies in this file.
857 ;;; Local Variables:
858 ;;; no-byte-compile: t
859 ;;; no-update-autoloads: t
860 ;;; End:
862 ;;; bindings.el ends here