1 ;;; ledit.el --- Emacs side of ledit interface
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;; o lisp -> emacs side of things (grind-definition and find-definition)
29 (defvar ledit-mode-map nil
)
31 (defconst ledit-zap-file
(concat "/tmp/" (user-login-name) ".l1")
32 "File name for data sent to Lisp by Ledit.")
33 (defconst ledit-read-file
(concat "/tmp/" (user-login-name) ".l2")
34 "File name for data sent to Ledit by Lisp.")
35 (defconst ledit-compile-file
36 (concat "/tmp/" (user-login-name) ".l4")
37 "File name for data sent to Lisp compiler by Ledit.")
38 (defconst ledit-buffer
"*LEDIT*"
39 "Name of buffer in which Ledit accumulates data to send to Lisp.")
42 (defconst ledit-save-files t
"\
43 *Non-nil means Ledit should save files before transferring to Lisp.")
45 (defconst ledit-go-to-lisp-string
"%?lisp" "\
46 *Shell commands to execute to resume Lisp job.")
48 (defconst ledit-go-to-liszt-string
"%?liszt" "\
49 *Shell commands to execute to resume Lisp compiler job.")
51 (defun ledit-save-defun ()
52 "Save the current defun in the ledit buffer"
58 (append-to-buffer ledit-buffer
(point) end
))
59 (message "Current defun saved for Lisp")))
61 (defun ledit-save-region (beg end
)
62 "Save the current region in the ledit buffer"
64 (append-to-buffer ledit-buffer beg end
)
65 (message "Region saved for Lisp"))
67 (defun ledit-zap-defun-to-lisp ()
68 "Carry the current defun to Lisp."
73 (defun ledit-zap-defun-to-liszt ()
74 "Carry the current defun to liszt."
79 (defun ledit-zap-region-to-lisp (beg end
)
80 "Carry the current region to Lisp."
82 (ledit-save-region beg end
)
85 (defun ledit-go-to-lisp ()
86 "Suspend Emacs and restart a waiting Lisp job."
90 (if (get-buffer ledit-buffer
)
92 (set-buffer ledit-buffer
)
93 (goto-char (point-min))
94 (write-region (point-min) (point-max) ledit-zap-file
)
96 (suspend-emacs ledit-go-to-lisp-string
)
97 (load ledit-read-file t t
))
99 (defun ledit-go-to-liszt ()
100 "Suspend Emacs and restart a waiting Liszt job."
104 (if (get-buffer ledit-buffer
)
106 (set-buffer ledit-buffer
)
107 (goto-char (point-min))
108 (insert "(declare (macros t))\n")
109 (write-region (point-min) (point-max) ledit-compile-file
)
111 (suspend-emacs ledit-go-to-liszt-string
)
112 (load ledit-read-file t t
))
114 (defun ledit-setup ()
115 "Set up key bindings for the Lisp/Emacs interface."
116 (if (not ledit-mode-map
)
117 (progn (setq ledit-mode-map
(make-sparse-keymap))
118 (lisp-mode-commands ledit-mode-map
)))
119 (define-key ledit-mode-map
"\e\^d" 'ledit-save-defun
)
120 (define-key ledit-mode-map
"\e\^r" 'ledit-save-region
)
121 (define-key ledit-mode-map
"\^xz" 'ledit-go-to-lisp
)
122 (define-key ledit-mode-map
"\e\^c" 'ledit-go-to-liszt
))
128 "\\<ledit-mode-map>Major mode for editing text and stuffing it to a Lisp job.
129 Like Lisp mode, plus these special commands:
130 \\[ledit-save-defun] -- record defun at or after point
131 for later transmission to Lisp job.
132 \\[ledit-save-region] -- record region for later transmission to Lisp job.
133 \\[ledit-go-to-lisp] -- transfer to Lisp job and transmit saved text.
134 \\[ledit-go-to-liszt] -- transfer to Liszt (Lisp compiler) job
135 and transmit saved text.
137 To make Lisp mode automatically change to Ledit mode,
138 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
141 (ledit-from-lisp-mode))
144 (defun ledit-from-lisp-mode ()
145 (use-local-map ledit-mode-map
)
146 (setq mode-name
"Ledit")
147 (setq major-mode
'ledit-mode
)
148 (run-hooks 'ledit-mode-hook
))
150 ;;; ledit.el ends here