(require (quote mim-mode))

(defconst medit-zap-file (concat "/tmp/" (getenv "USER") ".medit.mud") "\
File name for data sent to MDL by Medit.")

(defconst medit-buffer "*MEDIT*" "\
Name of buffer in which Medit accumulates data to send to MDL.")

(defconst medit-save-files t "\
If non-nil, Medit offers to save files on return to MDL.")

(defun medit-save-define nil "\
Mark the previous or surrounding toplevel object to be sent back to MDL." (interactive) (byte-code "ˆ `!	`#b `\"!))" [start medit-buffer nil beginning-of-DEFINE forward-mim-object 1 append-to-buffer message buffer-substring end-of-line] 8))

(defun medit-save-region (start end) "\
Mark the current region to be sent to back to MDL." (interactive "r") (byte-code "È	
#!" [medit-buffer start end nil append-to-buffer message "Current region saved for MDL."] 4))

(defun medit-save-buffer nil "\
Mark the current buffer to be sent back to MDL." (interactive) (byte-code "ed#!" [medit-buffer nil append-to-buffer message "Current buffer saved for MDL."] 4))

(defun medit-zap-define-to-mdl nil "\
Return to MDL with surrounding or previous toplevel MDL object." (byte-code "   " [indetarctive medit-save-defun medit-go-to-mdl] 4))

(defun medit-zap-region-mdl (start end) "\
Return to MDL with current region." (interactive) (byte-code "ˆ	\" " [start end nil medit-save-region medit-go-to-mdl] 3))

(defun medit-zap-buffer nil "\
Return to MDL with current buffer." (interactive) (byte-code "  " [nil medit-save-buffer medit-go-to-mdl] 3))

(defun medit-goto-mdl nil "\
Return from Emacs to superior MDL, sending saved code.
Optionally, offers to save changed files." (interactive) (byte-code "È	!(q!ed
#È! ))È3 4È )" [buffer medit-buffer medit-zap-file nil medit-save-files get-buffer buffer-modified-p write-region set-buffer-modified-p erase-buffer save-some-buffers suspend-emacs] 8))

(defconst medit-mode-map nil)

(if (not medit-mode-map) (progn (setq medit-mode-map (copy-alist mim-mode-map)) (define-key medit-mode-map "z" (quote medit-save-define)) (define-key medit-mode-map "" (quote medit-save-buffer)) (define-key medit-mode-map "z" (quote medit-goto-mdl)) (define-key medit-mode-map "s" (quote medit-zap-buffer))))

(defconst medit-mode-hook (and (boundp (quote mim-mode-hook)) mim-mode-hook) "\

(setq mim-mode-hook (quote (lambda nil (medit-mode))))

(defun medit-mode (&optional state) "\
Major mode for editing text and returning it to a superior MDL.
Like Mim mode, plus these special commands:
\\{medit-mode-map}" (interactive) (byte-code "È!!ljȉ" [medit-mode-map major-mode mode-name nil use-local-map run-hooks medit-mode-hook medit-mode "Medit"] 4))