annotate etc/ledit.l @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +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 ;;; -*- Mode: lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ; load in the c functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 (removeaddress '_signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 (removeaddress '_switch_to_proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 (removeaddress '_set_proc_str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 (cfasl "/src/mdc/ledit/leditcfns.o" '_switch_to_proc 'emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 (getaddress '_set_proc_str 'set_proc_str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 (declare (special *ledit-infile* ; emacs->lisp tempfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 *ledit-outfile* ; lisp->emacs tempfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 *ledit-ppfile* ; pp->emacs tempfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 *ledit-lisztfile* ; compiler input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 *ledit-objfile* ; compiler output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 *ledit-initialized*) ; flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (setq *ledit-initialized* nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; INIT-LEDIT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (defun init-ledit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (let ((user (getenv '|USER|))) ;USER must be uppercase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 *ledit-outfile* (concat "/tmp/" user ".l2") ; lisp -> emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 *ledit-infile* (concat "/tmp/" user ".l1") ; emacs -> lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 *ledit-ppfile* (concat "/tmp/" user ".l3") ; pp output to emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 *ledit-lisztfile* (concat "/tmp/" user ".l4")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 *ledit-objfile* (concat "/tmp/" user ".o")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 *ledit-initialized* t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; LEDIT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ; if 1 arg, arg is taken as a tag name to pass to emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ; if 2 args, second arg is a keyword. If 2nd arg is pp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ; pp is applied to first arg, and result is sent to emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ; to put in a buffer called LEDIT (which is first erased.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defun ledit fexpr (args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (apply #'ledit* args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; LEDIT*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun ledit* n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (if (not *ledit-initialized*) (init-ledit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (ledit-output (listify n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (syscall 10. *ledit-infile*) ; syscall 10 is "delete"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (syscall 10. *ledit-lisztfile*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (ledit-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (syscall 10. *ledit-outfile*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (syscall 10. *ledit-ppfile*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; LEDIT-OUTPUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; Egad, what a mess! Doesn't work for XEMACS yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; Here's an example from Mocklisp:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; -> (defun bar (nothing) (bar nothing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; -> (ledit bar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; should produce...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; (progn) (progn tag (setq tag "bar") (&goto-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; -> (ledit bar pp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; should stuff this to emacs...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; (progn) (switch-to-buffer "LEDIT") (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; (insert-file "/tmp/walter.l3") (lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; and this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; (def bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; (bar nothing)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; into *LEDIT*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defun ledit-output (args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let ((ofile (outfile *ledit-outfile*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (format ofile "(progn)") ; this is necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (cond ((null (cdr args)) ; no keyword -> arg is a tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (format ofile "(progn tag (setq tag \"~A\"~
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (&goto-tag))"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ((eq (cadr args) 'pp) ; pp-> pp first arg to emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (apply 'pp `((|F| ,*ledit-ppfile*) ,(car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (format ofile "(switch-to-buffer \"LEDIT\")~
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (erase-buffer)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (format ofile "(insert-file \"~A\")"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 *ledit-ppfile*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (format ofile "(lisp-mode)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (t (format t "~&~A -- unknown option~%" (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (close ofile))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; LISZT*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; Need this guy to do compile-input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; Liszt returns 0 if all was well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; Note that in ordinary use the user will have to get used to looking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; at "%Warning: ... Compiler declared *foo* special" messages, since
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
101 ;;; you don't usually want to hunt around in your file, zap in the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; declarations, then go back to what you were doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; Fortunately this doesn't cause the compiler to bomb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; Some sleepless night I will think of a way to get around this.
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 liszt* (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (apply #'liszt args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; LEDIT-INPUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; Although there are two cases here, in practice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; it is never the case that there is both input to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; interpreted and input to be compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defun ledit-input ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if (probef *ledit-lisztfile*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (cond ((getd #'liszt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (format t ";Compiling LEDIT:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (and (zerop (liszt* *ledit-lisztfile* '-o *ledit-objfile*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (load *ledit-objfile*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (t (format t ";Can't compile LEDIT: No liszt.~%;Reading instead:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (let ((ifile (infile *ledit-lisztfile*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (ledit-load ifile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (close ifile)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (if (probef *ledit-infile*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((ifile (infile *ledit-infile*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (format t ";Reading from LEDIT:~%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (ledit-load ifile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (close ifile))))
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-LOAD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; A generally useful form of load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defun ledit-load (ifile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (let ((eof-form (list 'eof-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (do ((form (read ifile eof-form) (read ifile eof-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ((eq form eof-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (format t "; ~A~%" (eval form)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setsyntax #/ 'macro 'ledit) ; make ^E = (ledit)<return>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; more robust version of the c function set_proc_str. Does argument checking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; set_proc_str sets the string that is stuffed to the tty after franz pauses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; and the csh wakes up. It is usually "%emacs" or "%vemacs" or "%?emacs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defun set-proc-str (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (stringp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (set_proc_str arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if (symbolp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (set_proc_str (get-pname arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (error arg " is illegal argument to set-proc-str"))))