36
|
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/" (user-login-name) ".l1")
|
|
27 "File name for data sent to Lisp by Ledit.")
|
|
28 (defconst ledit-read-file (concat "/tmp/" (user-login-name) ".l2")
|
|
29 "File name for data sent to Ledit by Lisp.")
|
|
30 (defconst ledit-compile-file
|
|
31 (concat "/tmp/" (user-login-name) ".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.")
|
256
|
35
|
269
|
36 ;;;###autoload
|
|
37 (defconst ledit-save-files t "\
|
|
38 *Non-nil means Ledit should save files before transferring to Lisp.")
|
|
39 ;;;###autoload
|
|
40 (defconst ledit-go-to-lisp-string "%?lisp" "\
|
|
41 *Shell commands to execute to resume Lisp job.")
|
|
42 ;;;###autoload
|
|
43 (defconst ledit-go-to-liszt-string "%?liszt" "\
|
|
44 *Shell commands to execute to resume Lisp compiler job.")
|
36
|
45
|
|
46 (defun ledit-save-defun ()
|
|
47 "Save the current defun in the ledit buffer"
|
|
48 (interactive)
|
|
49 (save-excursion
|
|
50 (end-of-defun)
|
|
51 (let ((end (point)))
|
|
52 (beginning-of-defun)
|
|
53 (append-to-buffer ledit-buffer (point) end))
|
|
54 (message "Current defun saved for Lisp")))
|
|
55
|
|
56 (defun ledit-save-region (beg end)
|
|
57 "Save the current region in the ledit buffer"
|
|
58 (interactive "r")
|
|
59 (append-to-buffer ledit-buffer beg end)
|
|
60 (message "Region saved for Lisp"))
|
|
61
|
|
62 (defun ledit-zap-defun-to-lisp ()
|
214
|
63 "Carry the current defun to Lisp."
|
36
|
64 (interactive)
|
|
65 (ledit-save-defun)
|
|
66 (ledit-go-to-lisp))
|
|
67
|
|
68 (defun ledit-zap-defun-to-liszt ()
|
214
|
69 "Carry the current defun to liszt."
|
36
|
70 (interactive)
|
|
71 (ledit-save-defun)
|
|
72 (ledit-go-to-liszt))
|
|
73
|
|
74 (defun ledit-zap-region-to-lisp (beg end)
|
214
|
75 "Carry the current region to Lisp."
|
36
|
76 (interactive "r")
|
|
77 (ledit-save-region beg end)
|
|
78 (ledit-go-to-lisp))
|
|
79
|
|
80 (defun ledit-go-to-lisp ()
|
|
81 "Suspend Emacs and restart a waiting Lisp job."
|
|
82 (interactive)
|
|
83 (if ledit-save-files
|
|
84 (save-some-buffers))
|
|
85 (if (get-buffer ledit-buffer)
|
|
86 (save-excursion
|
|
87 (set-buffer ledit-buffer)
|
|
88 (goto-char (point-min))
|
|
89 (write-region (point-min) (point-max) ledit-zap-file)
|
|
90 (erase-buffer)))
|
|
91 (suspend-emacs ledit-go-to-lisp-string)
|
|
92 (load ledit-read-file t t))
|
|
93
|
|
94 (defun ledit-go-to-liszt ()
|
|
95 "Suspend Emacs and restart a waiting Liszt job."
|
|
96 (interactive)
|
|
97 (if ledit-save-files
|
|
98 (save-some-buffers))
|
|
99 (if (get-buffer ledit-buffer)
|
|
100 (save-excursion
|
|
101 (set-buffer ledit-buffer)
|
|
102 (goto-char (point-min))
|
|
103 (insert "(declare (macros t))\n")
|
|
104 (write-region (point-min) (point-max) ledit-compile-file)
|
|
105 (erase-buffer)))
|
|
106 (suspend-emacs ledit-go-to-liszt-string)
|
|
107 (load ledit-read-file t t))
|
|
108
|
|
109 (defun ledit-setup ()
|
214
|
110 "Set up key bindings for the Lisp/Emacs interface."
|
36
|
111 (if (not ledit-mode-map)
|
|
112 (progn (setq ledit-mode-map (make-sparse-keymap))
|
|
113 (lisp-mode-commands ledit-mode-map)))
|
|
114 (define-key ledit-mode-map "\e\^d" 'ledit-save-defun)
|
|
115 (define-key ledit-mode-map "\e\^r" 'ledit-save-region)
|
|
116 (define-key ledit-mode-map "\^xz" 'ledit-go-to-lisp)
|
|
117 (define-key ledit-mode-map "\e\^c" 'ledit-go-to-liszt))
|
|
118
|
|
119 (ledit-setup)
|
|
120
|
256
|
121 ;;;###autoload
|
36
|
122 (defun ledit-mode ()
|
214
|
123 "\\<ledit-mode-map>Major mode for editing text and stuffing it to a Lisp job.
|
36
|
124 Like Lisp mode, plus these special commands:
|
214
|
125 \\[ledit-save-defun] -- record defun at or after point
|
36
|
126 for later transmission to Lisp job.
|
214
|
127 \\[ledit-save-region] -- record region for later transmission to Lisp job.
|
|
128 \\[ledit-go-to-lisp] -- transfer to Lisp job and transmit saved text.
|
|
129 \\[ledit-go-to-liszt] -- transfer to Liszt (Lisp compiler) job
|
36
|
130 and transmit saved text.
|
|
131 \\{ledit-mode-map}
|
|
132 To make Lisp mode automatically change to Ledit mode,
|
|
133 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
|
|
134 (interactive)
|
|
135 (lisp-mode)
|
|
136 (ledit-from-lisp-mode))
|
|
137
|
256
|
138 ;;;###autoload
|
36
|
139 (defun ledit-from-lisp-mode ()
|
|
140 (use-local-map ledit-mode-map)
|
|
141 (setq mode-name "Ledit")
|
|
142 (setq major-mode 'ledit-mode)
|
|
143 (run-hooks 'ledit-mode-hook))
|