1 ;; Emacs side of ledit interface
2 ;; Copyright (C) 1985 Free Software Foundation, Inc.
4 ;; This file is part of GNU Emacs.
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)
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.
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.
22 ;;; o lisp -> emacs side of things (grind-definition and find-definition)
24 (defvar ledit-mode-map nil
)
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.")
35 ;These are now in loaddefs.el
36 ;(defconst ledit-save-files t
37 ; "*Non-nil means Ledit should save files before transferring to Lisp.")
38 ;(defconst ledit-go-to-lisp-string "%?lisp"
39 ; "*Shell commands to execute to resume Lisp job.")
40 ;(defconst ledit-go-to-liszt-string "%?liszt"
41 ; "*Shell commands to execute to resume Lisp compiler job.")
43 (defun ledit-save-defun ()
44 "Save the current defun in the ledit buffer"
50 (append-to-buffer ledit-buffer
(point) end
))
51 (message "Current defun saved for Lisp")))
53 (defun ledit-save-region (beg end
)
54 "Save the current region in the ledit buffer"
56 (append-to-buffer ledit-buffer beg end
)
57 (message "Region saved for Lisp"))
59 (defun ledit-zap-defun-to-lisp ()
60 "Carry the current defun to lisp"
65 (defun ledit-zap-defun-to-liszt ()
66 "Carry the current defun to liszt"
71 (defun ledit-zap-region-to-lisp (beg end
)
72 "Carry the current region to lisp"
74 (ledit-save-region beg end
)
77 (defun ledit-go-to-lisp ()
78 "Suspend Emacs and restart a waiting Lisp job."
82 (if (get-buffer ledit-buffer
)
84 (set-buffer ledit-buffer
)
85 (goto-char (point-min))
86 (write-region (point-min) (point-max) ledit-zap-file
)
88 (suspend-emacs ledit-go-to-lisp-string
)
89 (load ledit-read-file t t
))
91 (defun ledit-go-to-liszt ()
92 "Suspend Emacs and restart a waiting Liszt job."
96 (if (get-buffer ledit-buffer
)
98 (set-buffer ledit-buffer
)
99 (goto-char (point-min))
100 (insert "(declare (macros t))\n")
101 (write-region (point-min) (point-max) ledit-compile-file
)
103 (suspend-emacs ledit-go-to-liszt-string
)
104 (load ledit-read-file t t
))
106 (defun ledit-setup ()
107 "Set up key bindings for the Lisp / Emacs interface"
108 (if (not ledit-mode-map
)
109 (progn (setq ledit-mode-map
(make-sparse-keymap))
110 (lisp-mode-commands ledit-mode-map
)))
111 (define-key ledit-mode-map
"\e\^d" 'ledit-save-defun
)
112 (define-key ledit-mode-map
"\e\^r" 'ledit-save-region
)
113 (define-key ledit-mode-map
"\^xz" 'ledit-go-to-lisp
)
114 (define-key ledit-mode-map
"\e\^c" 'ledit-go-to-liszt
))
119 "Major mode for editing text and stuffing it to a Lisp job.
120 Like Lisp mode, plus these special commands:
121 M-C-d -- record defun at or after point
122 for later transmission to Lisp job.
123 M-C-r -- record region for later transmission to Lisp job.
124 C-x z -- transfer to Lisp job and transmit saved text.
125 M-C-c -- transfer to Liszt (Lisp compiler) job
126 and transmit saved text.
128 To make Lisp mode automatically change to Ledit mode,
129 do (setq lisp-mode-hook 'ledit-from-lisp-mode)"
132 (ledit-from-lisp-mode))
134 (defun ledit-from-lisp-mode ()
135 (use-local-map ledit-mode-map
)
136 (setq mode-name
"Ledit")
137 (setq major-mode
'ledit-mode
)
138 (run-hooks 'ledit-mode-hook
))