(PER_CHAR_METRIC): Removed because not used.
[emacs.git] / lisp / bindings.el
blob2deea04faec35d0ed4516836df98acfb406375fc
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] f)
56 map))
59 (defun mode-line-toggle-read-only (event)
60 "Like `toggle-read-only', for the mode-line."
61 (interactive "e")
62 (save-selected-window
63 (select-window (posn-window (event-start event)))
64 (toggle-read-only)
65 (force-mode-line-update)))
68 (defun mode-line-toggle-modified (event)
69 "Toggle the buffer-modified flag from the mode-line."
70 (interactive "e")
71 (save-selected-window
72 (select-window (posn-window (event-start event)))
73 (set-buffer-modified-p (not (buffer-modified-p)))
74 (force-mode-line-update)))
77 (defun mode-line-widen (event)
78 "Widen a buffer from the mode-line."
79 (interactive "e")
80 (save-selected-window
81 (select-window (posn-window (event-start event)))
82 (widen)
83 (force-mode-line-update)))
86 (defun mode-line-abbrev-mode (event)
87 "Turn off `abbrev-mode' from the mode-line."
88 (interactive "e")
89 (save-selected-window
90 (select-window (posn-window (event-start event)))
91 (abbrev-mode)
92 (force-mode-line-update)))
95 (defun mode-line-auto-fill-mode (event)
96 "Turn off `auto-fill-mode' from the mode-line."
97 (interactive "e")
98 (save-selected-window
99 (select-window (posn-window (event-start event)))
100 (auto-fill-mode)
101 (force-mode-line-update)))
104 (defvar mode-line-input-method-map
105 (let ((map (make-sparse-keymap)))
106 (define-key map [mode-line mouse-2]
107 (lambda (e)
108 (interactive "e")
109 (save-selected-window
110 (select-window
111 (posn-window (event-start e)))
112 (toggle-input-method)
113 (force-mode-line-update))))
114 (define-key map [mode-line mouse-3]
115 (lambda (e)
116 (interactive "e")
117 (save-selected-window
118 (select-window
119 (posn-window (event-start e)))
120 (describe-current-input-method))))
121 (purecopy map)))
123 (defvar mode-line-mule-info
124 `(""
125 (current-input-method
126 (:eval
127 ,(purecopy
128 '(propertize current-input-method-title
129 'help-echo (concat
130 "Input method: "
131 current-input-method
132 ". mouse-2 disables, mouse-3 describes")
133 'local-map mode-line-input-method-map))))
134 ,(propertize
135 "%Z"
136 'help-echo
137 (purecopy (lambda (window object point)
138 (save-window-excursion
139 (select-window window)
140 (if enable-multibyte-characters
141 (concat (symbol-name buffer-file-coding-system)
142 " buffer; see M-x describe-coding-system")
143 (concat "Unibyte "
144 (symbol-name buffer-file-coding-system)
145 " buffer")))))))
146 "Mode-line control for displaying information of multilingual environment.
147 Normally it displays current input method (if any activated) and
148 mnemonics of the following coding systems:
149 coding system for saving or writing the current buffer
150 coding system for keyboard input (if Emacs is running on terminal)
151 coding system for terminal output (if Emacs is running on terminal)"
152 ;; Currently not:
153 ;;; coding system for decoding output of buffer process (if any)
154 ;;; coding system for encoding text to send to buffer process (if any)."
157 (make-variable-buffer-local 'mode-line-mule-info)
159 (defvar mode-line-buffer-identification (purecopy '("%12b")) "\
160 Mode-line control for identifying the buffer being displayed.
161 Its default value is (\"%12b\").
162 Major modes that edit things other than ordinary files may change this
163 \(e.g. Info, Dired,...)")
165 (make-variable-buffer-local 'mode-line-buffer-identification)
167 (defvar mode-line-frame-identification '("-%F "))
169 (defvar mode-line-process nil "\
170 Mode-line control for displaying info on process status.
171 Normally nil in most modes, since there is no process to display.")
173 (make-variable-buffer-local 'mode-line-process)
175 (defvar mode-line-modified
176 (list (propertize
177 "%1*"
178 'help-echo (purecopy (lambda (window object point)
179 (format "%sead-only: mouse-2 toggles"
180 (save-selected-window
181 (select-window window)
182 (if buffer-read-only
184 "Not r")))))
185 'local-map (purecopy (make-mode-line-mouse2-map
186 #'mode-line-toggle-read-only)))
187 (propertize
188 "%1+"
189 'help-echo (purecopy (lambda (window object point)
190 (format "%sodified: mouse-2 toggles flag"
191 (save-selected-window
192 (select-window window)
193 (if (buffer-modified-p)
195 "Not m")))))
196 'local-map (purecopy (make-mode-line-mouse2-map
197 #'mode-line-toggle-modified))))
198 "Mode-line control for displaying whether current buffer is modified.")
200 (make-variable-buffer-local 'mode-line-modified)
202 (setq-default mode-line-format
203 (let* ((help-echo
204 ;; The multi-line message doesn't work terribly well on the
205 ;; bottom mode line... Better ideas?
206 ;;; "\
207 ;;; mouse-1: select window, mouse-2: delete others, mouse-3: delete,
208 ;;; drag-mouse-1: resize, C-mouse-2: split horizontally"
209 "mouse-1: select window, mouse-2: delete others, mouse-3: delete ...")
210 (dashes (propertize "--" 'help-echo help-echo)))
211 (list
212 (propertize "-" 'help-echo help-echo)
213 'mode-line-mule-info
214 'mode-line-modified
215 'mode-line-frame-identification
216 'mode-line-buffer-identification
217 (propertize " " 'help-echo help-echo)
218 'global-mode-string
219 (propertize " %[(" 'help-echo help-echo)
220 '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist
221 (propertize "%n" 'help-echo "mouse-2: widen"
222 'local-map (make-mode-line-mouse2-map #'mode-line-widen))
223 (propertize ")%]--" 'help-echo help-echo)
224 `(which-func-mode ("" which-func-format ,dashes))
225 `(line-number-mode ("L%l" ,dashes))
226 `(column-number-mode ("C%c" ,dashes))
227 (purecopy '(-3 . "%p"))
228 (propertize "-%-" 'help-echo help-echo))))
230 (defvar minor-mode-alist nil "\
231 Alist saying how to show minor modes in the mode line.
232 Each element looks like (VARIABLE STRING);
233 STRING is included in the mode line iff VARIABLE's value is non-nil.
235 Actually, STRING need not be a string; any possible mode-line element
236 is okay. See `mode-line-format'.")
237 ;; Don't use purecopy here--some people want to change these strings.
238 (setq minor-mode-alist
239 (list
240 (list 'abbrev-mode
241 (propertize " Abbrev"
242 'help-echo (purecopy
243 "mouse-2: turn off Abbrev mode")
244 'local-map (purecopy (make-mode-line-mouse2-map
245 #'mode-line-abbrev-mode))))
246 '(overwrite-mode overwrite-mode)
247 (list 'auto-fill-function
248 (propertize " Fill"
249 'help-echo (purecopy
250 "mouse-2: turn off Autofill mode")
251 'local-map (purecopy (make-mode-line-mouse2-map
252 #'mode-line-auto-fill-mode))))
253 ;; not really a minor mode...
254 '(defining-kbd-macro " Def")))
256 (defvar mode-line-buffer-identification-keymap nil "\
257 Keymap for what is displayed by `mode-line-buffer-identification'.")
259 (defvar mode-line-minor-mode-keymap nil "\
260 Keymap for what is displayed by `mode-line-mode-name'.")
262 (defvar mode-line-mode-menu-keymap nil "\
263 Keymap for mode operations menu in the mode line.")
265 (defun mode-line-unbury-buffer () "\
266 Switch to the last buffer in the buffer list that is not hidden."
267 (interactive)
268 (let ((list (reverse (buffer-list))))
269 (while (eq (aref (buffer-name (car list)) 0) ? )
270 (setq list (cdr list)))
271 (switch-to-buffer (car list))))
273 (defun mode-line-other-buffer () "\
274 Switch to the most recently selected buffer other than the current one."
275 (interactive)
276 (switch-to-buffer (other-buffer)))
278 (defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
279 Menu of mode operations in the mode line.")
281 (defun mode-line-mode-menu-1 (event)
282 (interactive "e")
283 (save-selected-window
284 (select-window (posn-window (event-start event)))
285 (let* ((selection (mode-line-mode-menu event))
286 (binding (and selection (lookup-key mode-line-mode-menu
287 (vector (car selection))))))
288 (if binding
289 (call-interactively binding)))))
291 (defun mode-line-mode-name () "\
292 Return a string to display in the mode line for the current mode name."
293 (let (length (result mode-name))
294 (let ((local-map (get-text-property 0 'local-map result))
295 (help-echo (get-text-property 0 'help-echo result)))
296 (setq result (copy-sequence result))
297 ;; Add `local-map' property if there isn't already one.
298 (when (and (null local-map)
299 (null (next-single-property-change 0 'local-map result)))
300 (put-text-property 0 (length result)
301 'local-map mode-line-minor-mode-keymap result))
302 ;; Add `help-echo' property if there isn't already one.
303 (when (and (null help-echo)
304 (null (next-single-property-change 0 'help-echo result)))
305 (put-text-property 0 (length result)
306 'help-echo "mouse-3: minor mode menu" result)))
307 result))
309 (defmacro bound-and-true-p (var)
310 "Return the value of symbol VAR if it is bound, else nil."
311 `(and (boundp (quote ,var)) ,var))
313 (define-key mode-line-mode-menu [abbrev-mode]
314 `(menu-item ,(purecopy "Abbrev") abbrev-mode
315 :button (:toggle . abbrev-mode)))
316 (define-key mode-line-mode-menu [auto-revert-mode]
317 `(menu-item ,(purecopy "Auto revert") auto-revert-mode
318 :button (:toggle . auto-revert-mode)))
319 (define-key mode-line-mode-menu [auto-fill-mode]
320 `(menu-item ,(purecopy "Auto-fill") auto-fill-mode
321 :button (:toggle . auto-fill-function)))
322 (define-key mode-line-mode-menu [column-number-mode]
323 `(menu-item ,(purecopy "Column number") column-number-mode
324 :button (:toggle . column-number-mode)))
325 (define-key mode-line-mode-menu [flyspell-mode]
326 `(menu-item ,(purecopy "Flyspell") flyspell-mode
327 :button (:toggle . (bound-and-true-p flyspell-mode))))
328 (define-key mode-line-mode-menu [font-lock-mode]
329 `(menu-item ,(purecopy "Font-lock") font-lock-mode
330 :button (:toggle . font-lock-mode)))
331 (define-key mode-line-mode-menu [hide-ifdef-mode]
332 `(menu-item ,(purecopy "Hide ifdef") hide-ifdef-mode
333 :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
334 (define-key mode-line-mode-menu [highlight-changes-mode]
335 `(menu-item ,(purecopy "Highlight changes") highlight-changes-mode
336 :button (:toggle . highlight-changes-mode)))
337 (define-key mode-line-mode-menu [line-number-mode]
338 `(menu-item ,(purecopy "Line number") line-number-mode
339 :button (:toggle . line-number-mode)))
340 (define-key mode-line-mode-menu [outline-minor-mode]
341 `(menu-item ,(purecopy "Outline") outline-minor-mode
342 :button (:toggle . (bound-and-true-p outline-minor-mode))))
343 (define-key mode-line-mode-menu [overwrite-mode]
344 `(menu-item ,(purecopy "Overwrite") overwrite-mode
345 :button (:toggle . overwrite-mode)))
347 (defun mode-line-mode-menu (event)
348 (interactive "@e")
349 (x-popup-menu event mode-line-mode-menu))
351 ;; Add menu of buffer operations to the buffer identification part
352 ;; of the mode line.
353 (let ((map (make-sparse-keymap)))
354 (define-key map [mode-line mouse-1] 'mode-line-other-buffer)
355 (define-key map [header-line mouse-1] 'mode-line-other-buffer)
356 (define-key map [mode-line M-mouse-2] 'mode-line-unbury-buffer)
357 (define-key map [header-line M-mouse-2] 'mode-line-unbury-buffer)
358 (define-key map [mode-line mouse-2] 'bury-buffer)
359 (define-key map [header-line mouse-2] 'bury-buffer)
360 (define-key map [mode-line down-mouse-3] 'mouse-buffer-menu)
361 (define-key map [header-line down-mouse-3] 'mouse-buffer-menu)
362 (setq mode-line-buffer-identification-keymap map))
364 (defun propertized-buffer-identification (fmt)
365 "Return a list suitable for `mode-line-buffer-identification'.
366 FMT is a format specifier such as \"%12b\". This function adds
367 text properties for face, help-echo, and local-map to it."
368 (list (propertize fmt
369 'face '(:weight bold)
370 'help-echo (purecopy "mouse-1: other \
371 buffer, mouse-2: prev, M-mouse-2: next, mouse-3: buffer menu")
372 'local-map mode-line-buffer-identification-keymap)))
374 (setq-default mode-line-buffer-identification
375 (propertized-buffer-identification "%12b"))
377 ;; Menu of minor modes.
378 (let ((map (make-sparse-keymap)))
379 (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
380 (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1)
381 (setq mode-line-minor-mode-keymap map))
383 ;; These variables are used by autoloadable packages.
384 ;; They are defined here so that they do not get overridden
385 ;; by the loading of those packages.
387 ;; Names in directory that end in one of these
388 ;; are ignored in completion,
389 ;; making it more likely you will get a unique match.
390 (setq completion-ignored-extensions
391 (append
392 (cond ((or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
393 '(".o" "~" ".bin" ".bak" ".obj" ".map"
394 ".a" ".ln" ".blg" ".bbl"))
395 ((eq system-type 'vax-vms)
396 '(".obj" ".exe" ".bin" ".lbin" ".sbin"
397 ".brn" ".rnt" ".mem" ".lni" ".lis"
398 ".olb" ".tlb" ".mlb" ".hlb"))
400 '(".o" "~" ".bin" ".lbin" ".fasl" ".ufsl"
401 ".a" ".ln" ".blg" ".bbl")))
402 '(".elc" ".lof"
403 ".glo" ".idx" ".lot"
404 ;; TeX-related
405 ".dvi" ".fmt" ".tfm" ".pdf"
406 ;; Java compiled
407 ".class"
408 ;; Clisp
409 ".fas" ".lib"
410 ;; CMUCL
411 ".x86f" ".sparcf"
412 ;; Libtool
413 ".lo" ".la"
414 ;; Java
415 ".class"
416 ;; Texinfo-related
417 ".toc" ".log" ".aux"
418 ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
419 ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs")))
421 ;; Packages should add to this list appropriately when they are
422 ;; loaded, rather than listing everything here.
423 (setq debug-ignored-errors
424 '(beginning-of-line beginning-of-buffer end-of-line
425 end-of-buffer end-of-file buffer-read-only
426 file-supersession
427 "^Previous command was not a yank$"
428 "^Minibuffer window is not active$"
429 "^End of history; no next item$"
430 "^Beginning of history; no preceding item$"
431 "^No recursive edit is in progress$"
432 "^Changes to be undone are outside visible portion of buffer$"
433 "^No undo information in this buffer$"
434 "^No further undo information$"
435 "^Save not confirmed$"
436 "^Recover-file cancelled\\.$"
437 "^Cannot switch buffers in a dedicated window$"
439 ;; ediff
440 "^Errors in diff output. Diff output is in "
441 "^Hmm... I don't see an Ediff command around here...$"
442 "^Undocumented command! Type `G' in Ediff Control Panel to drop a note to the Ediff maintainer$"
443 ": This command runs in Ediff Control Buffer only!$"
444 ": Invalid op in ediff-check-version$"
445 "^ediff-shrink-window-C can be used only for merging jobs$"
446 "^Lost difference info on these directories$"
447 "^This command is inapplicable in the present context$"
448 "^This session group has no parent$"
449 "^Can't hide active session, $"
450 "^Ediff: something wrong--no multiple diffs buffer$"
451 "^Can't make context diff for Session $"
452 "^The patch buffer wasn't found$"
453 "^Aborted$"
454 "^This Ediff session is not part of a session group$"
455 "^No active Ediff sessions or corrupted session registry$"
456 "^No session info in this line$"
457 "^`.*' is not an ordinary file$"
458 "^Patch appears to have failed$"
459 "^Recomputation of differences cancelled$"
460 "^No fine differences in this mode$"
461 "^Lost connection to ancestor buffer...sorry$"
462 "^Not merging with ancestor$"
463 "^Don't know how to toggle read-only in buffer "
464 "Emacs is not running as a window application$"
465 "^This command makes sense only when merging with an ancestor$"
466 "^At end of the difference list$"
467 "^At beginning of the difference list$"
468 "^Nothing saved for diff .* in buffer "
469 "^Buffer is out of sync for file "
470 "^Buffer out of sync for file "
471 "^Output from `diff' not found$"
472 "^You forgot to specify a region in buffer "
473 "^All right. Make up your mind and come back...$"
474 "^Current buffer is not visiting any file$"
475 "^Failed to retrieve revision: $"
476 "^Can't determine display width.$"
477 "^File `.*' does not exist or is not readable$"
478 "^File `.*' is a directory$"
479 "^Buffer .* doesn't exist$"
480 "^Directories . and . are the same: "
481 "^Directory merge aborted$"
482 "^Merge of directory revisions aborted$"
483 "^Buffer .* doesn't exist$"
484 "^There is no file to merge$"
485 "^Version control package .*.el not found. Use vc.el instead$"))
488 (make-variable-buffer-local 'indent-tabs-mode)
490 ;; We have base64 functions built in now.
491 (add-to-list 'features 'base64)
493 (define-key esc-map "\t" 'complete-symbol)
495 (defun complete-symbol (arg) "\
496 Perform tags completion on the text around point.
497 Completes to the set of names listed in the current tags table.
498 The string to complete is chosen in the same way as the default
499 for \\[find-tag] (which see).
501 With a prefix argument, this command does completion within
502 the collection of symbols listed in the index of the manual for the
503 language you are using."
504 (interactive "P")
505 (if arg
506 (info-complete-symbol)
507 (if (fboundp 'complete-tag)
508 (complete-tag)
509 ;; Don't autoload etags if we have no tags table.
510 (error (substitute-command-keys
511 "No tags table loaded; use \\[visit-tags-table] to load one")))))
513 ;; Reduce total amount of space we must allocate during this function
514 ;; that we will not need to keep permanently.
515 (garbage-collect)
517 ;; Make all multibyte characters self-insert.
518 (let ((l (generic-character-list))
519 (table (nth 1 global-map)))
520 (while l
521 (set-char-table-default table (car l) 'self-insert-command)
522 (setq l (cdr l))))
524 (setq help-event-list '(help f1))
526 (make-variable-buffer-local 'minor-mode-overriding-map-alist)
528 ;These commands are defined in editfns.c
529 ;but they are not assigned to keys there.
530 (put 'narrow-to-region 'disabled t)
531 (define-key ctl-x-map "nn" 'narrow-to-region)
532 (define-key ctl-x-map "nw" 'widen)
533 ;; (define-key ctl-x-map "n" 'narrow-to-region)
534 ;; (define-key ctl-x-map "w" 'widen)
536 (define-key global-map "\C-j" 'newline-and-indent)
537 (define-key global-map "\C-m" 'newline)
538 (define-key global-map "\C-o" 'open-line)
539 (define-key esc-map "\C-o" 'split-line)
540 (define-key global-map "\C-q" 'quoted-insert)
541 (define-key esc-map "^" 'delete-indentation)
542 (define-key esc-map "\\" 'delete-horizontal-space)
543 (define-key esc-map "m" 'back-to-indentation)
544 (define-key ctl-x-map "\C-o" 'delete-blank-lines)
545 (define-key esc-map " " 'just-one-space)
546 (define-key esc-map "z" 'zap-to-char)
547 (define-key esc-map "=" 'count-lines-region)
548 (define-key ctl-x-map "=" 'what-cursor-position)
549 (define-key esc-map ":" 'eval-expression)
550 ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
551 (define-key esc-map "\M-:" 'eval-expression)
552 ;; Changed from C-x ESC so that function keys work following C-x.
553 (define-key ctl-x-map "\e\e" 'repeat-complex-command)
554 ;; New binding analogous to M-:.
555 (define-key ctl-x-map "\M-:" 'repeat-complex-command)
556 (define-key ctl-x-map "u" 'advertised-undo)
557 ;; Many people are used to typing C-/ on X terminals and getting C-_.
558 (define-key global-map [?\C-/] 'undo)
559 (define-key global-map "\C-_" 'undo)
560 (define-key esc-map "!" 'shell-command)
561 (define-key esc-map "|" 'shell-command-on-region)
563 ;; This is an experiment--make up and down arrows do history.
564 (define-key minibuffer-local-map [up] 'previous-history-element)
565 (define-key minibuffer-local-map [down] 'next-history-element)
566 (define-key minibuffer-local-ns-map [up] 'previous-history-element)
567 (define-key minibuffer-local-ns-map [down] 'next-history-element)
568 (define-key minibuffer-local-completion-map [up] 'previous-history-element)
569 (define-key minibuffer-local-completion-map [down] 'next-history-element)
570 (define-key minibuffer-local-must-match-map [up] 'previous-history-element)
571 (define-key minibuffer-local-must-match-map [down] 'next-history-element)
573 (define-key global-map "\C-u" 'universal-argument)
574 (let ((i ?0))
575 (while (<= i ?9)
576 (define-key esc-map (char-to-string i) 'digit-argument)
577 (setq i (1+ i))))
578 (define-key esc-map "-" 'negative-argument)
579 ;; Define control-digits.
580 (let ((i ?0))
581 (while (<= i ?9)
582 (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
583 (setq i (1+ i))))
584 (define-key global-map [?\C--] 'negative-argument)
585 ;; Define control-meta-digits.
586 (let ((i ?0))
587 (while (<= i ?9)
588 (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
589 (setq i (1+ i))))
590 (define-key global-map [?\C-\M--] 'negative-argument)
592 (define-key global-map "\C-k" 'kill-line)
593 (define-key global-map "\C-w" 'kill-region)
594 (define-key esc-map "w" 'kill-ring-save)
595 (define-key esc-map "\C-w" 'append-next-kill)
596 (define-key global-map "\C-y" 'yank)
597 (define-key esc-map "y" 'yank-pop)
599 ;; (define-key ctl-x-map "a" 'append-to-buffer)
601 (define-key global-map "\C-@" 'set-mark-command)
602 ;; Many people are used to typing C-SPC and getting C-@.
603 (define-key global-map [?\C- ] 'set-mark-command)
604 (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
605 (define-key ctl-x-map "\C-@" 'pop-global-mark)
606 (define-key ctl-x-map [?\C- ] 'pop-global-mark)
608 (define-key global-map "\C-n" 'next-line)
609 (define-key global-map "\C-p" 'previous-line)
610 (define-key ctl-x-map "\C-n" 'set-goal-column)
612 ;;(defun function-key-error ()
613 ;; (interactive)
614 ;; (error "That function key is not bound to anything."))
616 (define-key global-map [menu] 'execute-extended-command)
617 (define-key global-map [find] 'search-forward)
619 (define-key global-map [delete] 'delete-char)
621 ;; natural bindings for terminal keycaps --- defined in X keysym order
622 (define-key global-map [home] 'beginning-of-buffer)
623 (define-key global-map [M-home] 'beginning-of-buffer-other-window)
624 (define-key global-map [left] 'backward-char)
625 (define-key global-map [up] 'previous-line)
626 (define-key global-map [right] 'forward-char)
627 (define-key global-map [down] 'next-line)
628 (define-key global-map [prior] 'scroll-down)
629 (define-key global-map [next] 'scroll-up)
630 (define-key global-map [C-up] 'backward-paragraph)
631 (define-key global-map [C-down] 'forward-paragraph)
632 (define-key global-map [C-prior] 'scroll-right)
633 (define-key global-map [C-next] 'scroll-left)
634 (define-key global-map [M-next] 'scroll-other-window)
635 (define-key global-map [M-prior] 'scroll-other-window-down)
636 (define-key global-map [end] 'end-of-buffer)
637 (define-key global-map [M-end] 'end-of-buffer-other-window)
638 (define-key global-map [begin] 'beginning-of-buffer)
639 (define-key global-map [M-begin] 'beginning-of-buffer-other-window)
640 ;; (define-key global-map [select] 'function-key-error)
641 ;; (define-key global-map [print] 'function-key-error)
642 (define-key global-map [execute] 'execute-extended-command)
643 (define-key global-map [insert] 'overwrite-mode)
644 (define-key global-map [C-insert] 'kill-ring-save)
645 (define-key global-map [S-insert] 'yank)
646 (define-key global-map [undo] 'undo)
647 (define-key global-map [redo] 'repeat-complex-command)
648 ;; (define-key global-map [clearline] 'function-key-error)
649 (define-key global-map [insertline] 'open-line)
650 (define-key global-map [deleteline] 'kill-line)
651 ;; (define-key global-map [insertchar] 'function-key-error)
652 (define-key global-map [deletechar] 'delete-char)
653 ;; (define-key global-map [backtab] 'function-key-error)
654 ;; (define-key global-map [f1] 'function-key-error)
655 ;; (define-key global-map [f2] 'function-key-error)
656 ;; (define-key global-map [f3] 'function-key-error)
657 ;; (define-key global-map [f4] 'function-key-error)
658 ;; (define-key global-map [f5] 'function-key-error)
659 ;; (define-key global-map [f6] 'function-key-error)
660 ;; (define-key global-map [f7] 'function-key-error)
661 ;; (define-key global-map [f8] 'function-key-error)
662 ;; (define-key global-map [f9] 'function-key-error)
663 ;; (define-key global-map [f10] 'function-key-error)
664 ;; (define-key global-map [f11] 'function-key-error)
665 ;; (define-key global-map [f12] 'function-key-error)
666 ;; (define-key global-map [f13] 'function-key-error)
667 ;; (define-key global-map [f14] 'function-key-error)
668 ;; (define-key global-map [f15] 'function-key-error)
669 ;; (define-key global-map [f16] 'function-key-error)
670 ;; (define-key global-map [f17] 'function-key-error)
671 ;; (define-key global-map [f18] 'function-key-error)
672 ;; (define-key global-map [f19] 'function-key-error)
673 ;; (define-key global-map [f20] 'function-key-error)
674 ;; (define-key global-map [f21] 'function-key-error)
675 ;; (define-key global-map [f22] 'function-key-error)
676 ;; (define-key global-map [f23] 'function-key-error)
677 ;; (define-key global-map [f24] 'function-key-error)
678 ;; (define-key global-map [f25] 'function-key-error)
679 ;; (define-key global-map [f26] 'function-key-error)
680 ;; (define-key global-map [f27] 'function-key-error)
681 ;; (define-key global-map [f28] 'function-key-error)
682 ;; (define-key global-map [f29] 'function-key-error)
683 ;; (define-key global-map [f30] 'function-key-error)
684 ;; (define-key global-map [f31] 'function-key-error)
685 ;; (define-key global-map [f32] 'function-key-error)
686 ;; (define-key global-map [f33] 'function-key-error)
687 ;; (define-key global-map [f34] 'function-key-error)
688 ;; (define-key global-map [f35] 'function-key-error)
689 ;; (define-key global-map [kp-backtab] 'function-key-error)
690 ;; (define-key global-map [kp-space] 'function-key-error)
691 ;; (define-key global-map [kp-tab] 'function-key-error)
692 ;; (define-key global-map [kp-enter] 'function-key-error)
693 ;; (define-key global-map [kp-f1] 'function-key-error)
694 ;; (define-key global-map [kp-f2] 'function-key-error)
695 ;; (define-key global-map [kp-f3] 'function-key-error)
696 ;; (define-key global-map [kp-f4] 'function-key-error)
697 ;; (define-key global-map [kp-multiply] 'function-key-error)
698 ;; (define-key global-map [kp-add] 'function-key-error)
699 ;; (define-key global-map [kp-separator] 'function-key-error)
700 ;; (define-key global-map [kp-subtract] 'function-key-error)
701 ;; (define-key global-map [kp-decimal] 'function-key-error)
702 ;; (define-key global-map [kp-divide] 'function-key-error)
703 ;; (define-key global-map [kp-0] 'function-key-error)
704 ;; (define-key global-map [kp-1] 'function-key-error)
705 ;; (define-key global-map [kp-2] 'function-key-error)
706 ;; (define-key global-map [kp-3] 'function-key-error)
707 ;; (define-key global-map [kp-4] 'function-key-error)
708 ;; (define-key global-map [kp-5] 'recenter)
709 ;; (define-key global-map [kp-6] 'function-key-error)
710 ;; (define-key global-map [kp-7] 'function-key-error)
711 ;; (define-key global-map [kp-8] 'function-key-error)
712 ;; (define-key global-map [kp-9] 'function-key-error)
713 ;; (define-key global-map [kp-equal] 'function-key-error)
715 ;; X11R6 distinguishes these keys from the non-kp keys.
716 ;; Make them behave like the non-kp keys unless otherwise bound.
717 (define-key function-key-map [kp-home] [home])
718 (define-key function-key-map [kp-left] [left])
719 (define-key function-key-map [kp-up] [up])
720 (define-key function-key-map [kp-right] [right])
721 (define-key function-key-map [kp-down] [down])
722 (define-key function-key-map [kp-prior] [prior])
723 (define-key function-key-map [kp-next] [next])
724 (define-key function-key-map [M-kp-next] [M-next])
725 (define-key function-key-map [kp-end] [end])
726 (define-key function-key-map [kp-begin] [begin])
727 (define-key function-key-map [kp-insert] [insert])
728 (define-key function-key-map [kp-delete] [delete])
730 (define-key global-map [mouse-movement] 'ignore)
732 (define-key global-map "\C-t" 'transpose-chars)
733 (define-key esc-map "t" 'transpose-words)
734 (define-key esc-map "\C-t" 'transpose-sexps)
735 (define-key ctl-x-map "\C-t" 'transpose-lines)
737 (define-key esc-map ";" 'comment-dwim)
738 (define-key esc-map "j" 'comment-indent-new-line)
739 (define-key esc-map "\C-j" 'comment-indent-new-line)
740 (define-key ctl-x-map ";" 'comment-set-column)
741 (define-key ctl-x-map "f" 'set-fill-column)
742 (define-key ctl-x-map "$" 'set-selective-display)
744 (define-key esc-map "@" 'mark-word)
745 (define-key esc-map "f" 'forward-word)
746 (define-key esc-map "b" 'backward-word)
747 (define-key esc-map "d" 'kill-word)
748 (define-key esc-map "\177" 'backward-kill-word)
750 (define-key esc-map "<" 'beginning-of-buffer)
751 (define-key esc-map ">" 'end-of-buffer)
752 (define-key ctl-x-map "h" 'mark-whole-buffer)
753 (define-key esc-map "\\" 'delete-horizontal-space)
755 (defalias 'mode-specific-command-prefix (make-sparse-keymap))
756 (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
757 "Keymap for characters following C-c.")
758 (define-key global-map "\C-c" 'mode-specific-command-prefix)
760 (global-set-key [M-right] 'forward-word)
761 (global-set-key [M-left] 'backward-word)
762 ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
763 (global-set-key [C-right] 'forward-word)
764 (global-set-key [C-left] 'backward-word)
765 ;; This is not quite compatible, but at least is analogous
766 (global-set-key [C-delete] 'backward-kill-word)
767 ;; This is "move to the clipboard", or as close as we come.
768 (global-set-key [S-delete] 'kill-region)
770 (define-key esc-map "\C-f" 'forward-sexp)
771 (define-key esc-map "\C-b" 'backward-sexp)
772 (define-key esc-map "\C-u" 'backward-up-list)
773 (define-key esc-map "\C-@" 'mark-sexp)
774 (define-key esc-map [?\C-\ ] 'mark-sexp)
775 (define-key esc-map "\C-d" 'down-list)
776 (define-key esc-map "\C-k" 'kill-sexp)
777 (define-key global-map [C-M-delete] 'backward-kill-sexp)
778 (define-key global-map [C-M-backspace] 'backward-kill-sexp)
779 (define-key esc-map [C-delete] 'backward-kill-sexp)
780 (define-key esc-map [C-backspace] 'backward-kill-sexp)
781 (define-key esc-map "\C-n" 'forward-list)
782 (define-key esc-map "\C-p" 'backward-list)
783 (define-key esc-map "\C-a" 'beginning-of-defun)
784 (define-key esc-map "\C-e" 'end-of-defun)
785 (define-key esc-map "\C-h" 'mark-defun)
786 (define-key ctl-x-map "nd" 'narrow-to-defun)
787 (define-key esc-map "(" 'insert-parentheses)
788 (define-key esc-map ")" 'move-past-close-and-reindent)
790 (define-key ctl-x-map "\C-e" 'eval-last-sexp)
792 (define-key ctl-x-map "m" 'compose-mail)
793 (define-key ctl-x-4-map "m" 'compose-mail-other-window)
794 (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
796 (define-key ctl-x-map "r\C-@" 'point-to-register)
797 (define-key ctl-x-map [?r ?\C-\ ] 'point-to-register)
798 (define-key ctl-x-map "r " 'point-to-register)
799 (define-key ctl-x-map "rj" 'jump-to-register)
800 (define-key ctl-x-map "rs" 'copy-to-register)
801 (define-key ctl-x-map "rx" 'copy-to-register)
802 (define-key ctl-x-map "ri" 'insert-register)
803 (define-key ctl-x-map "rg" 'insert-register)
804 (define-key ctl-x-map "rr" 'copy-rectangle-to-register)
805 (define-key ctl-x-map "rn" 'number-to-register)
806 (define-key ctl-x-map "r+" 'increment-register)
807 (define-key ctl-x-map "rc" 'clear-rectangle)
808 (define-key ctl-x-map "rk" 'kill-rectangle)
809 (define-key ctl-x-map "rd" 'delete-rectangle)
810 (define-key ctl-x-map "ry" 'yank-rectangle)
811 (define-key ctl-x-map "ro" 'open-rectangle)
812 (define-key ctl-x-map "rt" 'string-rectangle)
813 (define-key ctl-x-map "rw" 'window-configuration-to-register)
814 (define-key ctl-x-map "rf" 'frame-configuration-to-register)
816 ;; These key bindings are deprecated; use the above C-x r map instead.
817 ;; We use these aliases so \[...] will show the C-x r bindings instead.
818 (defalias 'point-to-register-compatibility-binding 'point-to-register)
819 (defalias 'jump-to-register-compatibility-binding 'jump-to-register)
820 (defalias 'copy-to-register-compatibility-binding 'copy-to-register)
821 (defalias 'insert-register-compatibility-binding 'insert-register)
822 (define-key ctl-x-map "/" 'point-to-register-compatibility-binding)
823 (define-key ctl-x-map "j" 'jump-to-register-compatibility-binding)
824 (define-key ctl-x-map "x" 'copy-to-register-compatibility-binding)
825 (define-key ctl-x-map "g" 'insert-register-compatibility-binding)
826 ;; (define-key ctl-x-map "r" 'copy-rectangle-to-register)
828 (define-key esc-map "q" 'fill-paragraph)
829 ;; (define-key esc-map "g" 'fill-region)
830 (define-key ctl-x-map "." 'set-fill-prefix)
832 (define-key esc-map "{" 'backward-paragraph)
833 (define-key esc-map "}" 'forward-paragraph)
834 (define-key esc-map "h" 'mark-paragraph)
835 (define-key esc-map "a" 'backward-sentence)
836 (define-key esc-map "e" 'forward-sentence)
837 (define-key esc-map "k" 'kill-sentence)
838 (define-key ctl-x-map "\177" 'backward-kill-sentence)
840 (define-key ctl-x-map "[" 'backward-page)
841 (define-key ctl-x-map "]" 'forward-page)
842 (define-key ctl-x-map "\C-p" 'mark-page)
843 (define-key ctl-x-map "l" 'count-lines-page)
844 (define-key ctl-x-map "np" 'narrow-to-page)
845 ;; (define-key ctl-x-map "p" 'narrow-to-page)
847 (define-key ctl-x-map "al" 'add-mode-abbrev)
848 (define-key ctl-x-map "a\C-a" 'add-mode-abbrev)
849 (define-key ctl-x-map "ag" 'add-global-abbrev)
850 (define-key ctl-x-map "a+" 'add-mode-abbrev)
851 (define-key ctl-x-map "aig" 'inverse-add-global-abbrev)
852 (define-key ctl-x-map "ail" 'inverse-add-mode-abbrev)
853 ;; (define-key ctl-x-map "a\C-h" 'inverse-add-global-abbrev)
854 (define-key ctl-x-map "a-" 'inverse-add-global-abbrev)
855 (define-key ctl-x-map "ae" 'expand-abbrev)
856 (define-key ctl-x-map "a'" 'expand-abbrev)
857 ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
858 ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
859 ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
860 ;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev)
861 (define-key esc-map "'" 'abbrev-prefix-mark)
862 (define-key ctl-x-map "'" 'expand-abbrev)
864 (define-key ctl-x-map "z" 'repeat)
866 ;;; Don't compile this file; it contains no large function definitions.
867 ;;; Don't look for autoload cookies in this file.
868 ;;; Local Variables:
869 ;;; no-byte-compile: t
870 ;;; no-update-autoloads: t
871 ;;; End:
873 ;;; bindings.el ends here