bindings.el 46.9 KB
Newer Older
1
;;; bindings.el --- define standard key bindings and some variables
Richard M. Stallman's avatar
Richard M. Stallman committed
2

3
;; Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994, 1995, 1996, 1999,
Glenn Morris's avatar
Glenn Morris committed
4
;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5
;;   Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
6 7 8

;; Maintainer: FSF
;; Keywords: internal
9
;; Package: emacs
Richard M. Stallman's avatar
Richard M. Stallman committed
10 11 12

;; This file is part of GNU Emacs.

13
;; GNU Emacs is free software: you can redistribute it and/or modify
Richard M. Stallman's avatar
Richard M. Stallman committed
14
;; it under the terms of the GNU General Public License as published by
15 16
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Richard M. Stallman's avatar
Richard M. Stallman committed
17 18 19 20 21 22 23

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
24
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Richard M. Stallman's avatar
Richard M. Stallman committed
25 26 27 28 29

;;; Commentary:

;;; Code:

30 31 32
(defun make-mode-line-mouse-map (mouse function) "\
Return a keymap with single entry for mouse key MOUSE on the mode line.
MOUSE is defined to run function FUNCTION with no args in the buffer
33 34
corresponding to the mode line clicked."
  (let ((map (make-sparse-keymap)))
35
    (define-key map (vector 'mode-line mouse) function)
36 37
    map))

Gerd Moellmann's avatar
Gerd Moellmann committed
38 39 40 41 42 43 44 45 46 47 48 49

(defun mode-line-toggle-read-only (event)
  "Like `toggle-read-only', for the mode-line."
  (interactive "e")
  (save-selected-window
    (select-window (posn-window (event-start event)))
    (toggle-read-only)
    (force-mode-line-update)))


(defun mode-line-toggle-modified (event)
  "Toggle the buffer-modified flag from the mode-line."
50
  (interactive "e")
Gerd Moellmann's avatar
Gerd Moellmann committed
51 52 53 54 55 56 57 58
  (save-selected-window
    (select-window (posn-window (event-start event)))
    (set-buffer-modified-p (not (buffer-modified-p)))
    (force-mode-line-update)))


(defun mode-line-widen (event)
  "Widen a buffer from the mode-line."
59
  (interactive "e")
Gerd Moellmann's avatar
Gerd Moellmann committed
60 61 62 63 64 65
  (save-selected-window
    (select-window (posn-window (event-start event)))
    (widen)
    (force-mode-line-update)))


66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
(defvar mode-line-input-method-map
  (let ((map (make-sparse-keymap)))
    (define-key map [mode-line mouse-2]
      (lambda (e)
	(interactive "e")
	(save-selected-window
	  (select-window
	   (posn-window (event-start e)))
	  (toggle-input-method)
	  (force-mode-line-update))))
    (define-key map [mode-line mouse-3]
      (lambda (e)
	(interactive "e")
	(save-selected-window
	  (select-window
	   (posn-window (event-start e)))
	  (describe-current-input-method))))
    (purecopy map)))

85 86 87

(defvar mode-line-coding-system-map
  (let ((map (make-sparse-keymap)))
88
    (define-key map [mode-line mouse-1]
89 90 91 92 93 94 95 96 97 98 99
      (lambda (e)
	(interactive "e")
	(save-selected-window
	  (select-window (posn-window (event-start e)))
	  (when (and enable-multibyte-characters
		     buffer-file-coding-system)
	    (describe-coding-system buffer-file-coding-system)))))
    (purecopy map))
  "Local keymap for the coding-system part of the mode line.")


Kenichi Handa's avatar
Kenichi Handa committed
100
(defun mode-line-change-eol (event)
101
  "Cycle through the various possible kinds of end-of-line styles."
Kenichi Handa's avatar
Kenichi Handa committed
102
  (interactive "e")
103
  (with-selected-window (posn-window (event-start event))
Kenichi Handa's avatar
Kenichi Handa committed
104 105 106
    (let ((eol (coding-system-eol-type buffer-file-coding-system)))
      (set-buffer-file-coding-system
       (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix))))))
107 108 109 110 111 112

(defvar mode-line-eol-desc-cache nil)

(defun mode-line-eol-desc ()
  (let* ((eol (coding-system-eol-type buffer-file-coding-system))
	 (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system))
113
	 (desc (assoc eol mode-line-eol-desc-cache)))
114 115 116 117 118 119
    (if (and desc (eq (cadr desc) mnemonic))
	(cddr desc)
      (if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale.
      (setq desc
	    (propertize
	     mnemonic
Dan Nicolaescu's avatar
Dan Nicolaescu committed
120
	     'help-echo (format "End-of-line style: %s\nmouse-1 to cycle"
121
				(if (eq eol 0) "Unix-style LF"
122
				  (if (eq eol 1) "DOS-style CRLF"
123 124 125 126 127
				    (if (eq eol 2) "Mac-style CR"
				      "Undecided"))))
	     'keymap
	     (eval-when-compile
	       (let ((map (make-sparse-keymap)))
128
		 (define-key map [mode-line mouse-1] 'mode-line-change-eol)
129 130
		 map))
	     'mouse-face 'mode-line-highlight))
131 132 133
      (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache)
      desc)))

134 135 136
(defvar mode-line-client
  `(""
    (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" "")))
137
		 help-echo ,(purecopy "emacsclient frame")))
138
  "Mode-line control for identifying emacsclient frames.")
139
;;;###autoload
140
(put 'mode-line-client 'risky-local-variable t)
141

142 143
(defvar mode-line-mule-info
  `(""
144
    (current-input-method
145 146
     (:propertize ("" current-input-method-title)
		  help-echo (concat
147
			     ,(purecopy "Current input method: ")
148
			     current-input-method
149
			     ,(purecopy "\n\
150
mouse-2: Disable input method\n\
151
mouse-3: Describe current input method"))
152 153
		  local-map ,mode-line-input-method-map
		  mouse-face mode-line-highlight))
154
    ,(propertize
155
      "%z"
156
      'help-echo
157 158 159 160 161
      #'(lambda (window object point)
	  (with-current-buffer (window-buffer window)
	    ;; Don't show this tip if the coding system is nil,
	    ;; it reads like a bug, and is not useful anyway.
	    (when buffer-file-coding-system
162 163 164 165 166 167
	      (format "Buffer coding system %s\nmouse-1: describe coding system"
		      (if enable-multibyte-characters
			  (concat "(multi-byte): "
				  (symbol-name buffer-file-coding-system))
			(concat "(unibyte): "
				(symbol-name buffer-file-coding-system)))))))
168
      'mouse-face 'mode-line-highlight
169 170
      'local-map mode-line-coding-system-map)
    (:eval (mode-line-eol-desc)))
171 172 173 174 175
  "Mode-line control for displaying information of multilingual environment.
Normally it displays current input method (if any activated) and
mnemonics of the following coding systems:
  coding system for saving or writing the current buffer
  coding system for keyboard input (if Emacs is running on terminal)
Dave Love's avatar
Dave Love committed
176
  coding system for terminal output (if Emacs is running on terminal)"
177 178 179
  ;; Currently not:
  ;;  coding system for decoding output of buffer process (if any)
  ;;  coding system for encoding text to send to buffer process (if any)."
Dave Love's avatar
Dave Love committed
180
)
181

182
;;;###autoload
183
(put 'mode-line-mule-info 'risky-local-variable t)
184 185
(make-variable-buffer-local 'mode-line-mule-info)

186 187 188 189
;; MSDOS frames have window-system, but want the Fn identification.
(defun mode-line-frame-control ()
  "Compute mode-line control for frame identification.
Value is used for `mode-line-frame-identification', which see."
190 191
  (if (or (null window-system)
	  (eq window-system 'pc))
192 193 194
      "-%F  "
    "  "))

195 196
;; We need to defer the call to mode-line-frame-control to the time
;; the mode line is actually displayed.
197 198
(defvar mode-line-frame-identification '(:eval (mode-line-frame-control))
  "Mode-line control to describe the current frame.")
199
;;;###autoload
200
(put 'mode-line-frame-identification 'risky-local-variable t)
201

202 203
(defvar mode-line-process nil "\
Mode-line control for displaying info on process status.
Richard M. Stallman's avatar
Richard M. Stallman committed
204 205
Normally nil in most modes, since there is no process to display.")

206
;;;###autoload
207
(put 'mode-line-process 'risky-local-variable t)
Richard M. Stallman's avatar
Richard M. Stallman committed
208 209
(make-variable-buffer-local 'mode-line-process)

210 211
(defvar mode-line-modified
  (list (propertize
212 213
	 "%1*"
	 'help-echo (purecopy (lambda (window object point)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
214
 				(format "Buffer is %s\nmouse-1 toggles"
215 216 217
					(save-selected-window
					  (select-window window)
					  (if buffer-read-only
Dan Nicolaescu's avatar
Dan Nicolaescu committed
218 219
					      "read-only"
					    "writable")))))
220
	 'local-map (purecopy (make-mode-line-mouse-map
221
			       'mouse-1
222 223
			       #'mode-line-toggle-read-only))
	 'mouse-face 'mode-line-highlight)
224 225 226
	(propertize
	 "%1+"
	 'help-echo  (purecopy (lambda (window object point)
227
				 (format "Buffer is %sodified\nmouse-1 toggles modified state"
228 229 230
					 (save-selected-window
					   (select-window window)
					   (if (buffer-modified-p)
231 232
					     "m"
					   "not m")))))
233
	 'local-map (purecopy (make-mode-line-mouse-map
234
			       'mouse-1 #'mode-line-toggle-modified))
235
	 'mouse-face 'mode-line-highlight))
Richard M. Stallman's avatar
Richard M. Stallman committed
236 237
  "Mode-line control for displaying whether current buffer is modified.")

238
;;;###autoload
239
(put 'mode-line-modified 'risky-local-variable t)
Richard M. Stallman's avatar
Richard M. Stallman committed
240 241
(make-variable-buffer-local 'mode-line-modified)

242 243
(defvar mode-line-remote
  (list (propertize
244
	 "%1@"
245
	 'mouse-face 'mode-line-highlight
246 247 248 249
	 'help-echo (purecopy (lambda (window object point)
 				(format "%s"
					(save-selected-window
					  (select-window window)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
250
					  (concat
251 252 253 254
					   (if (file-remote-p default-directory)
					       "Current directory is remote: "
					     "Current directory is local: ")
					   default-directory)))))))
255
  "Mode-line flag to show if default-directory for current buffer is remote.")
256
;;;###autoload
257
(put 'mode-line-remote 'risky-local-variable t)
258 259 260

(make-variable-buffer-local 'mode-line-remote)

261 262
;; Actual initialization is below.
(defvar mode-line-position nil
Kenichi Handa's avatar
Kenichi Handa committed
263 264 265
  "Mode-line control for displaying the position in the buffer.
Normally displays the buffer percentage and, optionally, the
buffer size, the line number and the column number.")
266
;;;###autoload
267
(put 'mode-line-position 'risky-local-variable t)
268 269 270

(defvar mode-line-modes nil
  "Mode-line control for displaying major and minor modes.")
271
;;;###autoload
272
(put 'mode-line-modes 'risky-local-variable t)
273

274 275 276
(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
Menu of mode operations in the mode line.")

Kenichi Handa's avatar
Kenichi Handa committed
277
(defvar mode-line-major-mode-keymap
278
  (let ((map (make-sparse-keymap)))
279
    (define-key map [mode-line down-mouse-1]
280
      `(menu-item ,(purecopy "Menu Bar") ignore
281
        :filter (lambda (_) (mouse-menu-major-mode-map))))
282
    (define-key map [mode-line mouse-2] 'describe-mode)
283
    (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
284
    map) "\
285 286
Keymap to display on major mode.")

Kenichi Handa's avatar
Kenichi Handa committed
287
(defvar mode-line-minor-mode-keymap
288
  (let ((map (make-sparse-keymap)))
289
    (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu)
290
    (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
291 292
    (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
    (define-key map [header-line down-mouse-3] mode-line-mode-menu)
293
    map) "\
294 295
Keymap to display on minor modes.")

296 297 298 299 300
(defvar mode-line-column-line-number-mode-map
  (let ((map (make-sparse-keymap))
	(menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
    (define-key menu-map [line-number-mode]
      `(menu-item ,(purecopy "Display Line Numbers") line-number-mode
301
		  :help ,(purecopy "Toggle displaying line numbers in the mode-line")
302 303 304
		  :button (:toggle . line-number-mode)))
    (define-key menu-map [column-number-mode]
      `(menu-item ,(purecopy "Display Column Numbers") column-number-mode
305
		  :help ,(purecopy "Toggle displaying column numbers in the mode-line")
306 307 308 309 310
		  :button (:toggle . column-number-mode)))
    (define-key map [mode-line down-mouse-1] menu-map)
    map) "\
Keymap to display on column and line numbers.")

311 312 313
(let* ((help-echo
	;; The multi-line message doesn't work terribly well on the
	;; bottom mode line...  Better ideas?
314 315 316
	;; 	  "\
	;; mouse-1: select window, mouse-2: delete others, mouse-3: delete,
	;; drag-mouse-1: resize, C-mouse-2: split horizontally"
Dan Nicolaescu's avatar
Dan Nicolaescu committed
317 318 319
	"mouse-1: Select (drag to resize)\n\
mouse-2: Make current window occupy the whole frame\n\
mouse-3: Remove current window from display")
320
       (recursive-edit-help-echo "Recursive edit, type C-M-c to get out")
321
       (spaces (propertize " " 'help-echo help-echo))
322 323 324 325 326
       (standard-mode-line-format
	(list
	 "%e"
	 (propertize "-" 'help-echo help-echo)
	 'mode-line-mule-info
Karoly Lorentey's avatar
Karoly Lorentey committed
327
	 'mode-line-client
328
	 'mode-line-modified
329
	 'mode-line-remote
330 331 332 333 334 335 336
	 'mode-line-frame-identification
	 'mode-line-buffer-identification
	 (propertize "   " 'help-echo help-echo)
	 'mode-line-position
	 '(vc-mode vc-mode)
	 (propertize "  " 'help-echo help-echo)
	 'mode-line-modes
337 338 339 340
	 `(which-func-mode ("" which-func-format ,spaces))
	 `(global-mode-string ("" global-mode-string ,spaces))
	 `(:eval (unless (display-graphic-p)
		   ,(propertize "-%-" 'help-echo help-echo)))))
341 342
       (standard-mode-line-modes
	(list
343
	 (propertize "%[" 'help-echo recursive-edit-help-echo)
344
	 (propertize "(" 'help-echo help-echo)
345
	 `(:propertize ("" mode-name)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
346 347 348 349
		       help-echo "Major mode\n\
mouse-1: Display major mode menu\n\
mouse-2: Show help for major mode\n\
mouse-3: Toggle minor modes"
350 351 352 353 354
		       mouse-face mode-line-highlight
		       local-map ,mode-line-major-mode-keymap)
	 '("" mode-line-process)
	 `(:propertize ("" minor-mode-alist)
		       mouse-face mode-line-highlight
Dan Nicolaescu's avatar
Dan Nicolaescu committed
355 356 357 358
		       help-echo "Minor mode\n\
mouse-1: Display minor mode menu\n\
mouse-2: Show help for minor mode\n\
mouse-3: Toggle minor modes"
359
		       local-map ,mode-line-minor-mode-keymap)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
360
	 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from the current buffer"
361 362 363
		     'mouse-face 'mode-line-highlight
		     'local-map (make-mode-line-mouse-map
				 'mouse-2 #'mode-line-widen))
364
	 (propertize ")" 'help-echo help-echo)
365
	 (propertize "%]" 'help-echo recursive-edit-help-echo)
366
	 spaces))
Karoly Lorentey's avatar
Karoly Lorentey committed
367

368
       (standard-mode-line-position
369 370 371
	`((-3 ,(propertize
		"%p"
		'local-map mode-line-column-line-number-mode-map
372
		'mouse-face 'mode-line-highlight
373 374 375
		;; XXX needs better description
		'help-echo "Size indication mode\n\
mouse-1: Display Line and Column Mode Menu"))
376
	  (size-indication-mode
Dan Nicolaescu's avatar
Dan Nicolaescu committed
377
	   (8 ,(propertize
Dan Nicolaescu's avatar
Dan Nicolaescu committed
378
		" of %I"
379
		'local-map mode-line-column-line-number-mode-map
380
		'mouse-face 'mode-line-highlight
Dan Nicolaescu's avatar
Dan Nicolaescu committed
381
		;; XXX needs better description
382 383
		'help-echo "Size indication mode\n\
mouse-1: Display Line and Column Mode Menu")))
384 385
	  (line-number-mode
	   ((column-number-mode
Dan Nicolaescu's avatar
Dan Nicolaescu committed
386 387
	     (10 ,(propertize
		   " (%l,%c)"
388
		   'local-map mode-line-column-line-number-mode-map
389
		   'mouse-face 'mode-line-highlight
390 391
		   'help-echo "Line number and Column number\n\
mouse-1: Display Line and Column Mode Menu"))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
392 393
	     (6 ,(propertize
		  " L%l"
394
		  'local-map mode-line-column-line-number-mode-map
395
		  'mouse-face 'mode-line-highlight
396 397
		  'help-echo "Line Number\n\
mouse-1: Display Line and Column Mode Menu"))))
398
	   ((column-number-mode
Dan Nicolaescu's avatar
Dan Nicolaescu committed
399 400
	     (5 ,(propertize
		  " C%c"
401
		  'local-map mode-line-column-line-number-mode-map
402
		  'mouse-face 'mode-line-highlight
403 404
		  'help-echo "Column number\n\
mouse-1: Display Line and Column Mode Menu"))))))))
405 406 407 408 409 410 411 412 413 414 415 416

  (setq-default mode-line-format standard-mode-line-format)
  (put 'mode-line-format 'standard-value
       (list `(quote ,standard-mode-line-format)))

  (setq-default mode-line-modes standard-mode-line-modes)
  (put 'mode-line-modes 'standard-value
       (list `(quote ,standard-mode-line-modes)))

  (setq-default mode-line-position standard-mode-line-position)
  (put 'mode-line-position 'standard-value
       (list `(quote ,standard-mode-line-position))))
Richard M. Stallman's avatar
Richard M. Stallman committed
417

418 419 420 421 422 423 424 425 426 427 428 429 430
(defvar mode-line-buffer-identification-keymap
  ;; Add menu of buffer operations to the buffer identification part
  ;; of the mode line.or header line.
  (let ((map (make-sparse-keymap)))
    ;; Bind down- events so that the global keymap won't ``shine
    ;; through''.
    (define-key map [mode-line mouse-1] 'mode-line-previous-buffer)
    (define-key map [header-line down-mouse-1] 'ignore)
    (define-key map [header-line mouse-1] 'mode-line-previous-buffer)
    (define-key map [mode-line mouse-3] 'mode-line-next-buffer)
    (define-key map [header-line down-mouse-3] 'ignore)
    (define-key map [header-line mouse-3] 'mode-line-next-buffer)
    map) "\
431
Keymap for what is displayed by `mode-line-buffer-identification'.")
432

433 434 435 436
(defun propertized-buffer-identification (fmt)
  "Return a list suitable for `mode-line-buffer-identification'.
FMT is a format specifier such as \"%12b\".  This function adds
text properties for face, help-echo, and local-map to it."
437
  (list (propertize fmt
438 439
		    'face 'mode-line-buffer-id
		    'help-echo
440
		    (purecopy "Buffer name\n\
Dan Nicolaescu's avatar
Dan Nicolaescu committed
441 442
mouse-1: previous buffer\n\
mouse-3: next buffer")
443 444 445
		    'mouse-face 'mode-line-highlight
		    'local-map mode-line-buffer-identification-keymap)))

446
(defvar mode-line-buffer-identification (propertized-buffer-identification "%12b") "\
447 448 449 450 451
Mode-line control for identifying the buffer being displayed.
Its default value is (\"%12b\") with some text properties added.
Major modes that edit things other than ordinary files may change this
\(e.g. Info, Dired,...)")

452
;;;###autoload
453
(put 'mode-line-buffer-identification 'risky-local-variable t)
454 455
(make-variable-buffer-local 'mode-line-buffer-identification)

456 457
(defun unbury-buffer () "\
Switch to the last buffer in the buffer list."
458 459 460
  (interactive)
  (switch-to-buffer (last-buffer)))

461
(defun mode-line-unbury-buffer (event) "\
462
Call `unbury-buffer' in this window."
463 464 465
  (interactive "e")
  (save-selected-window
    (select-window (posn-window (event-start event)))
466
    (unbury-buffer)))
467 468

(defun mode-line-bury-buffer (event) "\
Sam Steingold's avatar
Sam Steingold committed
469
Like `bury-buffer', but temporarily select EVENT's window."
470 471 472 473
  (interactive "e")
  (save-selected-window
    (select-window (posn-window (event-start event)))
    (bury-buffer)))
474

475 476
(defun mode-line-other-buffer () "\
Switch to the most recently selected buffer other than the current one."
477 478 479
  (interactive)
  (switch-to-buffer (other-buffer)))

480 481 482 483 484 485 486 487 488 489 490 491 492 493
(defun mode-line-next-buffer (event)
  "Like `next-buffer', but temporarily select EVENT's window."
  (interactive "e")
  (save-selected-window
    (select-window (posn-window (event-start event)))
    (next-buffer)))

(defun mode-line-previous-buffer (event)
  "Like `previous-buffer', but temporarily select EVENT's window."
  (interactive "e")
  (save-selected-window
    (select-window (posn-window (event-start event)))
    (previous-buffer)))

Dave Love's avatar
Dave Love committed
494 495
(defmacro bound-and-true-p (var)
  "Return the value of symbol VAR if it is bound, else nil."
496
  `(and (boundp (quote ,var)) ,var))
Dave Love's avatar
Dave Love committed
497

498 499
;; Use mode-line-mode-menu for local minor-modes only.
;; Global ones can go on the menubar (Options --> Show/Hide).
500
(define-key mode-line-mode-menu [overwrite-mode]
501
  `(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode
502
	      :help ,(purecopy "Overwrite mode: typed characters replace existing text")
503
	      :button (:toggle . overwrite-mode)))
504
(define-key mode-line-mode-menu [outline-minor-mode]
505
  `(menu-item ,(purecopy "Outline (Outl)") outline-minor-mode
Dan Nicolaescu's avatar
Dan Nicolaescu committed
506
	      ;; XXX: This needs a good, brief description.
507
	      :help ,(purecopy "")
508 509
	      :button (:toggle . (bound-and-true-p outline-minor-mode))))
(define-key mode-line-mode-menu [highlight-changes-mode]
510
  `(menu-item ,(purecopy "Highlight changes (Chg)") highlight-changes-mode
511
	      :help ,(purecopy "Show changes in the buffer in a distinctive color")
512
	      :button (:toggle . (bound-and-true-p highlight-changes-mode))))
513
(define-key mode-line-mode-menu [hide-ifdef-mode]
514
  `(menu-item ,(purecopy "Hide ifdef (Ifdef)") hide-ifdef-mode
515
	      :help ,(purecopy "Show/Hide code within #ifdef constructs")
516
	      :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
517 518
(define-key mode-line-mode-menu [glasses-mode]
  `(menu-item ,(purecopy "Glasses (o^o)") glasses-mode
519
	      :help ,(purecopy "Insert virtual separators to make long identifiers easy to read")
520
	      :button (:toggle . (bound-and-true-p glasses-mode))))
521
(define-key mode-line-mode-menu [font-lock-mode]
522
  `(menu-item ,(purecopy "Font Lock") font-lock-mode
523
	      :help ,(purecopy "Syntax coloring")
524 525
	      :button (:toggle . font-lock-mode)))
(define-key mode-line-mode-menu [flyspell-mode]
526
  `(menu-item ,(purecopy "Flyspell (Fly)") flyspell-mode
527
	      :help ,(purecopy "Spell checking on the fly")
528
	      :button (:toggle . (bound-and-true-p flyspell-mode))))
529 530
(define-key mode-line-mode-menu [auto-revert-tail-mode]
  `(menu-item ,(purecopy "Auto revert tail (Tail)") auto-revert-tail-mode
531
	      :help ,(purecopy "Revert the tail of the buffer when buffer grows")
532
	      :enable (buffer-file-name)
533
	      :button (:toggle . (bound-and-true-p auto-revert-tail-mode))))
534
(define-key mode-line-mode-menu [auto-revert-mode]
535
  `(menu-item ,(purecopy "Auto revert (ARev)") auto-revert-mode
536
	      :help ,(purecopy "Revert the buffer when the file on disk changes")
537
	      :button (:toggle . (bound-and-true-p auto-revert-mode))))
538 539
(define-key mode-line-mode-menu [auto-fill-mode]
  `(menu-item ,(purecopy "Auto fill (Fill)") auto-fill-mode
540
	      :help ,(purecopy "Automatically insert new lines")
541
	      :button (:toggle . auto-fill-function)))
542
(define-key mode-line-mode-menu [abbrev-mode]
543
  `(menu-item ,(purecopy "Abbrev (Abbrev)") abbrev-mode
544
	      :help ,(purecopy "Automatically expand abbreviations")
545
	      :button (:toggle . abbrev-mode)))
546

547
(defun mode-line-minor-mode-help (event)
548
  "Describe minor mode for EVENT on minor modes area of the mode line."
549 550 551 552
  (interactive "@e")
  (let ((indicator (car (nth 4 (car (cdr event))))))
    (describe-minor-mode-from-indicator indicator)))

553 554 555
(defvar minor-mode-alist nil "\
Alist saying how to show minor modes in the mode line.
Each element looks like (VARIABLE STRING);
556
STRING is included in the mode line if VARIABLE's value is non-nil.
557 558 559

Actually, STRING need not be a string; any possible mode-line element
is okay.  See `mode-line-format'.")
560
;;;###autoload
561
(put 'minor-mode-alist 'risky-local-variable t)
562 563
;; Don't use purecopy here--some people want to change these strings.
(setq minor-mode-alist
564 565 566 567 568
      '((abbrev-mode " Abbrev")
        (overwrite-mode overwrite-mode)
        (auto-fill-function " Fill")
        ;; not really a minor mode...
        (defining-kbd-macro " Def")))
569

Richard M. Stallman's avatar
Richard M. Stallman committed
570 571 572 573 574 575 576 577
;; These variables are used by autoloadable packages.
;; They are defined here so that they do not get overridden
;; by the loading of those packages.

;; Names in directory that end in one of these
;; are ignored in completion,
;; making it more likely you will get a unique match.
(setq completion-ignored-extensions
578
      (append
579
       (cond ((memq system-type '(ms-dos windows-nt))
580
	      (mapcar 'purecopy
581
	      '(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk"
582
		".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386")))
583
	     (t
584
	      (mapcar 'purecopy
585
	      '(".o" "~" ".bin" ".lbin" ".so"
586 587
		".a" ".ln" ".blg" ".bbl"))))
       (mapcar 'purecopy
588 589
       '(".elc" ".lof"
	 ".glo" ".idx" ".lot"
590 591
	 ;; VCS metadata directories
	 ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/"
592
	 ;; TeX-related
593
	 ".fmt" ".tfm"
594 595
	 ;; Java compiled
	 ".class"
596 597
	 ;; CLISP
	 ".fas" ".lib" ".mem"
598
	 ;; CMUCL
599
	 ".x86f" ".sparcf"
Kenichi Handa's avatar
Kenichi Handa committed
600
         ;; Other CL implementations (Allegro, LispWorks, OpenMCL)
601
         ".fasl" ".ufsl" ".fsl" ".dxl" ".pfsl" ".dfsl"
602
	 ".p64fsl" ".d64fsl" ".dx64fsl"
603 604
	 ;; Libtool
	 ".lo" ".la"
605 606
	 ;; Gettext
	 ".gmo" ".mo"
607
	 ;; Texinfo-related
Kenichi Handa's avatar
Kenichi Handa committed
608 609 610
	 ;; This used to contain .log, but that's commonly used for log
	 ;; files you do want to see, not just TeX stuff.  -- fx
	 ".toc" ".aux"
611
	 ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
612 613
	 ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs"
	 ;; Python byte-compiled
614
	 ".pyc" ".pyo"))))
Richard M. Stallman's avatar
Richard M. Stallman committed
615

616 617 618 619 620 621 622 623
;; Suffixes used for executables.
(setq exec-suffixes
      (cond
       ((memq system-type '(ms-dos windows-nt))
	'(".exe" ".com" ".bat" ".cmd" ".btm" ""))
       (t
	'(""))))

624 625
;; Packages should add to this list appropriately when they are
;; loaded, rather than listing everything here.
Richard M. Stallman's avatar
Richard M. Stallman committed
626
(setq debug-ignored-errors
627
      `(beginning-of-line beginning-of-buffer end-of-line
Richard M. Stallman's avatar
Richard M. Stallman committed
628
	end-of-buffer end-of-file buffer-read-only
629
	file-supersession
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
      	,(purecopy "^Previous command was not a yank$")
	,(purecopy "^Minibuffer window is not active$")
	,(purecopy "^No previous history search regexp$")
	,(purecopy "^No later matching history item$")
	,(purecopy "^No earlier matching history item$")
	,(purecopy "^End of history; no default available$")
	,(purecopy "^End of defaults; no next item$")
	,(purecopy "^Beginning of history; no preceding item$")
	,(purecopy "^No recursive edit is in progress$")
	,(purecopy "^Changes to be undone are outside visible portion of buffer$")
	,(purecopy "^No undo information in this buffer$")
	,(purecopy "^No further undo information")
	,(purecopy "^Save not confirmed$")
	,(purecopy "^Recover-file cancelled\\.$")
	,(purecopy "^Cannot switch buffers in a dedicated window$")
645
        ))
Richard M. Stallman's avatar
Richard M. Stallman committed
646 647 648 649


(make-variable-buffer-local 'indent-tabs-mode)

650
;; We have base64 and md5 functions built in now.
651 652 653 654
(provide 'base64)
(provide 'md5)
(provide 'overlay '(display syntax-table field))
(provide 'text-properties '(display syntax-table field point-entered))
655

656 657
(define-key esc-map "\t" 'complete-symbol)

Richard M. Stallman's avatar
Richard M. Stallman committed
658 659 660 661
;; Reduce total amount of space we must allocate during this function
;; that we will not need to keep permanently.
(garbage-collect)

662

Richard M. Stallman's avatar
Richard M. Stallman committed
663 664
(setq help-event-list '(help f1))

665 666
(make-variable-buffer-local 'minor-mode-overriding-map-alist)

667 668
;; From frame.c
(global-set-key [switch-frame] 'handle-switch-frame)
669 670 671 672 673
(global-set-key [select-window] 'handle-select-window)

;; FIXME: Do those 3 events really ever reach the global-map ?
;;        It seems that they can't because they're handled via
;;        special-event-map which is used at very low-level.  -stef
674 675 676 677 678
(global-set-key [delete-frame] 'handle-delete-frame)
(global-set-key [iconify-frame] 'ignore-event)
(global-set-key [make-frame-visible] 'ignore-event)


Richard M. Stallman's avatar
Richard M. Stallman committed
679 680 681
;These commands are defined in editfns.c
;but they are not assigned to keys there.
(put 'narrow-to-region 'disabled t)
682

683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
;; Moving with arrows in bidi-sensitive direction.
(defun right-char (&optional n)
  "Move point N characters to the right (to the left if N is negative).
On reaching beginning or end of buffer, stop and signal error.

Depending on the bidirectional context, this may move either forward
or backward in the buffer.  This is in contrast with \\[forward-char]
and \\[backward-char], which see."
  (interactive "^p")
  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
      (forward-char n)
    (backward-char n)))

(defun left-char ( &optional n)
  "Move point N characters to the left (to the right if N is negative).
On reaching beginning or end of buffer, stop and signal error.

Depending on the bidirectional context, this may move either backward
or forward in the buffer.  This is in contrast with \\[backward-char]
and \\[forward-char], which see."
  (interactive "^p")
  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
      (backward-char n)
    (forward-char n)))

(defun right-word (&optional n)
  "Move point N words to the right (to the left if N is negative).

Depending on the bidirectional context, this may move either forward
or backward in the buffer.  This is in contrast with \\[forward-word]
and \\[backward-word], which see.

Value is normally t.
If an edge of the buffer or a field boundary is reached, point is left there
there and the function returns nil.  Field boundaries are not noticed
if `inhibit-field-text-motion' is non-nil."
  (interactive "^p")
  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
      (forward-word n)
    (backward-word n)))

(defun left-word (&optional n)
  "Move point N words to the left (to the right if N is negative).

Depending on the bidirectional context, this may move either backward
or forward in the buffer.  This is in contrast with \\[backward-word]
and \\[forward-word], which see.

Value is normally t.
If an edge of the buffer or a field boundary is reached, point is left there
there and the function returns nil.  Field boundaries are not noticed
if `inhibit-field-text-motion' is non-nil."
  (interactive "^p")
  (if (eq (current-bidi-paragraph-direction) 'left-to-right)
      (backward-word n)
    (forward-word n)))

740 741 742 743 744 745
(defvar narrow-map (make-sparse-keymap)
  "Keymap for narrowing commands.")
(define-key ctl-x-map "n" narrow-map)

(define-key narrow-map "n" 'narrow-to-region)
(define-key narrow-map "w" 'widen)
Richard M. Stallman's avatar
Richard M. Stallman committed
746

747 748 749 750
;; Quitting
(define-key global-map "\e\e\e" 'keyboard-escape-quit)
(define-key global-map "\C-g" 'keyboard-quit)

751 752 753 754
;; Used to be in termdev.el: when using several terminals, make C-z
;; suspend only the relevant terminal.
(substitute-key-definition 'suspend-emacs 'suspend-frame global-map)

Richard M. Stallman's avatar
Richard M. Stallman committed
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
(define-key global-map "\C-j" 'newline-and-indent)
(define-key global-map "\C-m" 'newline)
(define-key global-map "\C-o" 'open-line)
(define-key esc-map "\C-o" 'split-line)
(define-key global-map "\C-q" 'quoted-insert)
(define-key esc-map "^" 'delete-indentation)
(define-key esc-map "\\" 'delete-horizontal-space)
(define-key esc-map "m" 'back-to-indentation)
(define-key ctl-x-map "\C-o" 'delete-blank-lines)
(define-key esc-map " " 'just-one-space)
(define-key esc-map "z" 'zap-to-char)
(define-key esc-map "=" 'count-lines-region)
(define-key ctl-x-map "=" 'what-cursor-position)
(define-key esc-map ":" 'eval-expression)
;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
(define-key esc-map "\M-:" 'eval-expression)
;; Changed from C-x ESC so that function keys work following C-x.
(define-key ctl-x-map "\e\e" 'repeat-complex-command)
;; New binding analogous to M-:.
(define-key ctl-x-map "\M-:" 'repeat-complex-command)
775 776
(define-key ctl-x-map "u" 'undo)
(put 'undo :advertised-binding [?\C-x ?u])
Richard M. Stallman's avatar
Richard M. Stallman committed
777 778 779
;; Many people are used to typing C-/ on X terminals and getting C-_.
(define-key global-map [?\C-/] 'undo)
(define-key global-map "\C-_" 'undo)
780 781 782 783
;; Richard said that we should not use C-x <uppercase letter> and I have
;; no idea whereas to bind it.  Any suggestion welcome.  -stef
;; (define-key ctl-x-map "U" 'undo-only)

Richard M. Stallman's avatar
Richard M. Stallman committed
784 785
(define-key esc-map "!" 'shell-command)
(define-key esc-map "|" 'shell-command-on-region)
786
(define-key esc-map "&" 'async-shell-command)
Richard M. Stallman's avatar
Richard M. Stallman committed
787

788 789 790 791
(define-key ctl-x-map [right] 'next-buffer)
(define-key ctl-x-map [C-right] 'next-buffer)
(define-key ctl-x-map [left] 'previous-buffer)
(define-key ctl-x-map [C-left] 'previous-buffer)
792

793 794 795 796 797 798 799 800
(let ((map minibuffer-local-map))
  (define-key map "\en"   'next-history-element)
  (define-key map [next]  'next-history-element)
  (define-key map [down]  'next-history-element)
  (define-key map "\ep"   'previous-history-element)
  (define-key map [prior] 'previous-history-element)
  (define-key map [up]    'previous-history-element)
  (define-key map "\es"   'next-matching-history-element)
801 802 803 804
  (define-key map "\er"   'previous-matching-history-element)
  ;; Override the global binding (which calls indent-relative via
  ;; indent-for-tab-command).  The alignment that indent-relative tries to
  ;; do doesn't make much sense here since the prompt messes it up.
805
  (define-key map "\t"    'self-insert-command)
806
  (define-key map [C-tab] 'file-cache-minibuffer-complete))
Richard M. Stallman's avatar
Richard M. Stallman committed
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826

(define-key global-map "\C-u" 'universal-argument)
(let ((i ?0))
  (while (<= i ?9)
    (define-key esc-map (char-to-string i) 'digit-argument)
    (setq i (1+ i))))
(define-key esc-map "-" 'negative-argument)
;; Define control-digits.
(let ((i ?0))
  (while (<= i ?9)
    (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
    (setq i (1+ i))))
(define-key global-map [?\C--] 'negative-argument)
;; Define control-meta-digits.
(let ((i ?0))
  (while (<= i ?9)
    (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
    (setq i (1+ i))))
(define-key global-map [?\C-\M--] 'negative-argument)

827
(define-key global-map "\177" 'delete-backward-char)
828
(define-key global-map "\C-d" 'delete-char)
829

Richard M. Stallman's avatar
Richard M. Stallman committed
830 831 832 833 834 835 836 837 838 839 840
(define-key global-map "\C-k" 'kill-line)
(define-key global-map "\C-w" 'kill-region)
(define-key esc-map "w" 'kill-ring-save)
(define-key esc-map "\C-w" 'append-next-kill)
(define-key global-map "\C-y" 'yank)
(define-key esc-map "y" 'yank-pop)

;; (define-key ctl-x-map "a" 'append-to-buffer)

(define-key global-map "\C-@" 'set-mark-command)
;; Many people are used to typing C-SPC and getting C-@.
841
(define-key global-map [?\C- ] 'set-mark-command)
Richard M. Stallman's avatar
Richard M. Stallman committed
842 843
(define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
(define-key ctl-x-map "\C-@" 'pop-global-mark)
844
(define-key ctl-x-map [?\C- ] 'pop-global-mark)
Richard M. Stallman's avatar
Richard M. Stallman committed
845 846 847 848

(define-key global-map "\C-n" 'next-line)
(define-key global-map "\C-p" 'previous-line)
(define-key ctl-x-map "\C-n" 'set-goal-column)
849
(define-key global-map "\C-a" 'move-beginning-of-line)
850
(define-key global-map "\C-e" 'move-end-of-line)
Richard M. Stallman's avatar
Richard M. Stallman committed
851

852 853
(define-key ctl-x-map "`" 'next-error)

854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875
(defvar goto-map (make-sparse-keymap)
  "Keymap for navigation commands.")
(define-key esc-map "g" goto-map)

(define-key goto-map    "g" 'goto-line)
(define-key goto-map "\M-g" 'goto-line)
(define-key goto-map    "n" 'next-error)
(define-key goto-map "\M-n" 'next-error)
(define-key goto-map    "p" 'previous-error)
(define-key goto-map "\M-p" 'previous-error)

(defvar search-map (make-sparse-keymap)
  "Keymap for search related commands.")
(define-key esc-map "s" search-map)

(define-key search-map "o"  'occur)
(define-key search-map "hr" 'highlight-regexp)
(define-key search-map "hp" 'highlight-phrase)
(define-key search-map "hl" 'highlight-lines-matching-regexp)
(define-key search-map "hu" 'unhighlight-regexp)
(define-key search-map "hf" 'hi-lock-find-patterns)
(define-key search-map "hw" 'hi-lock-write-interactive-patterns)
876

Richard M. Stallman's avatar
Richard M. Stallman committed
877 878
;;(defun function-key-error ()
;;  (interactive)
879
;;  (error "That function key is not bound to anything"))
Richard M. Stallman's avatar
Richard M. Stallman committed
880 881 882 883

(define-key global-map [menu] 'execute-extended-command)
(define-key global-map [find] 'search-forward)

884 885
;; Don't do this.  We define <delete> in function-key-map instead.
;(define-key global-map [delete] 'backward-delete-char)
886

Richard M. Stallman's avatar
Richard M. Stallman committed
887
;; natural bindings for terminal keycaps --- defined in X keysym order
888
(define-key global-map [C-S-backspace]  'kill-whole-line)
889
(define-key global-map [home]		'move-beginning-of-line)
890
(define-key global-map [C-home]		'beginning-of-buffer)
Richard M. Stallman's avatar
Richard M. Stallman committed
891
(define-key global-map [M-home]		'beginning-of-buffer-other-window)
892
(define-key esc-map    [home]		'beginning-of-buffer-other-window)
893
(define-key global-map [left]		'left-char)
Richard M. Stallman's avatar
Richard M. Stallman committed
894
(define-key global-map [up]		'previous-line)
895
(define-key global-map [right]		'right-char)
Richard M. Stallman's avatar
Richard M. Stallman committed
896
(define-key global-map [down]		'next-line)
897 898
(define-key global-map [prior]		'scroll-down-command)
(define-key global-map [next]		'scroll-up-command)
Richard M. Stallman's avatar
Richard M. Stallman committed
899 900 901
(define-key global-map [C-up]		'backward-paragraph)
(define-key global-map [C-down]		'forward-paragraph)
(define-key global-map [C-prior]	'scroll-right)
902
(put 'scroll-left 'disabled t)
Richard M. Stallman's avatar
Richard M. Stallman committed
903 904
(define-key global-map [C-next]		'scroll-left)
(define-key global-map [M-next]		'scroll-other-window)
905
(define-key esc-map    [next]		'scroll-other-window)
Richard M. Stallman's avatar
Richard M. Stallman committed
906
(define-key global-map [M-prior]	'scroll-other-window-down)
907
(define-key esc-map    [prior]		'scroll-other-window-down)
908
(define-key esc-map [?\C-\S-v]		'scroll-other-window-down)
909
(define-key global-map [end]		'move-end-of-line)
910
(define-key global-map [C-end]		'end-of-buffer)
Richard M. Stallman's avatar
Richard M. Stallman committed
911
(define-key global-map [M-end]		'end-of-buffer-other-window)
912
(define-key esc-map    [end]		'end-of-buffer-other-window)
Richard M. Stallman's avatar
Richard M. Stallman committed
913 914
(define-key global-map [begin]		'beginning-of-buffer)
(define-key global-map [M-begin]	'beginning-of-buffer-other-window)
915
(define-key esc-map    [begin]		'beginning-of-buffer-other-window)
Richard M. Stallman's avatar
Richard M. Stallman committed
916 917 918 919 920 921
;; (define-key global-map [select]	'function-key-error)
;; (define-key global-map [print]	'function-key-error)
(define-key global-map [execute]	'execute-extended-command)
(define-key global-map [insert]		'overwrite-mode)
(define-key global-map [C-insert]	'kill-ring-save)
(define-key global-map [S-insert]	'yank)
922 923 924 925 926
;; `insertchar' is what term.c produces.  Should we change term.c
;; to produce `insert' instead?
(define-key global-map [insertchar]	'overwrite-mode)
(define-key global-map [C-insertchar]	'kill-ring-save)
(define-key global-map [S-insertchar]	'yank)
Richard M. Stallman's avatar
Richard M. Stallman committed
927 928
(define-key global-map [undo]		'undo)
(define-key global-map [redo]		'repeat-complex-command)
Kenichi Handa's avatar
Kenichi Handa committed
929 930 931 932 933
(define-key global-map [again]		'repeat-complex-command) ; Sun keyboard
(define-key global-map [open]		'find-file) ; Sun
;; The following wouldn't work to interrupt running code since C-g is
;; treated specially in the event loop.
;; (define-key global-map [stop]		'keyboard-quit) ; Sun
Richard M. Stallman's avatar
Richard M. Stallman committed
934 935 936
;; (define-key global-map [clearline]	'function-key-error)
(define-key global-map [insertline]	'open-line)
(define-key global-map [deleteline]	'kill-line)
937
(define-key global-map [deletechar]	'delete-forward-char)
Richard M. Stallman's avatar
Richard M. Stallman committed
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
;; (define-key global-map [backtab]	'function-key-error)
;; (define-key global-map [f1]		'function-key-error)
;; (define-key global-map [f2]		'function-key-error)
;; (define-key global-map [f3]		'function-key-error)
;; (define-key global-map [f4]		'function-key-error)
;; (define-key global-map [f5]		'function-key-error)
;; (define-key global-map [f6]		'function-key-error)
;; (define-key global-map [f7]		'function-key-error)
;; (define-key global-map [f8]		'function-key-error)
;; (define-key global-map [f9]		'function-key-error)
;; (define-key global-map [f10]		'function-key-error)
;; (define-key global-map [f11]		'function-key-error)
;; (define-key global-map [f12]		'function-key-error)
;; (define-key global-map [f13]		'function-key-error)
;; (define-key global-map [f14]		'function-key-error)
;; (define-key global-map [f15]		'function-key-error)
;; (define-key global-map [f16]		'function-key-error)
;; (define-key global-map [f17]		'function-key-error)
;; (define-key global-map [f18]		'function-key-error)
;; (define-key global-map [f19]		'function-key-error)
;; (define-key global-map [f20]		'function-key-error)
;; (define-key global-map [f21]		'function-key-error)
;; (define-key global-map [f22]		'function-key-error)
;; (define-key global-map [f23]		'function-key-error)
;; (define-key global-map [f24]		'function-key-error)
;; (define-key global-map [f25]		'function-key-error)
;; (define-key global-map [f26]		'function-key-error)
;; (define-key global-map [f27]		'function-key-error)
;; (define-key global-map [f28]		'function-key-error)
;; (define-key global-map [f29]		'function-key-error)
;; (define-key global-map [f30]		'function-key-error)
;; (define-key global-map [f31]		'function-key-error)
;; (define-key global-map [f32]		'function-key-error)
;; (define-key global-map [f33]		'function-key-error)
;; (define-key global-map [f34]		'function-key-error)
;; (define-key global-map [f35]		'function-key-error)
;; (define-key global-map [kp-backtab]	'function-key-error)
;; (define-key global-map [kp-space]	'function-key-error)
;; (define-key global-map [kp-tab]		'function-key-error)
;; (define-key global-map [kp-enter]	'function-key-error)
;; (define-key global-map [kp-f1]		'function-key-error)
;; (define-key global-map [kp-f2]		'function-key-error)
;; (define-key global-map [kp-f3]		'function-key-error)
;; (define-key global-map [kp-f4]		'function-key-error)
;; (define-key global-map [kp-multiply]	'function-key-error)
;; (define-key global-map [kp-add]		'function-key-error)
;; (define-key global-map [kp-separator]	'function-key-error)
;; (define-key global-map [kp-subtract]	'function-key-error)
;; (define-key global-map [kp-decimal]	'function-key-error)
;; (define-key global-map [kp-divide]	'function-key-error)
;; (define-key global-map [kp-0]		'function-key-error)
;; (define-key global-map [kp-1]		'function-key-error)
;; (define-key global-map [kp-2]		'function-key-error)
;; (define-key global-map [kp-3]		'function-key-error)
;; (define-key global-map [kp-4]		'function-key-error)
;; (define-key global-map [kp-5]		'recenter)
;; (define-key global-map [kp-6]		'function-key-error)
;; (define-key global-map [kp-7]		'function-key-error)
;; (define-key global-map [kp-8]		'function-key-error)
;; (define-key global-map [kp-9]		'function-key-error)
;; (define-key global-map [kp-equal]	'function-key-error)

;; X11R6 distinguishes these keys from the non-kp keys.
;; Make them behave like the non-kp keys unless otherwise bound.
1002 1003 1004
;; FIXME: rather than list such mappings for every modifier-combination,
;;   we should come up with a way to do it generically, something like
;;   (define-key function-key-map [*-kp-home] [*-home])
Richard M. Stallman's avatar
Richard M. Stallman committed
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
(define-key function-key-map [kp-home] [home])
(define-key function-key-map [kp-left] [left])
(define-key function-key-map [kp-up] [up])
(define-key function-key-map [kp-right] [right])
(define-key function-key-map [kp-down] [down])
(define-key function-key-map [kp-prior] [prior])
(define-key function-key-map [kp-next] [next])
(define-key function-key-map [M-kp-next] [M-next])
(define-key function-key-map [kp-end] [end])
(define-key function-key-map [kp-begin] [begin])
(define-key function-key-map [kp-insert] [insert])
1016 1017
(define-key function-key-map [backspace] [?\C-?])
(define-key function-key-map [delete] [?\C-?])