Annotation of GNUtools/emacs/lisp/mlconvert.el, revision 1.1

1.1     ! root        1: ;; Convert buffer of Mocklisp code to real lisp.
        !             2: ;; Copyright (C) 1985 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: (defun convert-mocklisp-buffer ()
        !            21:   "Convert buffer of Mocklisp code to real Lisp that GNU Emacs can run."
        !            22:   (interactive)
        !            23:   (emacs-lisp-mode)
        !            24:   (set-syntax-table (copy-sequence (syntax-table)))
        !            25:   (modify-syntax-entry ?\| "w")
        !            26:   (message "Converting mocklisp (ugh!)...")
        !            27:   (goto-char (point-min))
        !            28:   (fix-mlisp-syntax)
        !            29: 
        !            30:   ;; Emulation of mocklisp is accurate only within a mocklisp-function
        !            31:   ;; so turn any non-function into a defun and then call it.
        !            32:   (goto-char (point-min))
        !            33:   (condition-case ignore
        !            34:       (while t
        !            35:        (let ((opt (point))
        !            36:              (form (read (current-buffer))))
        !            37:          (and (listp form)
        !            38:               (not (eq (car form) 'defun))
        !            39:               (progn (insert "))\n\n(ml-foo)\n\n")
        !            40:                      (save-excursion
        !            41:                        (goto-char opt)
        !            42:                        (skip-chars-forward "\n")
        !            43:                        (insert "(defun (ml-foo \n "))))))
        !            44:     (end-of-file nil))
        !            45: 
        !            46:   (goto-char (point-min))
        !            47:   (insert ";;; GNU Emacs code converted from Mocklisp\n")
        !            48:   (insert "(require 'mlsupport)\n\n")
        !            49:   (fix-mlisp-symbols)
        !            50: 
        !            51:   (goto-char (point-min))
        !            52:   (message "Converting mocklisp...done"))
        !            53: 
        !            54: (defun fix-mlisp-syntax ()
        !            55:   (while (re-search-forward "['\"]" nil t)
        !            56:     (if (= (preceding-char) ?\")
        !            57:        (progn (forward-char -1)
        !            58:               (forward-sexp 1))
        !            59:       (delete-char -1)
        !            60:       (insert "?")
        !            61:     (if (or (= (following-char) ?\\) (= (following-char) ?^))
        !            62:          (forward-char 1)
        !            63:        (if (looking-at "[^a-zA-Z]")
        !            64:            (insert ?\\)))
        !            65:       (forward-char 1)
        !            66:       (delete-char 1))))
        !            67: 
        !            68: (defun fix-mlisp-symbols ()
        !            69:   (while (progn
        !            70:           (skip-chars-forward " \t\n()")
        !            71:           (not (eobp)))
        !            72:     (cond ((or (= (following-char) ?\?)
        !            73:               (= (following-char) ?\"))
        !            74:           (forward-sexp 1))
        !            75:          ((= (following-char) ?\;)
        !            76:           (forward-line 1))
        !            77:          (t
        !            78:           (let ((start (point)) prop)
        !            79:             (forward-sexp 1)
        !            80:             (setq prop (get (intern-soft (buffer-substring start (point)))
        !            81:                             'mocklisp))
        !            82:             (cond ((null prop))
        !            83:                   ((stringp prop)
        !            84:                    (delete-region start (point))
        !            85:                    (insert prop))
        !            86:                   (t
        !            87:                    (save-excursion
        !            88:                      (goto-char start)
        !            89:                      (funcall prop)))))))))
        !            90: 
        !            91: (defun ml-expansion (ml-name lisp-string)
        !            92:   (put ml-name 'mocklisp lisp-string))
        !            93: 
        !            94: (ml-expansion 'defun "ml-defun")
        !            95: (ml-expansion 'if "ml-if")
        !            96: (ml-expansion 'setq '(lambda ()
        !            97:                       (if (looking-at "setq[ \t\n]+buffer-modified-p")
        !            98:                           (replace-match "set-buffer-modified-p"))))
        !            99: 
        !           100: (ml-expansion 'while '(lambda ()
        !           101:                         (let ((end (progn (forward-sexp 2) (point-marker)))
        !           102:                               (start (progn (forward-sexp -1) (point))))
        !           103:                           (let ((cond (buffer-substring start end)))
        !           104:                             (cond ((equal cond "1")
        !           105:                                    (delete-region (point) end)
        !           106:                                    (insert "t"))
        !           107:                                   (t
        !           108:                                    (insert "(not (zerop ")
        !           109:                                    (goto-char end)
        !           110:                                    (insert "))")))
        !           111:                             (set-marker end nil)
        !           112:                             (goto-char start)))))
        !           113: 
        !           114: (ml-expansion 'arg "ml-arg")
        !           115: (ml-expansion 'nargs "ml-nargs")
        !           116: (ml-expansion 'interactive "ml-interactive")
        !           117: (ml-expansion 'message "ml-message")
        !           118: (ml-expansion 'print "ml-print")
        !           119: (ml-expansion 'set "ml-set")
        !           120: (ml-expansion 'set-default "ml-set-default")
        !           121: (ml-expansion 'provide-prefix-argument "ml-provide-prefix-argument")
        !           122: (ml-expansion 'prefix-argument-loop "ml-prefix-argument-loop")
        !           123: (ml-expansion 'prefix-argument "ml-prefix-arg")
        !           124: (ml-expansion 'use-local-map "ml-use-local-map")
        !           125: (ml-expansion 'use-global-map "ml-use-global-map")
        !           126: (ml-expansion 'modify-syntax-entry "ml-modify-syntax-entry")
        !           127: (ml-expansion 'error-message "error")
        !           128: 
        !           129: (ml-expansion 'dot "point-marker")
        !           130: (ml-expansion 'mark "mark-marker")
        !           131: (ml-expansion 'beginning-of-file "beginning-of-buffer")
        !           132: (ml-expansion 'end-of-file "end-of-buffer")
        !           133: (ml-expansion 'exchange-dot-and-mark "exchange-point-and-mark")
        !           134: (ml-expansion 'set-mark "set-mark-command")
        !           135: (ml-expansion 'argument-prefix "universal-arg")
        !           136: 
        !           137: (ml-expansion 'previous-page "ml-previous-page")
        !           138: (ml-expansion 'next-page "ml-next-page")
        !           139: (ml-expansion 'next-window "ml-next-window")
        !           140: (ml-expansion 'previous-window "ml-previous-window")
        !           141: 
        !           142: (ml-expansion 'newline "ml-newline")
        !           143: (ml-expansion 'next-line "ml-next-line")
        !           144: (ml-expansion 'previous-line "ml-previous-line")
        !           145: (ml-expansion 'self-insert "self-insert-command")
        !           146: (ml-expansion 'meta-digit "digit-argument")
        !           147: (ml-expansion 'meta-minus "negative-argument")
        !           148: 
        !           149: (ml-expansion 'newline-and-indent "ml-newline-and-indent")
        !           150: (ml-expansion 'yank-from-killbuffer "yank")
        !           151: (ml-expansion 'yank-buffer "insert-buffer")
        !           152: (ml-expansion 'copy-region "copy-region-as-kill")
        !           153: (ml-expansion 'delete-white-space "delete-horizontal-space")
        !           154: (ml-expansion 'widen-region "widen")
        !           155: 
        !           156: (ml-expansion 'forward-word '(lambda ()
        !           157:                               (if (looking-at "forward-word[ \t\n]*)")
        !           158:                                   (replace-match "forward-word 1)"))))
        !           159: (ml-expansion 'backward-word '(lambda ()
        !           160:                               (if (looking-at "backward-word[ \t\n]*)")
        !           161:                                   (replace-match "backward-word 1)"))))
        !           162: 
        !           163: (ml-expansion 'forward-paren "forward-list")
        !           164: (ml-expansion 'backward-paren "backward-list")
        !           165: (ml-expansion 'search-reverse "ml-search-backward")
        !           166: (ml-expansion 're-search-reverse "ml-re-search-backward")
        !           167: (ml-expansion 'search-forward "ml-search-forward")
        !           168: (ml-expansion 're-search-forward "ml-re-search-forward")
        !           169: (ml-expansion 'quote "regexp-quote")
        !           170: (ml-expansion 're-query-replace "query-replace-regexp")
        !           171: (ml-expansion 're-replace-string "replace-regexp")
        !           172: 
        !           173: ; forward-paren-bl, backward-paren-bl
        !           174: 
        !           175: (ml-expansion 'get-tty-character "read-char")
        !           176: (ml-expansion 'get-tty-input "read-input")
        !           177: (ml-expansion 'get-tty-string "read-string")
        !           178: (ml-expansion 'get-tty-buffer "read-buffer")
        !           179: (ml-expansion 'get-tty-command "read-command")
        !           180: (ml-expansion 'get-tty-variable "read-variable")
        !           181: (ml-expansion 'get-tty-no-blanks-input "read-no-blanks-input")
        !           182: (ml-expansion 'get-tty-key "read-key")
        !           183: 
        !           184: (ml-expansion 'c= "char-equal")
        !           185: (ml-expansion 'goto-character "goto-char")
        !           186: (ml-expansion 'substr "ml-substr")
        !           187: (ml-expansion 'variable-apropos "apropos")
        !           188: (ml-expansion 'execute-mlisp-buffer "eval-current-buffer")
        !           189: (ml-expansion 'execute-mlisp-file "load")
        !           190: (ml-expansion 'visit-file "find-file")
        !           191: (ml-expansion 'read-file "find-file")
        !           192: (ml-expansion 'write-modified-files "save-some-buffers")
        !           193: (ml-expansion 'backup-before-writing "make-backup-files")
        !           194: (ml-expansion 'write-file-exit "save-buffers-kill-emacs")
        !           195: (ml-expansion 'write-named-file "write-file")
        !           196: (ml-expansion 'change-file-name "set-visited-file-name")
        !           197: (ml-expansion 'change-buffer-name "rename-buffer")
        !           198: (ml-expansion 'buffer-exists "get-buffer")
        !           199: (ml-expansion 'delete-buffer "kill-buffer")
        !           200: (ml-expansion 'unlink-file "delete-file")
        !           201: (ml-expansion 'unlink-checkpoint-files "delete-auto-save-files")
        !           202: (ml-expansion 'file-exists "file-exists-p")
        !           203: (ml-expansion 'write-current-file "save-buffer")
        !           204: (ml-expansion 'change-directory "cd")
        !           205: (ml-expansion 'temp-use-buffer "set-buffer")
        !           206: (ml-expansion 'fast-filter-region "filter-region")
        !           207: 
        !           208: (ml-expansion 'pending-input "input-pending-p")
        !           209: (ml-expansion 'execute-keyboard-macro "call-last-kbd-macro")
        !           210: (ml-expansion 'start-remembering "start-kbd-macro")
        !           211: (ml-expansion 'end-remembering "end-kbd-macro")
        !           212: (ml-expansion 'define-keyboard-macro "name-last-kbd-macro")
        !           213: (ml-expansion 'define-string-macro "ml-define-string-macro")
        !           214: 
        !           215: (ml-expansion 'current-column "ml-current-column")
        !           216: (ml-expansion 'current-indent "ml-current-indent")
        !           217: (ml-expansion 'insert-character "insert")
        !           218: 
        !           219: (ml-expansion 'users-login-name "user-login-name")
        !           220: (ml-expansion 'users-full-name "user-full-name")
        !           221: (ml-expansion 'current-time "current-time-string")
        !           222: (ml-expansion 'current-numeric-time "current-numeric-time-you-lose")
        !           223: (ml-expansion 'current-buffer-name "buffer-name")
        !           224: (ml-expansion 'current-file-name "buffer-file-name")
        !           225: 
        !           226: (ml-expansion 'local-binding-of "local-key-binding")
        !           227: (ml-expansion 'global-binding-of "global-key-binding")
        !           228: 
        !           229: ;defproc (ProcedureType, "procedure-type");
        !           230: 
        !           231: (ml-expansion 'remove-key-binding "global-unset-key")
        !           232: (ml-expansion 'remove-binding "global-unset-key")
        !           233: (ml-expansion 'remove-local-binding "local-unset-key")
        !           234: (ml-expansion 'remove-all-local-bindings "use-local-map nil")
        !           235: (ml-expansion 'autoload "ml-autoload")
        !           236: 
        !           237: (ml-expansion 'checkpoint-frequency "auto-save-interval")
        !           238: 
        !           239: (ml-expansion 'mode-string "mode-name")
        !           240: (ml-expansion 'right-margin "fill-column")
        !           241: (ml-expansion 'tab-size "tab-width")
        !           242: (ml-expansion 'default-right-margin "default-fill-column")
        !           243: (ml-expansion 'default-tab-size "default-tab-width")
        !           244: (ml-expansion 'buffer-is-modified "(buffer-modified-p)")
        !           245: 
        !           246: (ml-expansion 'file-modified-time "you-lose-on-file-modified-time")
        !           247: (ml-expansion 'needs-checkpointing "you-lose-on-needs-checkpointing")
        !           248: 
        !           249: (ml-expansion 'lines-on-screen "set-screen-height")
        !           250: (ml-expansion 'columns-on-screen "set-screen-width")
        !           251: 
        !           252: (ml-expansion 'dumped-emacs "t")
        !           253: 
        !           254: (ml-expansion 'buffer-size "ml-buffer-size")
        !           255: (ml-expansion 'dot-is-visible "pos-visible-in-window-p")
        !           256: 
        !           257: (ml-expansion 'track-eol-on-^N-^P "track-eol")
        !           258: (ml-expansion 'ctlchar-with-^ "ctl-arrow")
        !           259: (ml-expansion 'help-on-command-completion-error "completion-auto-help")
        !           260: (ml-expansion 'dump-stack-trace "backtrace")
        !           261: (ml-expansion 'pause-emacs "suspend-emacs")
        !           262: (ml-expansion 'compile-it "compile")
        !           263: 
        !           264: (ml-expansion '!= "/=")
        !           265: (ml-expansion '& "logand")
        !           266: (ml-expansion '| "logior")
        !           267: (ml-expansion '^ "logxor")
        !           268: (ml-expansion '! "ml-not")
        !           269: (ml-expansion '<< "lsh")
        !           270: 
        !           271: ;Variable pause-writes-files
        !           272: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.