Commit | Line | Data |
---|---|---|
a2535589 JA |
1 | ;; Rebindings to imitate Gosmacs. |
2 | ;; Copyright (C) 1986 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 1, 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 | ||
21 | (defvar non-gosmacs-binding-alist nil) | |
22 | ||
23 | (defun set-gosmacs-bindings () | |
24 | "Rebind some keys globally to make GNU Emacs resemble Gosling Emacs. | |
25 | Use \\[set-gnu-bindings] to restore previous global bindings." | |
26 | (interactive) | |
27 | (setq non-gosmacs-binding-alist | |
28 | (rebind-and-record | |
29 | '(("\C-x\C-e" compile) | |
30 | ("\C-x\C-f" save-buffers-kill-emacs) | |
31 | ("\C-x\C-i" insert-file) | |
32 | ("\C-x\C-m" save-some-buffers) | |
33 | ("\C-x\C-n" next-error) | |
34 | ("\C-x\C-o" switch-to-buffer) | |
35 | ("\C-x\C-r" insert-file) | |
36 | ("\C-x\C-u" undo) | |
37 | ("\C-x\C-v" find-file-other-window) | |
38 | ("\C-x\C-z" shrink-window) | |
39 | ("\C-x!" shell-command) | |
40 | ("\C-xd" delete-window) | |
41 | ("\C-xn" gosmacs-next-window) | |
42 | ("\C-xp" gosmacs-previous-window) | |
43 | ("\C-xz" enlarge-window) | |
44 | ("\C-z" scroll-one-line-up) | |
45 | ("\e\C-c" save-buffers-kill-emacs) | |
46 | ("\e!" line-to-top-of-window) | |
47 | ("\e(" backward-paragraph) | |
48 | ("\e)" forward-paragraph) | |
49 | ("\e?" apropos) | |
50 | ("\eh" delete-previous-word) | |
51 | ("\ej" indent-sexp) | |
52 | ("\eq" query-replace) | |
53 | ("\er" replace-string) | |
54 | ("\ez" scroll-one-line-down) | |
55 | ("\C-_" suspend-emacs))))) | |
56 | ||
57 | (defun rebind-and-record (bindings) | |
58 | "Establish many new global bindings and record the bindings replaced. | |
59 | Arg is an alist whose elements are (KEY DEFINITION). | |
60 | Value is a similar alist whose elements describe the same KEYs | |
61 | but each with the old definition that was replaced," | |
62 | (let (old) | |
63 | (while bindings | |
64 | (let* ((this (car bindings)) | |
65 | (key (car this)) | |
66 | (newdef (nth 1 this))) | |
67 | (setq old (cons (list key (lookup-key global-map key)) old)) | |
68 | (global-set-key key newdef)) | |
69 | (setq bindings (cdr bindings))) | |
70 | (nreverse old))) | |
71 | ||
72 | (defun set-gnu-bindings () | |
73 | "Restore the global bindings that were changed by \\[set-gosmacs-bindings]." | |
74 | (interactive) | |
75 | (rebind-and-record non-gosmacs-binding-alist)) | |
76 | ||
77 | (defun gosmacs-previous-window () | |
78 | "Select the window above or to the left of the window now selected. | |
79 | From the window at the upper left corner, select the one at the lower right." | |
80 | (interactive) | |
81 | (select-window (previous-window))) | |
82 | ||
83 | (defun gosmacs-next-window () | |
84 | "Select the window below or to the right of the window now selected. | |
85 | From the window at the lower right corner, select the one at the upper left." | |
86 | (interactive) | |
87 | (select-window (next-window))) | |
88 | ||
89 | (defun scroll-one-line-up (&optional arg) | |
90 | "Scroll the selected window up (forward in the text) one line (or N lines)." | |
91 | (interactive "p") | |
92 | (scroll-up (or arg 1))) | |
93 | ||
94 | (defun scroll-one-line-down (&optional arg) | |
95 | "Scroll the selected window down (backward in the text) one line (or N)." | |
96 | (interactive "p") | |
97 | (scroll-down (or arg 1))) | |
98 | ||
99 | (defun line-to-top-of-window () | |
100 | "Scroll the selected window up so that the current line is at the top." | |
101 | (interactive) | |
102 | (recenter 0)) |