Cleanup intervals.
[emacs.git] / lisp / bindings.el
blob655cda235b468f3469a540d4715db72fd5ddc2ad
1 ;;; bindings.el --- define standard key bindings and some variables
3 ;; Copyright (C) 1985-1987, 1992-1996, 1999-2012
4 ;; Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: internal
8 ;; Package: emacs
10 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;;; Commentary:
27 ;;; Code:
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))
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 nil t)
44 (force-mode-line-update)))
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)))
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)))
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)))
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.")
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))))))
108 (defvar mode-line-eol-desc-cache nil)
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)))
135 ;;; Mode line contents
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)
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)
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")))
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)
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)
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")))
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 ")))
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)
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)
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 " "))
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)
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)
276 (defun bindings--define-key (map key item)
277 "Make as much as possible of the menus pure."
278 (declare (indent 2))
279 (define-key map key
280 (cond
281 ((not (consp item)) item) ;Not sure that could be other than a symbol.
282 ;; Keymaps can't be made pure otherwise users can't remove/add elements
283 ;; from/to them any more.
284 ((keymapp item) item)
285 ((stringp (car item))
286 (if (keymapp (cdr item))
287 (cons (purecopy (car item)) (cdr item))
288 (purecopy item)))
289 ((eq 'menu-item (car item))
290 (if (keymapp (nth 2 item))
291 `(menu-item ,(purecopy (nth 1 item)) ,(nth 2 item)
292 ,@(purecopy (nthcdr 3 item)))
293 (purecopy item)))
294 (t (message "non-menu-item: %S" item) item))))
296 (defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
297 Menu of mode operations in the mode line.")
299 (defvar mode-line-major-mode-keymap
300 (let ((map (make-sparse-keymap)))
301 (bindings--define-key map [mode-line down-mouse-1]
302 `(menu-item "Menu Bar" ignore
303 :filter ,(lambda (_) (mouse-menu-major-mode-map))))
304 (define-key map [mode-line mouse-2] 'describe-mode)
305 (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
306 map) "\
307 Keymap to display on major mode.")
309 (defvar mode-line-minor-mode-keymap
310 (let ((map (make-sparse-keymap)))
311 (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu)
312 (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
313 (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
314 (define-key map [header-line down-mouse-3] mode-line-mode-menu)
315 map) "\
316 Keymap to display on minor modes.")
318 (defvar mode-line-modes
319 (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out"))
320 (list (propertize "%[" 'help-echo recursive-edit-help-echo)
322 `(:propertize ("" mode-name)
323 help-echo "Major mode\n\
324 mouse-1: Display major mode menu\n\
325 mouse-2: Show help for major mode\n\
326 mouse-3: Toggle minor modes"
327 mouse-face mode-line-highlight
328 local-map ,mode-line-major-mode-keymap)
329 '("" mode-line-process)
330 `(:propertize ("" minor-mode-alist)
331 mouse-face mode-line-highlight
332 help-echo "Minor mode\n\
333 mouse-1: Display minor mode menu\n\
334 mouse-2: Show help for minor mode\n\
335 mouse-3: Toggle minor modes"
336 local-map ,mode-line-minor-mode-keymap)
337 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer"
338 'mouse-face 'mode-line-highlight
339 'local-map (make-mode-line-mouse-map
340 'mouse-2 #'mode-line-widen))
342 (propertize "%]" 'help-echo recursive-edit-help-echo)
343 " "))
344 "Mode line construct for displaying major and minor modes.")
345 (put 'mode-line-modes 'risky-local-variable t)
347 (defvar mode-line-column-line-number-mode-map
348 (let ((map (make-sparse-keymap))
349 (menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
350 (bindings--define-key menu-map [line-number-mode]
351 '(menu-item "Display Line Numbers" line-number-mode
352 :help "Toggle displaying line numbers in the mode-line"
353 :button (:toggle . line-number-mode)))
354 (bindings--define-key menu-map [column-number-mode]
355 '(menu-item "Display Column Numbers" column-number-mode
356 :help "Toggle displaying column numbers in the mode-line"
357 :button (:toggle . column-number-mode)))
358 (define-key map [mode-line down-mouse-1] menu-map)
359 map) "\
360 Keymap to display on column and line numbers.")
362 (defvar mode-line-position
363 `((-3 ,(propertize
364 "%p"
365 'local-map mode-line-column-line-number-mode-map
366 'mouse-face 'mode-line-highlight
367 ;; XXX needs better description
368 'help-echo "Size indication mode\n\
369 mouse-1: Display Line and Column Mode Menu"))
370 (size-indication-mode
371 (8 ,(propertize
372 " of %I"
373 'local-map mode-line-column-line-number-mode-map
374 'mouse-face 'mode-line-highlight
375 ;; XXX needs better description
376 'help-echo "Size indication mode\n\
377 mouse-1: Display Line and Column Mode Menu")))
378 (line-number-mode
379 ((column-number-mode
380 (10 ,(propertize
381 " (%l,%c)"
382 'local-map mode-line-column-line-number-mode-map
383 'mouse-face 'mode-line-highlight
384 'help-echo "Line number and Column number\n\
385 mouse-1: Display Line and Column Mode Menu"))
386 (6 ,(propertize
387 " L%l"
388 'local-map mode-line-column-line-number-mode-map
389 'mouse-face 'mode-line-highlight
390 'help-echo "Line Number\n\
391 mouse-1: Display Line and Column Mode Menu"))))
392 ((column-number-mode
393 (5 ,(propertize
394 " C%c"
395 'local-map mode-line-column-line-number-mode-map
396 'mouse-face 'mode-line-highlight
397 'help-echo "Column number\n\
398 mouse-1: Display Line and Column Mode Menu"))))))
399 "Mode line construct for displaying the position in the buffer.
400 Normally displays the buffer percentage and, optionally, the
401 buffer size, the line number and the column number.")
402 (put 'mode-line-position 'risky-local-variable t)
404 (defvar mode-line-buffer-identification-keymap
405 ;; Add menu of buffer operations to the buffer identification part
406 ;; of the mode line.or header line.
407 (let ((map (make-sparse-keymap)))
408 ;; Bind down- events so that the global keymap won't ``shine
409 ;; through''.
410 (define-key map [mode-line mouse-1] 'mode-line-previous-buffer)
411 (define-key map [header-line down-mouse-1] 'ignore)
412 (define-key map [header-line mouse-1] 'mode-line-previous-buffer)
413 (define-key map [mode-line mouse-3] 'mode-line-next-buffer)
414 (define-key map [header-line down-mouse-3] 'ignore)
415 (define-key map [header-line mouse-3] 'mode-line-next-buffer)
416 map) "\
417 Keymap for what is displayed by `mode-line-buffer-identification'.")
419 (defun propertized-buffer-identification (fmt)
420 "Return a list suitable for `mode-line-buffer-identification'.
421 FMT is a format specifier such as \"%12b\". This function adds
422 text properties for face, help-echo, and local-map to it."
423 (list (propertize fmt
424 'face 'mode-line-buffer-id
425 'help-echo
426 (purecopy "Buffer name
427 mouse-1: Previous buffer\nmouse-3: Next buffer")
428 'mouse-face 'mode-line-highlight
429 'local-map mode-line-buffer-identification-keymap)))
431 (defvar mode-line-buffer-identification
432 (propertized-buffer-identification "%12b")
433 "Mode line construct for identifying the buffer being displayed.
434 Its default value is (\"%12b\") with some text properties added.
435 Major modes that edit things other than ordinary files may change this
436 \(e.g. Info, Dired,...)")
437 ;;;###autoload
438 (put 'mode-line-buffer-identification 'risky-local-variable t)
439 (make-variable-buffer-local 'mode-line-buffer-identification)
441 (defvar mode-line-misc-info
442 '((which-func-mode ("" which-func-format " "))
443 (global-mode-string ("" global-mode-string " ")))
444 "Mode line construct for miscellaneous information.
445 By default, this shows the information specified by
446 `which-func-mode' and `global-mode-string'.")
447 (put 'mode-line-misc-info 'risky-local-variable t)
449 (defvar mode-line-end-spaces '(:eval (unless (display-graphic-p) "-%-"))
450 "Mode line construct to put at the end of the mode line.")
451 (put 'mode-line-end-spaces 'risky-local-variable t)
453 ;; Default value of the top-level `mode-line-format' variable:
454 (let ((standard-mode-line-format
455 (list "%e"
456 'mode-line-front-space
457 'mode-line-mule-info
458 'mode-line-client
459 'mode-line-modified
460 'mode-line-remote
461 'mode-line-frame-identification
462 'mode-line-buffer-identification
464 'mode-line-position
465 '(vc-mode vc-mode)
467 'mode-line-modes
468 'mode-line-misc-info
469 'mode-line-end-spaces)))
470 (setq-default mode-line-format standard-mode-line-format)
471 (put 'mode-line-format 'standard-value
472 (list `(quote ,standard-mode-line-format))))
475 (defun mode-line-unbury-buffer (event) "\
476 Call `unbury-buffer' in this window."
477 (interactive "e")
478 (save-selected-window
479 (select-window (posn-window (event-start event)))
480 (unbury-buffer)))
482 (defun mode-line-bury-buffer (event) "\
483 Like `bury-buffer', but temporarily select EVENT's window."
484 (interactive "e")
485 (save-selected-window
486 (select-window (posn-window (event-start event)))
487 (bury-buffer)))
489 (defun mode-line-other-buffer () "\
490 Switch to the most recently selected buffer other than the current one."
491 (interactive)
492 (switch-to-buffer (other-buffer) nil t))
494 (defun mode-line-next-buffer (event)
495 "Like `next-buffer', but temporarily select EVENT's window."
496 (interactive "e")
497 (save-selected-window
498 (select-window (posn-window (event-start event)))
499 (next-buffer)))
501 (defun mode-line-previous-buffer (event)
502 "Like `previous-buffer', but temporarily select EVENT's window."
503 (interactive "e")
504 (save-selected-window
505 (select-window (posn-window (event-start event)))
506 (previous-buffer)))
508 (defmacro bound-and-true-p (var)
509 "Return the value of symbol VAR if it is bound, else nil."
510 `(and (boundp (quote ,var)) ,var))
512 ;; Use mode-line-mode-menu for local minor-modes only.
513 ;; Global ones can go on the menubar (Options --> Show/Hide).
514 (bindings--define-key mode-line-mode-menu [overwrite-mode]
515 '(menu-item "Overwrite (Ovwrt)" overwrite-mode
516 :help "Overwrite mode: typed characters replace existing text"
517 :button (:toggle . overwrite-mode)))
518 (bindings--define-key mode-line-mode-menu [outline-minor-mode]
519 '(menu-item "Outline (Outl)" outline-minor-mode
520 ;; XXX: This needs a good, brief description.
521 :help ""
522 :button (:toggle . (bound-and-true-p outline-minor-mode))))
523 (bindings--define-key mode-line-mode-menu [highlight-changes-mode]
524 '(menu-item "Highlight changes (Chg)" highlight-changes-mode
525 :help "Show changes in the buffer in a distinctive color"
526 :button (:toggle . (bound-and-true-p highlight-changes-mode))))
527 (bindings--define-key mode-line-mode-menu [hide-ifdef-mode]
528 '(menu-item "Hide ifdef (Ifdef)" hide-ifdef-mode
529 :help "Show/Hide code within #ifdef constructs"
530 :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
531 (bindings--define-key mode-line-mode-menu [glasses-mode]
532 '(menu-item "Glasses (o^o)" glasses-mode
533 :help "Insert virtual separators to make long identifiers easy to read"
534 :button (:toggle . (bound-and-true-p glasses-mode))))
535 (bindings--define-key mode-line-mode-menu [font-lock-mode]
536 '(menu-item "Font Lock" font-lock-mode
537 :help "Syntax coloring"
538 :button (:toggle . font-lock-mode)))
539 (bindings--define-key mode-line-mode-menu [flyspell-mode]
540 '(menu-item "Flyspell (Fly)" flyspell-mode
541 :help "Spell checking on the fly"
542 :button (:toggle . (bound-and-true-p flyspell-mode))))
543 (bindings--define-key mode-line-mode-menu [auto-revert-tail-mode]
544 '(menu-item "Auto revert tail (Tail)" auto-revert-tail-mode
545 :help "Revert the tail of the buffer when buffer grows"
546 :enable (buffer-file-name)
547 :button (:toggle . (bound-and-true-p auto-revert-tail-mode))))
548 (bindings--define-key mode-line-mode-menu [auto-revert-mode]
549 '(menu-item "Auto revert (ARev)" auto-revert-mode
550 :help "Revert the buffer when the file on disk changes"
551 :button (:toggle . (bound-and-true-p auto-revert-mode))))
552 (bindings--define-key mode-line-mode-menu [auto-fill-mode]
553 '(menu-item "Auto fill (Fill)" auto-fill-mode
554 :help "Automatically insert new lines"
555 :button (:toggle . auto-fill-function)))
556 (bindings--define-key mode-line-mode-menu [abbrev-mode]
557 '(menu-item "Abbrev (Abbrev)" abbrev-mode
558 :help "Automatically expand abbreviations"
559 :button (:toggle . abbrev-mode)))
561 (defun mode-line-minor-mode-help (event)
562 "Describe minor mode for EVENT on minor modes area of the mode line."
563 (interactive "@e")
564 (let ((indicator (car (nth 4 (car (cdr event))))))
565 (describe-minor-mode-from-indicator indicator)))
567 (defvar minor-mode-alist nil "\
568 Alist saying how to show minor modes in the mode line.
569 Each element looks like (VARIABLE STRING);
570 STRING is included in the mode line if VARIABLE's value is non-nil.
572 Actually, STRING need not be a string; any mode-line construct is
573 okay. See `mode-line-format'.")
574 ;;;###autoload
575 (put 'minor-mode-alist 'risky-local-variable t)
576 ;; Don't use purecopy here--some people want to change these strings.
577 (setq minor-mode-alist
578 '((abbrev-mode " Abbrev")
579 (overwrite-mode overwrite-mode)
580 (auto-fill-function " Fill")
581 ;; not really a minor mode...
582 (defining-kbd-macro " Def")))
584 ;; These variables are used by autoloadable packages.
585 ;; They are defined here so that they do not get overridden
586 ;; by the loading of those packages.
588 ;; Names in directory that end in one of these
589 ;; are ignored in completion,
590 ;; making it more likely you will get a unique match.
591 (setq completion-ignored-extensions
592 (append
593 (cond ((memq system-type '(ms-dos windows-nt))
594 (mapcar 'purecopy
595 '(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk"
596 ".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386")))
598 (mapcar 'purecopy
599 '(".o" "~" ".bin" ".lbin" ".so"
600 ".a" ".ln" ".blg" ".bbl"))))
601 (mapcar 'purecopy
602 '(".elc" ".lof"
603 ".glo" ".idx" ".lot"
604 ;; VCS metadata directories
605 ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/"
606 ;; TeX-related
607 ".fmt" ".tfm"
608 ;; Java compiled
609 ".class"
610 ;; CLISP
611 ".fas" ".lib" ".mem"
612 ;; CMUCL
613 ".x86f" ".sparcf"
614 ;; OpenMCL / Clozure CL
615 ".dfsl" ".pfsl" ".d64fsl" ".p64fsl" ".lx64fsl" ".lx32fsl"
616 ".dx64fsl" ".dx32fsl" ".fx64fsl" ".fx32fsl" ".sx64fsl"
617 ".sx32fsl" ".wx64fsl" ".wx32fsl"
618 ;; Other CL implementations (Allegro, LispWorks)
619 ".fasl" ".ufsl" ".fsl" ".dxl"
620 ;; Libtool
621 ".lo" ".la"
622 ;; Gettext
623 ".gmo" ".mo"
624 ;; Texinfo-related
625 ;; This used to contain .log, but that's commonly used for log
626 ;; files you do want to see, not just TeX stuff. -- fx
627 ".toc" ".aux"
628 ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
629 ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs"
630 ;; Python byte-compiled
631 ".pyc" ".pyo"))))
633 ;; Suffixes used for executables.
634 (setq exec-suffixes
635 (cond
636 ((memq system-type '(ms-dos windows-nt))
637 '(".exe" ".com" ".bat" ".cmd" ".btm" ""))
639 '(""))))
641 ;; Packages should add to this list appropriately when they are
642 ;; loaded, rather than listing everything here.
643 (setq debug-ignored-errors
644 ;; FIXME: Maybe beginning-of-line, beginning-of-buffer, end-of-line,
645 ;; end-of-buffer, end-of-file, buffer-read-only, and
646 ;; file-supersession should all be user-errors!
647 `(beginning-of-line beginning-of-buffer end-of-line
648 end-of-buffer end-of-file buffer-read-only
649 file-supersession
650 user-error ;; That's the main one!
653 (make-variable-buffer-local 'indent-tabs-mode)
655 ;; These per-buffer variables are never reset by
656 ;; `kill-all-local-variables', because they have no default value.
657 ;; For consistency, we give them the `permanent-local' property, even
658 ;; though `kill-all-local-variables' does not actually consult it.
660 (mapc (lambda (sym) (put sym 'permanent-local t))
661 '(buffer-file-name default-directory buffer-backed-up
662 buffer-saved-size buffer-auto-save-file-name
663 buffer-read-only buffer-undo-list mark-active
664 point-before-scroll buffer-file-truename
665 buffer-file-format buffer-auto-save-file-format
666 buffer-display-count buffer-display-time
667 enable-multibyte-characters))
669 ;; We have base64, md5 and sha1 functions built in now.
670 (provide 'base64)
671 (provide 'md5)
672 (provide 'sha1)
673 (provide 'overlay '(display syntax-table field))
674 (provide 'text-properties '(display syntax-table field point-entered))
676 (define-key esc-map "\t" 'complete-symbol)
678 (defun complete-symbol (arg)
679 "Perform completion on the text around point.
680 The completion method is determined by `completion-at-point-functions'.
682 With a prefix argument, this command does completion within
683 the collection of symbols listed in the index of the manual for the
684 language you are using."
685 (interactive "P")
686 (if arg (info-complete-symbol) (completion-at-point)))
688 ;; Reduce total amount of space we must allocate during this function
689 ;; that we will not need to keep permanently.
690 (garbage-collect)
693 (setq help-event-list '(help f1))
695 (make-variable-buffer-local 'minor-mode-overriding-map-alist)
697 ;; From frame.c
698 (global-set-key [switch-frame] 'handle-switch-frame)
699 (global-set-key [select-window] 'handle-select-window)
701 ;; FIXME: Do those 3 events really ever reach the global-map ?
702 ;; It seems that they can't because they're handled via
703 ;; special-event-map which is used at very low-level. -stef
704 (global-set-key [delete-frame] 'handle-delete-frame)
705 (global-set-key [iconify-frame] 'ignore-event)
706 (global-set-key [make-frame-visible] 'ignore-event)
709 ;These commands are defined in editfns.c
710 ;but they are not assigned to keys there.
711 (put 'narrow-to-region 'disabled t)
713 ;; Moving with arrows in bidi-sensitive direction.
714 (defun right-char (&optional n)
715 "Move point N characters to the right (to the left if N is negative).
716 On reaching beginning or end of buffer, stop and signal error.
718 Depending on the bidirectional context, this may move either forward
719 or backward in the buffer. This is in contrast with \\[forward-char]
720 and \\[backward-char], which see."
721 (interactive "^p")
722 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
723 (forward-char n)
724 (backward-char n)))
726 (defun left-char ( &optional n)
727 "Move point N characters to the left (to the right if N is negative).
728 On reaching beginning or end of buffer, stop and signal error.
730 Depending on the bidirectional context, this may move either backward
731 or forward in the buffer. This is in contrast with \\[backward-char]
732 and \\[forward-char], which see."
733 (interactive "^p")
734 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
735 (backward-char n)
736 (forward-char n)))
738 (defun right-word (&optional n)
739 "Move point N words to the right (to the left if N is negative).
741 Depending on the bidirectional context, this may move either forward
742 or backward in the buffer. This is in contrast with \\[forward-word]
743 and \\[backward-word], which see.
745 Value is normally t.
746 If an edge of the buffer or a field boundary is reached, point is left there
747 there and the function returns nil. Field boundaries are not noticed
748 if `inhibit-field-text-motion' is non-nil."
749 (interactive "^p")
750 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
751 (forward-word n)
752 (backward-word n)))
754 (defun left-word (&optional n)
755 "Move point N words to the left (to the right if N is negative).
757 Depending on the bidirectional context, this may move either backward
758 or forward in the buffer. This is in contrast with \\[backward-word]
759 and \\[forward-word], which see.
761 Value is normally t.
762 If an edge of the buffer or a field boundary is reached, point is left there
763 there and the function returns nil. Field boundaries are not noticed
764 if `inhibit-field-text-motion' is non-nil."
765 (interactive "^p")
766 (if (eq (current-bidi-paragraph-direction) 'left-to-right)
767 (backward-word n)
768 (forward-word n)))
770 (defvar narrow-map (make-sparse-keymap)
771 "Keymap for narrowing commands.")
772 (define-key ctl-x-map "n" narrow-map)
774 (define-key narrow-map "n" 'narrow-to-region)
775 (define-key narrow-map "w" 'widen)
777 ;; Quitting
778 (define-key global-map "\e\e\e" 'keyboard-escape-quit)
779 (define-key global-map "\C-g" 'keyboard-quit)
781 ;; Used to be in termdev.el: when using several terminals, make C-z
782 ;; suspend only the relevant terminal.
783 (substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
785 (define-key global-map "\C-j" 'newline-and-indent)
786 (define-key global-map "\C-m" 'newline)
787 (define-key global-map "\C-o" 'open-line)
788 (define-key esc-map "\C-o" 'split-line)
789 (define-key global-map "\C-q" 'quoted-insert)
790 (define-key esc-map "^" 'delete-indentation)
791 (define-key esc-map "\\" 'delete-horizontal-space)
792 (define-key esc-map "m" 'back-to-indentation)
793 (define-key ctl-x-map "\C-o" 'delete-blank-lines)
794 (define-key esc-map " " 'just-one-space)
795 (define-key esc-map "z" 'zap-to-char)
796 (define-key esc-map "=" 'count-words)
797 (define-key ctl-x-map "=" 'what-cursor-position)
798 (define-key esc-map ":" 'eval-expression)
799 ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
800 (define-key esc-map "\M-:" 'eval-expression)
801 ;; Changed from C-x ESC so that function keys work following C-x.
802 (define-key ctl-x-map "\e\e" 'repeat-complex-command)
803 ;; New binding analogous to M-:.
804 (define-key ctl-x-map "\M-:" 'repeat-complex-command)
805 (define-key ctl-x-map "u" 'undo)
806 (put 'undo :advertised-binding [?\C-x ?u])
807 ;; Many people are used to typing C-/ on X terminals and getting C-_.
808 (define-key global-map [?\C-/] 'undo)
809 (define-key global-map "\C-_" 'undo)
810 ;; Richard said that we should not use C-x <uppercase letter> and I have
811 ;; no idea whereas to bind it. Any suggestion welcome. -stef
812 ;; (define-key ctl-x-map "U" 'undo-only)
814 (define-key esc-map "!" 'shell-command)
815 (define-key esc-map "|" 'shell-command-on-region)
816 (define-key esc-map "&" 'async-shell-command)
818 (define-key ctl-x-map [right] 'next-buffer)
819 (define-key ctl-x-map [C-right] 'next-buffer)
820 (define-key global-map [XF86Forward] 'next-buffer)
821 (define-key ctl-x-map [left] 'previous-buffer)
822 (define-key ctl-x-map [C-left] 'previous-buffer)
823 (define-key global-map [XF86Back] 'previous-buffer)
825 (let ((map minibuffer-local-map))
826 (define-key map "\en" 'next-history-element)
827 (define-key map [next] 'next-history-element)
828 (define-key map [down] 'next-history-element)
829 (define-key map [XF86Forward] 'next-history-element)
830 (define-key map "\ep" 'previous-history-element)
831 (define-key map [prior] 'previous-history-element)
832 (define-key map [up] 'previous-history-element)
833 (define-key map [XF86Back] 'previous-history-element)
834 (define-key map "\es" 'next-matching-history-element)
835 (define-key map "\er" 'previous-matching-history-element)
836 ;; Override the global binding (which calls indent-relative via
837 ;; indent-for-tab-command). The alignment that indent-relative tries to
838 ;; do doesn't make much sense here since the prompt messes it up.
839 (define-key map "\t" 'self-insert-command)
840 (define-key map [C-tab] 'file-cache-minibuffer-complete))
842 (define-key global-map "\C-u" 'universal-argument)
843 (let ((i ?0))
844 (while (<= i ?9)
845 (define-key esc-map (char-to-string i) 'digit-argument)
846 (setq i (1+ i))))
847 (define-key esc-map "-" 'negative-argument)
848 ;; Define control-digits.
849 (let ((i ?0))
850 (while (<= i ?9)
851 (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
852 (setq i (1+ i))))
853 (define-key global-map [?\C--] 'negative-argument)
854 ;; Define control-meta-digits.
855 (let ((i ?0))
856 (while (<= i ?9)
857 (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
858 (setq i (1+ i))))
859 (define-key global-map [?\C-\M--] 'negative-argument)
861 ;; Update tutorial--default-keys if you change these.
862 (define-key global-map "\177" 'delete-backward-char)
863 (define-key global-map "\C-d" 'delete-char)
865 (define-key global-map "\C-k" 'kill-line)
866 (define-key global-map "\C-w" 'kill-region)
867 (define-key esc-map "w" 'kill-ring-save)
868 (define-key esc-map "\C-w" 'append-next-kill)
869 (define-key global-map "\C-y" 'yank)
870 (define-key esc-map "y" 'yank-pop)
872 ;; (define-key ctl-x-map "a" 'append-to-buffer)
874 (define-key global-map "\C-@" 'set-mark-command)
875 ;; Many people are used to typing C-SPC and getting C-@.
876 (define-key global-map [?\C- ] 'set-mark-command)
877 (put 'set-mark-command :advertised-binding [?\C- ])
879 (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
880 (define-key ctl-x-map "\C-@" 'pop-global-mark)
881 (define-key ctl-x-map [?\C- ] 'pop-global-mark)
883 (define-key global-map "\C-n" 'next-line)
884 (define-key global-map "\C-p" 'previous-line)
885 (define-key ctl-x-map "\C-n" 'set-goal-column)
886 (define-key global-map "\C-a" 'move-beginning-of-line)
887 (define-key global-map "\C-e" 'move-end-of-line)
889 (define-key ctl-x-map "`" 'next-error)
891 (defvar goto-map (make-sparse-keymap)
892 "Keymap for navigation commands.")
893 (define-key esc-map "g" goto-map)
895 (define-key goto-map "c" 'goto-char)
896 (define-key goto-map "g" 'goto-line)
897 (define-key goto-map "\M-g" 'goto-line)
898 (define-key goto-map "n" 'next-error)
899 (define-key goto-map "\M-n" 'next-error)
900 (define-key goto-map "p" 'previous-error)
901 (define-key goto-map "\M-p" 'previous-error)
903 (defvar search-map (make-sparse-keymap)
904 "Keymap for search related commands.")
905 (define-key esc-map "s" search-map)
907 (define-key search-map "o" 'occur)
908 (define-key search-map "hr" 'highlight-regexp)
909 (define-key search-map "hp" 'highlight-phrase)
910 (define-key search-map "hl" 'highlight-lines-matching-regexp)
911 (define-key search-map "hu" 'unhighlight-regexp)
912 (define-key search-map "hf" 'hi-lock-find-patterns)
913 (define-key search-map "hw" 'hi-lock-write-interactive-patterns)
915 ;;(defun function-key-error ()
916 ;; (interactive)
917 ;; (error "That function key is not bound to anything"))
919 (define-key global-map [menu] 'execute-extended-command)
920 (define-key global-map [find] 'search-forward)
922 ;; Don't do this. We define <delete> in function-key-map instead.
923 ;(define-key global-map [delete] 'backward-delete-char)
925 ;; natural bindings for terminal keycaps --- defined in X keysym order
926 (define-key global-map [C-S-backspace] 'kill-whole-line)
927 (define-key global-map [home] 'move-beginning-of-line)
928 (define-key global-map [C-home] 'beginning-of-buffer)
929 (define-key global-map [M-home] 'beginning-of-buffer-other-window)
930 (define-key esc-map [home] 'beginning-of-buffer-other-window)
931 (define-key global-map [left] 'left-char)
932 (define-key global-map [up] 'previous-line)
933 (define-key global-map [right] 'right-char)
934 (define-key global-map [down] 'next-line)
935 (define-key global-map [prior] 'scroll-down-command)
936 (define-key global-map [next] 'scroll-up-command)
937 (define-key global-map [C-up] 'backward-paragraph)
938 (define-key global-map [C-down] 'forward-paragraph)
939 (define-key global-map [C-prior] 'scroll-right)
940 (put 'scroll-left 'disabled t)
941 (define-key global-map [C-next] 'scroll-left)
942 (define-key global-map [M-next] 'scroll-other-window)
943 (define-key esc-map [next] 'scroll-other-window)
944 (define-key global-map [M-prior] 'scroll-other-window-down)
945 (define-key esc-map [prior] 'scroll-other-window-down)
946 (define-key esc-map [?\C-\S-v] 'scroll-other-window-down)
947 (define-key global-map [end] 'move-end-of-line)
948 (define-key global-map [C-end] 'end-of-buffer)
949 (define-key global-map [M-end] 'end-of-buffer-other-window)
950 (define-key esc-map [end] 'end-of-buffer-other-window)
951 (define-key global-map [begin] 'beginning-of-buffer)
952 (define-key global-map [M-begin] 'beginning-of-buffer-other-window)
953 (define-key esc-map [begin] 'beginning-of-buffer-other-window)
954 ;; (define-key global-map [select] 'function-key-error)
955 ;; (define-key global-map [print] 'function-key-error)
956 (define-key global-map [execute] 'execute-extended-command)
957 (define-key global-map [insert] 'overwrite-mode)
958 (define-key global-map [C-insert] 'kill-ring-save)
959 (define-key global-map [S-insert] 'yank)
960 ;; `insertchar' is what term.c produces. Should we change term.c
961 ;; to produce `insert' instead?
962 (define-key global-map [insertchar] 'overwrite-mode)
963 (define-key global-map [C-insertchar] 'kill-ring-save)
964 (define-key global-map [S-insertchar] 'yank)
965 (define-key global-map [undo] 'undo)
966 (define-key global-map [redo] 'repeat-complex-command)
967 (define-key global-map [again] 'repeat-complex-command) ; Sun keyboard
968 (define-key global-map [open] 'find-file) ; Sun
969 ;; The following wouldn't work to interrupt running code since C-g is
970 ;; treated specially in the event loop.
971 ;; (define-key global-map [stop] 'keyboard-quit) ; Sun
972 ;; (define-key global-map [clearline] 'function-key-error)
973 (define-key global-map [insertline] 'open-line)
974 (define-key global-map [deleteline] 'kill-line)
975 (define-key global-map [deletechar] 'delete-forward-char)
976 ;; (define-key global-map [backtab] 'function-key-error)
977 ;; (define-key global-map [f1] 'function-key-error)
978 ;; (define-key global-map [f2] 'function-key-error)
979 ;; (define-key global-map [f3] 'function-key-error)
980 ;; (define-key global-map [f4] 'function-key-error)
981 ;; (define-key global-map [f5] 'function-key-error)
982 ;; (define-key global-map [f6] 'function-key-error)
983 ;; (define-key global-map [f7] 'function-key-error)
984 ;; (define-key global-map [f8] 'function-key-error)
985 ;; (define-key global-map [f9] 'function-key-error)
986 ;; (define-key global-map [f10] 'function-key-error)
987 ;; (define-key global-map [f11] 'function-key-error)
988 ;; (define-key global-map [f12] 'function-key-error)
989 ;; (define-key global-map [f13] 'function-key-error)
990 ;; (define-key global-map [f14] 'function-key-error)
991 ;; (define-key global-map [f15] 'function-key-error)
992 ;; (define-key global-map [f16] 'function-key-error)
993 ;; (define-key global-map [f17] 'function-key-error)
994 ;; (define-key global-map [f18] 'function-key-error)
995 ;; (define-key global-map [f19] 'function-key-error)
996 ;; (define-key global-map [f20] 'function-key-error)
997 ;; (define-key global-map [f21] 'function-key-error)
998 ;; (define-key global-map [f22] 'function-key-error)
999 ;; (define-key global-map [f23] 'function-key-error)
1000 ;; (define-key global-map [f24] 'function-key-error)
1001 ;; (define-key global-map [f25] 'function-key-error)
1002 ;; (define-key global-map [f26] 'function-key-error)
1003 ;; (define-key global-map [f27] 'function-key-error)
1004 ;; (define-key global-map [f28] 'function-key-error)
1005 ;; (define-key global-map [f29] 'function-key-error)
1006 ;; (define-key global-map [f30] 'function-key-error)
1007 ;; (define-key global-map [f31] 'function-key-error)
1008 ;; (define-key global-map [f32] 'function-key-error)
1009 ;; (define-key global-map [f33] 'function-key-error)
1010 ;; (define-key global-map [f34] 'function-key-error)
1011 ;; (define-key global-map [f35] 'function-key-error)
1012 ;; (define-key global-map [kp-backtab] 'function-key-error)
1013 ;; (define-key global-map [kp-space] 'function-key-error)
1014 ;; (define-key global-map [kp-tab] 'function-key-error)
1015 ;; (define-key global-map [kp-enter] 'function-key-error)
1016 ;; (define-key global-map [kp-f1] 'function-key-error)
1017 ;; (define-key global-map [kp-f2] 'function-key-error)
1018 ;; (define-key global-map [kp-f3] 'function-key-error)
1019 ;; (define-key global-map [kp-f4] 'function-key-error)
1020 ;; (define-key global-map [kp-multiply] 'function-key-error)
1021 ;; (define-key global-map [kp-add] 'function-key-error)
1022 ;; (define-key global-map [kp-separator] 'function-key-error)
1023 ;; (define-key global-map [kp-subtract] 'function-key-error)
1024 ;; (define-key global-map [kp-decimal] 'function-key-error)
1025 ;; (define-key global-map [kp-divide] 'function-key-error)
1026 ;; (define-key global-map [kp-0] 'function-key-error)
1027 ;; (define-key global-map [kp-1] 'function-key-error)
1028 ;; (define-key global-map [kp-2] 'function-key-error)
1029 ;; (define-key global-map [kp-3] 'function-key-error)
1030 ;; (define-key global-map [kp-4] 'function-key-error)
1031 ;; (define-key global-map [kp-5] 'recenter)
1032 ;; (define-key global-map [kp-6] 'function-key-error)
1033 ;; (define-key global-map [kp-7] 'function-key-error)
1034 ;; (define-key global-map [kp-8] 'function-key-error)
1035 ;; (define-key global-map [kp-9] 'function-key-error)
1036 ;; (define-key global-map [kp-equal] 'function-key-error)
1038 ;; X11R6 distinguishes these keys from the non-kp keys.
1039 ;; Make them behave like the non-kp keys unless otherwise bound.
1040 ;; FIXME: rather than list such mappings for every modifier-combination,
1041 ;; we should come up with a way to do it generically, something like
1042 ;; (define-key function-key-map [*-kp-home] [*-home])
1043 (define-key function-key-map [kp-home] [home])
1044 (define-key function-key-map [kp-left] [left])
1045 (define-key function-key-map [kp-up] [up])
1046 (define-key function-key-map [kp-right] [right])
1047 (define-key function-key-map [kp-down] [down])
1048 (define-key function-key-map [kp-prior] [prior])
1049 (define-key function-key-map [kp-next] [next])
1050 (define-key function-key-map [M-kp-next] [M-next])
1051 (define-key function-key-map [kp-end] [end])
1052 (define-key function-key-map [kp-begin] [begin])
1053 (define-key function-key-map [kp-insert] [insert])
1054 (define-key function-key-map [backspace] [?\C-?])
1055 (define-key function-key-map [delete] [?\C-?])
1056 (define-key function-key-map [kp-delete] [?\C-?])
1057 (define-key function-key-map [S-kp-end] [S-end])
1058 (define-key function-key-map [S-kp-down] [S-down])
1059 (define-key function-key-map [S-kp-next] [S-next])
1060 (define-key function-key-map [S-kp-left] [S-left])
1061 (define-key function-key-map [S-kp-right] [S-right])
1062 (define-key function-key-map [S-kp-home] [S-home])
1063 (define-key function-key-map [S-kp-up] [S-up])
1064 (define-key function-key-map [S-kp-prior] [S-prior])
1065 (define-key function-key-map [C-S-kp-end] [C-S-end])
1066 (define-key function-key-map [C-S-kp-down] [C-S-down])
1067 (define-key function-key-map [C-S-kp-next] [C-S-next])
1068 (define-key function-key-map [C-S-kp-left] [C-S-left])
1069 (define-key function-key-map [C-S-kp-right] [C-S-right])
1070 (define-key function-key-map [C-S-kp-home] [C-S-home])
1071 (define-key function-key-map [C-S-kp-up] [C-S-up])
1072 (define-key function-key-map [C-S-kp-prior] [C-S-prior])
1073 ;; Don't bind shifted keypad numeric keys, they reportedly
1074 ;; interfere with the feature of some keyboards to produce
1075 ;; numbers when NumLock is off.
1076 ;(define-key function-key-map [S-kp-1] [S-end])
1077 ;(define-key function-key-map [S-kp-2] [S-down])
1078 ;(define-key function-key-map [S-kp-3] [S-next])
1079 ;(define-key function-key-map [S-kp-4] [S-left])
1080 ;(define-key function-key-map [S-kp-6] [S-right])
1081 ;(define-key function-key-map [S-kp-7] [S-home])
1082 ;(define-key function-key-map [S-kp-8] [S-up])
1083 ;(define-key function-key-map [S-kp-9] [S-prior])
1084 (define-key function-key-map [C-S-kp-1] [C-S-end])
1085 (define-key function-key-map [C-S-kp-2] [C-S-down])
1086 (define-key function-key-map [C-S-kp-3] [C-S-next])
1087 (define-key function-key-map [C-S-kp-4] [C-S-left])
1088 (define-key function-key-map [C-S-kp-6] [C-S-right])
1089 (define-key function-key-map [C-S-kp-7] [C-S-home])
1090 (define-key function-key-map [C-S-kp-8] [C-S-up])
1091 (define-key function-key-map [C-S-kp-9] [C-S-prior])
1093 ;; Hitting C-SPC on text terminals, usually sends the ascii code 0 (aka C-@),
1094 ;; so we can't distinguish those two keys, but usually we consider C-SPC
1095 ;; (rather than C-@) as the "canonical" binding.
1096 (define-key function-key-map [?\C-@] [?\C-\s])
1097 ;; Many keyboards don't have a `backtab' key, so by convention the user
1098 ;; can use S-tab instead to access that binding.
1099 (define-key function-key-map [S-tab] [backtab])
1101 (define-key global-map [mouse-movement] 'ignore)
1103 (define-key global-map "\C-t" 'transpose-chars)
1104 (define-key esc-map "t" 'transpose-words)
1105 (define-key esc-map "\C-t" 'transpose-sexps)
1106 (define-key ctl-x-map "\C-t" 'transpose-lines)
1108 (define-key esc-map ";" 'comment-dwim)
1109 (define-key esc-map "j" 'indent-new-comment-line)
1110 (define-key esc-map "\C-j" 'indent-new-comment-line)
1111 (define-key ctl-x-map ";" 'comment-set-column)
1112 (define-key ctl-x-map "f" 'set-fill-column)
1113 (define-key ctl-x-map "$" 'set-selective-display)
1115 (define-key esc-map "@" 'mark-word)
1116 (define-key esc-map "f" 'forward-word)
1117 (define-key esc-map "b" 'backward-word)
1118 (define-key esc-map "d" 'kill-word)
1119 (define-key esc-map "\177" 'backward-kill-word)
1121 (define-key esc-map "<" 'beginning-of-buffer)
1122 (define-key esc-map ">" 'end-of-buffer)
1123 (define-key ctl-x-map "h" 'mark-whole-buffer)
1124 (define-key esc-map "\\" 'delete-horizontal-space)
1126 (defalias 'mode-specific-command-prefix (make-sparse-keymap))
1127 (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
1128 "Keymap for characters following C-c.")
1129 (define-key global-map "\C-c" 'mode-specific-command-prefix)
1131 (global-set-key [M-right] 'right-word)
1132 (define-key esc-map [right] 'forward-word)
1133 (global-set-key [M-left] 'left-word)
1134 (define-key esc-map [left] 'backward-word)
1135 ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
1136 (global-set-key [C-right] 'right-word)
1137 (global-set-key [C-left] 'left-word)
1138 ;; This is not quite compatible, but at least is analogous
1139 (global-set-key [C-delete] 'kill-word)
1140 (global-set-key [C-backspace] 'backward-kill-word)
1141 ;; This is "move to the clipboard", or as close as we come.
1142 (global-set-key [S-delete] 'kill-region)
1144 (global-set-key [C-M-left] 'backward-sexp)
1145 (define-key esc-map [C-left] 'backward-sexp)
1146 (global-set-key [C-M-right] 'forward-sexp)
1147 (define-key esc-map [C-right] 'forward-sexp)
1148 (global-set-key [C-M-up] 'backward-up-list)
1149 (define-key esc-map [C-up] 'backward-up-list)
1150 (global-set-key [C-M-down] 'down-list)
1151 (define-key esc-map [C-down] 'down-list)
1152 (global-set-key [C-M-home] 'beginning-of-defun)
1153 (define-key esc-map [C-home] 'beginning-of-defun)
1154 (global-set-key [C-M-end] 'end-of-defun)
1155 (define-key esc-map [C-end] 'end-of-defun)
1157 (define-key esc-map "\C-f" 'forward-sexp)
1158 (define-key esc-map "\C-b" 'backward-sexp)
1159 (define-key esc-map "\C-u" 'backward-up-list)
1160 (define-key esc-map "\C-@" 'mark-sexp)
1161 (define-key esc-map [?\C-\ ] 'mark-sexp)
1162 (define-key esc-map "\C-d" 'down-list)
1163 (define-key esc-map "\C-k" 'kill-sexp)
1164 ;;; These are dangerous in various situations,
1165 ;;; so let's not encourage anyone to use them.
1166 ;;;(define-key global-map [C-M-delete] 'backward-kill-sexp)
1167 ;;;(define-key global-map [C-M-backspace] 'backward-kill-sexp)
1168 (define-key esc-map [C-delete] 'backward-kill-sexp)
1169 (define-key esc-map [C-backspace] 'backward-kill-sexp)
1170 (define-key esc-map "\C-n" 'forward-list)
1171 (define-key esc-map "\C-p" 'backward-list)
1172 (define-key esc-map "\C-a" 'beginning-of-defun)
1173 (define-key esc-map "\C-e" 'end-of-defun)
1174 (define-key esc-map "\C-h" 'mark-defun)
1175 (define-key ctl-x-map "nd" 'narrow-to-defun)
1176 (define-key esc-map "(" 'insert-parentheses)
1177 (define-key esc-map ")" 'move-past-close-and-reindent)
1179 (define-key ctl-x-map "\C-e" 'eval-last-sexp)
1181 (define-key ctl-x-map "m" 'compose-mail)
1182 (define-key ctl-x-4-map "m" 'compose-mail-other-window)
1183 (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
1186 (defvar ctl-x-r-map
1187 (let ((map (make-sparse-keymap)))
1188 (define-key map "c" 'clear-rectangle)
1189 (define-key map "k" 'kill-rectangle)
1190 (define-key map "d" 'delete-rectangle)
1191 (define-key map "y" 'yank-rectangle)
1192 (define-key map "o" 'open-rectangle)
1193 (define-key map "t" 'string-rectangle)
1194 (define-key map "N" 'rectangle-number-lines)
1195 (define-key map "\M-w" 'copy-rectangle-as-kill)
1196 (define-key map "\C-@" 'point-to-register)
1197 (define-key map [?\C-\ ] 'point-to-register)
1198 (define-key map " " 'point-to-register)
1199 (define-key map "j" 'jump-to-register)
1200 (define-key map "s" 'copy-to-register)
1201 (define-key map "x" 'copy-to-register)
1202 (define-key map "i" 'insert-register)
1203 (define-key map "g" 'insert-register)
1204 (define-key map "r" 'copy-rectangle-to-register)
1205 (define-key map "n" 'number-to-register)
1206 (define-key map "+" 'increment-register)
1207 (define-key map "w" 'window-configuration-to-register)
1208 (define-key map "f" 'frame-configuration-to-register)
1209 map)
1210 "Keymap for subcommands of C-x r.")
1211 (define-key ctl-x-map "r" ctl-x-r-map)
1213 (define-key esc-map "q" 'fill-paragraph)
1214 (define-key ctl-x-map "." 'set-fill-prefix)
1216 (define-key esc-map "{" 'backward-paragraph)
1217 (define-key esc-map "}" 'forward-paragraph)
1218 (define-key esc-map "h" 'mark-paragraph)
1219 (define-key esc-map "a" 'backward-sentence)
1220 (define-key esc-map "e" 'forward-sentence)
1221 (define-key esc-map "k" 'kill-sentence)
1222 (define-key ctl-x-map "\177" 'backward-kill-sentence)
1224 (define-key ctl-x-map "[" 'backward-page)
1225 (define-key ctl-x-map "]" 'forward-page)
1226 (define-key ctl-x-map "\C-p" 'mark-page)
1227 (define-key ctl-x-map "l" 'count-lines-page)
1228 (define-key ctl-x-map "np" 'narrow-to-page)
1229 ;; (define-key ctl-x-map "p" 'narrow-to-page)
1231 (defvar abbrev-map (make-sparse-keymap)
1232 "Keymap for abbrev commands.")
1233 (define-key ctl-x-map "a" abbrev-map)
1235 (define-key abbrev-map "l" 'add-mode-abbrev)
1236 (define-key abbrev-map "\C-a" 'add-mode-abbrev)
1237 (define-key abbrev-map "g" 'add-global-abbrev)
1238 (define-key abbrev-map "+" 'add-mode-abbrev)
1239 (define-key abbrev-map "ig" 'inverse-add-global-abbrev)
1240 (define-key abbrev-map "il" 'inverse-add-mode-abbrev)
1241 ;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev)
1242 (define-key abbrev-map "-" 'inverse-add-global-abbrev)
1243 (define-key abbrev-map "e" 'expand-abbrev)
1244 (define-key abbrev-map "'" 'expand-abbrev)
1245 ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
1246 ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
1247 ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
1248 ;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev)
1249 (define-key esc-map "'" 'abbrev-prefix-mark)
1250 (define-key ctl-x-map "'" 'expand-abbrev)
1251 (define-key ctl-x-map "\C-b" 'list-buffers)
1253 (define-key ctl-x-map "z" 'repeat)
1255 (define-key esc-map "\C-l" 'reposition-window)
1257 (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
1258 (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
1260 ;; Signal handlers
1261 (define-key special-event-map [sigusr1] 'ignore)
1262 (define-key special-event-map [sigusr2] 'ignore)
1264 ;; Don't look for autoload cookies in this file.
1265 ;; Local Variables:
1266 ;; no-update-autoloads: t
1267 ;; End:
1269 ;;; bindings.el ends here