|
|
1.1 root 1: ;; Convert buffer of Mocklisp code to real lisp.
2: ;; Copyright (C) 1985 Richard M. Stallman.
3:
4: ;; This file is part of GNU Emacs.
5:
6: ;; GNU Emacs is distributed in the hope that it will be useful,
7: ;; but WITHOUT ANY WARRANTY. No author or distributor
8: ;; accepts responsibility to anyone for the consequences of using it
9: ;; or for whether it serves any particular purpose or works at all,
10: ;; unless he says so in writing. Refer to the GNU Emacs General Public
11: ;; License for full details.
12:
13: ;; Everyone is granted permission to copy, modify and redistribute
14: ;; GNU Emacs, but only under the conditions described in the
15: ;; GNU Emacs General Public License. A copy of this license is
16: ;; supposed to have been given to you along with GNU Emacs so you
17: ;; can know your rights and responsibilities. It should be in a
18: ;; file named COPYING. Among other things, the copyright notice
19: ;; and this notice must be preserved on all copies.
20:
21:
22: (defun convert-mocklisp-buffer ()
23: "Convert buffer of mocklisp code into real lisp."
24: (interactive)
25: (emacs-lisp-mode)
26: (message "Converting mocklisp (ugh!)...")
27: (goto-char (point-min))
28: (insert ";;; GNU Emacs code converted from Mocklisp\n")
29: (insert "(require 'mlsupport)\n\n")
30: (fix-mlisp-syntax)
31: (goto-char (point-min))
32: (fix-mlisp-symbols)
33: (goto-char (point-min))
34: (message "Converting mocklisp...done"))
35:
36: (defun fix-mlisp-syntax ()
37: (while (re-search-forward "['\"]" nil t)
38: (if (= (preceding-char) ?\")
39: (progn (forward-char -1)
40: (forward-sexp 1))
41: (delete-char -1)
42: (insert "?")
43: (if (= (following-char) ?\\)
44: (forward-char 1)
45: (if (looking-at "[^a-zA-Z]")
46: (insert ?\\)))
47: (forward-char 1)
48: (delete-char 1))))
49:
50: (defun fix-mlisp-symbols ()
51: (while (progn
52: (skip-chars-forward " \t\n()")
53: (not (eobp)))
54: (cond ((or (= (following-char) ?\?)
55: (= (following-char) ?\"))
56: (forward-sexp 1))
57: ((= (following-char) ?\;)
58: (forward-line 1))
59: (t
60: (let ((start (point)) prop)
61: (forward-sexp 1)
62: (setq prop (get (intern-soft (buffer-substring start (point)))
63: 'mocklisp))
64: (cond ((null prop))
65: ((stringp prop)
66: (delete-region start (point))
67: (insert prop))
68: (t
69: (save-excursion
70: (goto-char start)
71: (funcall prop)))))))))
72:
73: (defun ml-expansion (ml-name lisp-string)
74: (put ml-name 'mocklisp lisp-string))
75:
76: (ml-expansion 'defun "ml-defun")
77: (ml-expansion 'if "ml-if")
78: (ml-expansion 'setq '(lambda ()
79: (if (looking-at "setq[ \t\n]+buffer-modified-p")
80: (replace-match "set-buffer-modified-p"))))
81:
82: (ml-expansion 'while '(lambda ()
83: (let ((end (progn (forward-sexp 2) (point-marker)))
84: (start (progn (forward-sexp -1) (point))))
85: (let ((cond (buffer-substring start end)))
86: (cond ((equal cond "1")
87: (delete-region (point) end)
88: (insert "t"))
89: (t
90: (insert "(not (zerop ")
91: (goto-char end)
92: (insert "))")))
93: (set-marker end nil)
94: (goto-char start)))))
95:
96: (ml-expansion 'arg "ml-arg")
97: (ml-expansion 'nargs "ml-nargs")
98: (ml-expansion 'interactive "ml-interactive")
99: (ml-expansion 'message "ml-message")
100: (ml-expansion 'print "ml-print")
101: (ml-expansion 'set "ml-set")
102: (ml-expansion 'set-default "ml-set-default")
103: (ml-expansion 'provide-prefix-argument "ml-provide-prefix-argument")
104: (ml-expansion 'prefix-argument-loop "ml-prefix-argument-loop")
105: (ml-expansion 'prefix-argument "ml-prefix-arg")
106: (ml-expansion 'use-local-map "ml-use-local-map")
107: (ml-expansion 'use-global-map "ml-use-global-map")
108: (ml-expansion 'modify-syntax-entry "ml-modify-syntax-entry")
109: (ml-expansion 'error-message "error")
110:
111: (ml-expansion 'dot "point-marker")
112: (ml-expansion 'mark "mark-marker")
113: (ml-expansion 'beginning-of-file "beginning-of-buffer")
114: (ml-expansion 'end-of-file "end-of-buffer")
115: (ml-expansion 'set-mark "set-mark-command")
116: (ml-expansion 'argument-prefix "universal-arg")
117:
118: (ml-expansion 'previous-page "ml-previous-page")
119: (ml-expansion 'next-page "ml-next-page")
120: (ml-expansion 'next-window "ml-next-window")
121: (ml-expansion 'previous-window "ml-previous-window")
122:
123: (ml-expansion 'newline "ml-newline")
124: (ml-expansion 'next-line "ml-next-line")
125: (ml-expansion 'previous-line "ml-previous-line")
126: (ml-expansion 'self-insert "self-insert-command")
127: (ml-expansion 'meta-digit "digit-argument")
128: (ml-expansion 'meta-minus "negative-argument")
129:
130: (ml-expansion 'newline-and-indent "ml-newline-and-indent")
131: (ml-expansion 'yank-from-killbuffer "yank")
132: (ml-expansion 'yank-buffer "insert-buffer")
133: (ml-expansion 'delete-white-space "delete-horizontal-space")
134: (ml-expansion 'widen-region "widen")
135:
136: (ml-expansion 'forward-word '(lambda ()
137: (if (looking-at "forward-word[ \t\n]*)")
138: (replace-match "forward-word 1)"))))
139: (ml-expansion 'backward-word '(lambda ()
140: (if (looking-at "backward-word[ \t\n]*)")
141: (replace-match "backward-word 1)"))))
142:
143: (ml-expansion 'forward-paren "forward-list")
144: (ml-expansion 'backward-paren "backward-list")
145: (ml-expansion 'search-reverse "ml-search-backward")
146: (ml-expansion 're-search-reverse "ml-re-search-backward")
147: (ml-expansion 'search-forward "ml-search-forward")
148: (ml-expansion 're-search-forward "ml-re-search-forward")
149: (ml-expansion 'quote "regexp-quote")
150: (ml-expansion 're-query-replace "query-replace-regexp")
151: (ml-expansion 're-replace-string "replace-regexp")
152:
153: ; forward-paren-bl, backward-paren-bl
154:
155: (ml-expansion 'get-tty-character "read-char")
156: (ml-expansion 'get-tty-input "read-input")
157: (ml-expansion 'get-tty-string "read-string")
158: (ml-expansion 'get-tty-buffer "read-buffer")
159: (ml-expansion 'get-tty-command "read-command")
160: (ml-expansion 'get-tty-variable "read-variable")
161: (ml-expansion 'get-tty-no-blanks-input "read-no-blanks-input")
162: (ml-expansion 'get-tty-key "read-key")
163:
164: (ml-expansion 'c= "char-equal")
165: (ml-expansion 'goto-character "goto-char")
166: (ml-expansion 'substr "ml-substr")
167: (ml-expansion 'variable-apropos "apropos")
168: (ml-expansion 'execute-mlisp-buffer "eval-current-buffer")
169: (ml-expansion 'execute-mlisp-file "load")
170: (ml-expansion 'visit-file "find-file")
171: (ml-expansion 'read-file "find-file")
172: (ml-expansion 'write-modified-files "save-some-buffers")
173: (ml-expansion 'backup-before-writing "make-backup-files")
174: (ml-expansion 'write-file-exit "save-buffers-kill-emacs")
175: (ml-expansion 'write-named-file "write-file")
176: (ml-expansion 'change-file-name "set-visited-file-name")
177: (ml-expansion 'change-buffer-name "rename-buffer")
178: (ml-expansion 'delete-buffer "kill-buffer")
179: (ml-expansion 'unlink-file "delete-file")
180: (ml-expansion 'unlink-checkpoint-files "delete-auto-save-files")
181: (ml-expansion 'file-exists "file-exists-p")
182: (ml-expansion 'write-current-file "save-buffer")
183: (ml-expansion 'change-directory "cd")
184: (ml-expansion 'temp-use-buffer "set-buffer")
185:
186: (ml-expansion 'pending-input "input-pending-p")
187: (ml-expansion 'execute-keyboard-macro "call-last-kbd-macro")
188: (ml-expansion 'start-remembering "start-kbd-macro")
189: (ml-expansion 'end-remembering "end-kbd-macro")
190: (ml-expansion 'define-keyboard-macro "name-last-kbd-macro")
191: (ml-expansion 'define-string-macro "ml-define-string-macro")
192:
193: (ml-expansion 'current-column "ml-current-column")
194: (ml-expansion 'current-indent "ml-current-indent")
195: (ml-expansion 'insert-character "insert")
196:
197: (ml-expansion 'users-login-name "user-login-name")
198: (ml-expansion 'users-full-name "user-full-name")
199: (ml-expansion 'current-time "current-time-string")
200: (ml-expansion 'current-buffer-name "buffer-name")
201: (ml-expansion 'current-file-name "buffer-file-name")
202:
203: (ml-expansion 'local-binding-of "local-key-binding")
204: (ml-expansion 'global-binding-of "global-key-binding")
205:
206: ;defproc (ProcedureType, "procedure-type");
207:
208: (ml-expansion 'remove-key-binding "global-unset-key")
209: (ml-expansion 'remove-binding "global-unset-key")
210: (ml-expansion 'remove-local-binding "local-unset-key")
211: (ml-expansion 'remove-all-local-bindings "use-local-map nil")
212: (ml-expansion 'autoload "ml-autoload")
213:
214: (ml-expansion 'checkpoint-frequency "auto-save-interval")
215:
216: (ml-expansion 'mode-string "mode-name")
217: (ml-expansion 'right-margin "fill-column")
218: (ml-expansion 'tab-size "tab-width")
219: (ml-expansion 'default-right-margin "default-fill-column")
220: (ml-expansion 'default-tab-size "default-tab-width")
221: (ml-expansion 'buffer-is-modified "(buffer-modified-p)")
222:
223: (ml-expansion 'file-modified-time "you-lose-on-file-modified-time")
224: (ml-expansion 'needs-checkpointing "you-lose-on-needs-checkpointing")
225:
226: (ml-expansion 'lines-on-screen "set-screen-height")
227: (ml-expansion 'columns-on-screen "set-screen-width")
228:
229: (ml-expansion 'dumped-emacs "t")
230:
231: (ml-expansion 'buffer-size "ml-buffer-size")
232: (ml-expansion 'dot-is-visible "pos-visible-in-window-p")
233:
234: (ml-expansion 'track-eol-on-^N-^P "track-eol")
235: (ml-expansion 'ctlchar-with-^ "ctl-arrow")
236: (ml-expansion 'help-on-command-completion-error "completion-auto-help")
237: (ml-expansion 'dump-stack-trace "backtrace")
238: (ml-expansion 'pause-emacs "suspend-emacs")
239: (ml-expansion 'compile-it "compile")
240:
241: (ml-expansion '!= "/=")
242: (ml-expansion '& "logand")
243: (ml-expansion '| "logior")
244: (ml-expansion '^ "logxor")
245: (ml-expansion '! "lognot")
246: (ml-expansion '<< "lsh")
247:
248: ;Variable pause-writes-files
249:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.