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