]> code.delx.au - gnu-emacs/blob - lisp/bindings.el
Merge changes from emacs-23 branch
[gnu-emacs] / lisp / bindings.el
1 ;;; bindings.el --- define standard key bindings and some variables
2
3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994, 1995, 1996, 1999,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 ;; Free Software Foundation, Inc.
6
7 ;; Maintainer: FSF
8 ;; Keywords: internal
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (defun make-mode-line-mouse-map (mouse function) "\
30 Return a keymap with single entry for mouse key MOUSE on the mode line.
31 MOUSE is defined to run function FUNCTION with no args in the buffer
32 corresponding to the mode line clicked."
33 (let ((map (make-sparse-keymap)))
34 (define-key map (vector 'mode-line mouse) function)
35 map))
36
37
38 (defun mode-line-toggle-read-only (event)
39 "Like `toggle-read-only', for the mode-line."
40 (interactive "e")
41 (save-selected-window
42 (select-window (posn-window (event-start event)))
43 (toggle-read-only)
44 (force-mode-line-update)))
45
46
47 (defun mode-line-toggle-modified (event)
48 "Toggle the buffer-modified flag from the mode-line."
49 (interactive "e")
50 (save-selected-window
51 (select-window (posn-window (event-start event)))
52 (set-buffer-modified-p (not (buffer-modified-p)))
53 (force-mode-line-update)))
54
55
56 (defun mode-line-widen (event)
57 "Widen a buffer from the mode-line."
58 (interactive "e")
59 (save-selected-window
60 (select-window (posn-window (event-start event)))
61 (widen)
62 (force-mode-line-update)))
63
64
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
84
85 (defvar mode-line-coding-system-map
86 (let ((map (make-sparse-keymap)))
87 (define-key map [mode-line mouse-1]
88 (lambda (e)
89 (interactive "e")
90 (save-selected-window
91 (select-window (posn-window (event-start e)))
92 (when (and enable-multibyte-characters
93 buffer-file-coding-system)
94 (describe-coding-system buffer-file-coding-system)))))
95 (purecopy map))
96 "Local keymap for the coding-system part of the mode line.")
97
98
99 (defun mode-line-change-eol (event)
100 "Cycle through the various possible kinds of end-of-line styles."
101 (interactive "e")
102 (with-selected-window (posn-window (event-start event))
103 (let ((eol (coding-system-eol-type buffer-file-coding-system)))
104 (set-buffer-file-coding-system
105 (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix))))))
106
107 (defvar mode-line-eol-desc-cache nil)
108
109 (defun mode-line-eol-desc ()
110 (let* ((eol (coding-system-eol-type buffer-file-coding-system))
111 (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system))
112 (desc (assoc eol mode-line-eol-desc-cache)))
113 (if (and desc (eq (cadr desc) mnemonic))
114 (cddr desc)
115 (if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale.
116 (setq desc
117 (propertize
118 mnemonic
119 'help-echo (format "End-of-line style: %s\nmouse-1 to cycle"
120 (if (eq eol 0) "Unix-style LF"
121 (if (eq eol 1) "DOS-style CRLF"
122 (if (eq eol 2) "Mac-style CR"
123 "Undecided"))))
124 'keymap
125 (eval-when-compile
126 (let ((map (make-sparse-keymap)))
127 (define-key map [mode-line mouse-1] 'mode-line-change-eol)
128 map))
129 'mouse-face 'mode-line-highlight))
130 (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache)
131 desc)))
132
133 (defvar mode-line-client
134 `(""
135 (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" "")))
136 help-echo ,(purecopy "emacsclient frame")))
137 "Mode-line control for identifying emacsclient frames.")
138 ;;;###autoload
139 (put 'mode-line-client 'risky-local-variable t)
140
141 (defvar mode-line-mule-info
142 `(""
143 (current-input-method
144 (:propertize ("" current-input-method-title)
145 help-echo (concat
146 ,(purecopy "Current input method: ")
147 current-input-method
148 ,(purecopy "\n\
149 mouse-2: Disable input method\n\
150 mouse-3: Describe current input method"))
151 local-map ,mode-line-input-method-map
152 mouse-face mode-line-highlight))
153 ,(propertize
154 "%z"
155 'help-echo
156 #'(lambda (window object point)
157 (with-current-buffer (window-buffer window)
158 ;; Don't show this tip if the coding system is nil,
159 ;; it reads like a bug, and is not useful anyway.
160 (when buffer-file-coding-system
161 (format "Buffer coding system %s\nmouse-1: describe coding system"
162 (if enable-multibyte-characters
163 (concat "(multi-byte): "
164 (symbol-name buffer-file-coding-system))
165 (concat "(unibyte): "
166 (symbol-name buffer-file-coding-system)))))))
167 'mouse-face 'mode-line-highlight
168 'local-map mode-line-coding-system-map)
169 (:eval (mode-line-eol-desc)))
170 "Mode-line control for displaying information of multilingual environment.
171 Normally it displays current input method (if any activated) and
172 mnemonics of the following coding systems:
173 coding system for saving or writing the current buffer
174 coding system for keyboard input (if Emacs is running on terminal)
175 coding system for terminal output (if Emacs is running on terminal)"
176 ;; Currently not:
177 ;; coding system for decoding output of buffer process (if any)
178 ;; coding system for encoding text to send to buffer process (if any)."
179 )
180
181 ;;;###autoload
182 (put 'mode-line-mule-info 'risky-local-variable t)
183 (make-variable-buffer-local 'mode-line-mule-info)
184
185 ;; MSDOS frames have window-system, but want the Fn identification.
186 (defun mode-line-frame-control ()
187 "Compute mode-line control for frame identification.
188 Value is used for `mode-line-frame-identification', which see."
189 (if (or (null window-system)
190 (eq window-system 'pc))
191 "-%F "
192 " "))
193
194 ;; We need to defer the call to mode-line-frame-control to the time
195 ;; the mode line is actually displayed.
196 (defvar mode-line-frame-identification '(:eval (mode-line-frame-control))
197 "Mode-line control to describe the current frame.")
198 ;;;###autoload
199 (put 'mode-line-frame-identification 'risky-local-variable t)
200
201 (defvar mode-line-process nil "\
202 Mode-line control for displaying info on process status.
203 Normally nil in most modes, since there is no process to display.")
204
205 ;;;###autoload
206 (put 'mode-line-process 'risky-local-variable t)
207 (make-variable-buffer-local 'mode-line-process)
208
209 (defvar mode-line-modified
210 (list (propertize
211 "%1*"
212 'help-echo (purecopy (lambda (window object point)
213 (format "Buffer is %s\nmouse-1 toggles"
214 (save-selected-window
215 (select-window window)
216 (if buffer-read-only
217 "read-only"
218 "writable")))))
219 'local-map (purecopy (make-mode-line-mouse-map
220 'mouse-1
221 #'mode-line-toggle-read-only))
222 'mouse-face 'mode-line-highlight)
223 (propertize
224 "%1+"
225 'help-echo (purecopy (lambda (window object point)
226 (format "Buffer is %sodified\nmouse-1 toggles modified state"
227 (save-selected-window
228 (select-window window)
229 (if (buffer-modified-p)
230 "m"
231 "not m")))))
232 'local-map (purecopy (make-mode-line-mouse-map
233 'mouse-1 #'mode-line-toggle-modified))
234 'mouse-face 'mode-line-highlight))
235 "Mode-line control for displaying whether current buffer is modified.")
236
237 ;;;###autoload
238 (put 'mode-line-modified 'risky-local-variable t)
239 (make-variable-buffer-local 'mode-line-modified)
240
241 (defvar mode-line-remote
242 (list (propertize
243 "%1@"
244 'mouse-face 'mode-line-highlight
245 'help-echo (purecopy (lambda (window object point)
246 (format "%s"
247 (save-selected-window
248 (select-window window)
249 (concat
250 (if (file-remote-p default-directory)
251 "Current directory is remote: "
252 "Current directory is local: ")
253 default-directory)))))))
254 "Mode-line flag to show if default-directory for current buffer is remote.")
255 ;;;###autoload
256 (put 'mode-line-remote 'risky-local-variable t)
257
258 (make-variable-buffer-local 'mode-line-remote)
259
260 ;; Actual initialization is below.
261 (defvar mode-line-position nil
262 "Mode-line control for displaying the position in the buffer.
263 Normally displays the buffer percentage and, optionally, the
264 buffer size, the line number and the column number.")
265 ;;;###autoload
266 (put 'mode-line-position 'risky-local-variable t)
267
268 (defvar mode-line-modes nil
269 "Mode-line control for displaying major and minor modes.")
270 ;;;###autoload
271 (put 'mode-line-modes 'risky-local-variable t)
272
273 (defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
274 Menu of mode operations in the mode line.")
275
276 (defvar mode-line-major-mode-keymap
277 (let ((map (make-sparse-keymap)))
278 (define-key map [mode-line down-mouse-1]
279 `(menu-item ,(purecopy "Menu Bar") ignore
280 :filter (lambda (_) (mouse-menu-major-mode-map))))
281 (define-key map [mode-line mouse-2] 'describe-mode)
282 (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
283 map) "\
284 Keymap to display on major mode.")
285
286 (defvar mode-line-minor-mode-keymap
287 (let ((map (make-sparse-keymap)))
288 (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu)
289 (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
290 (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
291 (define-key map [header-line down-mouse-3] mode-line-mode-menu)
292 map) "\
293 Keymap to display on minor modes.")
294
295 (defvar mode-line-column-line-number-mode-map
296 (let ((map (make-sparse-keymap))
297 (menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
298 (define-key menu-map [line-number-mode]
299 `(menu-item ,(purecopy "Display Line Numbers") line-number-mode
300 :help ,(purecopy "Toggle displaying line numbers in the mode-line")
301 :button (:toggle . line-number-mode)))
302 (define-key menu-map [column-number-mode]
303 `(menu-item ,(purecopy "Display Column Numbers") column-number-mode
304 :help ,(purecopy "Toggle displaying column numbers in the mode-line")
305 :button (:toggle . column-number-mode)))
306 (define-key map [mode-line down-mouse-1] menu-map)
307 map) "\
308 Keymap to display on column and line numbers.")
309
310 (let* ((help-echo
311 ;; The multi-line message doesn't work terribly well on the
312 ;; bottom mode line... Better ideas?
313 ;; "\
314 ;; mouse-1: select window, mouse-2: delete others, mouse-3: delete,
315 ;; drag-mouse-1: resize, C-mouse-2: split horizontally"
316 "mouse-1: Select (drag to resize)\n\
317 mouse-2: Make current window occupy the whole frame\n\
318 mouse-3: Remove current window from display")
319 (recursive-edit-help-echo "Recursive edit, type C-M-c to get out")
320 (dashes (propertize "--" 'help-echo help-echo))
321 (standard-mode-line-format
322 (list
323 "%e"
324 (propertize "-" 'help-echo help-echo)
325 'mode-line-mule-info
326 'mode-line-client
327 'mode-line-modified
328 'mode-line-remote
329 'mode-line-frame-identification
330 'mode-line-buffer-identification
331 (propertize " " 'help-echo help-echo)
332 'mode-line-position
333 '(vc-mode vc-mode)
334 (propertize " " 'help-echo help-echo)
335 'mode-line-modes
336 `(which-func-mode ("" which-func-format ,dashes))
337 `(global-mode-string ("" global-mode-string ,dashes))
338 (propertize "-%-" 'help-echo help-echo)))
339 (standard-mode-line-modes
340 (list
341 (propertize "%[" 'help-echo recursive-edit-help-echo)
342 (propertize "(" 'help-echo help-echo)
343 `(:propertize ("" mode-name)
344 help-echo "Major mode\n\
345 mouse-1: Display major mode menu\n\
346 mouse-2: Show help for major mode\n\
347 mouse-3: Toggle minor modes"
348 mouse-face mode-line-highlight
349 local-map ,mode-line-major-mode-keymap)
350 '("" mode-line-process)
351 `(:propertize ("" minor-mode-alist)
352 mouse-face mode-line-highlight
353 help-echo "Minor mode\n\
354 mouse-1: Display minor mode menu\n\
355 mouse-2: Show help for minor mode\n\
356 mouse-3: Toggle minor modes"
357 local-map ,mode-line-minor-mode-keymap)
358 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from the current buffer"
359 'mouse-face 'mode-line-highlight
360 'local-map (make-mode-line-mouse-map
361 'mouse-2 #'mode-line-widen))
362 (propertize ")" 'help-echo help-echo)
363 (propertize "%]" 'help-echo recursive-edit-help-echo)
364 (propertize "--" 'help-echo help-echo)))
365
366 (standard-mode-line-position
367 `((-3 ,(propertize
368 "%p"
369 'local-map mode-line-column-line-number-mode-map
370 'mouse-face 'mode-line-highlight
371 ;; XXX needs better description
372 'help-echo "Size indication mode\n\
373 mouse-1: Display Line and Column Mode Menu"))
374 (size-indication-mode
375 (8 ,(propertize
376 " of %I"
377 'local-map mode-line-column-line-number-mode-map
378 'mouse-face 'mode-line-highlight
379 ;; XXX needs better description
380 'help-echo "Size indication mode\n\
381 mouse-1: Display Line and Column Mode Menu")))
382 (line-number-mode
383 ((column-number-mode
384 (10 ,(propertize
385 " (%l,%c)"
386 'local-map mode-line-column-line-number-mode-map
387 'mouse-face 'mode-line-highlight
388 'help-echo "Line number and Column number\n\
389 mouse-1: Display Line and Column Mode Menu"))
390 (6 ,(propertize
391 " L%l"
392 'local-map mode-line-column-line-number-mode-map
393 'mouse-face 'mode-line-highlight
394 'help-echo "Line Number\n\
395 mouse-1: Display Line and Column Mode Menu"))))
396 ((column-number-mode
397 (5 ,(propertize
398 " C%c"
399 'local-map mode-line-column-line-number-mode-map
400 'mouse-face 'mode-line-highlight
401 'help-echo "Column number\n\
402 mouse-1: Display Line and Column Mode Menu"))))))))
403
404 (setq-default mode-line-format standard-mode-line-format)
405 (put 'mode-line-format 'standard-value
406 (list `(quote ,standard-mode-line-format)))
407
408 (setq-default mode-line-modes standard-mode-line-modes)
409 (put 'mode-line-modes 'standard-value
410 (list `(quote ,standard-mode-line-modes)))
411
412 (setq-default mode-line-position standard-mode-line-position)
413 (put 'mode-line-position 'standard-value
414 (list `(quote ,standard-mode-line-position))))
415
416 (defvar mode-line-buffer-identification-keymap
417 ;; Add menu of buffer operations to the buffer identification part
418 ;; of the mode line.or header line.
419 (let ((map (make-sparse-keymap)))
420 ;; Bind down- events so that the global keymap won't ``shine
421 ;; through''.
422 (define-key map [mode-line mouse-1] 'mode-line-previous-buffer)
423 (define-key map [header-line down-mouse-1] 'ignore)
424 (define-key map [header-line mouse-1] 'mode-line-previous-buffer)
425 (define-key map [mode-line mouse-3] 'mode-line-next-buffer)
426 (define-key map [header-line down-mouse-3] 'ignore)
427 (define-key map [header-line mouse-3] 'mode-line-next-buffer)
428 map) "\
429 Keymap for what is displayed by `mode-line-buffer-identification'.")
430
431 (defun propertized-buffer-identification (fmt)
432 "Return a list suitable for `mode-line-buffer-identification'.
433 FMT is a format specifier such as \"%12b\". This function adds
434 text properties for face, help-echo, and local-map to it."
435 (list (propertize fmt
436 'face 'mode-line-buffer-id
437 'help-echo
438 (purecopy "Buffer name\n\
439 mouse-1: previous buffer\n\
440 mouse-3: next buffer")
441 'mouse-face 'mode-line-highlight
442 'local-map mode-line-buffer-identification-keymap)))
443
444 (defvar mode-line-buffer-identification (propertized-buffer-identification "%12b") "\
445 Mode-line control for identifying the buffer being displayed.
446 Its default value is (\"%12b\") with some text properties added.
447 Major modes that edit things other than ordinary files may change this
448 \(e.g. Info, Dired,...)")
449
450 ;;;###autoload
451 (put 'mode-line-buffer-identification 'risky-local-variable t)
452 (make-variable-buffer-local 'mode-line-buffer-identification)
453
454 (defun unbury-buffer () "\
455 Switch to the last buffer in the buffer list."
456 (interactive)
457 (switch-to-buffer (last-buffer)))
458
459 (defun mode-line-unbury-buffer (event) "\
460 Call `unbury-buffer' in this window."
461 (interactive "e")
462 (save-selected-window
463 (select-window (posn-window (event-start event)))
464 (unbury-buffer)))
465
466 (defun mode-line-bury-buffer (event) "\
467 Like `bury-buffer', but temporarily select EVENT's window."
468 (interactive "e")
469 (save-selected-window
470 (select-window (posn-window (event-start event)))
471 (bury-buffer)))
472
473 (defun mode-line-other-buffer () "\
474 Switch to the most recently selected buffer other than the current one."
475 (interactive)
476 (switch-to-buffer (other-buffer)))
477
478 (defun mode-line-next-buffer (event)
479 "Like `next-buffer', but temporarily select EVENT's window."
480 (interactive "e")
481 (save-selected-window
482 (select-window (posn-window (event-start event)))
483 (next-buffer)))
484
485 (defun mode-line-previous-buffer (event)
486 "Like `previous-buffer', but temporarily select EVENT's window."
487 (interactive "e")
488 (save-selected-window
489 (select-window (posn-window (event-start event)))
490 (previous-buffer)))
491
492 (defmacro bound-and-true-p (var)
493 "Return the value of symbol VAR if it is bound, else nil."
494 `(and (boundp (quote ,var)) ,var))
495
496 ;; Use mode-line-mode-menu for local minor-modes only.
497 ;; Global ones can go on the menubar (Options --> Show/Hide).
498 (define-key mode-line-mode-menu [overwrite-mode]
499 `(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode
500 :help ,(purecopy "Overwrite mode: typed characters replace existing text")
501 :button (:toggle . overwrite-mode)))
502 (define-key mode-line-mode-menu [outline-minor-mode]
503 `(menu-item ,(purecopy "Outline (Outl)") outline-minor-mode
504 ;; XXX: This needs a good, brief description.
505 :help ,(purecopy "")
506 :button (:toggle . (bound-and-true-p outline-minor-mode))))
507 (define-key mode-line-mode-menu [highlight-changes-mode]
508 `(menu-item ,(purecopy "Highlight changes (Chg)") highlight-changes-mode
509 :help ,(purecopy "Show changes in the buffer in a distinctive color")
510 :button (:toggle . (bound-and-true-p highlight-changes-mode))))
511 (define-key mode-line-mode-menu [hide-ifdef-mode]
512 `(menu-item ,(purecopy "Hide ifdef (Ifdef)") hide-ifdef-mode
513 :help ,(purecopy "Show/Hide code within #ifdef constructs")
514 :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
515 (define-key mode-line-mode-menu [glasses-mode]
516 `(menu-item ,(purecopy "Glasses (o^o)") glasses-mode
517 :help ,(purecopy "Insert virtual separators to make long identifiers easy to read")
518 :button (:toggle . (bound-and-true-p glasses-mode))))
519 (define-key mode-line-mode-menu [font-lock-mode]
520 `(menu-item ,(purecopy "Font Lock") font-lock-mode
521 :help ,(purecopy "Syntax coloring")
522 :button (:toggle . font-lock-mode)))
523 (define-key mode-line-mode-menu [flyspell-mode]
524 `(menu-item ,(purecopy "Flyspell (Fly)") flyspell-mode
525 :help ,(purecopy "Spell checking on the fly")
526 :button (:toggle . (bound-and-true-p flyspell-mode))))
527 (define-key mode-line-mode-menu [auto-revert-tail-mode]
528 `(menu-item ,(purecopy "Auto revert tail (Tail)") auto-revert-tail-mode
529 :help ,(purecopy "Revert the tail of the buffer when buffer grows")
530 :enable (buffer-file-name)
531 :button (:toggle . (bound-and-true-p auto-revert-tail-mode))))
532 (define-key mode-line-mode-menu [auto-revert-mode]
533 `(menu-item ,(purecopy "Auto revert (ARev)") auto-revert-mode
534 :help ,(purecopy "Revert the buffer when the file on disk changes")
535 :button (:toggle . (bound-and-true-p auto-revert-mode))))
536 (define-key mode-line-mode-menu [auto-fill-mode]
537 `(menu-item ,(purecopy "Auto fill (Fill)") auto-fill-mode
538 :help ,(purecopy "Automatically insert new lines")
539 :button (:toggle . auto-fill-function)))
540 (define-key mode-line-mode-menu [abbrev-mode]
541 `(menu-item ,(purecopy "Abbrev (Abbrev)") abbrev-mode
542 :help ,(purecopy "Automatically expand abbreviations")
543 :button (:toggle . abbrev-mode)))
544
545 (defun mode-line-minor-mode-help (event)
546 "Describe minor mode for EVENT on minor modes area of the mode line."
547 (interactive "@e")
548 (let ((indicator (car (nth 4 (car (cdr event))))))
549 (describe-minor-mode-from-indicator indicator)))
550
551 (defvar minor-mode-alist nil "\
552 Alist saying how to show minor modes in the mode line.
553 Each element looks like (VARIABLE STRING);
554 STRING is included in the mode line if VARIABLE's value is non-nil.
555
556 Actually, STRING need not be a string; any possible mode-line element
557 is okay. See `mode-line-format'.")
558 ;;;###autoload
559 (put 'minor-mode-alist 'risky-local-variable t)
560 ;; Don't use purecopy here--some people want to change these strings.
561 (setq minor-mode-alist
562 '((abbrev-mode " Abbrev")
563 (overwrite-mode overwrite-mode)
564 (auto-fill-function " Fill")
565 ;; not really a minor mode...
566 (defining-kbd-macro " Def")))
567
568 ;; These variables are used by autoloadable packages.
569 ;; They are defined here so that they do not get overridden
570 ;; by the loading of those packages.
571
572 ;; Names in directory that end in one of these
573 ;; are ignored in completion,
574 ;; making it more likely you will get a unique match.
575 (setq completion-ignored-extensions
576 (append
577 (cond ((memq system-type '(ms-dos windows-nt))
578 (mapcar 'purecopy
579 '(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk"
580 ".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386")))
581 (t
582 (mapcar 'purecopy
583 '(".o" "~" ".bin" ".lbin" ".so"
584 ".a" ".ln" ".blg" ".bbl"))))
585 (mapcar 'purecopy
586 '(".elc" ".lof"
587 ".glo" ".idx" ".lot"
588 ;; VCS metadata directories
589 ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/"
590 ;; TeX-related
591 ".fmt" ".tfm"
592 ;; Java compiled
593 ".class"
594 ;; CLISP
595 ".fas" ".lib" ".mem"
596 ;; CMUCL
597 ".x86f" ".sparcf"
598 ;; Other CL implementations (Allegro, LispWorks, OpenMCL)
599 ".fasl" ".ufsl" ".fsl" ".dxl" ".pfsl" ".dfsl"
600 ".p64fsl" ".d64fsl" ".dx64fsl"
601 ;; Libtool
602 ".lo" ".la"
603 ;; Gettext
604 ".gmo" ".mo"
605 ;; Texinfo-related
606 ;; This used to contain .log, but that's commonly used for log
607 ;; files you do want to see, not just TeX stuff. -- fx
608 ".toc" ".aux"
609 ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
610 ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs"
611 ;; Python byte-compiled
612 ".pyc" ".pyo"))))
613
614 ;; Suffixes used for executables.
615 (setq exec-suffixes
616 (cond
617 ((memq system-type '(ms-dos windows-nt))
618 '(".exe" ".com" ".bat" ".cmd" ".btm" ""))
619 (t
620 '(""))))
621
622 ;; Packages should add to this list appropriately when they are
623 ;; loaded, rather than listing everything here.
624 (setq debug-ignored-errors
625 `(beginning-of-line beginning-of-buffer end-of-line
626 end-of-buffer end-of-file buffer-read-only
627 file-supersession
628 ,(purecopy "^Previous command was not a yank$")
629 ,(purecopy "^Minibuffer window is not active$")
630 ,(purecopy "^No previous history search regexp$")
631 ,(purecopy "^No later matching history item$")
632 ,(purecopy "^No earlier matching history item$")
633 ,(purecopy "^End of history; no default available$")
634 ,(purecopy "^End of defaults; no next item$")
635 ,(purecopy "^Beginning of history; no preceding item$")
636 ,(purecopy "^No recursive edit is in progress$")
637 ,(purecopy "^Changes to be undone are outside visible portion of buffer$")
638 ,(purecopy "^No undo information in this buffer$")
639 ,(purecopy "^No further undo information")
640 ,(purecopy "^Save not confirmed$")
641 ,(purecopy "^Recover-file cancelled\\.$")
642 ,(purecopy "^Cannot switch buffers in a dedicated window$")
643 ))
644
645
646 (make-variable-buffer-local 'indent-tabs-mode)
647
648 ;; We have base64 and md5 functions built in now.
649 (provide 'base64)
650 (provide 'md5)
651 (provide 'overlay '(display syntax-table field))
652 (provide 'text-properties '(display syntax-table field point-entered))
653
654 (define-key esc-map "\t" 'complete-symbol)
655
656 ;; Reduce total amount of space we must allocate during this function
657 ;; that we will not need to keep permanently.
658 (garbage-collect)
659 \f
660
661 (setq help-event-list '(help f1))
662
663 (make-variable-buffer-local 'minor-mode-overriding-map-alist)
664
665 ;; From frame.c
666 (global-set-key [switch-frame] 'handle-switch-frame)
667 (global-set-key [select-window] 'handle-select-window)
668
669 ;; FIXME: Do those 3 events really ever reach the global-map ?
670 ;; It seems that they can't because they're handled via
671 ;; special-event-map which is used at very low-level. -stef
672 (global-set-key [delete-frame] 'handle-delete-frame)
673 (global-set-key [iconify-frame] 'ignore-event)
674 (global-set-key [make-frame-visible] 'ignore-event)
675
676
677 ;These commands are defined in editfns.c
678 ;but they are not assigned to keys there.
679 (put 'narrow-to-region 'disabled t)
680
681 ;; Moving with arrows in bidi-sensitive direction.
682 (defun right-char (&optional n)
683 "Move point N characters to the right (to the left if N is negative).
684 On reaching beginning or end of buffer, stop and signal error.
685
686 Depending on the bidirectional context, this may move either forward
687 or backward in the buffer. This is in contrast with \\[forward-char]
688 and \\[backward-char], which see."
689 (interactive "^p")
690 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
691 (forward-char n)
692 (backward-char n)))
693
694 (defun left-char ( &optional n)
695 "Move point N characters to the left (to the right if N is negative).
696 On reaching beginning or end of buffer, stop and signal error.
697
698 Depending on the bidirectional context, this may move either backward
699 or forward in the buffer. This is in contrast with \\[backward-char]
700 and \\[forward-char], which see."
701 (interactive "^p")
702 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
703 (backward-char n)
704 (forward-char n)))
705
706 (defun right-word (&optional n)
707 "Move point N words to the right (to the left if N is negative).
708
709 Depending on the bidirectional context, this may move either forward
710 or backward in the buffer. This is in contrast with \\[forward-word]
711 and \\[backward-word], which see.
712
713 Value is normally t.
714 If an edge of the buffer or a field boundary is reached, point is left there
715 there and the function returns nil. Field boundaries are not noticed
716 if `inhibit-field-text-motion' is non-nil."
717 (interactive "^p")
718 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
719 (forward-word n)
720 (backward-word n)))
721
722 (defun left-word (&optional n)
723 "Move point N words to the left (to the right if N is negative).
724
725 Depending on the bidirectional context, this may move either backward
726 or forward in the buffer. This is in contrast with \\[backward-word]
727 and \\[forward-word], which see.
728
729 Value is normally t.
730 If an edge of the buffer or a field boundary is reached, point is left there
731 there and the function returns nil. Field boundaries are not noticed
732 if `inhibit-field-text-motion' is non-nil."
733 (interactive "^p")
734 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
735 (backward-word n)
736 (forward-word n)))
737
738 (defvar narrow-map (make-sparse-keymap)
739 "Keymap for narrowing commands.")
740 (define-key ctl-x-map "n" narrow-map)
741
742 (define-key narrow-map "n" 'narrow-to-region)
743 (define-key narrow-map "w" 'widen)
744
745 ;; Quitting
746 (define-key global-map "\e\e\e" 'keyboard-escape-quit)
747 (define-key global-map "\C-g" 'keyboard-quit)
748
749 ;; Used to be in termdev.el: when using several terminals, make C-z
750 ;; suspend only the relevant terminal.
751 (substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
752
753 (define-key global-map "\C-j" 'newline-and-indent)
754 (define-key global-map "\C-m" 'newline)
755 (define-key global-map "\C-o" 'open-line)
756 (define-key esc-map "\C-o" 'split-line)
757 (define-key global-map "\C-q" 'quoted-insert)
758 (define-key esc-map "^" 'delete-indentation)
759 (define-key esc-map "\\" 'delete-horizontal-space)
760 (define-key esc-map "m" 'back-to-indentation)
761 (define-key ctl-x-map "\C-o" 'delete-blank-lines)
762 (define-key esc-map " " 'just-one-space)
763 (define-key esc-map "z" 'zap-to-char)
764 (define-key esc-map "=" 'count-lines-region)
765 (define-key ctl-x-map "=" 'what-cursor-position)
766 (define-key esc-map ":" 'eval-expression)
767 ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
768 (define-key esc-map "\M-:" 'eval-expression)
769 ;; Changed from C-x ESC so that function keys work following C-x.
770 (define-key ctl-x-map "\e\e" 'repeat-complex-command)
771 ;; New binding analogous to M-:.
772 (define-key ctl-x-map "\M-:" 'repeat-complex-command)
773 (define-key ctl-x-map "u" 'undo)
774 (put 'undo :advertised-binding [?\C-x ?u])
775 ;; Many people are used to typing C-/ on X terminals and getting C-_.
776 (define-key global-map [?\C-/] 'undo)
777 (define-key global-map "\C-_" 'undo)
778 ;; Richard said that we should not use C-x <uppercase letter> and I have
779 ;; no idea whereas to bind it. Any suggestion welcome. -stef
780 ;; (define-key ctl-x-map "U" 'undo-only)
781
782 (define-key esc-map "!" 'shell-command)
783 (define-key esc-map "|" 'shell-command-on-region)
784 (define-key esc-map "&" 'async-shell-command)
785
786 (define-key ctl-x-map [right] 'next-buffer)
787 (define-key ctl-x-map [C-right] 'next-buffer)
788 (define-key ctl-x-map [left] 'previous-buffer)
789 (define-key ctl-x-map [C-left] 'previous-buffer)
790
791 (let ((map minibuffer-local-map))
792 (define-key map "\en" 'next-history-element)
793 (define-key map [next] 'next-history-element)
794 (define-key map [down] 'next-history-element)
795 (define-key map "\ep" 'previous-history-element)
796 (define-key map [prior] 'previous-history-element)
797 (define-key map [up] 'previous-history-element)
798 (define-key map "\es" 'next-matching-history-element)
799 (define-key map "\er" 'previous-matching-history-element)
800 ;; Override the global binding (which calls indent-relative via
801 ;; indent-for-tab-command). The alignment that indent-relative tries to
802 ;; do doesn't make much sense here since the prompt messes it up.
803 (define-key map "\t" 'self-insert-command)
804 (define-key map [C-tab] 'file-cache-minibuffer-complete))
805
806 (define-key global-map "\C-u" 'universal-argument)
807 (let ((i ?0))
808 (while (<= i ?9)
809 (define-key esc-map (char-to-string i) 'digit-argument)
810 (setq i (1+ i))))
811 (define-key esc-map "-" 'negative-argument)
812 ;; Define control-digits.
813 (let ((i ?0))
814 (while (<= i ?9)
815 (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
816 (setq i (1+ i))))
817 (define-key global-map [?\C--] 'negative-argument)
818 ;; Define control-meta-digits.
819 (let ((i ?0))
820 (while (<= i ?9)
821 (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
822 (setq i (1+ i))))
823 (define-key global-map [?\C-\M--] 'negative-argument)
824
825 (define-key global-map "\177" 'delete-backward-char)
826 (define-key global-map "\C-d" 'delete-forward-char)
827
828 (define-key global-map "\C-k" 'kill-line)
829 (define-key global-map "\C-w" 'kill-region)
830 (define-key esc-map "w" 'kill-ring-save)
831 (define-key esc-map "\C-w" 'append-next-kill)
832 (define-key global-map "\C-y" 'yank)
833 (define-key esc-map "y" 'yank-pop)
834
835 ;; (define-key ctl-x-map "a" 'append-to-buffer)
836
837 (define-key global-map "\C-@" 'set-mark-command)
838 ;; Many people are used to typing C-SPC and getting C-@.
839 (define-key global-map [?\C- ] 'set-mark-command)
840 (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
841 (define-key ctl-x-map "\C-@" 'pop-global-mark)
842 (define-key ctl-x-map [?\C- ] 'pop-global-mark)
843
844 (define-key global-map "\C-n" 'next-line)
845 (define-key global-map "\C-p" 'previous-line)
846 (define-key ctl-x-map "\C-n" 'set-goal-column)
847 (define-key global-map "\C-a" 'move-beginning-of-line)
848 (define-key global-map "\C-e" 'move-end-of-line)
849
850 (define-key ctl-x-map "`" 'next-error)
851
852 (defvar goto-map (make-sparse-keymap)
853 "Keymap for navigation commands.")
854 (define-key esc-map "g" goto-map)
855
856 (define-key goto-map "g" 'goto-line)
857 (define-key goto-map "\M-g" 'goto-line)
858 (define-key goto-map "n" 'next-error)
859 (define-key goto-map "\M-n" 'next-error)
860 (define-key goto-map "p" 'previous-error)
861 (define-key goto-map "\M-p" 'previous-error)
862
863 (defvar search-map (make-sparse-keymap)
864 "Keymap for search related commands.")
865 (define-key esc-map "s" search-map)
866
867 (define-key search-map "o" 'occur)
868 (define-key search-map "hr" 'highlight-regexp)
869 (define-key search-map "hp" 'highlight-phrase)
870 (define-key search-map "hl" 'highlight-lines-matching-regexp)
871 (define-key search-map "hu" 'unhighlight-regexp)
872 (define-key search-map "hf" 'hi-lock-find-patterns)
873 (define-key search-map "hw" 'hi-lock-write-interactive-patterns)
874
875 ;;(defun function-key-error ()
876 ;; (interactive)
877 ;; (error "That function key is not bound to anything"))
878
879 (define-key global-map [menu] 'execute-extended-command)
880 (define-key global-map [find] 'search-forward)
881
882 ;; Don't do this. We define <delete> in function-key-map instead.
883 ;(define-key global-map [delete] 'backward-delete-char)
884
885 ;; natural bindings for terminal keycaps --- defined in X keysym order
886 (define-key global-map [C-S-backspace] 'kill-whole-line)
887 (define-key global-map [home] 'move-beginning-of-line)
888 (define-key global-map [C-home] 'beginning-of-buffer)
889 (define-key global-map [M-home] 'beginning-of-buffer-other-window)
890 (define-key esc-map [home] 'beginning-of-buffer-other-window)
891 (define-key global-map [left] 'left-char)
892 (define-key global-map [up] 'previous-line)
893 (define-key global-map [right] 'right-char)
894 (define-key global-map [down] 'next-line)
895 (define-key global-map [prior] 'scroll-down-command)
896 (define-key global-map [next] 'scroll-up-command)
897 (define-key global-map [C-up] 'backward-paragraph)
898 (define-key global-map [C-down] 'forward-paragraph)
899 (define-key global-map [C-prior] 'scroll-right)
900 (put 'scroll-left 'disabled t)
901 (define-key global-map [C-next] 'scroll-left)
902 (define-key global-map [M-next] 'scroll-other-window)
903 (define-key esc-map [next] 'scroll-other-window)
904 (define-key global-map [M-prior] 'scroll-other-window-down)
905 (define-key esc-map [prior] 'scroll-other-window-down)
906 (define-key esc-map [?\C-\S-v] 'scroll-other-window-down)
907 (define-key global-map [end] 'move-end-of-line)
908 (define-key global-map [C-end] 'end-of-buffer)
909 (define-key global-map [M-end] 'end-of-buffer-other-window)
910 (define-key esc-map [end] 'end-of-buffer-other-window)
911 (define-key global-map [begin] 'beginning-of-buffer)
912 (define-key global-map [M-begin] 'beginning-of-buffer-other-window)
913 (define-key esc-map [begin] 'beginning-of-buffer-other-window)
914 ;; (define-key global-map [select] 'function-key-error)
915 ;; (define-key global-map [print] 'function-key-error)
916 (define-key global-map [execute] 'execute-extended-command)
917 (define-key global-map [insert] 'overwrite-mode)
918 (define-key global-map [C-insert] 'kill-ring-save)
919 (define-key global-map [S-insert] 'yank)
920 ;; `insertchar' is what term.c produces. Should we change term.c
921 ;; to produce `insert' instead?
922 (define-key global-map [insertchar] 'overwrite-mode)
923 (define-key global-map [C-insertchar] 'kill-ring-save)
924 (define-key global-map [S-insertchar] 'yank)
925 (define-key global-map [undo] 'undo)
926 (define-key global-map [redo] 'repeat-complex-command)
927 (define-key global-map [again] 'repeat-complex-command) ; Sun keyboard
928 (define-key global-map [open] 'find-file) ; Sun
929 ;; The following wouldn't work to interrupt running code since C-g is
930 ;; treated specially in the event loop.
931 ;; (define-key global-map [stop] 'keyboard-quit) ; Sun
932 ;; (define-key global-map [clearline] 'function-key-error)
933 (define-key global-map [insertline] 'open-line)
934 (define-key global-map [deleteline] 'kill-line)
935 (define-key global-map [deletechar] 'delete-char)
936 ;; (define-key global-map [backtab] 'function-key-error)
937 ;; (define-key global-map [f1] 'function-key-error)
938 ;; (define-key global-map [f2] 'function-key-error)
939 ;; (define-key global-map [f3] 'function-key-error)
940 ;; (define-key global-map [f4] 'function-key-error)
941 ;; (define-key global-map [f5] 'function-key-error)
942 ;; (define-key global-map [f6] 'function-key-error)
943 ;; (define-key global-map [f7] 'function-key-error)
944 ;; (define-key global-map [f8] 'function-key-error)
945 ;; (define-key global-map [f9] 'function-key-error)
946 ;; (define-key global-map [f10] 'function-key-error)
947 ;; (define-key global-map [f11] 'function-key-error)
948 ;; (define-key global-map [f12] 'function-key-error)
949 ;; (define-key global-map [f13] 'function-key-error)
950 ;; (define-key global-map [f14] 'function-key-error)
951 ;; (define-key global-map [f15] 'function-key-error)
952 ;; (define-key global-map [f16] 'function-key-error)
953 ;; (define-key global-map [f17] 'function-key-error)
954 ;; (define-key global-map [f18] 'function-key-error)
955 ;; (define-key global-map [f19] 'function-key-error)
956 ;; (define-key global-map [f20] 'function-key-error)
957 ;; (define-key global-map [f21] 'function-key-error)
958 ;; (define-key global-map [f22] 'function-key-error)
959 ;; (define-key global-map [f23] 'function-key-error)
960 ;; (define-key global-map [f24] 'function-key-error)
961 ;; (define-key global-map [f25] 'function-key-error)
962 ;; (define-key global-map [f26] 'function-key-error)
963 ;; (define-key global-map [f27] 'function-key-error)
964 ;; (define-key global-map [f28] 'function-key-error)
965 ;; (define-key global-map [f29] 'function-key-error)
966 ;; (define-key global-map [f30] 'function-key-error)
967 ;; (define-key global-map [f31] 'function-key-error)
968 ;; (define-key global-map [f32] 'function-key-error)
969 ;; (define-key global-map [f33] 'function-key-error)
970 ;; (define-key global-map [f34] 'function-key-error)
971 ;; (define-key global-map [f35] 'function-key-error)
972 ;; (define-key global-map [kp-backtab] 'function-key-error)
973 ;; (define-key global-map [kp-space] 'function-key-error)
974 ;; (define-key global-map [kp-tab] 'function-key-error)
975 ;; (define-key global-map [kp-enter] 'function-key-error)
976 ;; (define-key global-map [kp-f1] 'function-key-error)
977 ;; (define-key global-map [kp-f2] 'function-key-error)
978 ;; (define-key global-map [kp-f3] 'function-key-error)
979 ;; (define-key global-map [kp-f4] 'function-key-error)
980 ;; (define-key global-map [kp-multiply] 'function-key-error)
981 ;; (define-key global-map [kp-add] 'function-key-error)
982 ;; (define-key global-map [kp-separator] 'function-key-error)
983 ;; (define-key global-map [kp-subtract] 'function-key-error)
984 ;; (define-key global-map [kp-decimal] 'function-key-error)
985 ;; (define-key global-map [kp-divide] 'function-key-error)
986 ;; (define-key global-map [kp-0] 'function-key-error)
987 ;; (define-key global-map [kp-1] 'function-key-error)
988 ;; (define-key global-map [kp-2] 'function-key-error)
989 ;; (define-key global-map [kp-3] 'function-key-error)
990 ;; (define-key global-map [kp-4] 'function-key-error)
991 ;; (define-key global-map [kp-5] 'recenter)
992 ;; (define-key global-map [kp-6] 'function-key-error)
993 ;; (define-key global-map [kp-7] 'function-key-error)
994 ;; (define-key global-map [kp-8] 'function-key-error)
995 ;; (define-key global-map [kp-9] 'function-key-error)
996 ;; (define-key global-map [kp-equal] 'function-key-error)
997
998 ;; X11R6 distinguishes these keys from the non-kp keys.
999 ;; Make them behave like the non-kp keys unless otherwise bound.
1000 ;; FIXME: rather than list such mappings for every modifier-combination,
1001 ;; we should come up with a way to do it generically, something like
1002 ;; (define-key function-key-map [*-kp-home] [*-home])
1003 (define-key function-key-map [kp-home] [home])
1004 (define-key function-key-map [kp-left] [left])
1005 (define-key function-key-map [kp-up] [up])
1006 (define-key function-key-map [kp-right] [right])
1007 (define-key function-key-map [kp-down] [down])
1008 (define-key function-key-map [kp-prior] [prior])
1009 (define-key function-key-map [kp-next] [next])
1010 (define-key function-key-map [M-kp-next] [M-next])
1011 (define-key function-key-map [kp-end] [end])
1012 (define-key function-key-map [kp-begin] [begin])
1013 (define-key function-key-map [kp-insert] [insert])
1014 (define-key function-key-map [backspace] [?\C-?])
1015 (define-key function-key-map [delete] [?\C-?])
1016 (define-key function-key-map [kp-delete] [?\C-?])
1017 (define-key function-key-map [S-kp-end] [S-end])
1018 (define-key function-key-map [S-kp-down] [S-down])
1019 (define-key function-key-map [S-kp-next] [S-next])
1020 (define-key function-key-map [S-kp-left] [S-left])
1021 (define-key function-key-map [S-kp-right] [S-right])
1022 (define-key function-key-map [S-kp-home] [S-home])
1023 (define-key function-key-map [S-kp-up] [S-up])
1024 (define-key function-key-map [S-kp-prior] [S-prior])
1025 (define-key function-key-map [C-S-kp-end] [C-S-end])
1026 (define-key function-key-map [C-S-kp-down] [C-S-down])
1027 (define-key function-key-map [C-S-kp-next] [C-S-next])
1028 (define-key function-key-map [C-S-kp-left] [C-S-left])
1029 (define-key function-key-map [C-S-kp-right] [C-S-right])
1030 (define-key function-key-map [C-S-kp-home] [C-S-home])
1031 (define-key function-key-map [C-S-kp-up] [C-S-up])
1032 (define-key function-key-map [C-S-kp-prior] [C-S-prior])
1033 ;; Don't bind shifted keypad numeric keys, they reportedly
1034 ;; interfere with the feature of some keyboards to produce
1035 ;; numbers when NumLock is off.
1036 ;(define-key function-key-map [S-kp-1] [S-end])
1037 ;(define-key function-key-map [S-kp-2] [S-down])
1038 ;(define-key function-key-map [S-kp-3] [S-next])
1039 ;(define-key function-key-map [S-kp-4] [S-left])
1040 ;(define-key function-key-map [S-kp-6] [S-right])
1041 ;(define-key function-key-map [S-kp-7] [S-home])
1042 ;(define-key function-key-map [S-kp-8] [S-up])
1043 ;(define-key function-key-map [S-kp-9] [S-prior])
1044 (define-key function-key-map [C-S-kp-1] [C-S-end])
1045 (define-key function-key-map [C-S-kp-2] [C-S-down])
1046 (define-key function-key-map [C-S-kp-3] [C-S-next])
1047 (define-key function-key-map [C-S-kp-4] [C-S-left])
1048 (define-key function-key-map [C-S-kp-6] [C-S-right])
1049 (define-key function-key-map [C-S-kp-7] [C-S-home])
1050 (define-key function-key-map [C-S-kp-8] [C-S-up])
1051 (define-key function-key-map [C-S-kp-9] [C-S-prior])
1052
1053 ;; Hitting C-SPC on text terminals, usually sends the ascii code 0 (aka C-@),
1054 ;; so we can't distinguish those two keys, but usually we consider C-SPC
1055 ;; (rather than C-@) as the "canonical" binding.
1056 (define-key function-key-map [?\C-@] [?\C-\s])
1057 ;; Many keyboards don't have a `backtab' key, so by convention the user
1058 ;; can use S-tab instead to access that binding.
1059 (define-key function-key-map [S-tab] [backtab])
1060
1061 (define-key global-map [mouse-movement] 'ignore)
1062
1063 (define-key global-map "\C-t" 'transpose-chars)
1064 (define-key esc-map "t" 'transpose-words)
1065 (define-key esc-map "\C-t" 'transpose-sexps)
1066 (define-key ctl-x-map "\C-t" 'transpose-lines)
1067
1068 (define-key esc-map ";" 'comment-dwim)
1069 (define-key esc-map "j" 'indent-new-comment-line)
1070 (define-key esc-map "\C-j" 'indent-new-comment-line)
1071 (define-key ctl-x-map ";" 'comment-set-column)
1072 (define-key ctl-x-map "f" 'set-fill-column)
1073 (define-key ctl-x-map "$" 'set-selective-display)
1074
1075 (define-key esc-map "@" 'mark-word)
1076 (define-key esc-map "f" 'forward-word)
1077 (define-key esc-map "b" 'backward-word)
1078 (define-key esc-map "d" 'kill-word)
1079 (define-key esc-map "\177" 'backward-kill-word)
1080
1081 (define-key esc-map "<" 'beginning-of-buffer)
1082 (define-key esc-map ">" 'end-of-buffer)
1083 (define-key ctl-x-map "h" 'mark-whole-buffer)
1084 (define-key esc-map "\\" 'delete-horizontal-space)
1085
1086 (defalias 'mode-specific-command-prefix (make-sparse-keymap))
1087 (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
1088 "Keymap for characters following C-c.")
1089 (define-key global-map "\C-c" 'mode-specific-command-prefix)
1090
1091 (global-set-key [M-right] 'forward-word)
1092 (define-key esc-map [right] 'forward-word)
1093 (global-set-key [M-left] 'backward-word)
1094 (define-key esc-map [left] 'backward-word)
1095 ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
1096 (global-set-key [C-right] 'right-word)
1097 (global-set-key [C-left] 'left-word)
1098 ;; This is not quite compatible, but at least is analogous
1099 (global-set-key [C-delete] 'kill-word)
1100 (global-set-key [C-backspace] 'backward-kill-word)
1101 ;; This is "move to the clipboard", or as close as we come.
1102 (global-set-key [S-delete] 'kill-region)
1103
1104 (global-set-key [C-M-left] 'backward-sexp)
1105 (define-key esc-map [C-left] 'backward-sexp)
1106 (global-set-key [C-M-right] 'forward-sexp)
1107 (define-key esc-map [C-right] 'forward-sexp)
1108 (global-set-key [C-M-up] 'backward-up-list)
1109 (define-key esc-map [C-up] 'backward-up-list)
1110 (global-set-key [C-M-down] 'down-list)
1111 (define-key esc-map [C-down] 'down-list)
1112 (global-set-key [C-M-home] 'beginning-of-defun)
1113 (define-key esc-map [C-home] 'beginning-of-defun)
1114 (global-set-key [C-M-end] 'end-of-defun)
1115 (define-key esc-map [C-end] 'end-of-defun)
1116
1117 (define-key esc-map "\C-f" 'forward-sexp)
1118 (define-key esc-map "\C-b" 'backward-sexp)
1119 (define-key esc-map "\C-u" 'backward-up-list)
1120 (define-key esc-map "\C-@" 'mark-sexp)
1121 (define-key esc-map [?\C-\ ] 'mark-sexp)
1122 (define-key esc-map "\C-d" 'down-list)
1123 (define-key esc-map "\C-k" 'kill-sexp)
1124 ;;; These are dangerous in various situations,
1125 ;;; so let's not encourage anyone to use them.
1126 ;;;(define-key global-map [C-M-delete] 'backward-kill-sexp)
1127 ;;;(define-key global-map [C-M-backspace] 'backward-kill-sexp)
1128 (define-key esc-map [C-delete] 'backward-kill-sexp)
1129 (define-key esc-map [C-backspace] 'backward-kill-sexp)
1130 (define-key esc-map "\C-n" 'forward-list)
1131 (define-key esc-map "\C-p" 'backward-list)
1132 (define-key esc-map "\C-a" 'beginning-of-defun)
1133 (define-key esc-map "\C-e" 'end-of-defun)
1134 (define-key esc-map "\C-h" 'mark-defun)
1135 (define-key ctl-x-map "nd" 'narrow-to-defun)
1136 (define-key esc-map "(" 'insert-parentheses)
1137 (define-key esc-map ")" 'move-past-close-and-reindent)
1138
1139 (define-key ctl-x-map "\C-e" 'eval-last-sexp)
1140
1141 (define-key ctl-x-map "m" 'compose-mail)
1142 (define-key ctl-x-4-map "m" 'compose-mail-other-window)
1143 (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
1144 \f
1145
1146 (defvar ctl-x-r-map (make-sparse-keymap)
1147 "Keymap for subcommands of C-x r.")
1148 (define-key ctl-x-map "r" ctl-x-r-map)
1149
1150 (define-key esc-map "q" 'fill-paragraph)
1151 (define-key ctl-x-map "." 'set-fill-prefix)
1152 \f
1153 (define-key esc-map "{" 'backward-paragraph)
1154 (define-key esc-map "}" 'forward-paragraph)
1155 (define-key esc-map "h" 'mark-paragraph)
1156 (define-key esc-map "a" 'backward-sentence)
1157 (define-key esc-map "e" 'forward-sentence)
1158 (define-key esc-map "k" 'kill-sentence)
1159 (define-key ctl-x-map "\177" 'backward-kill-sentence)
1160
1161 (define-key ctl-x-map "[" 'backward-page)
1162 (define-key ctl-x-map "]" 'forward-page)
1163 (define-key ctl-x-map "\C-p" 'mark-page)
1164 (define-key ctl-x-map "l" 'count-lines-page)
1165 (define-key ctl-x-map "np" 'narrow-to-page)
1166 ;; (define-key ctl-x-map "p" 'narrow-to-page)
1167 \f
1168 (defvar abbrev-map (make-sparse-keymap)
1169 "Keymap for abbrev commands.")
1170 (define-key ctl-x-map "a" abbrev-map)
1171
1172 (define-key abbrev-map "l" 'add-mode-abbrev)
1173 (define-key abbrev-map "\C-a" 'add-mode-abbrev)
1174 (define-key abbrev-map "g" 'add-global-abbrev)
1175 (define-key abbrev-map "+" 'add-mode-abbrev)
1176 (define-key abbrev-map "ig" 'inverse-add-global-abbrev)
1177 (define-key abbrev-map "il" 'inverse-add-mode-abbrev)
1178 ;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev)
1179 (define-key abbrev-map "-" 'inverse-add-global-abbrev)
1180 (define-key abbrev-map "e" 'expand-abbrev)
1181 (define-key abbrev-map "'" 'expand-abbrev)
1182 ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
1183 ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
1184 ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
1185 ;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev)
1186 (define-key esc-map "'" 'abbrev-prefix-mark)
1187 (define-key ctl-x-map "'" 'expand-abbrev)
1188
1189 (define-key ctl-x-map "z" 'repeat)
1190
1191 (define-key esc-map "\C-l" 'reposition-window)
1192
1193 (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
1194 (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
1195
1196 ;; Signal handlers
1197 (define-key special-event-map [sigusr1] 'ignore)
1198 (define-key special-event-map [sigusr2] 'ignore)
1199
1200 ;; Don't look for autoload cookies in this file.
1201 ;; Local Variables:
1202 ;; no-update-autoloads: t
1203 ;; End:
1204
1205 ;; arch-tag: 23b5c7e6-e47b-49ed-8c6c-ed213c5fffe0
1206 ;;; bindings.el ends here