(provide (quote mim-mode)) (autoload (quote fast-syntax-check-mim) "mim-syntax" "\ Checks Mim syntax quickly. Answers correct or incorrect, cannot point out the error context." t) (autoload (quote slow-syntax-check-mim) "mim-syntax" "\ Check Mim syntax slowly. Points out the context of the error, if the syntax is incorrect." t) (defvar mim-mode-hysterical-bindings t "\ *Non-nil means bind list manipulation commands to Meta keys as well as Control-Meta keys for historical reasons. Otherwise, only the latter keys are bound.") (defvar mim-mode-map nil) (defvar mim-mode-syntax-table nil) (if mim-mode-syntax-table nil (let ((i -1)) (setq mim-mode-syntax-table (make-syntax-table)) (while (< i 32) (modify-syntax-entry (setq i (1+ i)) " " mim-mode-syntax-table)) (while (< i 127) (modify-syntax-entry (setq i (1+ i)) "_ " mim-mode-syntax-table)) (setq i (1- 97)) (while (< i 122) (modify-syntax-entry (setq i (1+ i)) "w " mim-mode-syntax-table)) (setq i (1- 65)) (while (< i 90) (modify-syntax-entry (setq i (1+ i)) "w " mim-mode-syntax-table)) (setq i (1- 48)) (while (< i 57) (modify-syntax-entry (setq i (1+ i)) "w " mim-mode-syntax-table)) (modify-syntax-entry 58 " " mim-mode-syntax-table) (modify-syntax-entry 44 "' " mim-mode-syntax-table) (modify-syntax-entry 46 "' " mim-mode-syntax-table) (modify-syntax-entry 39 "' " mim-mode-syntax-table) (modify-syntax-entry 96 "' " mim-mode-syntax-table) (modify-syntax-entry 126 "' " mim-mode-syntax-table) (modify-syntax-entry 59 "' " mim-mode-syntax-table) (modify-syntax-entry 35 "' " mim-mode-syntax-table) (modify-syntax-e ntry 37 "' " mim-mode-syntax-table) (modify-syntax-entry 33 "' " mim-mode-syntax-table) (modify-syntax-entry 34 "\" " mim-mode-syntax-table) (modify-syntax-entry 92 "\\ " mim-mode-syntax-table) (modify-syntax-entry 40 "() " mim-mode-syntax-table) (modify-syntax-entry 60 "(> " mim-mode-syntax-table) (modify-syntax-entry 123 "(} " mim-mode-syntax-table) (modify-syntax-entry 91 "(] " mim-mode-syntax-table) (modify-syntax-entry 41 ")( " mim-mode-syntax-table) (modify-syntax-entry 62 ")< " mim-mode-syntax-table) (modify-syntax-entry 125 "){ " mim-mode-syntax-table) (modify-syntax-entry 93 ")[ " mim-mode-syntax-table))) (defconst mim-whitespace " (defvar mim-mode-hook nil "\ *User function run after mim mode initialization. Usage: (setq mim-mode-hook '(lambda () ... your init forms ...)).") (define-abbrev-table (quote mim-mode-abbrev-table) nil) (defconst indent-mim-hook (quote indent-mim-hook) "\ Controls (via properties) indenting of special forms. (put 'FOO 'indent-mim-hook n), integer n, means lines inside will be indented n spaces from start of form. (put 'FOO 'indent-mim-hook 'DEFINE) is like above but means use value of mim-body-indent as offset from start of form. (put 'FOO 'indent-mim-hook ) where is a list or pointted list of integers, means indent each form in by the amount specified in . When is exhausted, indent remaining forms by mim-body-indent unless is a pointted list, in which case the last cdr is used. Confused? Here is an example: (put 'FROBIT 'indent-mim-hook '(4 2 . 1)) ...> Finally, the property can be a function name (read the code).") (defvar indent-mim-comment t "\ *Non-nil means indent string comments.") (defvar mim-body-indent 2 "\ *Amount to indent in special forms which have DEFINE property on indent-mim-hook.") (defvar indent-mim-arglist t "\ *nil means indent arglists like ordinary lists. t means strings stack under start of arglist and variables stack to right of them. Otherwise, strings stack under last string (or start of arglist if none) and variables stack to right of them. Examples (for values 'stack, t, nil): (FOO \"OPT\" BAR (FOO \"OPT\" BAR (FOO \"OPT\" BAR BAZ MUMBLE BAZ MUMBLE BAZ MUMBLE \"AUX\" \"AUX\" \"AUX\" BLETCH ... BLETCH ... BLETCH ...") (put (quote DEFINE) (quote indent-mim-hook) (quote DEFINE)) (put (quote DEFMAC) (quote indent-mim-hook) (quote DEFINE)) (put (quote BIND) (quote indent-mim-hook) (quote DEFINE)) (put (quote PROG) (quote indent-mim-hook) (quote DEFINE)) (put (quote REPEAT) (quote indent-mim-hook) (quote DEFINE)) (put (quote CASE) (quote indent-mim-hook) (quote DEFINE)) (put (quote FUNCTION) (quote indent-mim-hook) (quote DEFINE)) (put (quote MAPF) (quote indent-mim-hook) (quote DEFINE)) (put (quote MAPR) (quote indent-mim-hook) (quote DEFINE)) (put (quote UNWIND) (quote indent-mim-hook) (cons (* 2 mim-body-indent) mim-body-indent)) (defvar mim-down-parens-only t "\ *nil means treat ADECLs and ATOM trailers like structures when moving down a level of structure.") (defvar mim-stop-for-slop t "\ *Non-nil means {next previous}-mim-object consider any non-whitespace character in column 0 to be a toplevel object, otherwise only open paren syntax characters will be considered.") (fset (quote mdl-mode) (quote mim-mode)) (defun mim-mode nil "\ Major mode for editing Mim (MDL in MDL) code. Commands: If value of mim-mode-hysterical-bindings is non-nil, then following commands are assigned to escape keys as well (e.g. M-f = M-C-f). The default action is bind the escape keys. Tab Indents the current line as MDL code. Delete Converts tabs to spaces as it moves back. M-C-f Move forward over next mim object. M-C-b Move backward over previous mim object. M-C-p Move to beginning of previous toplevel mim object. M-C-n Move to the beginning of the next toplevel mim object. M-C-a Move to the top of surrounding toplevel mim form. M-C-e Move to the end of surrounding toplevel mim form. M-C-u Move up a level of mim structure backwards. M-C-d Move down a level of mim structure forwards. M-C-t Transpose mim objects on either side of point. M-C-k Kill next mim object. M-C-h Place mark at end of next mim object. M-C-o Insert a newline before current line and indent. M-Delete Kill previous mim object. M-^ Join current line to previous line. M-\\ Delete whitespace around point. M-; Move to existing comment or insert empty comment if none. M-Tab Indent following mim object and all contained lines. Other Commands: Use \\[describe-function] to obtain documentation. replace-in-mim-object find-mim-definition fast-syntax-check-mim slow-syntax-check-mim backward-down-mim-object forward-up-mim-object Variables: Use \\[describe-variable] to obtain documentation. mim-mode-hook indent-mim-comment indent-mim-arglist indent-mim-hook mim-body-indent mim-down-parens-only mim-stop-for-slop mim-mode-hysterical-bindings Entry to this mode calls the value of mim-mode-hook if non-nil." (interactive) (byte-code "^O ^?.u ^?P " newline-and-mim-indent ";" begin-mim-comment " " indent-mim-line " " "!" line-to-top-of-window "o" "p" "n" "a" "e" "t" "u" "d" "k" "f" "b" use-local-map set-syntax-table make-local-variable "^$\\|" ";\"" "\"" 40 indent-mim-comment mim-mode "Mim" run-hooks mim-mode-hook] 50)) (defun line-to-top-of-window nil "\ Move current line to top of window." (interactive) (byte-code "?AA!+" [nil recenter 0] 2)) (defun forward-mim-object (arg) "\ Move forward across Mim object. With ARG, move forward that many objects." (interactive "p") (byte-code "^A!AUf (defun inside-atom-p nil (byte-code "hgA!AU+ (defun forward-mim-objects (arg &optional skip-bracket-p) (byte-code "A !AA?^`A!U. !^` \\b+" [skip-bracket-p conditions direction signal error skip-mim-whitespace] 4))) buffer-end skip-mim-whitespace] 4)) (defun backward-mim-object (&optional arg) "\ Move backward across Mim object. With ARG, move backward that many objects." (interactive "p") (byte-code "?Af (defun mark-mim-object (&optional arg) "\ Mark following Mim object. With ARG, mark that many following (preceding, ARG < 0) objects." (interactive "p") (byte-code "?SA+ (defun forward-kill-mim-object (&optional arg) "\ Kill following Mim object. With ARG, kill that many objects." (interactive "*p") (byte-code "?A`A+ (defun backward-kill-mim-object (&optional arg) "\ Kill preceding Mim object. With ARG, kill that many objects." (interactive "*p") (byte-code "?A+ (defun raise-mim-line (&optional arg) "\ Raise following line, fixing up whitespace at join. With ARG raise that many following lines. A negative ARG will raise current line and previous lines." (interactive "*p") (byte-code "EA + !^E``S\"^E ^ Z%^, (defun forward-down-mim-object (&optional arg) "\ Move down a level of Mim structure forwards. With ARG, move down that many levels forwards (backwards, ARG < 0)." (interactive "p") (byte-code "?A + ?f[ (defun backward-down-mim-object (&optional arg) "\ Move down a level of Mim structure backwards. With ARG, move down that many levels backwards (forwards, ARG < 0)." (interactive "p") (byte-code "?Af (defun forward-up-mim-object (&optional arg) "\ Move up a level of Mim structure forwards With ARG, move up that many levels forwards (backwards, ARG < 0)." (interactive "p") (byte-code "^A + (defun backward-up-mim-object (&optional arg) "\ Move up a level of Mim structure backwards With ARG, move up that many levels backwards (forwards, ARG > 0)." (interactive "p") (byte-code "?Af (defun replace-in-mim-object (old new) "\ Replace string in following Mim object." (interactive "*sReplace in object: sReplace %s with: ") (byte-code "^?A`SAA!^`)\"^A \")+" [old new nil narrow-to-region forward-mim-object 1 replace-string] 5)) (defun transpose-mim-objects (&optional arg) "\ Transpose Mim objects around point. With ARG, transpose preceding object that many times with following objects. A negative ARG will transpose backwards." (interactive "*p") (byte-code "?AA+ (defun beginning-of-DEFINE (&optional arg move) "\ Move backward to beginning of surrounding or previous toplevel Mim form. With ARG, do it that many times. Stops at last toplevel form seen if buffer end is reached." (interactive "p") (byte-code "?A + ?. $.8 (defun end-of-DEFINE (&optional arg) "\ Move forward to end of surrounding or next toplevel mim form. With ARG, do it that many times. Stops at end of last toplevel form seen if buffer end is reached." (interactive "p") (byte-code "??. (defun next-mim-object (&optional arg) "\ Move to beginning of next toplevel Mim object. With ARG, do it that many times. Stops at last object seen if buffer end is reached." (interactive "p") (byte-code "? f EV. $.9 Z%^, EV.C EW+S (defun previous-mim-object (&optional arg) "\ Move to beginning of previous toplevel Mim object. With ARG do it that many times. Stops at last object seen if buffer end is reached." (interactive "p") (byte-code "?A+ (defun calculate-mim-indent (&optional parse-start) "\ Calculate indentation for Mim line. Returns column." (byte-code "SO ^`IIIIIIIII  f' b,* @% .Q \"@%^ A@%^ Tb^ .q \"@.u fB b^UU!^ii!^aa!,Lb^id!^aU!^`%^nB!^a ^co!.afkTb,qb^TB!^i%^ #%+'i%^b^ )+" [indent-point retry state containing-sexp last-sexp desired-indent start peek where paren-depth parse-start t nil indent-mim-arglist eol last-string mim-whitespace indent-mim-comment indent-mim-hook beginning-of-line from-the-top (byte-code "?^.0 b^EEAEI$^IIA\"^.* (defun indent-mim-hook (state indent-point) "\ Compute indentation for Mim special forms. Returns column or nil." (byte-code " A@`STb^E ^EE!.o b^ (defun indent-mim-offset (state indent-point) (byte-code " EN A@EE \"@E Tb^`W.\" (defun indent-mim-comment (&optional start) "\ Indent a one line (string) Mim comment following object, if any." (byte-code "`A ^`AAA ^C?^b,+" [old-point eol state last-sexp end-of-line nil beginning-of-line no-comment (byte-code "A` \"%^CE\"@%?+ U.3 b^II!^D ^NO!?.I (defun indent-mim-line nil "\ Indent line of Mim code." (interactive "*") (byte-code "Ed`ZA ^`A AC!^Ei \". j^dZ`V.- (defun newline-and-mim-indent nil "\ Insert newline at point and indent." (interactive "*") (byte-code "?A ^A +" [nil newline indent-mim-line] 3)) (defun open-mim-line (&optional lines) "\ Insert newline before point and indent. With ARG insert that many newlines." (interactive "*p") (byte-code "^A ^A  AV. (defun indent-mim-object (&optional dont-indent-first-line) "\ Indent object following point and all lines contained inside it. With ARG, idents only contained lines (skips first line)." (interactive "*P") (byte-code "?CCCCSE`dEA$^`%^EE!^d`Z%)^S i\".R j^.Z (defun find-mim-definition (name) "\ Search for definition of function, macro, or gfcn. You need type only enough of the name to be unambiguous." (interactive "sName: ") (byte-code "?ASeb^AAI)^. (defun begin-mim-comment nil "\ Move to existing comment or insert empty comment." (interactive "*") (byte-code "?E ^`I ^`IIA#f' c)**+" [eol bol t indent-mim-comment where state last-sexp nil comment-column comment-start comment-end end-of-line beginning-of-line re-search-forward ";[ ]*\"" equal parse-partial-sexp 0 nthcdr 2 3 delete-region calculate-mim-indent tab-to-tab-stop] 14)) (defun skip-mim-whitespace (direction) (byte-code "AYf (defun inside-adecl-or-trailer-p (direction) (byte-code "AYf (defun sign (n) "\ Returns -1 if N < 0, else 1." (byte-code "AYf (defun abs (n) "\ Returns the absolute value of N." (byte-code "AYf (defun next-char (direction) "\ Returns preceding-char if DIRECTION < 0, otherwise following-char." (byte-code "AYf .