Mercurial > emacs
annotate lisp/ledit.el @ 873:0abaf590e0ca
entered into RCS
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 26 Jul 1992 19:36:03 +0000 |
parents | 20674ae6bf52 |
children | 9f3cc03dae67 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
1 ;;; ledit.el --- Emacs side of ledit interface |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
2 |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
3 ;; Copyright (C) 1985 Free Software Foundation, Inc. |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
5 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keyord: languages |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 |
36 | 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 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 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 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
24 ;;; Code: |
36 | 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.") | |
256 | 40 |
269 | 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.") | |
36 | 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 () | |
214 | 68 "Carry the current defun to Lisp." |
36 | 69 (interactive) |
70 (ledit-save-defun) | |
71 (ledit-go-to-lisp)) | |
72 | |
73 (defun ledit-zap-defun-to-liszt () | |
214 | 74 "Carry the current defun to liszt." |
36 | 75 (interactive) |
76 (ledit-save-defun) | |
77 (ledit-go-to-liszt)) | |
78 | |
79 (defun ledit-zap-region-to-lisp (beg end) | |
214 | 80 "Carry the current region to Lisp." |
36 | 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 () | |
214 | 115 "Set up key bindings for the Lisp/Emacs interface." |
36 | 116 (if (not ledit-mode-map) |
117 (progn (setq ledit-mode-map (make-sparse-keymap)) | |
118 (lisp-mode-commands ledit-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)) | |
123 | |
124 (ledit-setup) | |
125 | |
256 | 126 ;;;###autoload |
36 | 127 (defun ledit-mode () |
214 | 128 "\\<ledit-mode-map>Major mode for editing text and stuffing it to a Lisp job. |
36 | 129 Like Lisp mode, plus these special commands: |
214 | 130 \\[ledit-save-defun] -- record defun at or after point |
36 | 131 for later transmission to Lisp job. |
214 | 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 | |
36 | 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 | |
256 | 143 ;;;###autoload |
36 | 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)) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
149 |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
150 ;;; ledit.el ends here |