1 ;;; ledit.el --- Emacs side of ledit interface
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 ;;; o lisp -> emacs side of things (grind-definition and find-definition)
25 (defvar ledit-mode-map nil
)
27 (defconst ledit-zap-file
(concat "/tmp/" (user-login-name) ".l1")
28 "File name for data sent to Lisp by Ledit.")
29 (defconst ledit-read-file
(concat "/tmp/" (user-login-name) ".l2")
30 "File name for data sent to Ledit by Lisp.")
31 (defconst ledit-compile-file
32 (concat "/tmp/" (user-login-name) ".l4")
33 "File name for data sent to Lisp compiler by Ledit.")
34 (defconst ledit-buffer
"*LEDIT*"
35 "Name of buffer in which Ledit accumulates data to send to Lisp.")
38 (defconst ledit-save-files t
"\
39 *Non-nil means Ledit should save files before transferring to Lisp.")
41 (defconst ledit-go-to-lisp-string
"%?lisp" "\
42 *Shell commands to execute to resume Lisp job.")
44 (defconst ledit-go-to-liszt-string
"%?liszt" "\
45 *Shell commands to execute to resume Lisp compiler job.")
47 (defun ledit-save-defun ()
48 "Save the current defun in the ledit buffer"
54 (append-to-buffer ledit-buffer
(point) end
))
55 (message "Current defun saved for Lisp")))
57 (defun ledit-save-region (beg end
)
58 "Save the current region in the ledit buffer"
60 (append-to-buffer ledit-buffer beg end
)
61 (message "Region saved for Lisp"))
63 (defun ledit-zap-defun-to-lisp ()
64 "Carry the current defun to Lisp."
69 (defun ledit-zap-defun-to-liszt ()
70 "Carry the current defun to liszt."
75 (defun ledit-zap-region-to-lisp (beg end
)
76 "Carry the current region to Lisp."
78 (ledit-save-region beg end
)
81 (defun ledit-go-to-lisp ()
82 "Suspend Emacs and restart a waiting Lisp job."
86 (if (get-buffer ledit-buffer
)
88 (set-buffer ledit-buffer
)
89 (goto-char (point-min))
90 (write-region (point-min) (point-max) ledit-zap-file
)
92 (suspend-emacs ledit-go-to-lisp-string
)
93 (load ledit-read-file t t
))
95 (defun ledit-go-to-liszt ()
96 "Suspend Emacs and restart a waiting Liszt job."
100 (if (get-buffer ledit-buffer
)
102 (set-buffer ledit-buffer
)
103 (goto-char (point-min))
104 (insert "(declare (macros t))\n")
105 (write-region (point-min) (point-max) ledit-compile-file
)
107 (suspend-emacs ledit-go-to-liszt-string
)
108 (load ledit-read-file t t
))
110 (defun ledit-setup ()
111 "Set up key bindings for the Lisp/Emacs interface."
112 (if (not ledit-mode-map
)
113 (progn (setq ledit-mode-map
(make-sparse-keymap))
114 (lisp-mode-commands ledit-mode-map
)))
115 (define-key ledit-mode-map
"\e\^d" 'ledit-save-defun
)
116 (define-key ledit-mode-map
"\e\^r" 'ledit-save-region
)
117 (define-key ledit-mode-map
"\^xz" 'ledit-go-to-lisp
)
118 (define-key ledit-mode-map
"\e\^c" 'ledit-go-to-liszt
))
124 "\\<ledit-mode-map>Major mode for editing text and stuffing it to a Lisp job.
125 Like Lisp mode, plus these special commands:
126 \\[ledit-save-defun] -- record defun at or after point
127 for later transmission to Lisp job.
128 \\[ledit-save-region] -- record region for later transmission to Lisp job.
129 \\[ledit-go-to-lisp] -- transfer to Lisp job and transmit saved text.
130 \\[ledit-go-to-liszt] -- transfer to Liszt (Lisp compiler) job
131 and transmit saved text.
133 To make Lisp mode automatically change to Ledit mode,
134 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
137 (ledit-from-lisp-mode))
140 (defun ledit-from-lisp-mode ()
141 (use-local-map ledit-mode-map
)
142 (setq mode-name
"Ledit")
143 (setq major-mode
'ledit-mode
)
144 (run-hooks 'ledit-mode-hook
))
146 ;;; ledit.el ends here