*** empty log message ***
[emacs.git] / lisp / ledit.el
blob9034732305636b82b7eb0dd66bae14afdaa5cae2
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)
10 ;; any later version.
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.
22 ;;; To do:
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.")
37 ;;;###autoload
38 (defconst ledit-save-files t "\
39 *Non-nil means Ledit should save files before transferring to Lisp.")
40 ;;;###autoload
41 (defconst ledit-go-to-lisp-string "%?lisp" "\
42 *Shell commands to execute to resume Lisp job.")
43 ;;;###autoload
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"
49 (interactive)
50 (save-excursion
51 (end-of-defun)
52 (let ((end (point)))
53 (beginning-of-defun)
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"
59 (interactive "r")
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."
65 (interactive)
66 (ledit-save-defun)
67 (ledit-go-to-lisp))
69 (defun ledit-zap-defun-to-liszt ()
70 "Carry the current defun to liszt."
71 (interactive)
72 (ledit-save-defun)
73 (ledit-go-to-liszt))
75 (defun ledit-zap-region-to-lisp (beg end)
76 "Carry the current region to Lisp."
77 (interactive "r")
78 (ledit-save-region beg end)
79 (ledit-go-to-lisp))
81 (defun ledit-go-to-lisp ()
82 "Suspend Emacs and restart a waiting Lisp job."
83 (interactive)
84 (if ledit-save-files
85 (save-some-buffers))
86 (if (get-buffer ledit-buffer)
87 (save-excursion
88 (set-buffer ledit-buffer)
89 (goto-char (point-min))
90 (write-region (point-min) (point-max) ledit-zap-file)
91 (erase-buffer)))
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."
97 (interactive)
98 (if ledit-save-files
99 (save-some-buffers))
100 (if (get-buffer ledit-buffer)
101 (save-excursion
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)
106 (erase-buffer)))
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))
120 (ledit-setup)
122 ;;;###autoload
123 (defun ledit-mode ()
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.
132 \\{ledit-mode-map}
133 To make Lisp mode automatically change to Ledit mode,
134 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
135 (interactive)
136 (lisp-mode)
137 (ledit-from-lisp-mode))
139 ;;;###autoload
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