annotate lisp/packages/ledit.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; ledit.el --- Emacs side of ledit interface
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keyord: languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This is a major mode for editing Liszt. See etc/LEDIT for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; To do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; o lisp -> emacs side of things (grind-definition and find-definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar ledit-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defconst ledit-zap-file (concat "/tmp/" (user-login-name) ".l1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "File name for data sent to Lisp by Ledit.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defconst ledit-read-file (concat "/tmp/" (user-login-name) ".l2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "File name for data sent to Ledit by Lisp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defconst ledit-compile-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (concat "/tmp/" (user-login-name) ".l4")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "File name for data sent to Lisp compiler by Ledit.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defconst ledit-buffer "*LEDIT*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "Name of buffer in which Ledit accumulates data to send to Lisp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defconst ledit-save-files t "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 *Non-nil means Ledit should save files before transferring to Lisp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defconst ledit-go-to-lisp-string "%?lisp" "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 *Shell commands to execute to resume Lisp job.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defconst ledit-go-to-liszt-string "%?liszt" "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 *Shell commands to execute to resume Lisp compiler job.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defun ledit-save-defun ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "Save the current defun in the ledit buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (let ((end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (append-to-buffer ledit-buffer (point) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (message "Current defun saved for Lisp")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defun ledit-save-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "Save the current region in the ledit buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (append-to-buffer ledit-buffer beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (message "Region saved for Lisp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defun ledit-zap-defun-to-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 "Carry the current defun to Lisp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (ledit-save-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (ledit-go-to-lisp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun ledit-zap-defun-to-liszt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "Carry the current defun to liszt."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (ledit-save-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (ledit-go-to-liszt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defun ledit-zap-region-to-lisp (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 "Carry the current region to Lisp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (ledit-save-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (ledit-go-to-lisp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defun ledit-go-to-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 "Suspend Emacs and restart a waiting Lisp job."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if ledit-save-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (save-some-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if (get-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (set-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (write-region (point-min) (point-max) ledit-zap-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (suspend-emacs ledit-go-to-lisp-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (load ledit-read-file t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun ledit-go-to-liszt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Suspend Emacs and restart a waiting Liszt job."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if ledit-save-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (save-some-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (if (get-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (set-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (insert "(declare (macros t))\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (write-region (point-min) (point-max) ledit-compile-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (suspend-emacs ledit-go-to-liszt-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (load ledit-read-file t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun ledit-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Set up key bindings for the Lisp/Emacs interface."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (if (not ledit-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (progn (setq ledit-mode-map (nconc (make-sparse-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 shared-lisp-mode-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (define-key ledit-mode-map "\e\^d" 'ledit-save-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (define-key ledit-mode-map "\e\^r" 'ledit-save-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (define-key ledit-mode-map "\^xz" 'ledit-go-to-lisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (define-key ledit-mode-map "\e\^c" 'ledit-go-to-liszt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (ledit-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun ledit-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "\\<ledit-mode-map>Major mode for editing text and stuffing it to a Lisp job.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Like Lisp mode, plus these special commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 \\[ledit-save-defun] -- record defun at or after point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 for later transmission to Lisp job.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 \\[ledit-save-region] -- record region for later transmission to Lisp job.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 \\[ledit-go-to-lisp] -- transfer to Lisp job and transmit saved text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 \\[ledit-go-to-liszt] -- transfer to Liszt (Lisp compiler) job
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 and transmit saved text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 \\{ledit-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 To make Lisp mode automatically change to Ledit mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (ledit-from-lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defun ledit-from-lisp-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (use-local-map ledit-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (setq mode-name "Ledit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq major-mode 'ledit-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (run-hooks 'ledit-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;; ledit.el ends here