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