Mercurial > emacs
changeset 25928:bd1d7d04426c
#
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 08 Oct 1999 15:56:42 +0000 |
parents | 776bf3692d9d |
children | a955ea8f6b15 |
files | etc/LEDIT etc/ledit.l |
diffstat | 2 files changed, 227 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/LEDIT Fri Oct 08 15:56:42 1999 +0000 @@ -0,0 +1,77 @@ +Date: 17 Apr 85 15:45:42 EST (Wed) +From: Martin David Connor <mdc@MIT-HTVAX.ARPA> + + Date: Sat, 13 Apr 85 16:28:15 est + From: Richard M. Stallman <rms@mit-prep> + + Can you help this person? Also, can you give me the rest of ledit + to distribute, plus some info on how to use it? + +I have put the files "ledit.l" and "leditcfns.c" on prep:~mdc. +Much to my disgust ledit.l relied on some bogus little package of +functions on HT, so I had to massage it a bit. + +To get it to work, one must: + + - Compile leditcfns.c with something like: + + cc leditcfns.c + + - Edit ledit.l, changing the line beginning "(cfasl" to + have the right pathname for the cfns file you compiled in + the last step. + + - Compile ledit.l with: + + liszt ledit.l + +Then put the following lines in your .lisprc file: + + ;load in functions for emacs interface + (load "//src//mdc//ledit//ledit") ; Location of Ledit library + (set-proc-str "%gnumacs") ; Name of editor + +Then you can use ^E <RETURN> to get from LISP back to gnumacs. + +Here is the part of my .emacs file that pertains to ledit. + + ;;; Set up ledit mode + (setq ledit-go-to-lisp-string "%lisp") + (setq lisp-mode-hook 'ledit-from-lisp-mode) + + Date: Sat, 13 Apr 85 11:26:32 cst + From: neves@wisc-ai.arpa (David Neves) + + This is a documentation question. + I cannot figure out how to use Ledit. I suspect I need some + function on the Franz Lisp end of things to go to Emacs and read in + the temporary file. Is this true? Is the Lisp job started within + Emacs or outside of emacs? I'm just plain confused. Perhaps a couple + of words from someone in the know would help. + + A related question. I have been using a shell buffer when interacting + with Lisp (ie. put a definition in the kill buffer and then yank it + into the shell buffer to redefine it). This is nice but tends to fill + up the shell buffer with lots of code (I'd rather keep calls to functions + in the shell and not the functions themselves). + My question: Is using the shell buffer "better" than ledit? Am I using + it in the best way (i.e. copying definitions from an edit buffer to the + shell buffer)? -Thanks, David Neves + +I have found that ledit works well for doing programming development +when you are changing lots of little pieces of a file and don't wish +to recompile the whole file. Of course M-X Compile is very nice for +calling up a liszt on a buffer and watching it in the another window. +Of course the interface of something like NIL is even better because +you can compile your function directly into your lisp. But since NIL +doesn't run under Unix, this is probably the next best thing. + +I have tried the 2 window method (shell in lower window, lisp code in +upper), and have found it a little awkward. It does have certain +advantages, but most of the time, I get be fine using M-C-D to save a +defun for lisp, and C-X Z to jump back to LISP. C-E RETURN from lisp +is also mnemonic for getting back to gnumacs. + +I hope this helps somewhat. + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/ledit.l Fri Oct 08 15:56:42 1999 +0000 @@ -0,0 +1,150 @@ +;;; -*- Mode: lisp -*- + +; load in the c functions + +(removeaddress '_signal) +(removeaddress '_switch_to_proc) +(removeaddress '_set_proc_str) + +(cfasl "/src/mdc/ledit/leditcfns.o" '_switch_to_proc 'emacs) + +(getaddress '_set_proc_str 'set_proc_str) + +(declare (special *ledit-infile* ; emacs->lisp tempfile + *ledit-outfile* ; lisp->emacs tempfile + *ledit-ppfile* ; pp->emacs tempfile + *ledit-lisztfile* ; compiler input + *ledit-objfile* ; compiler output + *ledit-initialized*) ; flag + ) + +(setq *ledit-initialized* nil) + +;;; INIT-LEDIT + +(defun init-ledit () + (let ((user (getenv '|USER|))) ;USER must be uppercase + (setq + *ledit-outfile* (concat "/tmp/" user ".l2") ; lisp -> emacs + *ledit-infile* (concat "/tmp/" user ".l1") ; emacs -> lisp + *ledit-ppfile* (concat "/tmp/" user ".l3") ; pp output to emacs. + *ledit-lisztfile* (concat "/tmp/" user ".l4") + *ledit-objfile* (concat "/tmp/" user ".o") + *ledit-initialized* t))) + +;;; LEDIT +; if 1 arg, arg is taken as a tag name to pass to emacs. +; if 2 args, second arg is a keyword. If 2nd arg is pp, +; pp is applied to first arg, and result is sent to emacs +; to put in a buffer called LEDIT (which is first erased.) + +(defun ledit fexpr (args) + (apply #'ledit* args)) + +;;; LEDIT* + +(defun ledit* n + (if (not *ledit-initialized*) (init-ledit)) + (ledit-output (listify n)) + (syscall 10. *ledit-infile*) ; syscall 10 is "delete" + (syscall 10. *ledit-lisztfile*) + (emacs) + (ledit-input) + (syscall 10. *ledit-outfile*) + (syscall 10. *ledit-ppfile*) + t) + +;;; LEDIT-OUTPUT +;;; Egad, what a mess! Doesn't work for XEMACS yet. +;;; Here's an example from Mocklisp: +;;; -> (defun bar (nothing) (bar nothing)) +;;; bar +;;; -> (ledit bar) +;;; should produce... +;;; (progn) (progn tag (setq tag "bar") (&goto-tag)) +;;; and +;;; -> (ledit bar pp) +;;; should stuff this to emacs... +;;; (progn) (switch-to-buffer "LEDIT") (erase-buffer) +;;; (insert-file "/tmp/walter.l3") (lisp-mode) +;;; and this... +;;; (def bar +;;; (lambda (x) +;;; (bar nothing))) +;;; into *LEDIT* + +(defun ledit-output (args) + (if args + (let ((ofile (outfile *ledit-outfile*))) + (format ofile "(progn)") ; this is necessary. + + (cond ((null (cdr args)) ; no keyword -> arg is a tag. + (format ofile "(progn tag (setq tag \"~A\"~ + (&goto-tag))" + (car args))) + ((eq (cadr args) 'pp) ; pp-> pp first arg to emacs + (apply 'pp `((|F| ,*ledit-ppfile*) ,(car args))) + (format ofile "(switch-to-buffer \"LEDIT\")~ + (erase-buffer)") + (format ofile "(insert-file \"~A\")" + *ledit-ppfile*) + (format ofile "(lisp-mode)")) + + (t (format t "~&~A -- unknown option~%" (cdr args)))) + (close ofile)))) + +;;; LISZT* +;;; Need this guy to do compile-input. +;;; Liszt returns 0 if all was well. +;;; Note that in ordinary use the user will have to get used to looking +;;; at "%Warning: ... Compiler declared *foo* special" messages, since +;;; you don't usually want to hunt around in your file, zap in the the +;;; declarations, then go back to what you were doing. +;;; Fortunately this doesn't cause the compiler to bomb. +;;; Some sleepless night I will think of a way to get around this. + +(defun liszt* (&rest args) + (apply #'liszt args)) + +;;; LEDIT-INPUT +;;; Although there are two cases here, in practice +;;; it is never the case that there is both input to be +;;; interpreted and input to be compiled. + +(defun ledit-input () + (if (probef *ledit-lisztfile*) + (cond ((getd #'liszt) + (format t ";Compiling LEDIT:") + (and (zerop (liszt* *ledit-lisztfile* '-o *ledit-objfile*)) + (load *ledit-objfile*))) + (t (format t ";Can't compile LEDIT: No liszt.~%;Reading instead:") + (let ((ifile (infile *ledit-lisztfile*))) + (ledit-load ifile) + (close ifile))))) + + (if (probef *ledit-infile*) + (let ((ifile (infile *ledit-infile*))) + (format t ";Reading from LEDIT:~%") + (ledit-load ifile) + (close ifile)))) + +;;; LEDIT-LOAD +;;; A generally useful form of load + +(defun ledit-load (ifile) + (let ((eof-form (list 'eof-form))) + (do ((form (read ifile eof-form) (read ifile eof-form))) + ((eq form eof-form)) + (format t "; ~A~%" (eval form))))) + +(setsyntax #/ 'macro 'ledit) ; make ^E = (ledit)<return> + +;; more robust version of the c function set_proc_str. Does argument checking. +;; set_proc_str sets the string that is stuffed to the tty after franz pauses +;; and the csh wakes up. It is usually "%emacs" or "%vemacs" or "%?emacs" +(defun set-proc-str (arg) + (if (stringp arg) + (set_proc_str arg) + (if (symbolp arg) + (set_proc_str (get-pname arg)) + (error arg " is illegal argument to set-proc-str"))))