(rmail-clear-headers): Don't throw an error
[bpt/emacs.git] / lisp / bindings.el
CommitLineData
4d120e8c
RS
1;;; bindings.el --- define standard key bindings and some variables.
2
9ff33afb
DL
3;; Copyright (C) 1985,86,87,92,93,94,95,96,99,2000
4;; Free Software Foundation, Inc.
4d120e8c
RS
5
6;; Maintainer: FSF
7;; Keywords: internal
8
9;; This file is part of GNU Emacs.
10
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.
15
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.
20
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.
25
26;;; Commentary:
27
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
688953b5 37;;; and goes into etc/DOCnnn properly.
4d120e8c
RS
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;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
47
48;;; Code:
49
dfdabcf9
DL
50(defun make-mode-line-mouse2-map (f) "\
51Return a keymap with single entry for mouse-2 on mode line.
52This is defined to run function F with no args in the buffer
53corresponding 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))
64
5e1cddda
DL
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)))
83
dfdabcf9
DL
84(defvar mode-line-mule-info
85 `(""
9ff33afb 86 (current-input-method
5e1cddda
DL
87 (:eval
88 (propertize current-input-method-title
89 'help-echo (concat ,(purecopy "Input method: ")
90 current-input-method
2b4b2add 91 ,(purecopy ". mouse-2 disables, \
5e1cddda
DL
92mouse-3 describes"))
93 'local-map mode-line-input-method-map)))
94 ,(propertize "%Z"
95 'help-echo (purecopy "Coding system information: \
96see M-x describe-coding-system")))
44c034c1
KH
97 "Mode-line control for displaying information of multilingual environment.
98Normally it displays current input method (if any activated) and
99mnemonics 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)
ebc6753f
DL
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)."
106)
f8bce5df
KH
107
108(make-variable-buffer-local 'mode-line-mule-info)
109
688953b5
DL
110(defvar mode-line-buffer-identification (purecopy '("%12b")) "\
111Mode-line control for identifying the buffer being displayed.
4544e9db 112Its default value is (\"%12b\").
4d120e8c
RS
113Major modes that edit things other than ordinary files may change this
114\(e.g. Info, Dired,...)")
115
116(make-variable-buffer-local 'mode-line-buffer-identification)
117
4544e9db
RS
118(defvar mode-line-frame-identification '("-%F "))
119
688953b5
DL
120(defvar mode-line-process nil "\
121Mode-line control for displaying info on process status.
4d120e8c
RS
122Normally nil in most modes, since there is no process to display.")
123
124(make-variable-buffer-local 'mode-line-process)
125
dfdabcf9
DL
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))))
4d120e8c
RS
131 "Mode-line control for displaying whether current buffer is modified.")
132
133(make-variable-buffer-local 'mode-line-modified)
134
135(setq-default mode-line-format
2b4b2add
DL
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))))
4d120e8c
RS
162
163(defvar minor-mode-alist nil "\
164Alist saying how to show minor modes in the mode line.
165Each element looks like (VARIABLE STRING);
166STRING is included in the mode line iff VARIABLE's value is non-nil.
167
168Actually, STRING need not be a string; any possible mode-line element
169is okay. See `mode-line-format'.")
2fa58881 170;; Don't use purecopy here--some people want to change these strings.
dfdabcf9
DL
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")))
4d120e8c 188
688953b5
DL
189(defvar mode-line-buffer-identification-keymap nil "\
190Keymap for what is displayed by `mode-line-buffer-identification'.")
b1dcba7b 191
688953b5
DL
192(defvar mode-line-minor-mode-keymap nil "\
193Keymap for what is displayed by `mode-line-mode-name'.")
b1dcba7b 194
688953b5
DL
195(defvar mode-line-mode-menu-keymap nil "\
196Keymap for mode operations menu in the mode line.")
b1dcba7b 197
688953b5
DL
198(defun mode-line-unbury-buffer () "\
199Switch to the last buffer in the buffer list that is not hidden."
b1dcba7b
GM
200 (interactive)
201 (let ((list (reverse (buffer-list))))
4ac44b4c 202 (while (eq (aref (buffer-name (car list)) 0) ? )
b1dcba7b
GM
203 (setq list (cdr list)))
204 (switch-to-buffer (car list))))
205
688953b5
DL
206(defun mode-line-other-buffer () "\
207Switch to the most recently selected buffer other than the current one."
b1dcba7b
GM
208 (interactive)
209 (switch-to-buffer (other-buffer)))
210
5e1cddda
DL
211(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
212Menu of mode operations in the mode line.")
213
b1dcba7b
GM
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)))))
223
688953b5
DL
224(defun mode-line-mode-name () "\
225Return a string to display in the mode line for the current mode name."
b1dcba7b 226 (let (length (result mode-name))
5e1cddda
DL
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)))
b1dcba7b
GM
240 result))
241
842d2ee9
DL
242(defmacro bound-and-true-p (var)
243 "Return the value of symbol VAR if it is bound, else nil."
ff69e012 244 `(and (boundp (quote ,var)) ,var))
842d2ee9 245
dfdabcf9
DL
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)))
279
5e1cddda
DL
280(defun mode-line-mode-menu (event)
281 (interactive "@e")
282 (x-popup-menu event mode-line-mode-menu))
283
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)
ec9db7a7
GM
295 (setq mode-line-buffer-identification-keymap map))
296
297(defun propertized-buffer-identification (fmt)
298 "Return a list suitable for `mode-line-buffer-identification'.
299FMT is a format specifier such as \"%12b\". This function adds
300text 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 \
5e1cddda 304buffer, mouse-2: prev, M-mouse-2: next, mouse-3: buffer menu")
ec9db7a7
GM
305 'local-map mode-line-buffer-identification-keymap)))
306
307(setq-default mode-line-buffer-identification
308 (propertized-buffer-identification "%12b"))
5e1cddda
DL
309
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))
b1dcba7b 315
4d120e8c
RS
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.
319
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
d34c1b05
RS
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"))
332 (t
ff69e012 333 '(".o" "~" ".bin" ".lbin" ".fasl" ".ufsl"
d34c1b05
RS
334 ".a" ".ln" ".blg" ".bbl")))
335 '(".elc" ".lof"
336 ".glo" ".idx" ".lot"
337 ;; TeX-related
71a92751 338 ".dvi" ".fmt" ".tfm" ".pdf"
c79e04d8
RS
339 ;; Java compiled
340 ".class"
341 ;; Clisp
342 ".fas" ".lib"
343 ;; CMUCL
ff69e012 344 ".x86f" ".sparcf"
d34c1b05
RS
345 ;; Texinfo-related
346 ".toc" ".log" ".aux"
347 ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
348 ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs")))
4d120e8c 349
2b4b2add
DL
350;; Packages should add to this list appropriately when they are
351;; loaded, rather than listing everything here.
4d120e8c
RS
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
c79e04d8 355 file-supersession
4d120e8c
RS
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\\.$"
800c9512 366 "^Cannot switch buffers in a dedicated window$"
cdd4703c
RS
367
368 ;; ediff
369 "^Errors in diff output. Diff output is in "
370 "^Hmm... I don't see an Ediff command around here...$"
371 "^Undocumented command! Type `G' in Ediff Control Panel to drop a note to the Ediff maintainer$"
372 ": This command runs in Ediff Control Buffer only!$"
373 ": Invalid op in ediff-check-version$"
374 "^ediff-shrink-window-C can be used only for merging jobs$"
375 "^Lost difference info on these directories$"
376 "^This command is inapplicable in the present context$"
377 "^This session group has no parent$"
378 "^Can't hide active session, $"
cdd4703c
RS
379 "^Ediff: something wrong--no multiple diffs buffer$"
380 "^Can't make context diff for Session $"
381 "^The patch buffer wasn't found$"
382 "^Aborted$"
383 "^This Ediff session is not part of a session group$"
384 "^No active Ediff sessions or corrupted session registry$"
385 "^No session info in this line$"
386 "^`.*' is not an ordinary file$"
387 "^Patch appears to have failed$"
388 "^Recomputation of differences cancelled$"
389 "^No fine differences in this mode$"
390 "^Lost connection to ancestor buffer...sorry$"
391 "^Not merging with ancestor$"
392 "^Don't know how to toggle read-only in buffer "
393 "Emacs is not running as a window application$"
394 "^This command makes sense only when merging with an ancestor$"
395 "^At end of the difference list$"
396 "^At beginning of the difference list$"
cdd4703c
RS
397 "^Nothing saved for diff .* in buffer "
398 "^Buffer is out of sync for file "
399 "^Buffer out of sync for file "
400 "^Output from `diff' not found$"
401 "^You forgot to specify a region in buffer "
402 "^All right. Make up your mind and come back...$"
403 "^Current buffer is not visiting any file$"
404 "^Failed to retrieve revision: $"
405 "^Can't determine display width.$"
406 "^File `.*' does not exist or is not readable$"
407 "^File `.*' is a directory$"
408 "^Buffer .* doesn't exist$"
409 "^Directories . and . are the same: "
410 "^Directory merge aborted$"
411 "^Merge of directory revisions aborted$"
412 "^Buffer .* doesn't exist$"
413 "^There is no file to merge$"
d8d0fa6c 414 "^Version control package .*.el not found. Use vc.el instead$"))
4d120e8c
RS
415
416
417(make-variable-buffer-local 'indent-tabs-mode)
418
acafa9cf
RS
419;; We have base64 functions built in now.
420(add-to-list 'features 'base64)
421
0094907b
RS
422(define-key esc-map "\t" 'complete-symbol)
423
688953b5
DL
424(defun complete-symbol (arg) "\
425Perform tags completion on the text around point.
4d120e8c
RS
426Completes to the set of names listed in the current tags table.
427The string to complete is chosen in the same way as the default
364581dc
RS
428for \\[find-tag] (which see).
429
430With a prefix argument, this command does completion within
431the collection of symbols listed in the index of the manual for the
432language you are using."
0094907b
RS
433 (interactive "P")
434 (if arg
364581dc
RS
435 (info-complete-symbol)
436 (if (fboundp 'complete-tag)
437 (complete-tag)
438 ;; Don't autoload etags if we have no tags table.
439 (error (substitute-command-keys
440 "No tags table loaded; use \\[visit-tags-table] to load one")))))
4d120e8c
RS
441
442;; Reduce total amount of space we must allocate during this function
443;; that we will not need to keep permanently.
444(garbage-collect)
445\f
d92921c3
KH
446;; Make all multibyte characters self-insert.
447(let ((l (generic-character-list))
448 (table (nth 1 global-map)))
449 (while l
450 (set-char-table-default table (car l) 'self-insert-command)
451 (setq l (cdr l))))
3607b64d 452
4d120e8c
RS
453(setq help-event-list '(help f1))
454
97710114
RS
455(make-variable-buffer-local 'minor-mode-overriding-map-alist)
456
4d120e8c
RS
457;These commands are defined in editfns.c
458;but they are not assigned to keys there.
459(put 'narrow-to-region 'disabled t)
460(define-key ctl-x-map "nn" 'narrow-to-region)
461(define-key ctl-x-map "nw" 'widen)
462;; (define-key ctl-x-map "n" 'narrow-to-region)
463;; (define-key ctl-x-map "w" 'widen)
464
465(define-key global-map "\C-j" 'newline-and-indent)
466(define-key global-map "\C-m" 'newline)
467(define-key global-map "\C-o" 'open-line)
468(define-key esc-map "\C-o" 'split-line)
469(define-key global-map "\C-q" 'quoted-insert)
470(define-key esc-map "^" 'delete-indentation)
471(define-key esc-map "\\" 'delete-horizontal-space)
472(define-key esc-map "m" 'back-to-indentation)
473(define-key ctl-x-map "\C-o" 'delete-blank-lines)
474(define-key esc-map " " 'just-one-space)
475(define-key esc-map "z" 'zap-to-char)
476(define-key esc-map "=" 'count-lines-region)
477(define-key ctl-x-map "=" 'what-cursor-position)
478(define-key esc-map ":" 'eval-expression)
479;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
480(define-key esc-map "\M-:" 'eval-expression)
481;; Changed from C-x ESC so that function keys work following C-x.
482(define-key ctl-x-map "\e\e" 'repeat-complex-command)
483;; New binding analogous to M-:.
484(define-key ctl-x-map "\M-:" 'repeat-complex-command)
485(define-key ctl-x-map "u" 'advertised-undo)
486;; Many people are used to typing C-/ on X terminals and getting C-_.
487(define-key global-map [?\C-/] 'undo)
488(define-key global-map "\C-_" 'undo)
489(define-key esc-map "!" 'shell-command)
490(define-key esc-map "|" 'shell-command-on-region)
491
492;; This is an experiment--make up and down arrows do history.
493(define-key minibuffer-local-map [up] 'previous-history-element)
494(define-key minibuffer-local-map [down] 'next-history-element)
495(define-key minibuffer-local-ns-map [up] 'previous-history-element)
496(define-key minibuffer-local-ns-map [down] 'next-history-element)
497(define-key minibuffer-local-completion-map [up] 'previous-history-element)
498(define-key minibuffer-local-completion-map [down] 'next-history-element)
499(define-key minibuffer-local-must-match-map [up] 'previous-history-element)
500(define-key minibuffer-local-must-match-map [down] 'next-history-element)
501
502(define-key global-map "\C-u" 'universal-argument)
503(let ((i ?0))
504 (while (<= i ?9)
505 (define-key esc-map (char-to-string i) 'digit-argument)
506 (setq i (1+ i))))
507(define-key esc-map "-" 'negative-argument)
508;; Define control-digits.
509(let ((i ?0))
510 (while (<= i ?9)
511 (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
512 (setq i (1+ i))))
513(define-key global-map [?\C--] 'negative-argument)
514;; Define control-meta-digits.
515(let ((i ?0))
516 (while (<= i ?9)
517 (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
518 (setq i (1+ i))))
519(define-key global-map [?\C-\M--] 'negative-argument)
520
521(define-key global-map "\C-k" 'kill-line)
522(define-key global-map "\C-w" 'kill-region)
523(define-key esc-map "w" 'kill-ring-save)
524(define-key esc-map "\C-w" 'append-next-kill)
525(define-key global-map "\C-y" 'yank)
526(define-key esc-map "y" 'yank-pop)
527
528;; (define-key ctl-x-map "a" 'append-to-buffer)
529
530(define-key global-map "\C-@" 'set-mark-command)
531;; Many people are used to typing C-SPC and getting C-@.
e68e61b5 532(define-key global-map [?\C- ] 'set-mark-command)
4d120e8c
RS
533(define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
534(define-key ctl-x-map "\C-@" 'pop-global-mark)
e68e61b5 535(define-key ctl-x-map [?\C- ] 'pop-global-mark)
4d120e8c
RS
536
537(define-key global-map "\C-n" 'next-line)
538(define-key global-map "\C-p" 'previous-line)
539(define-key ctl-x-map "\C-n" 'set-goal-column)
540
541;;(defun function-key-error ()
542;; (interactive)
543;; (error "That function key is not bound to anything."))
544
545(define-key global-map [menu] 'execute-extended-command)
546(define-key global-map [find] 'search-forward)
547
548;; natural bindings for terminal keycaps --- defined in X keysym order
549(define-key global-map [home] 'beginning-of-buffer)
550(define-key global-map [M-home] 'beginning-of-buffer-other-window)
551(define-key global-map [left] 'backward-char)
552(define-key global-map [up] 'previous-line)
553(define-key global-map [right] 'forward-char)
554(define-key global-map [down] 'next-line)
555(define-key global-map [prior] 'scroll-down)
556(define-key global-map [next] 'scroll-up)
557(define-key global-map [C-up] 'backward-paragraph)
558(define-key global-map [C-down] 'forward-paragraph)
559(define-key global-map [C-prior] 'scroll-right)
560(define-key global-map [C-next] 'scroll-left)
561(define-key global-map [M-next] 'scroll-other-window)
562(define-key global-map [M-prior] 'scroll-other-window-down)
563(define-key global-map [end] 'end-of-buffer)
564(define-key global-map [M-end] 'end-of-buffer-other-window)
565(define-key global-map [begin] 'beginning-of-buffer)
566(define-key global-map [M-begin] 'beginning-of-buffer-other-window)
567;; (define-key global-map [select] 'function-key-error)
568;; (define-key global-map [print] 'function-key-error)
569(define-key global-map [execute] 'execute-extended-command)
570(define-key global-map [insert] 'overwrite-mode)
571(define-key global-map [C-insert] 'kill-ring-save)
572(define-key global-map [S-insert] 'yank)
573(define-key global-map [undo] 'undo)
574(define-key global-map [redo] 'repeat-complex-command)
575;; (define-key global-map [clearline] 'function-key-error)
576(define-key global-map [insertline] 'open-line)
577(define-key global-map [deleteline] 'kill-line)
578;; (define-key global-map [insertchar] 'function-key-error)
579(define-key global-map [deletechar] 'delete-char)
580;; (define-key global-map [backtab] 'function-key-error)
581;; (define-key global-map [f1] 'function-key-error)
582;; (define-key global-map [f2] 'function-key-error)
583;; (define-key global-map [f3] 'function-key-error)
584;; (define-key global-map [f4] 'function-key-error)
585;; (define-key global-map [f5] 'function-key-error)
586;; (define-key global-map [f6] 'function-key-error)
587;; (define-key global-map [f7] 'function-key-error)
588;; (define-key global-map [f8] 'function-key-error)
589;; (define-key global-map [f9] 'function-key-error)
590;; (define-key global-map [f10] 'function-key-error)
591;; (define-key global-map [f11] 'function-key-error)
592;; (define-key global-map [f12] 'function-key-error)
593;; (define-key global-map [f13] 'function-key-error)
594;; (define-key global-map [f14] 'function-key-error)
595;; (define-key global-map [f15] 'function-key-error)
596;; (define-key global-map [f16] 'function-key-error)
597;; (define-key global-map [f17] 'function-key-error)
598;; (define-key global-map [f18] 'function-key-error)
599;; (define-key global-map [f19] 'function-key-error)
600;; (define-key global-map [f20] 'function-key-error)
601;; (define-key global-map [f21] 'function-key-error)
602;; (define-key global-map [f22] 'function-key-error)
603;; (define-key global-map [f23] 'function-key-error)
604;; (define-key global-map [f24] 'function-key-error)
605;; (define-key global-map [f25] 'function-key-error)
606;; (define-key global-map [f26] 'function-key-error)
607;; (define-key global-map [f27] 'function-key-error)
608;; (define-key global-map [f28] 'function-key-error)
609;; (define-key global-map [f29] 'function-key-error)
610;; (define-key global-map [f30] 'function-key-error)
611;; (define-key global-map [f31] 'function-key-error)
612;; (define-key global-map [f32] 'function-key-error)
613;; (define-key global-map [f33] 'function-key-error)
614;; (define-key global-map [f34] 'function-key-error)
615;; (define-key global-map [f35] 'function-key-error)
616;; (define-key global-map [kp-backtab] 'function-key-error)
617;; (define-key global-map [kp-space] 'function-key-error)
618;; (define-key global-map [kp-tab] 'function-key-error)
619;; (define-key global-map [kp-enter] 'function-key-error)
620;; (define-key global-map [kp-f1] 'function-key-error)
621;; (define-key global-map [kp-f2] 'function-key-error)
622;; (define-key global-map [kp-f3] 'function-key-error)
623;; (define-key global-map [kp-f4] 'function-key-error)
624;; (define-key global-map [kp-multiply] 'function-key-error)
625;; (define-key global-map [kp-add] 'function-key-error)
626;; (define-key global-map [kp-separator] 'function-key-error)
627;; (define-key global-map [kp-subtract] 'function-key-error)
628;; (define-key global-map [kp-decimal] 'function-key-error)
629;; (define-key global-map [kp-divide] 'function-key-error)
630;; (define-key global-map [kp-0] 'function-key-error)
631;; (define-key global-map [kp-1] 'function-key-error)
632;; (define-key global-map [kp-2] 'function-key-error)
633;; (define-key global-map [kp-3] 'function-key-error)
634;; (define-key global-map [kp-4] 'function-key-error)
635;; (define-key global-map [kp-5] 'recenter)
636;; (define-key global-map [kp-6] 'function-key-error)
637;; (define-key global-map [kp-7] 'function-key-error)
638;; (define-key global-map [kp-8] 'function-key-error)
639;; (define-key global-map [kp-9] 'function-key-error)
640;; (define-key global-map [kp-equal] 'function-key-error)
641
642;; X11R6 distinguishes these keys from the non-kp keys.
643;; Make them behave like the non-kp keys unless otherwise bound.
644(define-key function-key-map [kp-home] [home])
645(define-key function-key-map [kp-left] [left])
646(define-key function-key-map [kp-up] [up])
647(define-key function-key-map [kp-right] [right])
648(define-key function-key-map [kp-down] [down])
649(define-key function-key-map [kp-prior] [prior])
650(define-key function-key-map [kp-next] [next])
651(define-key function-key-map [M-kp-next] [M-next])
652(define-key function-key-map [kp-end] [end])
653(define-key function-key-map [kp-begin] [begin])
654(define-key function-key-map [kp-insert] [insert])
655(define-key function-key-map [kp-delete] [delete])
656
657(define-key global-map [mouse-movement] 'ignore)
658
659(define-key global-map "\C-t" 'transpose-chars)
660(define-key esc-map "t" 'transpose-words)
661(define-key esc-map "\C-t" 'transpose-sexps)
662(define-key ctl-x-map "\C-t" 'transpose-lines)
663
5589b330
SM
664(define-key esc-map ";" 'comment-dwim)
665(define-key esc-map "j" 'comment-indent-new-line)
666(define-key esc-map "\C-j" 'comment-indent-new-line)
667(define-key ctl-x-map ";" 'comment-set-column)
4d120e8c
RS
668(define-key ctl-x-map "f" 'set-fill-column)
669(define-key ctl-x-map "$" 'set-selective-display)
670
671(define-key esc-map "@" 'mark-word)
672(define-key esc-map "f" 'forward-word)
673(define-key esc-map "b" 'backward-word)
674(define-key esc-map "d" 'kill-word)
675(define-key esc-map "\177" 'backward-kill-word)
676
677(define-key esc-map "<" 'beginning-of-buffer)
678(define-key esc-map ">" 'end-of-buffer)
679(define-key ctl-x-map "h" 'mark-whole-buffer)
680(define-key esc-map "\\" 'delete-horizontal-space)
681
682(defalias 'mode-specific-command-prefix (make-sparse-keymap))
4b189189 683(defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
4d120e8c
RS
684 "Keymap for characters following C-c.")
685(define-key global-map "\C-c" 'mode-specific-command-prefix)
686
687(global-set-key [M-right] 'forward-word)
688(global-set-key [M-left] 'backward-word)
689;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
690(global-set-key [C-right] 'forward-word)
691(global-set-key [C-left] 'backward-word)
692;; This is not quite compatible, but at least is analogous
693(global-set-key [C-delete] 'backward-kill-word)
694;; This is "move to the clipboard", or as close as we come.
695(global-set-key [S-delete] 'kill-region)
696
697(define-key esc-map "\C-f" 'forward-sexp)
698(define-key esc-map "\C-b" 'backward-sexp)
699(define-key esc-map "\C-u" 'backward-up-list)
700(define-key esc-map "\C-@" 'mark-sexp)
701(define-key esc-map [?\C-\ ] 'mark-sexp)
702(define-key esc-map "\C-d" 'down-list)
703(define-key esc-map "\C-k" 'kill-sexp)
704(define-key global-map [C-M-delete] 'backward-kill-sexp)
705(define-key global-map [C-M-backspace] 'backward-kill-sexp)
706(define-key esc-map "\C-n" 'forward-list)
707(define-key esc-map "\C-p" 'backward-list)
708(define-key esc-map "\C-a" 'beginning-of-defun)
709(define-key esc-map "\C-e" 'end-of-defun)
710(define-key esc-map "\C-h" 'mark-defun)
711(define-key ctl-x-map "nd" 'narrow-to-defun)
712(define-key esc-map "(" 'insert-parentheses)
713(define-key esc-map ")" 'move-past-close-and-reindent)
4d120e8c
RS
714
715(define-key ctl-x-map "\C-e" 'eval-last-sexp)
6d64bc9f
RS
716
717(define-key ctl-x-map "m" 'compose-mail)
718(define-key ctl-x-4-map "m" 'compose-mail-other-window)
719(define-key ctl-x-5-map "m" 'compose-mail-other-frame)
4d120e8c
RS
720\f
721(define-key ctl-x-map "r\C-@" 'point-to-register)
722(define-key ctl-x-map [?r ?\C-\ ] 'point-to-register)
723(define-key ctl-x-map "r " 'point-to-register)
724(define-key ctl-x-map "rj" 'jump-to-register)
725(define-key ctl-x-map "rs" 'copy-to-register)
726(define-key ctl-x-map "rx" 'copy-to-register)
727(define-key ctl-x-map "ri" 'insert-register)
728(define-key ctl-x-map "rg" 'insert-register)
729(define-key ctl-x-map "rr" 'copy-rectangle-to-register)
bdb45de9
KH
730(define-key ctl-x-map "rn" 'number-to-register)
731(define-key ctl-x-map "r+" 'increment-register)
4d120e8c
RS
732(define-key ctl-x-map "rc" 'clear-rectangle)
733(define-key ctl-x-map "rk" 'kill-rectangle)
734(define-key ctl-x-map "rd" 'delete-rectangle)
735(define-key ctl-x-map "ry" 'yank-rectangle)
736(define-key ctl-x-map "ro" 'open-rectangle)
737(define-key ctl-x-map "rt" 'string-rectangle)
738(define-key ctl-x-map "rw" 'window-configuration-to-register)
739(define-key ctl-x-map "rf" 'frame-configuration-to-register)
740
741;; These key bindings are deprecated; use the above C-x r map instead.
742;; We use these aliases so \[...] will show the C-x r bindings instead.
743(defalias 'point-to-register-compatibility-binding 'point-to-register)
744(defalias 'jump-to-register-compatibility-binding 'jump-to-register)
745(defalias 'copy-to-register-compatibility-binding 'copy-to-register)
746(defalias 'insert-register-compatibility-binding 'insert-register)
747(define-key ctl-x-map "/" 'point-to-register-compatibility-binding)
748(define-key ctl-x-map "j" 'jump-to-register-compatibility-binding)
749(define-key ctl-x-map "x" 'copy-to-register-compatibility-binding)
750(define-key ctl-x-map "g" 'insert-register-compatibility-binding)
751;; (define-key ctl-x-map "r" 'copy-rectangle-to-register)
752
753(define-key esc-map "q" 'fill-paragraph)
754;; (define-key esc-map "g" 'fill-region)
755(define-key ctl-x-map "." 'set-fill-prefix)
756\f
757(define-key esc-map "{" 'backward-paragraph)
758(define-key esc-map "}" 'forward-paragraph)
759(define-key esc-map "h" 'mark-paragraph)
760(define-key esc-map "a" 'backward-sentence)
761(define-key esc-map "e" 'forward-sentence)
762(define-key esc-map "k" 'kill-sentence)
763(define-key ctl-x-map "\177" 'backward-kill-sentence)
764
765(define-key ctl-x-map "[" 'backward-page)
766(define-key ctl-x-map "]" 'forward-page)
767(define-key ctl-x-map "\C-p" 'mark-page)
768(define-key ctl-x-map "l" 'count-lines-page)
769(define-key ctl-x-map "np" 'narrow-to-page)
770;; (define-key ctl-x-map "p" 'narrow-to-page)
771\f
772(define-key ctl-x-map "al" 'add-mode-abbrev)
773(define-key ctl-x-map "a\C-a" 'add-mode-abbrev)
774(define-key ctl-x-map "ag" 'add-global-abbrev)
775(define-key ctl-x-map "a+" 'add-mode-abbrev)
776(define-key ctl-x-map "aig" 'inverse-add-global-abbrev)
777(define-key ctl-x-map "ail" 'inverse-add-mode-abbrev)
778;; (define-key ctl-x-map "a\C-h" 'inverse-add-global-abbrev)
779(define-key ctl-x-map "a-" 'inverse-add-global-abbrev)
780(define-key ctl-x-map "ae" 'expand-abbrev)
781(define-key ctl-x-map "a'" 'expand-abbrev)
782;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
783;; (define-key ctl-x-map "\+" 'add-global-abbrev)
784;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
785;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev)
786(define-key esc-map "'" 'abbrev-prefix-mark)
787(define-key ctl-x-map "'" 'expand-abbrev)
788
aa5ba90e 789(define-key ctl-x-map "z" 'repeat)
e4ade21b 790
4d120e8c
RS
791;;; Don't compile this file; it contains no large function definitions.
792;;; Don't look for autoload cookies in this file.
793;;; Local Variables:
794;;; no-byte-compile: t
795;;; no-update-autoloads: t
796;;; End:
797
798;;; bindings.el ends here