Mercurial > emacs
annotate lisp/emulation/mlconvert.el @ 12904:0352cffbcc0d
(POSIX_SIGNALS, CLASH_DETECTION): Defined.
(SIGNALS_VIA_CHARACTERS, MAIL_USE_LOCKF): Defined.
(sigmask, sigsetmask, _setjmp, _longjmp): Add undefs.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 20 Aug 1995 16:04:10 +0000 |
parents | c20013843cb1 |
children | 83f275dcd93a |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; mlconvert.el --- convert buffer of Mocklisp code to real lisp. |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
2 |
845 | 3 ;; Copyright (C) 1985 Free Software Foundation, Inc. |
4 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
5 ;; Maintainer: FSF |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
6 ;; Keywords: emulations |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
7 |
36 | 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 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 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 | |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
24 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2308
diff
changeset
|
26 ;; This package converts Mocklisp code written under a Gosling or UniPress |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
27 ;; Emacs for use with GNU Emacs. The translated code will require runtime |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; support from the mlsupport.el equivalent. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
30 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
31 |
258 | 32 ;;;###autoload |
36 | 33 (defun convert-mocklisp-buffer () |
34 "Convert buffer of Mocklisp code to real Lisp that GNU Emacs can run." | |
35 (interactive) | |
36 (emacs-lisp-mode) | |
37 (set-syntax-table (copy-sequence (syntax-table))) | |
38 (modify-syntax-entry ?\| "w") | |
39 (message "Converting mocklisp (ugh!)...") | |
40 (goto-char (point-min)) | |
41 (fix-mlisp-syntax) | |
42 | |
43 ;; Emulation of mocklisp is accurate only within a mocklisp-function | |
44 ;; so turn any non-function into a defun and then call it. | |
45 (goto-char (point-min)) | |
46 (condition-case ignore | |
47 (while t | |
48 (let ((opt (point)) | |
49 (form (read (current-buffer)))) | |
50 (and (listp form) | |
51 (not (eq (car form) 'defun)) | |
52 (progn (insert "))\n\n(ml-foo)\n\n") | |
53 (save-excursion | |
54 (goto-char opt) | |
55 (skip-chars-forward "\n") | |
56 (insert "(defun (ml-foo \n ")))))) | |
57 (end-of-file nil)) | |
58 | |
59 (goto-char (point-min)) | |
60 (insert ";;; GNU Emacs code converted from Mocklisp\n") | |
61 (insert "(require 'mlsupport)\n\n") | |
62 (fix-mlisp-symbols) | |
63 | |
64 (goto-char (point-min)) | |
65 (message "Converting mocklisp...done")) | |
66 | |
67 (defun fix-mlisp-syntax () | |
68 (while (re-search-forward "['\"]" nil t) | |
69 (if (= (preceding-char) ?\") | |
70 (progn (forward-char -1) | |
71 (forward-sexp 1)) | |
72 (delete-char -1) | |
73 (insert "?") | |
74 (if (or (= (following-char) ?\\) (= (following-char) ?^)) | |
75 (forward-char 1) | |
76 (if (looking-at "[^a-zA-Z]") | |
77 (insert ?\\))) | |
78 (forward-char 1) | |
79 (delete-char 1)))) | |
80 | |
81 (defun fix-mlisp-symbols () | |
82 (while (progn | |
83 (skip-chars-forward " \t\n()") | |
84 (not (eobp))) | |
85 (cond ((or (= (following-char) ?\?) | |
86 (= (following-char) ?\")) | |
87 (forward-sexp 1)) | |
88 ((= (following-char) ?\;) | |
89 (forward-line 1)) | |
90 (t | |
91 (let ((start (point)) prop) | |
92 (forward-sexp 1) | |
93 (setq prop (get (intern-soft (buffer-substring start (point))) | |
94 'mocklisp)) | |
95 (cond ((null prop)) | |
96 ((stringp prop) | |
97 (delete-region start (point)) | |
98 (insert prop)) | |
99 (t | |
100 (save-excursion | |
101 (goto-char start) | |
102 (funcall prop))))))))) | |
103 | |
104 (defun ml-expansion (ml-name lisp-string) | |
105 (put ml-name 'mocklisp lisp-string)) | |
106 | |
107 (ml-expansion 'defun "ml-defun") | |
108 (ml-expansion 'if "ml-if") | |
109 (ml-expansion 'setq '(lambda () | |
110 (if (looking-at "setq[ \t\n]+buffer-modified-p") | |
111 (replace-match "set-buffer-modified-p")))) | |
112 | |
4166
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
113 ;;(ml-expansion 'while '(lambda () |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
114 ;; (let ((end (progn (forward-sexp 2) (point-marker))) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
115 ;; (start (progn (forward-sexp -1) (point)))) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
116 ;; (let ((cond (buffer-substring start end))) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
117 ;; (cond ((equal cond "1") |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
118 ;; (delete-region (point) end) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
119 ;; (insert "t")) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
120 ;; (t |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
121 ;; (insert "(not (zerop ") |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
122 ;; (goto-char end) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
123 ;; (insert "))"))) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
124 ;; (set-marker end nil) |
90003380b443
(while): Comment out converter.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
125 ;; (goto-char start))))) |
36 | 126 |
127 (ml-expansion 'arg "ml-arg") | |
128 (ml-expansion 'nargs "ml-nargs") | |
129 (ml-expansion 'interactive "ml-interactive") | |
130 (ml-expansion 'message "ml-message") | |
131 (ml-expansion 'print "ml-print") | |
132 (ml-expansion 'set "ml-set") | |
133 (ml-expansion 'set-default "ml-set-default") | |
134 (ml-expansion 'provide-prefix-argument "ml-provide-prefix-argument") | |
135 (ml-expansion 'prefix-argument-loop "ml-prefix-argument-loop") | |
136 (ml-expansion 'prefix-argument "ml-prefix-arg") | |
137 (ml-expansion 'use-local-map "ml-use-local-map") | |
138 (ml-expansion 'use-global-map "ml-use-global-map") | |
139 (ml-expansion 'modify-syntax-entry "ml-modify-syntax-entry") | |
140 (ml-expansion 'error-message "error") | |
141 | |
142 (ml-expansion 'dot "point-marker") | |
143 (ml-expansion 'mark "mark-marker") | |
144 (ml-expansion 'beginning-of-file "beginning-of-buffer") | |
145 (ml-expansion 'end-of-file "end-of-buffer") | |
146 (ml-expansion 'exchange-dot-and-mark "exchange-point-and-mark") | |
147 (ml-expansion 'set-mark "set-mark-command") | |
148 (ml-expansion 'argument-prefix "universal-arg") | |
149 | |
150 (ml-expansion 'previous-page "ml-previous-page") | |
151 (ml-expansion 'next-page "ml-next-page") | |
152 (ml-expansion 'next-window "ml-next-window") | |
153 (ml-expansion 'previous-window "ml-previous-window") | |
154 | |
155 (ml-expansion 'newline "ml-newline") | |
156 (ml-expansion 'next-line "ml-next-line") | |
157 (ml-expansion 'previous-line "ml-previous-line") | |
158 (ml-expansion 'self-insert "self-insert-command") | |
159 (ml-expansion 'meta-digit "digit-argument") | |
160 (ml-expansion 'meta-minus "negative-argument") | |
161 | |
162 (ml-expansion 'newline-and-indent "ml-newline-and-indent") | |
163 (ml-expansion 'yank-from-killbuffer "yank") | |
164 (ml-expansion 'yank-buffer "insert-buffer") | |
165 (ml-expansion 'copy-region "copy-region-as-kill") | |
166 (ml-expansion 'delete-white-space "delete-horizontal-space") | |
167 (ml-expansion 'widen-region "widen") | |
168 | |
169 (ml-expansion 'forward-word '(lambda () | |
170 (if (looking-at "forward-word[ \t\n]*)") | |
171 (replace-match "forward-word 1)")))) | |
172 (ml-expansion 'backward-word '(lambda () | |
173 (if (looking-at "backward-word[ \t\n]*)") | |
174 (replace-match "backward-word 1)")))) | |
175 | |
176 (ml-expansion 'forward-paren "forward-list") | |
177 (ml-expansion 'backward-paren "backward-list") | |
178 (ml-expansion 'search-reverse "ml-search-backward") | |
179 (ml-expansion 're-search-reverse "ml-re-search-backward") | |
180 (ml-expansion 'search-forward "ml-search-forward") | |
181 (ml-expansion 're-search-forward "ml-re-search-forward") | |
182 (ml-expansion 'quote "regexp-quote") | |
183 (ml-expansion 're-query-replace "query-replace-regexp") | |
184 (ml-expansion 're-replace-string "replace-regexp") | |
185 | |
186 ; forward-paren-bl, backward-paren-bl | |
187 | |
188 (ml-expansion 'get-tty-character "read-char") | |
189 (ml-expansion 'get-tty-input "read-input") | |
190 (ml-expansion 'get-tty-string "read-string") | |
191 (ml-expansion 'get-tty-buffer "read-buffer") | |
192 (ml-expansion 'get-tty-command "read-command") | |
193 (ml-expansion 'get-tty-variable "read-variable") | |
194 (ml-expansion 'get-tty-no-blanks-input "read-no-blanks-input") | |
195 (ml-expansion 'get-tty-key "read-key") | |
196 | |
11092 | 197 (ml-expansion 'concat "ml-concat") |
36 | 198 (ml-expansion 'c= "char-equal") |
199 (ml-expansion 'goto-character "goto-char") | |
200 (ml-expansion 'substr "ml-substr") | |
201 (ml-expansion 'variable-apropos "apropos") | |
202 (ml-expansion 'execute-mlisp-buffer "eval-current-buffer") | |
203 (ml-expansion 'execute-mlisp-file "load") | |
204 (ml-expansion 'visit-file "find-file") | |
205 (ml-expansion 'read-file "find-file") | |
206 (ml-expansion 'write-modified-files "save-some-buffers") | |
207 (ml-expansion 'backup-before-writing "make-backup-files") | |
208 (ml-expansion 'write-file-exit "save-buffers-kill-emacs") | |
209 (ml-expansion 'write-named-file "write-file") | |
210 (ml-expansion 'change-file-name "set-visited-file-name") | |
211 (ml-expansion 'change-buffer-name "rename-buffer") | |
212 (ml-expansion 'buffer-exists "get-buffer") | |
213 (ml-expansion 'delete-buffer "kill-buffer") | |
214 (ml-expansion 'unlink-file "delete-file") | |
215 (ml-expansion 'unlink-checkpoint-files "delete-auto-save-files") | |
216 (ml-expansion 'file-exists "file-exists-p") | |
217 (ml-expansion 'write-current-file "save-buffer") | |
218 (ml-expansion 'change-directory "cd") | |
219 (ml-expansion 'temp-use-buffer "set-buffer") | |
220 (ml-expansion 'fast-filter-region "filter-region") | |
221 | |
222 (ml-expansion 'pending-input "input-pending-p") | |
223 (ml-expansion 'execute-keyboard-macro "call-last-kbd-macro") | |
224 (ml-expansion 'start-remembering "start-kbd-macro") | |
225 (ml-expansion 'end-remembering "end-kbd-macro") | |
226 (ml-expansion 'define-keyboard-macro "name-last-kbd-macro") | |
227 (ml-expansion 'define-string-macro "ml-define-string-macro") | |
228 | |
229 (ml-expansion 'current-column "ml-current-column") | |
230 (ml-expansion 'current-indent "ml-current-indent") | |
231 (ml-expansion 'insert-character "insert") | |
232 | |
233 (ml-expansion 'users-login-name "user-login-name") | |
234 (ml-expansion 'users-full-name "user-full-name") | |
235 (ml-expansion 'current-time "current-time-string") | |
236 (ml-expansion 'current-numeric-time "current-numeric-time-you-lose") | |
237 (ml-expansion 'current-buffer-name "buffer-name") | |
238 (ml-expansion 'current-file-name "buffer-file-name") | |
239 | |
240 (ml-expansion 'local-binding-of "local-key-binding") | |
241 (ml-expansion 'global-binding-of "global-key-binding") | |
242 | |
243 ;defproc (ProcedureType, "procedure-type"); | |
244 | |
245 (ml-expansion 'remove-key-binding "global-unset-key") | |
246 (ml-expansion 'remove-binding "global-unset-key") | |
247 (ml-expansion 'remove-local-binding "local-unset-key") | |
248 (ml-expansion 'remove-all-local-bindings "use-local-map nil") | |
249 (ml-expansion 'autoload "ml-autoload") | |
250 | |
251 (ml-expansion 'checkpoint-frequency "auto-save-interval") | |
252 | |
253 (ml-expansion 'mode-string "mode-name") | |
254 (ml-expansion 'right-margin "fill-column") | |
255 (ml-expansion 'tab-size "tab-width") | |
256 (ml-expansion 'default-right-margin "default-fill-column") | |
257 (ml-expansion 'default-tab-size "default-tab-width") | |
258 (ml-expansion 'buffer-is-modified "(buffer-modified-p)") | |
259 | |
260 (ml-expansion 'file-modified-time "you-lose-on-file-modified-time") | |
261 (ml-expansion 'needs-checkpointing "you-lose-on-needs-checkpointing") | |
262 | |
779 | 263 (ml-expansion 'lines-on-screen "set-frame-height") |
264 (ml-expansion 'columns-on-screen "set-frame-width") | |
36 | 265 |
266 (ml-expansion 'dumped-emacs "t") | |
267 | |
268 (ml-expansion 'buffer-size "ml-buffer-size") | |
269 (ml-expansion 'dot-is-visible "pos-visible-in-window-p") | |
270 | |
271 (ml-expansion 'track-eol-on-^N-^P "track-eol") | |
272 (ml-expansion 'ctlchar-with-^ "ctl-arrow") | |
273 (ml-expansion 'help-on-command-completion-error "completion-auto-help") | |
274 (ml-expansion 'dump-stack-trace "backtrace") | |
275 (ml-expansion 'pause-emacs "suspend-emacs") | |
276 (ml-expansion 'compile-it "compile") | |
277 | |
278 (ml-expansion '!= "/=") | |
279 (ml-expansion '& "logand") | |
280 (ml-expansion '| "logior") | |
281 (ml-expansion '^ "logxor") | |
282 (ml-expansion '! "ml-not") | |
283 (ml-expansion '<< "lsh") | |
284 | |
285 ;Variable pause-writes-files | |
286 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
287 ;;; mlconvert.el ends here |