annotate lisp/packages/ledit.el @ 76:c0c698873ce1 r20-0b33

Import from CVS: tag r20-0b33
author cvs
date Mon, 13 Aug 2007 09:05:10 +0200
parents ac2d302a0011
children
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
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6 ;; Keyword: languages
0
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
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
25 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This is a major mode for editing Liszt. See etc/LEDIT for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; To do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; o lisp -> emacs side of things (grind-definition and find-definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defvar ledit-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defconst ledit-zap-file (concat "/tmp/" (user-login-name) ".l1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "File name for data sent to Lisp by Ledit.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defconst ledit-read-file (concat "/tmp/" (user-login-name) ".l2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "File name for data sent to Ledit by Lisp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defconst ledit-compile-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (concat "/tmp/" (user-login-name) ".l4")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "File name for data sent to Lisp compiler by Ledit.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defconst ledit-buffer "*LEDIT*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "Name of buffer in which Ledit accumulates data to send to Lisp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defconst ledit-save-files t "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 *Non-nil means Ledit should save files before transferring to Lisp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defconst ledit-go-to-lisp-string "%?lisp" "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 *Shell commands to execute to resume Lisp job.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defconst ledit-go-to-liszt-string "%?liszt" "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 *Shell commands to execute to resume Lisp compiler job.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defun ledit-save-defun ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Save the current defun in the ledit buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (let ((end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (append-to-buffer ledit-buffer (point) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (message "Current defun saved for Lisp")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun ledit-save-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "Save the current region in the ledit buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (append-to-buffer ledit-buffer beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (message "Region saved for Lisp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defun ledit-zap-defun-to-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "Carry the current defun to Lisp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (ledit-save-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (ledit-go-to-lisp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defun ledit-zap-defun-to-liszt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "Carry the current defun to liszt."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (ledit-save-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (ledit-go-to-liszt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defun ledit-zap-region-to-lisp (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Carry the current region to Lisp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (ledit-save-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (ledit-go-to-lisp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun ledit-go-to-lisp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Suspend Emacs and restart a waiting Lisp job."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if ledit-save-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (save-some-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (if (get-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (set-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (write-region (point-min) (point-max) ledit-zap-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (suspend-emacs ledit-go-to-lisp-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (load ledit-read-file t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (defun ledit-go-to-liszt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 "Suspend Emacs and restart a waiting Liszt job."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if ledit-save-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (save-some-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (get-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (set-buffer ledit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (insert "(declare (macros t))\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (write-region (point-min) (point-max) ledit-compile-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (suspend-emacs ledit-go-to-liszt-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (load ledit-read-file t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun ledit-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "Set up key bindings for the Lisp/Emacs interface."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (not ledit-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (progn (setq ledit-mode-map (nconc (make-sparse-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 shared-lisp-mode-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (define-key ledit-mode-map "\e\^d" 'ledit-save-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (define-key ledit-mode-map "\e\^r" 'ledit-save-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (define-key ledit-mode-map "\^xz" 'ledit-go-to-lisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (define-key ledit-mode-map "\e\^c" 'ledit-go-to-liszt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (ledit-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defun ledit-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 "\\<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
136 Like Lisp mode, plus these special commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 \\[ledit-save-defun] -- record defun at or after point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 for later transmission to Lisp job.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 \\[ledit-save-region] -- record region for later transmission to Lisp job.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 \\[ledit-go-to-lisp] -- transfer to Lisp job and transmit saved text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 \\[ledit-go-to-liszt] -- transfer to Liszt (Lisp compiler) job
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 and transmit saved text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 \\{ledit-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 To make Lisp mode automatically change to Ledit mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (ledit-from-lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun ledit-from-lisp-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (use-local-map ledit-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq mode-name "Ledit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq major-mode 'ledit-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (run-hooks 'ledit-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; ledit.el ends here