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