Added or corrected Commentary sections
[bpt/emacs.git] / lisp / gosmacs.el
CommitLineData
1a06eabd
ER
1;;; gosmacs.el --- rebindings to imitate Gosmacs.
2
9750e079
ER
3;; Copyright (C) 1986 Free Software Foundation, Inc.
4
e5167999 5;; Maintainer: FSF
fd7fa35a 6;; Keywords: emulations
e5167999 7
a2535589
JA
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
e5167999 12;; the Free Software Foundation; either version 2, or (at your option)
a2535589
JA
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs; see the file COPYING. If not, write to
22;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
e41b2db1
ER
24;;; Commentary:
25
26;; Make GNU Emacs look like Gosling Emacs. `M-x set-gosmacs-bindings'
27;; does this change; `M-x set-gnu-bindings' undoes it.
28
e5167999 29;;; Code:
a2535589 30
29130b95
JB
31(require 'mlsupport)
32
a2535589
JA
33(defvar non-gosmacs-binding-alist nil)
34
f9f9507e 35;;;###autoload
a2535589
JA
36(defun set-gosmacs-bindings ()
37 "Rebind some keys globally to make GNU Emacs resemble Gosling Emacs.
38Use \\[set-gnu-bindings] to restore previous global bindings."
39 (interactive)
40 (setq non-gosmacs-binding-alist
41 (rebind-and-record
42 '(("\C-x\C-e" compile)
43 ("\C-x\C-f" save-buffers-kill-emacs)
44 ("\C-x\C-i" insert-file)
45 ("\C-x\C-m" save-some-buffers)
46 ("\C-x\C-n" next-error)
47 ("\C-x\C-o" switch-to-buffer)
48 ("\C-x\C-r" insert-file)
49 ("\C-x\C-u" undo)
50 ("\C-x\C-v" find-file-other-window)
51 ("\C-x\C-z" shrink-window)
52 ("\C-x!" shell-command)
53 ("\C-xd" delete-window)
54 ("\C-xn" gosmacs-next-window)
55 ("\C-xp" gosmacs-previous-window)
56 ("\C-xz" enlarge-window)
57 ("\C-z" scroll-one-line-up)
58 ("\e\C-c" save-buffers-kill-emacs)
59 ("\e!" line-to-top-of-window)
60 ("\e(" backward-paragraph)
61 ("\e)" forward-paragraph)
62 ("\e?" apropos)
29130b95 63 ("\eh" delete-previous-word)
a2535589
JA
64 ("\ej" indent-sexp)
65 ("\eq" query-replace)
66 ("\er" replace-string)
67 ("\ez" scroll-one-line-down)
68 ("\C-_" suspend-emacs)))))
69
70(defun rebind-and-record (bindings)
71 "Establish many new global bindings and record the bindings replaced.
8a1281b5
RS
72Arg BINDINGS is an alist whose elements are (KEY DEFINITION).
73Returns a similar alist whose elements describe the same KEYs
a2535589
JA
74but each with the old definition that was replaced,"
75 (let (old)
76 (while bindings
77 (let* ((this (car bindings))
78 (key (car this))
79 (newdef (nth 1 this)))
80 (setq old (cons (list key (lookup-key global-map key)) old))
81 (global-set-key key newdef))
82 (setq bindings (cdr bindings)))
83 (nreverse old)))
84
85(defun set-gnu-bindings ()
86 "Restore the global bindings that were changed by \\[set-gosmacs-bindings]."
87 (interactive)
88 (rebind-and-record non-gosmacs-binding-alist))
89
90(defun gosmacs-previous-window ()
91 "Select the window above or to the left of the window now selected.
92From the window at the upper left corner, select the one at the lower right."
93 (interactive)
94 (select-window (previous-window)))
95
96(defun gosmacs-next-window ()
97 "Select the window below or to the right of the window now selected.
98From the window at the lower right corner, select the one at the upper left."
99 (interactive)
100 (select-window (next-window)))
101
102(defun scroll-one-line-up (&optional arg)
103 "Scroll the selected window up (forward in the text) one line (or N lines)."
104 (interactive "p")
105 (scroll-up (or arg 1)))
106
107(defun scroll-one-line-down (&optional arg)
108 "Scroll the selected window down (backward in the text) one line (or N)."
109 (interactive "p")
110 (scroll-down (or arg 1)))
111
112(defun line-to-top-of-window ()
113 "Scroll the selected window up so that the current line is at the top."
114 (interactive)
115 (recenter 0))
1a06eabd
ER
116
117;;; gosmacs.el ends here