home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / prim / keydefs.el < prev    next >
Encoding:
Text File  |  1995-07-14  |  16.3 KB  |  408 lines

  1. ;; Define standard keybindings.
  2. ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of XEmacs.
  5.  
  6. ;; XEmacs is free software; you can redistribute it and/or modify it
  7. ;; under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 2, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; XEmacs is distributed in the hope that it will be useful, but
  12. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. ;; General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  18. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. ;; All the global bindings should be here so that one can reload things
  21. ;; like files.el without trashing one's personal bindings.
  22.  
  23. ;; created by C code
  24. (defvar global-map (current-global-map) "\
  25. Default global keymap mapping XEmacs keyboard input into commands.
  26. The value is a keymap which is usually (but not necessarily) XEmacs's
  27. global map.")
  28.  
  29. ;; created by C code
  30. (defvar esc-map (symbol-function 'ESC-prefix) "\
  31. Default keymap for ESC (meta) commands.
  32. The normal global definition of the character ESC indirects to this keymap.")
  33.  
  34. (set-keymap-name global-map 'global-map)
  35. (set-keymap-name esc-map 'ESC-prefix)
  36.  
  37. (define-prefix-command 'Control-X-prefix t)
  38. (defvar ctl-x-map (symbol-function 'Control-X-prefix) "\
  39. Default keymap for C-x commands.
  40. The normal global definition of the character C-x indirects to this keymap.")
  41. (define-key global-map "\C-x" 'Control-X-prefix)
  42.  
  43. (define-prefix-command 'ctl-x-4-prefix t)
  44. (defvar ctl-x-4-map (symbol-function 'ctl-x-4-prefix) "\
  45. Keymap for subcommands of C-x 4")
  46. (define-key global-map "\C-x4" 'ctl-x-4-prefix)
  47.  
  48. (define-prefix-command 'ctl-x-5-prefix t)
  49. (defvar ctl-x-5-map (symbol-function 'ctl-x-5-prefix) "\
  50. Keymap for subcommands of C-x 5")
  51. (define-key global-map "\C-x5" 'ctl-x-5-prefix)
  52.  
  53. (define-prefix-command 'mode-specific-command-prefix t)
  54. (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix) "\
  55. Keymap for characters following C-c.")
  56. (define-key global-map "\C-c" 'mode-specific-command-prefix)
  57.  
  58. (define-key global-map "\C-z" 'suspend-or-iconify-emacs)
  59. (define-key global-map "\C-x\C-z" 'suspend-or-iconify-emacs)
  60.  
  61. (define-key global-map "\M-\C-c" 'exit-recursive-edit)
  62. (define-key global-map "\C-]" 'abort-recursive-edit)
  63. (define-key global-map "\M-x" 'execute-extended-command)
  64.  
  65. ;;(define-key global-map "\C-g" 'keyboard-quit)
  66. (define-key global-map (char-to-string (quit-char)) 'keyboard-quit)
  67.  
  68. ;;(define-key global-map "\t" 'self-insert-command)
  69. (define-key global-map "\t" 'indent-for-tab-command)
  70.  
  71. (let ((n 33))
  72.   (while (<= n 255)
  73.     (if (not (= n 127))
  74.         (define-key global-map n 'self-insert-command))
  75.     (setq n (1+ n))))
  76. (define-key global-map " " 'self-insert-command)
  77.  
  78. (define-key global-map "\C-a" 'beginning-of-line)
  79. (define-key global-map "\C-b" 'backward-char)
  80. (define-key global-map "\C-e" 'end-of-line)
  81. (define-key global-map "\C-f" 'forward-char)
  82. (define-key global-map "\C-d" 'delete-char)
  83. (define-key global-map "\177" 'delete-backward-char)
  84.  
  85. (define-key global-map "\C-x\C-u" 'upcase-region)
  86. (define-key global-map "\C-x\C-l" 'downcase-region)
  87. (define-key global-map "\M-u" 'upcase-region-or-word)
  88. (define-key global-map "\M-l" 'downcase-region-or-word)
  89. (define-key global-map "\M-c" 'capitalize-region-or-word)
  90.  
  91. (define-key global-map "\C-u" 'universal-argument)
  92. ;; Make Control-0 - Control-9 set the prefix argument, like Meta-0.
  93. (let ((i ?0))
  94.   (while (<= i ?9)
  95.     (define-key global-map (list 'meta i) 'digit-argument)
  96.     (define-key global-map (list 'control i) 'digit-argument)
  97.     (define-key global-map (list 'control 'meta i) 'digit-argument)
  98.     (setq i (1+ i))))
  99. (define-key global-map '(meta -) 'negative-argument)
  100. (define-key global-map '(control -) 'negative-argument)
  101. (define-key global-map '(control meta -) 'negative-argument)
  102.  
  103. (define-key global-map "\C-x0" 'delete-window)
  104. (define-key global-map "\C-x1" 'delete-other-windows)
  105. (define-key global-map "\C-x2" 'split-window-vertically)
  106. (define-key global-map "\C-x3" 'split-window-horizontally)
  107. ;; Old XEmacs binding
  108. ;;(define-key global-map "\C-x5" 'split-window-horizontally)
  109. (define-key global-map "\C-x6" 'window-configuration-to-register)
  110. ;(define-key global-map "\C-x7" 'jump-to-register);ie register-to-window-config
  111. (define-key global-map "\C-x}" 'enlarge-window-horizontally)
  112. (define-key global-map "\C-x{" 'shrink-window-horizontally)
  113.  
  114. ;; New FSF19 bindings: C-x 5 as prefix for window commands
  115. (define-key global-map "\C-x52" 'make-frame)
  116. (define-key global-map "\C-x50" 'delete-frame)
  117. (define-key global-map "\C-x5o" 'other-frame)
  118. (define-key global-map "\C-x5b" 'switch-to-buffer-other-frame)
  119. (define-key global-map "\C-x5f" 'find-file-other-frame)
  120. (define-key global-map "\C-x5\C-f" 'find-file-other-frame)
  121. (define-key global-map "\C-x5r" 'find-file-read-only-other-frame)
  122. (define-key global-map "\C-x5m" 'mail-other-frame)
  123.  
  124. (define-key global-map "\C-xo" 'other-window)
  125. (define-key global-map "\C-x^" 'enlarge-window)
  126. (define-key global-map "\C-x<" 'scroll-left)
  127. (define-key global-map "\C-x>" 'scroll-right)
  128.  
  129. (define-key global-map "\C-v" 'scroll-up)
  130. (define-key global-map "\M-v" 'scroll-down)
  131. (define-key global-map "\M-\C-v" 'scroll-other-window)
  132. (define-key global-map "\C-l" 'recenter)
  133. (define-key global-map "\M-r" 'move-to-window-line)
  134.  
  135.  
  136. (define-key global-map "\C-s" 'isearch-forward)
  137. (define-key global-map "\C-r" 'isearch-backward)
  138. (define-key global-map "\M-\C-s" 'isearch-forward-regexp)
  139. (define-key global-map "\M-\C-r" 'isearch-backward-regexp)
  140.  
  141. (define-key global-map "\M-%" 'query-replace)
  142.  
  143. ;; Old v18 bindings
  144. ;(define-key global-map "\C-x\C-a" 'add-mode-abbrev)
  145. ;(define-key global-map "\C-x+" 'add-global-abbrev)
  146. ;(define-key global-map "\C-x\C-h" 'inverse-add-mode-abbrev)
  147. ;(define-key global-map "\C-x-" 'inverse-add-global-abbrev)
  148.  
  149. (define-key global-map "\M-'" 'abbrev-prefix-mark)
  150. (define-key global-map "\C-x'" 'expand-abbrev)
  151.  
  152. ;; New FSF19 bindings: C-x a as a prefix for abbrev commands
  153. (define-key global-map "\C-xal" 'add-mode-abbrev)
  154. (define-key global-map "\C-xa\C-a" 'add-mode-abbrev)
  155. (define-key global-map "\C-xag" 'add-global-abbrev)
  156. (define-key global-map "\C-xa+" 'add-mode-abbrev)
  157. (define-key global-map "\C-xaig" 'inverse-add-global-abbrev)
  158. (define-key global-map "\C-xail" 'inverse-add-mode-abbrev)
  159. (define-key global-map "\C-xa-" 'inverse-add-global-abbrev)
  160. (define-key global-map "\C-xae" 'expand-abbrev)
  161. (define-key global-map "\C-xa'" 'expand-abbrev)
  162.  
  163. (define-key global-map "\C-xb" 'switch-to-buffer)
  164. (define-key global-map "\C-xk" 'kill-buffer)
  165. (define-key global-map "\C-x\C-b" 'list-buffers)
  166.  
  167. ;; New FSF19 bindings
  168. (define-key global-map "\C-x-" 'shrink-window-if-larger-than-buffer)
  169. (define-key global-map "\C-x+" 'balance-windows)
  170.  
  171. (define-key global-map "\C-xe" 'call-last-kbd-macro)
  172. (define-key global-map "\C-x\(" 'start-kbd-macro)
  173. (define-key global-map "\C-x\)" 'end-kbd-macro)
  174.  
  175. ; autoloaded
  176. ;(define-key global-map "\C-x4a" 'add-change-log-entry-other-window)
  177.  
  178. (define-key global-map "\C-x`" 'next-error)
  179.  
  180. ; autoloaded
  181. ;(define-key global-map "\M-/" 'dabbrev-expand)
  182.  
  183. ; autoloaded
  184. ;(define-key global-map "\C-xd" 'dired)
  185.  
  186. ; autoloaded
  187. ;(define-key global-map "\C-x4d" 'dired-other-window)
  188.  
  189. (define-key global-map "\M-$" 'ispell-word)
  190.  
  191. (define-key global-map "\C-xq" 'kbd-macro-query)
  192.  
  193. (define-key global-map "\C-x4m" 'mail-other-window)
  194.  
  195. (define-key global-map "\C-xm" 'mail)
  196.  
  197. (define-key global-map "\M-." 'find-tag)
  198.  
  199. (define-key global-map "\C-x4." 'find-tag-other-window)
  200.  
  201. (define-key global-map "\M-," 'tags-loop-continue)
  202.  
  203. (define-key global-map "\M-\C-f" 'forward-sexp)
  204. (define-key global-map "\M-\C-b" 'backward-sexp)
  205. (define-key global-map "\M-\C-u" 'backward-up-list)
  206. (define-key global-map "\M-\C-@" 'mark-sexp)
  207. (define-key global-map "\M-\C-d" 'down-list)
  208. (define-key global-map "\M-\C-k" 'kill-sexp)
  209. (define-key global-map "\M-\C-n" 'forward-list)
  210. (define-key global-map "\M-\C-p" 'backward-list)
  211. (define-key global-map "\M-\C-a" 'beginning-of-defun)
  212. (define-key global-map "\M-\C-e" 'end-of-defun)
  213. (define-key global-map "\M-\C-h" 'mark-defun)
  214. (define-key global-map "\M-\(" 'insert-parentheses)
  215. (define-key global-map "\M-\)" 'move-past-close-and-reindent)
  216. (define-key global-map "\M-\t" 'lisp-complete-symbol)
  217.  
  218. (define-key global-map '(control meta delete) 'backward-kill-sexp)
  219.  
  220. (define-key global-map '(control <) 'mark-beginning-of-buffer)
  221. (define-key global-map '(control >) 'mark-end-of-buffer)
  222.  
  223. (define-key global-map "\C-x\C-e" 'eval-last-sexp) ;bogus!
  224.  
  225. (define-key global-map "\C-x/" 'point-to-register)
  226. (define-key global-map "\C-xj" 'jump-to-register)
  227. (define-key global-map "\C-xx" 'copy-to-register)
  228. (define-key global-map "\C-xg" 'insert-register)
  229. ;; Old v18 binding
  230. ;(define-key global-map "\C-xr" 'copy-rectangle-to-register)
  231.  
  232. ;; New FSF19 bindings: C-x r as a prefix for register commands
  233. (define-key global-map "\C-xr" (let ((map (make-sparse-keymap)))
  234.                                  (set-keymap-name map 'rectangle-prefix)
  235.                                  map))
  236. (define-key global-map "\C-xr\C-@" 'point-to-register)
  237. (define-key global-map "\C-xr " 'point-to-register)
  238. (define-key global-map "\C-xrj" 'jump-to-register)
  239. (define-key global-map "\C-xrs" 'copy-to-register)
  240. (define-key global-map "\C-xrx" 'copy-to-register)
  241. (define-key global-map "\C-xri" 'insert-register)
  242. (define-key global-map "\C-xrg" 'insert-register)
  243. (define-key global-map "\C-xrr" 'copy-rectangle-to-register)
  244. (define-key global-map "\C-xrc" 'clear-rectangle)
  245. (define-key global-map "\C-xrk" 'kill-rectangle)
  246. (define-key global-map "\C-xry" 'yank-rectangle)
  247. (define-key global-map "\C-xro" 'open-rectangle)
  248. (define-key global-map "\C-xrt" 'string-rectangle)
  249. (define-key global-map "\C-xrw" 'window-configuration-to-register)
  250. ;(define-key global-map "\C-xrf" 'frame-configuration-to-register)
  251.  
  252. (define-key global-map "\M-q" 'fill-paragraph-or-region)
  253. ;(define-key global-map "\M-q" 'fill-paragraph)
  254. ;(define-key global-map "\M-g" 'fill-region) ;now bound to goto-line
  255. (define-key global-map "\C-x." 'set-fill-prefix)
  256.  
  257. ; Using {} instead of [] is 1) FSF compatible and 2) allows function
  258. ; keys to work on ttys.  M-[ is the beginning of most the function key
  259. ; sequences.
  260. (define-key global-map "\M-{" 'backward-paragraph)
  261. (define-key global-map "\M-}" 'forward-paragraph)
  262. (define-key global-map "\M-h" 'mark-paragraph)
  263. (define-key global-map "\M-a" 'backward-sentence)
  264. (define-key global-map "\M-e" 'forward-sentence)
  265. (define-key global-map "\M-k" 'kill-sentence)
  266. (define-key global-map "\C-x\177" 'backward-kill-sentence)
  267.  
  268. (define-key global-map "\C-x[" 'backward-page)
  269. (define-key global-map "\C-x]" 'forward-page)
  270. (define-key global-map "\C-x\C-p" 'mark-page)
  271. (define-key global-map "\C-xl" 'count-lines-page)
  272.  
  273. (define-key global-map "\M-g" 'goto-line)
  274.  
  275. (put 'erase-buffer 'disabled t)         ;from buffer.c
  276.  
  277. (put 'narrow-to-page 'disabled t)
  278. (put 'narrow-to-region 'disabled t)
  279.  
  280. ;; Old v18 bindings
  281. ;(define-key global-map "\C-xp" 'narrow-to-page)
  282. ;(define-key global-map "\C-xn" 'narrow-to-region)
  283. ;(define-key global-map "\C-xw" 'widen)
  284.  
  285. ;; New FSF19 bindings: C-x n as a prefix for narrowing commands.
  286. (define-key global-map "\C-xn" (let ((map (make-sparse-keymap)))
  287.                                  (set-keymap-name map 'narrowing-prefix)
  288.                                  map))
  289. (define-key global-map "\C-xnn" 'narrow-to-region)
  290. (define-key global-map "\C-xnw" 'widen)
  291.  
  292.  
  293. (define-key global-map "\C-j" 'newline-and-indent)
  294. (define-key global-map "\C-m" 'newline)
  295. (define-key global-map "\C-o" 'open-line)
  296. (define-key global-map "\M-\C-o" 'split-line)
  297. (define-key global-map "\C-q" 'quoted-insert)
  298. (define-key global-map "\M-^" 'delete-indentation)
  299. (define-key global-map "\M-\\" 'delete-horizontal-space)
  300. (define-key global-map "\M-m" 'back-to-indentation)
  301. (define-key global-map "\C-x\C-o" 'delete-blank-lines)
  302. (define-key global-map "\M- " 'just-one-space)
  303. (define-key global-map "\M-\C-z" 'activate-region)
  304. (define-key global-map "\M-z" 'zap-to-char)
  305. (define-key global-map "\M-=" 'count-lines-region)
  306. (define-key global-map "\C-x=" 'what-cursor-position)
  307. (define-key global-map "\M-\e" 'eval-expression)
  308. (put 'eval-expression 'disabled t)
  309. (define-key global-map "\C-x\e" 'repeat-complex-command)
  310. (define-key global-map "\C-xu" 'advertised-undo)
  311. (define-key global-map "\C-_" 'undo)
  312. ;; Many people are used to typing C-/ on X terminals and getting C-_.
  313. (define-key global-map '(control /) 'undo)
  314. (define-key global-map "\M-!" 'shell-command)
  315. (define-key global-map "\M-|" 'shell-command-on-region)
  316.  
  317.  
  318. (define-key global-map "\C-k" 'kill-line)
  319. (define-key global-map "\C-w" 'kill-region)
  320. (define-key global-map "\M-w" 'kill-ring-save)
  321. (define-key global-map "\M-\C-w" 'append-next-kill)
  322. (define-key global-map "\C-y" 'yank)
  323. (define-key global-map "\M-y" 'yank-pop)
  324.  
  325. ;; Old v18 binding
  326. ;(define-key global-map "\C-xa" 'append-to-buffer)
  327.  
  328. (define-key global-map "\C-@" 'set-mark-command)
  329. (define-key global-map "\C-x\C-x" 'exchange-point-and-mark)
  330. (define-key global-map "\C-x\C-@" 'pop-global-mark)
  331.  
  332. (define-key global-map "\C-n" 'next-line)
  333. (define-key global-map "\C-p" 'previous-line)
  334. (define-key global-map "\C-x\C-n" 'set-goal-column)
  335. ;;; Many people have said they rarely use this feature, and often type
  336. ;;; it by accident.  Maybe it shouldn't even be on a key.
  337. (put 'set-goal-column 'disabled t)
  338.  
  339. (define-key global-map "\C-t" 'transpose-chars)
  340. (define-key global-map "\M-t" 'transpose-words)
  341. (define-key global-map "\M-\C-t" 'transpose-sexps)
  342. (define-key global-map "\C-x\C-t" 'transpose-lines)
  343.  
  344. (define-key global-map "\M-;" 'indent-for-comment)
  345. (define-key global-map "\M-j" 'indent-new-comment-line)
  346. (define-key global-map "\M-\C-j" 'indent-new-comment-line)
  347. (define-key global-map "\C-x;" 'set-comment-column)
  348. (define-key global-map "\C-xf" 'set-fill-column)
  349. (define-key global-map "\C-x$" 'set-selective-display)
  350.  
  351. (define-key global-map "\M-@" 'mark-word)
  352. (define-key global-map "\M-f" 'forward-word)
  353. (define-key global-map "\M-b" 'backward-word)
  354. (define-key global-map "\M-d" 'kill-word)
  355. (define-key global-map "\M-\177" 'backward-kill-word)
  356.  
  357. (define-key global-map "\M-<" 'beginning-of-buffer)
  358. (define-key global-map "\M->" 'end-of-buffer)
  359. (define-key global-map "\C-xh" 'mark-whole-buffer)
  360. (define-key global-map "\M-\\" 'delete-horizontal-space)
  361.  
  362. (define-key global-map "\C-x\C-f" 'find-file)
  363. (define-key global-map "\C-x\C-q" 'toggle-read-only)
  364. (define-key global-map "\C-x\C-r" 'find-file-read-only)
  365. (define-key global-map "\C-x\C-v" 'find-alternate-file)
  366. (define-key global-map "\C-x\C-s" 'save-buffer)
  367. (define-key global-map "\C-xs" 'save-some-buffers)
  368. (define-key global-map "\C-x\C-w" 'write-file)
  369. (define-key global-map "\C-xi" 'insert-file)
  370. (define-key global-map "\M-~" 'not-modified)
  371. (define-key global-map "\C-x\C-d" 'list-directory)
  372. (define-key global-map "\C-x\C-c" 'save-buffers-kill-emacs)
  373.  
  374. (define-key global-map "\C-x4f" 'find-file-other-window)
  375. (define-key global-map "\C-x4r" 'find-file-read-only-other-window)
  376. (define-key global-map "\C-x4\C-f" 'find-file-other-window)
  377. (define-key global-map "\C-x4b" 'switch-to-buffer-other-window)
  378. (define-key global-map "\C-x4\C-o" 'display-buffer)
  379.  
  380. (define-key global-map "\M-\C-l" 'switch-to-other-buffer)
  381.  
  382. (define-key global-map "\M-\C-\\" 'indent-region)
  383. (define-key global-map "\C-x\t" 'indent-rigidly)
  384. (define-key global-map "\M-i" 'tab-to-tab-stop)
  385.  
  386. ;; Default binding of "Backspace" is the same as delete.
  387. ;; Default binding of "Control-h" is help.
  388. (define-key global-map 'backspace '[delete])
  389. (define-key global-map '(meta backspace) '[(meta delete)])
  390. (define-key global-map '(control backspace) '[(control delete)])
  391. (define-key global-map '(control meta backspace) '[(control meta delete)])
  392.  
  393. (define-key global-map '(control h) 'help-command)
  394.  
  395. ;;; Other FSFmacs bindings to deal with once we have key-translation-map
  396.  
  397. ;;; (define-key global-map [select]        'function-key-error)
  398. ;;; (define-key global-map [print]        'function-key-error)
  399. ;(define-key global-map [execute]    'execute-extended-command)
  400. ;(define-key global-map [insert]        'overwrite-mode)
  401. ;(define-key global-map [undo]        'undo)
  402. ;(define-key global-map [redo]        'repeat-complex-command)
  403. ;;; (define-key global-map [clearline]    'function-key-error)
  404. ;(define-key global-map [insertline]    'open-line)
  405. ;(define-key global-map [deleteline]    'kill-line)
  406. ;;; (define-key global-map [insertchar]    'function-key-error)
  407. ;(define-key global-map [deletechar]    'delete-char)
  408.