home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / packages / medit.el < prev    next >
Encoding:
Text File  |  1995-03-25  |  3.8 KB  |  119 lines

  1. ;;; medit.el --- front-end to the MEDIT package for editing MDL
  2. ;; Keywords: languages
  3.  
  4. ;; Copyright (C) 1985 Free Software Foundation, Inc.
  5. ;; Principal author K. Shane Hartman
  6.  
  7. ;; This file is part of XEmacs.
  8.  
  9. ;; XEmacs is free software; you can redistribute it and/or modify it
  10. ;; under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; XEmacs is distributed in the hope that it will be useful, but
  15. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. ;; General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  21. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.  
  24. ;; >> This package depends on two MDL packages: MEDIT and FORKS which
  25. ;; >> can be obtained from the public (network) library at mit-ajax.
  26.  
  27. (require 'mim-mode)
  28.  
  29. (defconst medit-zap-file (concat "/tmp/" (user-login-name) ".medit.mud")
  30.   "File name for data sent to MDL by Medit.")
  31. (defconst medit-buffer "*MEDIT*"
  32.   "Name of buffer in which Medit accumulates data to send to MDL.")
  33. (defconst medit-save-files t
  34.   "If non-nil, Medit offers to save files on return to MDL.")
  35.   
  36. (defun medit-save-define ()
  37.   "Mark the previous or surrounding toplevel object to be sent back to MDL."
  38.   (interactive)
  39.   (save-excursion
  40.       (beginning-of-DEFINE)
  41.       (let ((start (point)))
  42.     (forward-mim-object 1)
  43.     (append-to-buffer medit-buffer start (point))
  44.     (goto-char start)
  45.     (message (buffer-substring start (progn (end-of-line) (point)))))))
  46.  
  47. (defun medit-save-region (start end)
  48.   "Mark the current region to be sent to back to MDL."
  49.   (interactive "r")
  50.   (append-to-buffer medit-buffer start end)
  51.   (message "Current region saved for MDL."))
  52.  
  53. (defun medit-save-buffer ()
  54.   "Mark the current buffer to be sent back to MDL."
  55.   (interactive)
  56.   (append-to-buffer medit-buffer (point-min) (point-max))
  57.   (message "Current buffer saved for MDL."))
  58.  
  59. (defun medit-zap-define-to-mdl ()
  60.   "Return to MDL with surrounding or previous toplevel MDL object."
  61.   (indetarctive)
  62.   (medit-save-defun)
  63.   (medit-go-to-mdl))
  64.  
  65. (defun medit-zap-region-mdl (start end)
  66.   "Return to MDL with current region."
  67.   (interactive)
  68.   (medit-save-region start end)
  69.   (medit-go-to-mdl))
  70.  
  71. (defun medit-zap-buffer ()
  72.   "Return to MDL with current buffer."
  73.   (interactive)
  74.   (medit-save-buffer)
  75.   (medit-go-to-mdl))
  76.  
  77. (defun medit-goto-mdl ()
  78.   "Return from Emacs to superior MDL, sending saved code.
  79. Optionally, offers to save changed files."
  80.   (interactive)
  81.   (let ((buffer (get-buffer medit-buffer)))
  82.   (if buffer
  83.       (save-excursion
  84.     (set-buffer buffer)
  85.     (if (buffer-modified-p buffer)
  86.         (write-region (point-min) (point-max) medit-zap-file))
  87.     (set-buffer-modified-p nil)
  88.     (erase-buffer)))
  89.   (if medit-save-files (save-some-buffers))
  90.   ;; Note could handle parallel fork by giving argument "%xmdl".  Then
  91.   ;; mdl would have to invoke with "%emacs".
  92.   (suspend-emacs)))
  93.  
  94. (defconst medit-mode-map nil)
  95. (if (not medit-mode-map)
  96.     (progn
  97.       (setq medit-mode-map (copy-keymap mim-mode-map))
  98.       (define-key medit-mode-map "\e\z" 'medit-save-define)
  99.       (define-key medit-mode-map "\e\^z" 'medit-save-buffer)
  100.       (define-key medit-mode-map "\^xz" 'medit-goto-mdl)
  101.       (define-key medit-mode-map "\^xs" 'medit-zap-buffer)))
  102.  
  103. (defconst medit-mode-hook (and (boundp 'mim-mode-hook) mim-mode-hook) "")
  104. (setq mim-mode-hook '(lambda () (medit-mode)))
  105.      
  106. (defun medit-mode (&optional state)
  107.   "Major mode for editing text and returning it to a superior MDL.
  108. Like Mim mode, plus these special commands:
  109. \\{medit-mode-map}"
  110.   (interactive)
  111.   (use-local-map medit-mode-map)
  112.   (run-hooks 'medit-mode-hook)
  113.   (setq major-mode 'medit-mode)
  114.   (setq mode-name "Medit"))
  115.  
  116. (mim-mode)
  117.  
  118.  
  119.