Add standard library headers.
[emacs.git] / lisp / ledit.el
blobfa7892545cf3b662c91f3418e9b0e0dfad6fa4e7
1 ;;; ledit.el --- Emacs side of ledit interface
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keyord: languages
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)
13 ;; any later version.
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.
24 ;;; Code:
26 ;;; To do:
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.")
41 ;;;###autoload
42 (defconst ledit-save-files t "\
43 *Non-nil means Ledit should save files before transferring to Lisp.")
44 ;;;###autoload
45 (defconst ledit-go-to-lisp-string "%?lisp" "\
46 *Shell commands to execute to resume Lisp job.")
47 ;;;###autoload
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"
53 (interactive)
54 (save-excursion
55 (end-of-defun)
56 (let ((end (point)))
57 (beginning-of-defun)
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"
63 (interactive "r")
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."
69 (interactive)
70 (ledit-save-defun)
71 (ledit-go-to-lisp))
73 (defun ledit-zap-defun-to-liszt ()
74 "Carry the current defun to liszt."
75 (interactive)
76 (ledit-save-defun)
77 (ledit-go-to-liszt))
79 (defun ledit-zap-region-to-lisp (beg end)
80 "Carry the current region to Lisp."
81 (interactive "r")
82 (ledit-save-region beg end)
83 (ledit-go-to-lisp))
85 (defun ledit-go-to-lisp ()
86 "Suspend Emacs and restart a waiting Lisp job."
87 (interactive)
88 (if ledit-save-files
89 (save-some-buffers))
90 (if (get-buffer ledit-buffer)
91 (save-excursion
92 (set-buffer ledit-buffer)
93 (goto-char (point-min))
94 (write-region (point-min) (point-max) ledit-zap-file)
95 (erase-buffer)))
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."
101 (interactive)
102 (if ledit-save-files
103 (save-some-buffers))
104 (if (get-buffer ledit-buffer)
105 (save-excursion
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)
110 (erase-buffer)))
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 (nconc (make-sparse-keymap)
118 shared-lisp-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))
124 (ledit-setup)
126 ;;;###autoload
127 (defun ledit-mode ()
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.
136 \\{ledit-mode-map}
137 To make Lisp mode automatically change to Ledit mode,
138 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
139 (interactive)
140 (lisp-mode)
141 (ledit-from-lisp-mode))
143 ;;;###autoload
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