home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / prim / keydefs.el < prev    next >
Encoding:
Text File  |  1993-02-16  |  12.6 KB  |  327 lines

  1. ;; Define standard keybindings.
  2. ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is free software; you can redistribute it and/or modify
  7. ;; it 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. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  18. ;; the Free 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 ones' personal bindings.
  22.  
  23. ;; created by C code
  24. (defvar global-map (current-global-map) "\
  25. Default global keymap mapping Emacs keyboard input into commands.
  26. The value is a keymap which is usually (but not necessarily) Emacs'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 'mode-specific-command-prefix t)
  49. (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix) "\
  50. Keymap for characters following C-c.")
  51. (define-key global-map "\C-c" 'mode-specific-command-prefix)
  52.  
  53. (define-key global-map "\C-z" 'suspend-emacs)
  54. (define-key global-map "\C-x\C-z" 'suspend-emacs)
  55.  
  56. (define-key global-map "\M-\C-c" 'exit-recursive-edit)
  57. (define-key global-map "\C-]" 'abort-recursive-edit)
  58. (define-key global-map "\M-x" 'execute-extended-command)
  59.  
  60. ;;(define-key global-map "\C-g" 'keyboard-quit)
  61. (define-key global-map (char-to-string interrupt-char) 'keyboard-quit)
  62.  
  63. ;;(define-key global-map "\t" 'self-insert-command)
  64. (define-key global-map "\t" 'indent-for-tab-command)
  65.  
  66. (let ((n 32)
  67.       (s (make-string 1 ?.)))
  68.   (while (< n 127)
  69.     (aset s 0 n)
  70.     (define-key global-map s 'self-insert-command)
  71.     (setq n (1+ n))))
  72.  
  73. (define-key global-map "\C-a" 'beginning-of-line)
  74. (define-key global-map "\C-b" 'backward-char)
  75. (define-key global-map "\C-e" 'end-of-line)
  76. (define-key global-map "\C-f" 'forward-char)
  77. (define-key global-map "\C-d" 'delete-char)
  78. (define-key global-map "\177" 'delete-backward-char)
  79.  
  80. (define-key global-map "\C-x\C-u" 'upcase-region)
  81. (define-key global-map "\C-x\C-l" 'downcase-region)
  82. (define-key global-map "\M-u" 'upcase-word)
  83. (define-key global-map "\M-l" 'downcase-word)
  84. (define-key global-map "\M-c" 'capitalize-word)
  85.  
  86. (define-key global-map "\C-u" 'universal-argument)
  87. ;; Make Control-0 - Control-9 set the prefix argument, like Meta-0.
  88. (let ((i ?0))
  89.   (while (<= i ?9)
  90.     (define-key global-map (list 'meta i) 'digit-argument)
  91.     (define-key global-map (list 'control i) 'digit-argument)
  92.     (define-key global-map (list 'control 'meta i) 'digit-argument)
  93.     (setq i (1+ i))))
  94. (define-key global-map '(meta -) 'negative-argument)
  95. (define-key global-map '(control -) 'negative-argument)
  96. (define-key global-map '(control meta -) 'negative-argument)
  97.  
  98. (define-key global-map "\C-x0" 'delete-window)
  99. (define-key global-map "\C-x1" 'delete-other-windows)
  100. (define-key global-map "\C-x2" 'split-window-vertically)
  101. (define-key global-map "\C-x5" 'split-window-horizontally)
  102. (define-key global-map "\C-x6" 'window-config-to-register)
  103. (define-key global-map "\C-x7" 'register-to-window-config)
  104. (define-key global-map "\C-x}" 'enlarge-window-horizontally)
  105. (define-key global-map "\C-x{" 'shrink-window-horizontally)
  106.  
  107. (define-key global-map "\C-xo" 'other-window)
  108. (define-key global-map "\C-x^" 'enlarge-window)
  109. (define-key global-map "\C-x<" 'scroll-left)
  110. (define-key global-map "\C-x>" 'scroll-right)
  111.  
  112. (define-key global-map "\C-v" 'scroll-up)
  113. (define-key global-map "\M-v" 'scroll-down)
  114. (define-key global-map "\M-\C-v" 'scroll-other-window)
  115. (define-key global-map "\C-l" 'recenter)
  116. (define-key global-map "\M-r" 'move-to-window-line)
  117.  
  118.  
  119. (define-key global-map "\C-s" 'isearch-forward)
  120. (define-key global-map "\C-r" 'isearch-backward)
  121. (define-key global-map "\M-\C-s" 'isearch-forward-regexp)
  122.  
  123. (define-key global-map "\M-%" 'query-replace)
  124.  
  125. (define-key global-map "\C-x\C-a" 'add-mode-abbrev)
  126. (define-key global-map "\C-x+" 'add-global-abbrev)
  127. (define-key global-map "\C-x\C-h" 'inverse-add-mode-abbrev)
  128. (define-key global-map "\C-x-" 'inverse-add-global-abbrev)
  129. (define-key global-map "\M-'" 'abbrev-prefix-mark)
  130. (define-key global-map "\C-x'" 'expand-abbrev)
  131.  
  132.  
  133. (define-key global-map "\C-xb" 'switch-to-buffer)
  134. (define-key global-map "\C-xk" 'kill-buffer)
  135. (define-key global-map "\C-x\C-b" 'list-buffers)
  136.  
  137. (define-key global-map "\C-xe" 'call-last-kbd-macro)
  138. (define-key global-map "\C-x\(" 'start-kbd-macro)
  139. (define-key global-map "\C-x\)" 'end-kbd-macro)
  140.  
  141.  
  142. (define-key global-map "\C-x4a" 'add-change-log-entry-other-window)
  143.  
  144. (define-key global-map "\C-x`" 'next-error)
  145.  
  146. (define-key global-map "\M-/" 'dabbrev-expand)
  147.  
  148. (define-key global-map "\C-xd" 'dired)
  149.  
  150. (define-key global-map "\C-x4d" 'dired-other-window)
  151.  
  152. (define-key global-map "\M-$" 'ispell-word)
  153.  
  154. (define-key global-map "\C-xq" 'kbd-macro-query)
  155.  
  156. (define-key global-map "\C-x4m" 'mail-other-window)
  157.  
  158. (define-key global-map "\C-xm" 'mail)
  159.  
  160. (define-key global-map "\M-." 'find-tag)
  161.  
  162. (define-key global-map "\C-x4." 'find-tag-other-window)
  163.  
  164. (define-key global-map "\M-," 'tags-loop-continue)
  165.  
  166. ;; this is so that where-is says backward-list is M-C-p instead of M-up.
  167. (fset 'deprecated-backward-list 'backward-list)
  168. (fset 'deprecated-forward-list  'forward-list)
  169. (fset 'deprecated-backward-sexp 'backward-sexp)
  170. (fset 'deprecated-forward-sexp  'forward-sexp)
  171.  
  172. (define-key global-map '(meta left)  'deprecated-backward-sexp)
  173. (define-key global-map '(meta right) 'deprecated-forward-sexp)
  174. (define-key global-map '(meta up)    'deprecated-backward-list)
  175. (define-key global-map '(meta down)  'deprecated-forward-list)
  176.  
  177. (define-key global-map "\M-\C-f" 'forward-sexp)
  178. (define-key global-map "\M-\C-b" 'backward-sexp)
  179. (define-key global-map "\M-\C-u" 'backward-up-list)
  180. (define-key global-map "\M-\C-@" 'mark-sexp)
  181. (define-key global-map "\M-\C-d" 'down-list)
  182. (define-key global-map "\M-\C-k" 'kill-sexp)
  183. (define-key global-map "\M-\C-n" 'forward-list)
  184. (define-key global-map "\M-\C-p" 'backward-list)
  185. (define-key global-map "\M-\C-a" 'beginning-of-defun)
  186. (define-key global-map "\M-\C-e" 'end-of-defun)
  187. (define-key global-map "\M-\C-h" 'mark-defun)
  188. (define-key global-map "\M-\(" 'insert-parentheses)
  189. (define-key global-map "\M-\)" 'move-past-close-and-reindent)
  190. (define-key global-map "\M-\t" 'lisp-complete-symbol)
  191.  
  192. (define-key global-map '(control meta delete) 'backward-kill-sexp)
  193.  
  194. (define-key global-map '(control <) 'mark-beginning-of-buffer)
  195. (define-key global-map '(control >) 'mark-end-of-buffer)
  196.  
  197. (define-key global-map "\C-x\C-e" 'eval-last-sexp) ;bogus!
  198.  
  199. (define-key global-map "\C-x/" 'point-to-register)
  200. (define-key global-map "\C-xj" 'jump-to-register)
  201. (define-key global-map "\C-xx" 'copy-to-register)
  202. (define-key global-map "\C-xg" 'insert-register)
  203. (define-key global-map "\C-xr" 'copy-rectangle-to-register)
  204.  
  205. (define-key global-map "\M-q" 'fill-paragraph)
  206. (define-key global-map "\M-g" 'fill-region)
  207. (define-key global-map "\C-x." 'set-fill-prefix)
  208.  
  209. (define-key global-map "\M-[" 'backward-paragraph)
  210. (define-key global-map "\M-]" 'forward-paragraph)
  211. (define-key global-map "\M-h" 'mark-paragraph)
  212. (define-key global-map "\M-a" 'backward-sentence)
  213. (define-key global-map "\M-e" 'forward-sentence)
  214. (define-key global-map "\M-k" 'kill-sentence)
  215. (define-key global-map "\C-x\177" 'backward-kill-sentence)
  216.  
  217. (define-key global-map "\C-x[" 'backward-page)
  218. (define-key global-map "\C-x]" 'forward-page)
  219. (define-key global-map "\C-x\C-p" 'mark-page)
  220. (define-key global-map "\C-xl" 'count-lines-page)
  221.  
  222. (put 'narrow-to-page 'disabled t)
  223. (put 'narrow-to-region 'disabled t)
  224. (define-key global-map "\C-xp" 'narrow-to-page)
  225. (define-key global-map "\C-xn" 'narrow-to-region)
  226. (define-key global-map "\C-xw" 'widen)
  227.  
  228. ;; >>> FSF19 new keyboard assignments
  229. ;;(define-key global-map "\C-xn" (make-sparse-keymap))
  230. ;;(define-key global-map "\C-xr" (make-sparse-keymap))
  231. ;;(define-key global-map "\C-xnn" 'narrow-to-region)
  232. ;;(define-key global-map "\C-xnw" 'widen)
  233.  
  234.  
  235. (define-key global-map "\C-j" 'newline-and-indent)
  236. (define-key global-map "\C-m" 'newline)
  237. (define-key global-map "\C-o" 'open-line)
  238. (define-key global-map "\M-\C-o" 'split-line)
  239. (define-key global-map "\C-q" 'quoted-insert)
  240. (define-key global-map "\M-^" 'delete-indentation)
  241. (define-key global-map "\M-\\" 'delete-horizontal-space)
  242. (define-key global-map "\M-m" 'back-to-indentation)
  243. (define-key global-map "\C-x\C-o" 'delete-blank-lines)
  244. (define-key global-map "\M- " 'just-one-space)
  245. (define-key global-map "\M-z" 'zap-to-char)
  246. (define-key global-map "\M-=" 'count-lines-region)
  247. (define-key global-map "\C-x=" 'what-cursor-position)
  248. (define-key global-map "\M-\e" 'eval-expression)
  249. (define-key global-map "\C-x\e" 'repeat-complex-command)
  250. (define-key global-map "\C-xu" 'advertised-undo)
  251. (define-key global-map "\C-_" 'undo)
  252. (define-key global-map "\M-!" 'shell-command)
  253. (define-key global-map "\M-|" 'shell-command-on-region)
  254.  
  255.  
  256. (define-key global-map "\C-k" 'kill-line)
  257. (define-key global-map "\C-w" 'kill-region)
  258. (define-key global-map "\M-w" 'kill-ring-save)
  259. (define-key global-map "\M-\C-w" 'append-next-kill)
  260. (define-key global-map "\C-y" 'yank)
  261. (define-key global-map "\M-y" 'yank-pop)
  262.  
  263. (define-key global-map "\C-xa" 'append-to-buffer)
  264.  
  265. (define-key global-map "\C-@" 'set-mark-command)
  266. (define-key global-map "\C-x\C-x" 'exchange-point-and-mark)
  267.  
  268. (define-key global-map "\C-n" 'next-line)
  269. (define-key global-map "\C-p" 'previous-line)
  270. (define-key global-map "\C-x\C-n" 'set-goal-column)
  271.  
  272. (define-key global-map "\C-t" 'transpose-chars)
  273. (define-key global-map "\M-t" 'transpose-words)
  274. (define-key global-map "\M-\C-t" 'transpose-sexps)
  275. (define-key global-map "\C-x\C-t" 'transpose-lines)
  276.  
  277. (define-key global-map "\M-;" 'indent-for-comment)
  278. (define-key global-map "\M-j" 'indent-new-comment-line)
  279. (define-key global-map "\M-\C-j" 'indent-new-comment-line)
  280. (define-key global-map "\C-x;" 'set-comment-column)
  281. (define-key global-map "\C-xf" 'set-fill-column)
  282. (define-key global-map "\C-x$" 'set-selective-display)
  283.  
  284. (define-key global-map "\M-@" 'mark-word)
  285. (define-key global-map "\M-f" 'forward-word)
  286. (define-key global-map "\M-b" 'backward-word)
  287. (define-key global-map "\M-d" 'kill-word)
  288. (define-key global-map "\M-\177" 'backward-kill-word)
  289.  
  290. (define-key global-map "\M-<" 'beginning-of-buffer)
  291. (define-key global-map "\M->" 'end-of-buffer)
  292. (define-key global-map "\C-xh" 'mark-whole-buffer)
  293. (define-key global-map "\M-\\" 'delete-horizontal-space)
  294.  
  295. (define-key global-map "\C-x\C-f" 'find-file)
  296. (define-key global-map "\C-x\C-q" 'toggle-read-only)
  297. (define-key global-map "\C-x\C-r" 'find-file-read-only)
  298. (define-key global-map "\C-x\C-v" 'find-alternate-file)
  299. (define-key global-map "\C-x\C-s" 'save-buffer)
  300. (define-key global-map "\C-xs" 'save-some-buffers)
  301. (define-key global-map "\C-x\C-w" 'write-file)
  302. (define-key global-map "\C-xi" 'insert-file)
  303. (define-key global-map "\M-~" 'not-modified)
  304. (define-key global-map "\C-x\C-d" 'list-directory)
  305. (define-key global-map "\C-x\C-c" 'save-buffers-kill-emacs)
  306.  
  307. (define-key global-map "\C-x4f" 'find-file-other-window)
  308. (define-key global-map "\C-x4r" 'find-file-read-only-other-window)
  309. (define-key global-map "\C-x4\C-f" 'find-file-other-window)
  310. (define-key global-map "\C-x4b" 'switch-to-buffer-other-window)
  311. (define-key global-map "\C-x4\C-o" 'display-buffer)
  312.  
  313. (define-key global-map "\M-\C-l" 'switch-to-other-buffer)
  314.  
  315. (define-key global-map "\M-\C-\\" 'indent-region)
  316. (define-key global-map "\C-x\t" 'indent-rigidly)
  317. (define-key global-map "\M-i" 'tab-to-tab-stop)
  318.  
  319. ;; Default binding of "Backspace" is the same as delete.
  320. ;; Default binding of "Control-h" is help.
  321. (define-key global-map 'backspace '[delete])
  322. (define-key global-map '(meta backspace) '[(meta delete)])
  323. (define-key global-map '(control backspace) '[(control delete)])
  324. (define-key global-map '(control meta backspace) '[(control meta delete)])
  325.  
  326. (define-key global-map '(control h) 'help-command)
  327.