Commit | Line | Data |
---|---|---|
6594deb0 ER |
1 | ;;; ledit.el --- Emacs side of ledit interface |
2 | ||
3a801d0c ER |
3 | ;; Copyright (C) 1985 Free Software Foundation, Inc. |
4 | ||
e5167999 | 5 | ;; Maintainer: FSF |
fd7fa35a | 6 | ;; Keyord: languages |
e5167999 | 7 | |
a2535589 JA |
8 | ;; This file is part of GNU Emacs. |
9 | ||
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 | |
e5167999 | 12 | ;; the Free Software Foundation; either version 2, or (at your option) |
a2535589 JA |
13 | ;; any later version. |
14 | ||
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. | |
19 | ||
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. | |
23 | ||
e5167999 | 24 | ;;; Code: |
a2535589 JA |
25 | |
26 | ;;; To do: | |
27 | ;;; o lisp -> emacs side of things (grind-definition and find-definition) | |
28 | ||
29 | (defvar ledit-mode-map nil) | |
30 | ||
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.") | |
7229064d | 40 | |
6503cec3 JB |
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.") | |
a2535589 JA |
50 | |
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"))) | |
60 | ||
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")) | |
66 | ||
67 | (defun ledit-zap-defun-to-lisp () | |
f30ff39f | 68 | "Carry the current defun to Lisp." |
a2535589 JA |
69 | (interactive) |
70 | (ledit-save-defun) | |
71 | (ledit-go-to-lisp)) | |
72 | ||
73 | (defun ledit-zap-defun-to-liszt () | |
f30ff39f | 74 | "Carry the current defun to liszt." |
a2535589 JA |
75 | (interactive) |
76 | (ledit-save-defun) | |
77 | (ledit-go-to-liszt)) | |
78 | ||
79 | (defun ledit-zap-region-to-lisp (beg end) | |
f30ff39f | 80 | "Carry the current region to Lisp." |
a2535589 JA |
81 | (interactive "r") |
82 | (ledit-save-region beg end) | |
83 | (ledit-go-to-lisp)) | |
84 | ||
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)) | |
98 | ||
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)) | |
113 | ||
114 | (defun ledit-setup () | |
f30ff39f | 115 | "Set up key bindings for the Lisp/Emacs interface." |
a2535589 | 116 | (if (not ledit-mode-map) |
e8a57935 JB |
117 | (progn (setq ledit-mode-map (nconc (make-sparse-keymap) |
118 | shared-lisp-mode-map)))) | |
a2535589 JA |
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)) | |
123 | ||
124 | (ledit-setup) | |
125 | ||
7229064d | 126 | ;;;###autoload |
a2535589 | 127 | (defun ledit-mode () |
f30ff39f | 128 | "\\<ledit-mode-map>Major mode for editing text and stuffing it to a Lisp job. |
a2535589 | 129 | Like Lisp mode, plus these special commands: |
f30ff39f | 130 | \\[ledit-save-defun] -- record defun at or after point |
a2535589 | 131 | for later transmission to Lisp job. |
f30ff39f BP |
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 | |
a2535589 JA |
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)) | |
142 | ||
7229064d | 143 | ;;;###autoload |
a2535589 JA |
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)) | |
6594deb0 ER |
149 | |
150 | ;;; ledit.el ends here |