|
|
1.1 ! root 1: ;; Emacs side of ledit interface ! 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: ! 21: ;;; To do: ! 22: ;;; o lisp -> emacs side of things (grind-definition and find-definition) ! 23: ! 24: (defvar ledit-mode-map nil) ! 25: ! 26: (defconst ledit-zap-file (concat "/tmp/" (getenv "USER") ".l1") ! 27: "File name for data sent to Lisp by Ledit.") ! 28: (defconst ledit-read-file (concat "/tmp/" (getenv "USER") ".l2") ! 29: "File name for data sent to Ledit by Lisp.") ! 30: (defconst ledit-compile-file ! 31: (concat "/tmp/" (getenv "USER") ".l4") ! 32: "File name for data sent to Lisp compiler by Ledit.") ! 33: (defconst ledit-buffer "*LEDIT*" ! 34: "Name of buffer in which Ledit accumulates data to send to Lisp.") ! 35: ;These are now in loaddefs.el ! 36: ;(defconst ledit-save-files t ! 37: ; "*Non-nil means Ledit should save files before transferring to Lisp.") ! 38: ;(defconst ledit-go-to-lisp-string "%?lisp" ! 39: ; "*Shell commands to execute to resume Lisp job.") ! 40: ;(defconst ledit-go-to-liszt-string "%?liszt" ! 41: ; "*Shell commands to execute to resume Lisp compiler job.") ! 42: ! 43: (defun ledit-save-defun () ! 44: "Save the current defun in the ledit buffer" ! 45: (interactive) ! 46: (save-excursion ! 47: (end-of-defun) ! 48: (let ((end (point))) ! 49: (beginning-of-defun) ! 50: (append-to-buffer ledit-buffer (point) end)) ! 51: (message "Current defun saved for Lisp"))) ! 52: ! 53: (defun ledit-save-region (beg end) ! 54: "Save the current region in the ledit buffer" ! 55: (interactive "r") ! 56: (append-to-buffer ledit-buffer beg end) ! 57: (message "Region saved for Lisp")) ! 58: ! 59: (defun ledit-zap-defun-to-lisp () ! 60: "Carry the current defun to lisp" ! 61: (interactive) ! 62: (ledit-save-defun) ! 63: (ledit-go-to-lisp)) ! 64: ! 65: (defun ledit-zap-defun-to-liszt () ! 66: "Carry the current defun to liszt" ! 67: (interactive) ! 68: (ledit-save-defun) ! 69: (ledit-go-to-liszt)) ! 70: ! 71: (defun ledit-zap-region-to-lisp (beg end) ! 72: "Carry the current region to lisp" ! 73: (interactive "r") ! 74: (ledit-save-region beg end) ! 75: (ledit-go-to-lisp)) ! 76: ! 77: (defun ledit-go-to-lisp () ! 78: "Suspend Emacs and restart a waiting Lisp job." ! 79: (interactive) ! 80: (if ledit-save-files ! 81: (save-some-buffers)) ! 82: (if (get-buffer ledit-buffer) ! 83: (save-excursion ! 84: (set-buffer ledit-buffer) ! 85: (goto-char (point-min)) ! 86: (write-region (point-min) (point-max) ledit-zap-file) ! 87: (erase-buffer))) ! 88: (suspend-emacs ledit-go-to-lisp-string) ! 89: (load ledit-read-file t t)) ! 90: ! 91: (defun ledit-go-to-liszt () ! 92: "Suspend Emacs and restart a waiting Liszt job." ! 93: (interactive) ! 94: (if ledit-save-files ! 95: (save-some-buffers)) ! 96: (if (get-buffer ledit-buffer) ! 97: (save-excursion ! 98: (set-buffer ledit-buffer) ! 99: (goto-char (point-min)) ! 100: (insert "(declare (macros t))\n") ! 101: (write-region (point-min) (point-max) ledit-compile-file) ! 102: (erase-buffer))) ! 103: (suspend-emacs ledit-go-to-liszt-string) ! 104: (load ledit-read-file t t)) ! 105: ! 106: (defun ledit-setup () ! 107: "Set up key bindings for the Lisp / Emacs interface" ! 108: (if (not ledit-mode-map) ! 109: (progn (setq ledit-mode-map (make-sparse-keymap)) ! 110: (lisp-mode-commands ledit-mode-map))) ! 111: (define-key ledit-mode-map "\e\^d" 'ledit-save-defun) ! 112: (define-key ledit-mode-map "\e\^r" 'ledit-save-region) ! 113: (define-key ledit-mode-map "\^xz" 'ledit-go-to-lisp) ! 114: (define-key ledit-mode-map "\e\^c" 'ledit-go-to-liszt)) ! 115: ! 116: (ledit-setup) ! 117: ! 118: (defun ledit-mode () ! 119: "Major mode for editing text and stuffing it to a Lisp job. ! 120: Like Lisp mode, plus these special commands: ! 121: M-C-d -- record defun at or after point ! 122: for later transmission to Lisp job. ! 123: M-C-r -- record region for later transmission to Lisp job. ! 124: C-x z -- transfer to Lisp job and transmit saved text. ! 125: M-C-c -- transfer to Liszt (Lisp compiler) job ! 126: and transmit saved text. ! 127: \\{ledit-mode-map} ! 128: To make Lisp mode automatically change to Ledit mode, ! 129: do (setq lisp-mode-hook 'ledit-from-lisp-mode)" ! 130: (interactive) ! 131: (lisp-mode) ! 132: (ledit-from-lisp-mode)) ! 133: ! 134: (defun ledit-from-lisp-mode () ! 135: (use-local-map ledit-mode-map) ! 136: (setq mode-name "Ledit") ! 137: (setq major-mode 'ledit-mode) ! 138: (run-hooks 'ledit-mode-hook))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.