What is it? =========== This file is set of patches for the 01nov91 version of the Scheme->C system. These patches add support for the Sun4/Sparcstation (SPARC), the Sun3 (SUN3), the Apollo DNx500 (APOLLO) and DN1000 (PRISM) series, the 386 (running ISC Unix ?), the NeXT, and the Sony News. Most of this is not new work, I simply integrated all the patches that were posted for the 28sep90 version and the 23feb90 version. I have verified this patch on the following machine/OS combinations: Sun4 - SunOS 4.1.1 Sun4 - SunOS 4.0.3 Sun3 - SunOS 4.1.1 Apollo DN3500 - Domain/OS SR10.2 (cc 6.7, I think) DEC DS/5000-200 - ULTRIX V4.1 DEC cVAX-GPX (most like a vax3500) - ULTRIX V4.0 How to use it. ============== This patch was generated against a fresh, unmodified version of the 01nov91 release of Scheme->C. I suggest you start with the original tar file and untar it. 1. cd into the top directory of the distribution. You should see something like this from ls -F: CHANGES README cdecl/ gnuemacs/ scrt/ test/ MIPS VAX doc/ makefile scsc/ xlib/ 2. Run the patch file through the patch program, like this ("this" assumes the patch file lives in the directory that is one level up from the top of the distribution): patch -p -b ".MCC" <../MCC01-01nov91.patches When patch is done, check to be sure there were no rejections. This can be done with the following command: find . -name '*.rej' -print If there were rejections, find out why and correct them. If it was due to a problem in the patch, please let me know. (I tried the patch on the above machines and it works for me :-) 3. Edit the top level makefile-tail (./makefile-tail) to fix up the definition of SRCDIR at a minimum. You may also want to change the various *DIR, *BIN, and *LIB macros that are appropriate for your environment. 4. Run a "make for" command, where ARCH is one of APOLLO, I386, ISC386IX, MIPS, NeXT, PRISM, SPARC, SUN3, TITAN, or VAX. This will create the $(CPUDIR) directory, if it does not exist. It will then create a tree of symbolic links to all the necessary files in the distribution. [ If you can accept the values for CPUDIR that already exist in the makefile, you can just say "make for SRCDIR=$PWD" where $PWD has a valid pathname to the currect directory] 5. cd into $(SRCDIR) which you set in #3 above. 6. Do a "make port" 7. Verify the build as in step #4 in the README file. I also suggest running more tests. This can be done like this: 4 >cd test 5 >../scrt/sci Scheme->C -- 01nov91jfb+MCC01 ... > (load "test.sc") MODULE form ignored (DEFINE-EXTERNAL TEST-ERRORS TESTCHK) TEST LOAD-TESTS "test.sc" > (load-tests) . lots of messages . > (test) ***** Begin Scheme->C Tests ***** . . ***** End Scheme->C Tests 0 Errors ***** #F > ^D 6 >make test 7 >./test 8 >cd .. You can also test the compiler by doing a "make test" in the test directory and then executing the "./test" program. It should produce the same results as the "(test)" above. 8. Because these patches modify some of the Scheme (.sc) files in the original distribution, the corresponding .c files need to be recompiled/rebuilt. This can be done with the command "make all". 9. Re-verify the system as in #7 above. More comments ============= Like I said, most of this work is not original. I simply took all the patches produced for the 28sep90 version and made them work. This involved fixing rejections, adding some new parts to the changes and removing some changes because the bug/problem they addressed was already fixed in the 01nov91 version. Here is a list of the authors of the original patches: SPARC - rec@arris.com (Roger Critchlow) I386 - rec@arris.com (Roger Critchlow) SUN3 - Mikael Pettersson APOLLO - Ray Lischner {uunet,decwrl}!mntgfx!lisch or lisch@mentor.com PRISM - Ray Lischner {uunet,decwrl}!mntgfx!lisch or lisch@mentor.com Sony News 3200 - Christian Queinnec queinnec@poly.polytechnique.fr NeXT - I don't have the name of the orignal author/porter of Scheme->C for the NeXT system. I must have lost the original posting to comp.lang.scheme. :-( However, David Broman (davbro@poincare.geom.umn.edu) and Scott S. Bertilson (scott@poincare.geom.umn.edu) tested my integration of the NeXT patches for the 28sep90 version. I am not able to verify the I386, PRISM, NeXT, nor the Sony version of the system. I don't have access to those kinds of machines. The I386 patches seemed to mix conditionals between the 386 and SysV. It would be nice if someone with a 386 and SysV could figure out what things are SysV requirements. There are more SysV problems, though. You should look at the README that originally came with Critchlow's SPARC-I386 patches. I have not tried to integrate the AMIGA port that Mike Meyer (mwm@wse.dec.com) provided for the 28sep90+MCC version of Scheme->C. Mostly it is because I forgot about that work. :-( The APOLLO and PRSIM machines don't usually have an assembler. Ray Lischner provided the assembler source and an assembled .o file. I have provided the uuencoded .o file. You could put the following section into the APOLLO makefile header to convert the uuencoded file into the .o file: apollo.o: apollo.o.uu uudecode apollo.o.uu There may be problems with the assembler, even if you have it. The assembler we have here at MCC will not take the muls.l or the mulu.l instructions. Conclusion ========== I hope you find these changes useful. If you have any problems please let me know. I appreciate any comments that you might have, good or bad. You can reach me via eckelkamp@mcc.com or uunet!cs.utexas.edu!milano!cadillac!davide. ____________________________________________________________________________ David Eckelkamp Microelectronics and Computer Technology Corp. (MCC) eckelkamp@mcc.com 3500 W. Balcones Center Dr. (512) 343-0978 Austin,TX 78759 *** /dev/null Thu Oct 31 13:45:26 1991 --- APOLLO Wed Oct 23 16:32:49 1991 *************** *** 0 **** --- 1,43 ---- + # + # This is the header file for constructing make files for Apollo 3000 + # series processors (DN3000, DN3500, DN4000, DN4500). + # + + .SUFFIXES: + .SUFFIXES: .o .c .sc .s .asm .bin + + # Processor name: + + cpu = APOLLO + + # Default flags to use when invoking the C compiler. + + OPT = -O + CFLAGS = $(OPT) -A cpu,3000 -A sys,bsd4.3 + CC = cc + CLIBS = -lm + + # Assembly language object files. + + Aruntime = apollo.o + + # The assembler does not normally come with Domain/OS. If you don't have the + # assembler, then you can just use the apollo.o file that is supplied. + #ASM = /usr/apollo/bin/asm + #AFLAGS = -nl -dba + + apollo.o : apollo.o.uu + uudecode C system for multiple processor types. # ! SRCDIR = /wrl/Gen/src/schemetoc MIPSDIR = /wrl/pmax/src/schemetoc MIPSBIN = /wrl/pmax/bin --- 2,9 ---- # This file is used to make the Scheme->C system for multiple processor types. # ! #SRCDIR = /usrwrl/Gen/src/schemetoc ! SRCDIR = $${PWD:=`pwd`} MIPSDIR = /wrl/pmax/src/schemetoc MIPSBIN = /wrl/pmax/bin *************** *** 16,31 **** VAXBIN = /wrl/vax/bin VAXLIB = /wrl/vax/lib # Architecture specific directories and links to the source files are # constructed by the following commands which follow: forCPU: -mkdir ${CPUDIR} cp ${CPU} ${CPUDIR} echo "BINDIR = ${BINDIR}" > ${CPUDIR}/makefile echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/makefile ! cat makefile >> ${CPUDIR}/makefile @-echo @-echo '***** /doc *****' -mkdir ${CPUDIR}/doc --- 17,63 ---- VAXBIN = /wrl/vax/bin VAXLIB = /wrl/vax/lib + APOLLODIR = $(SRCDIR)/apollo + APOLLOBIN = $(SRCDIR)/bin.apollo + APOLLOLIB = $(SRCDIR)/lib.apollo + + PRISMDIR = $(SRCDIR)/prism + PRISMBIN = $(SRCDIR)/bin.prism + PRISMLIB = $(SRCDIR)/lib.prism + + SPARCDIR = ${SRCDIR}/sparc + SPARCBIN = ${SRCDIR}/bin.sparc + SPARCLIB = ${SRCDIR}/lib.sparc + + SUN3DIR = ${SRCDIR}/sun3 + SUN3BIN = ${SRCDIR}/bin.sun3 + SUN3LIB = ${SRCDIR}/lib.sun3 + + I386DIR = ${SRCDIR}/i386 + I386BIN = ${SRCDIR}/bin.i386 + I386LIB = ${SRCDIR}/lib.i386 + + NeXTDIR = ${SRCDIR}/next + NeXTBIN = /usr/local/bin + NeXTLIB = /usr/local/lib + + # This is a list of the machines/architectures that are currently supported. + # These are also the names of the necessary makefile fragements. + MACHINES = APOLLO I386 ISC386IX MIPS NeXT PRISM SPARC SUN3 TITAN VAX # Architecture specific directories and links to the source files are # constructed by the following commands which follow: + no-target: + @echo 'Use "make for", where is one of:' + @echo ' $(MACHINES)' + forCPU: -mkdir ${CPUDIR} cp ${CPU} ${CPUDIR} echo "BINDIR = ${BINDIR}" > ${CPUDIR}/makefile echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/makefile ! cat makefile-tail >> ${CPUDIR}/makefile @-echo @-echo '***** /doc *****' -mkdir ${CPUDIR}/doc *************** *** 63,157 **** cat test/makefile-tail >> ${CPUDIR}/test/makefile -cd ${CPUDIR}/test; make srclinks forMIPS: ! make "CPU = MIPS" "CPUDIR = ${MIPSDIR}" \ "BINDIR = ${MIPSBIN}" "LIBDIR = ${MIPSLIB}" forCPU forTITAN: ! make "CPU = TITAN" "CPUDIR = ${TITANDIR}" \ "BINDIR = ${TITANBIN}" "LIBDIR = ${TITANLIB}" forCPU forVAX: ! make "CPU = VAX" "CPUDIR = ${VAXDIR}" \ "BINDIR = ${VAXBIN}" "LIBDIR = ${VAXLIB}" forCPU # The Scheme->C system is initially compiled from the C sources by the # following: port: ! cd scrt; make port ! cd scsc; make port # A "private" working copy of the current compiler, libary, and interpreter # is installed in a directory by the following command: install-private: ! cd scrt; make "destdir = ${destdir}" install-private ! cd scsc; make "destdir = ${destdir}" install-private # Clean out working files. clean: rm -f *.BAK *.CKP SC-TO-C* ! cd doc; make clean ! cd scrt; make clean ! cd scsc; make clean ! cd test; make clean # Clean up C source files generated from Scheme source. clean-sc-to-c: ! cd scrt; make clean-sc-to-c ! cd scsc; make clean-sc-to-c ! cd test; make clean-sc-to-c # Delete programs and libraries. noprogs: ! cd scrt; make noprogs ! cd scsc; make noprogs ! cd test; make noprogs # All binaries and documentation files are installed by the following command # for access by all users. install: ! cd doc; make "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install ! cd scrt; make "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install ! cd scsc; make "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install # All files which must be constructed are made by the following command: all: ! cd scrt; make all ! cd scsc; make all # Distribute "source" files required to make the Scheme->C system. srcdist: ! rdist -c MIPS README TITAN VAX makefile ${destdir} ! cd doc; make "destdir = ${destdir}/doc" srcdist ! -cd scbenchmark; make "destdir = ${destdir}/scbenchmark" srcdist ! cd scrt; make "destdir = ${destdir}/scrt" srcdist ! cd scsc; make "destdir = ${destdir}/scsc" srcdist ! -cd test; make "destdir = ${destdir}/test" srcdist ! -cd tools; make "destdir = ${destdir}/tools" srcdist # Distribute "binary" files so that they may be installed on some other # system. bindist: ! rdist -c MIPS README TITAN VAX makefile ${destdir} ! cd doc; make "destdir = ${destdir}/doc" bindist ! cd scrt; make "destdir = ${destdir}/scrt" bindist ! cd scsc; make "destdir = ${destdir}/scsc" bindist # Write the tar tape for distribution. ! TARFILES = CHANGES MIPS README VAX makefile \ ! doc/[a-z]*.mss doc/[a-z]*.psf doc/[a-z]*.l doc/makefile \ gnuemacs/README gnuemacs/[a-z]* \ scrt/[a-z]*.sc scrt/[a-z]*.[chs] scrt/makefile-tail \ scsc/[a-z]*.sc scsc/[a-z]*.c scsc/[a-z]*.sch scsc/makefile-tail \ test/[a-z]*.sc test/test54c.c test/makefile-tail \ cdecl/README cdecl/[a-z]* \ --- 95,260 ---- cat test/makefile-tail >> ${CPUDIR}/test/makefile -cd ${CPUDIR}/test; make srclinks + # Architecture specific makefiles are constructed by the + # following commands. + + inplaceCPU: + test -f makefile-tail || cp makefile makefile-tail + echo "BINDIR = ${BINDIR}" > makefile + echo "LIBDIR = ${LIBDIR}" >> makefile + cat makefile-tail >> makefile + test -f doc/makefile-tail || cp doc/makefile doc/makefile-tail + echo "SRCDIR = ${SRCDIR}/doc" > doc/makefile + cat doc/makefile-tail >> doc/makefile + cat ${CPU} > scrt/makefile + echo "SRCDIR = ${SRCDIR}/scrt" >> scrt/makefile + echo "CPUDIR = ${CPUDIR}/scrt" >> scrt/makefile + echo "BINDIR = ${BINDIR}" >> scrt/makefile + echo "LIBDIR = ${LIBDIR}" >> scrt/makefile + cat scrt/makefile-tail >> scrt/makefile + cat ${CPU} > scsc/makefile + echo "SRCDIR = ${SRCDIR}/scsc" >> scsc/makefile + echo "CPUDIR = ${CPUDIR}/scsc" >> scsc/makefile + echo "BINDIR = ${BINDIR}" >> scsc/makefile + echo "LIBDIR = ${LIBDIR}" >> scsc/makefile + cat scsc/makefile-tail >> scsc/makefile + cat ${CPU} > test/makefile + echo "SRCDIR = ${SRCDIR}/test" >> test/makefile + echo "CPUDIR = ${CPUDIR}/test" >> test/makefile + echo "BINDIR = ${BINDIR}" >> test/makefile + echo "LIBDIR = ${LIBDIR}" >> test/makefile + cat test/makefile-tail >> test/makefile + forMIPS: ! $(MAKE) "CPU = MIPS" "CPUDIR = ${MIPSDIR}" "SRCDIR = ${SRCDIR}" \ "BINDIR = ${MIPSBIN}" "LIBDIR = ${MIPSLIB}" forCPU forTITAN: ! $(MAKE) "CPU = TITAN" "CPUDIR = ${TITANDIR}" "SRCDIR = ${SRCDIR}" \ "BINDIR = ${TITANBIN}" "LIBDIR = ${TITANLIB}" forCPU forVAX: ! $(MAKE) "CPU = VAX" "CPUDIR = ${VAXDIR}" "SRCDIR = ${SRCDIR}" \ "BINDIR = ${VAXBIN}" "LIBDIR = ${VAXLIB}" forCPU + forAPOLLO: + $(MAKE) "CPU = APOLLO" "CPUDIR = ${APOLLODIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${APOLLOBIN}" "LIBDIR = ${APOLLOLIB}" forCPU + + forPRISM: + $(MAKE) "CPU = PRISM" "CPUDIR = ${PRISMDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${PRISMBIN}" "LIBDIR = ${PRISMLIB}" forCPU + + forSPARC: + $(MAKE) "CPU = SPARC" "CPUDIR = ${SPARCDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${SPARCBIN}" "LIBDIR = ${SPARCLIB}" forCPU + + + forSUN3: + $(MAKE) "CPU = SUN3" "CPUDIR = ${SUN3DIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR=${SUN3BIN}" "LIBDIR=${SUN3LIB}" forCPU + + forI386: + $(MAKE) "CPU = I386" "CPUDIR = ${I386DIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${I386BIN}" "LIBDIR = ${I386LIB}" forCPU + + forNeXT forNEXT: + $(MAKE) "CPU = NeXT" "CPUDIR = ${NeXTDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${NeXTBIN}" "LIBDIR = ${NeXTLIB}" forCPU + + forI386-inplace: + $(MAKE) "CPU = I386" "CPUDIR = /usr/local/src/24mar90" \ + "SRCDIR = /usr/local/src/24mar90" \ + "BINDIR = /usr/local/bin" "LIBDIR = /usr/local/lib" inplaceCPU + + forISC386IX-inplace: + $(MAKE) "CPU = ISC386IX" "CPUDIR = /home/28sep90" \ + "SRCDIR = /home/28sep90" \ + "BINDIR = /usr/local/bin" "LIBDIR = /usr/local/lib" inplaceCPU + + forSPARC-inplace: + $(MAKE) "CPU = SPARC" "CPUDIR = ${SRCDIR}" \ + "SRCDIR = ${SRCDIR}" \ + "BINDIR = /usr/local/bin" "LIBDIR = /usr/local/lib" inplaceCPU + # The Scheme->C system is initially compiled from the C sources by the # following: port: ! cd scrt; $(MAKE) port ! cd scsc; $(MAKE) port # A "private" working copy of the current compiler, libary, and interpreter # is installed in a directory by the following command: install-private: ! cd scrt; $(MAKE) "destdir = ${destdir}" install-private ! cd scsc; $(MAKE) "destdir = ${destdir}" install-private # Clean out working files. clean: rm -f *.BAK *.CKP SC-TO-C* ! cd doc; $(MAKE) clean ! cd scrt; $(MAKE) clean ! cd scsc; $(MAKE) clean ! cd test; $(MAKE) clean # Clean up C source files generated from Scheme source. clean-sc-to-c: ! cd scrt; $(MAKE) clean-sc-to-c ! cd scsc; $(MAKE) clean-sc-to-c ! cd test; $(MAKE) clean-sc-to-c # Delete programs and libraries. noprogs: ! cd scrt; $(MAKE) noprogs ! cd scsc; $(MAKE) noprogs ! cd test; $(MAKE) noprogs # All binaries and documentation files are installed by the following command # for access by all users. install: ! cd doc; $(MAKE) "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install ! cd scrt; $(MAKE) "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install ! cd scsc; $(MAKE) "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install # All files which must be constructed are made by the following command: all: ! cd scrt; $(MAKE) all ! cd scsc; $(MAKE) all # Distribute "source" files required to make the Scheme->C system. srcdist: ! rdist -c $(MACHINES) README makefile makefile-tail ${destdir} ! cd doc; $(MAKE) "destdir = ${destdir}/doc" srcdist ! -cd scbenchmark; $(MAKE) "destdir = ${destdir}/scbenchmark" srcdist ! cd scrt; $(MAKE) "destdir = ${destdir}/scrt" srcdist ! cd scsc; $(MAKE) "destdir = ${destdir}/scsc" srcdist ! -cd test; $(MAKE) "destdir = ${destdir}/test" srcdist ! -cd tools; $(MAKE) "destdir = ${destdir}/tools" srcdist # Distribute "binary" files so that they may be installed on some other # system. bindist: ! rdist -c $(MACHINES) README makefile makefile-tail ${destdir} ! cd doc; $(MAKE) "destdir = ${destdir}/doc" bindist ! cd scrt; $(MAKE) "destdir = ${destdir}/scrt" bindist ! cd scsc; $(MAKE) "destdir = ${destdir}/scsc" bindist # Write the tar tape for distribution. ! TARFILES = CHANGES README $(MACHINES) makefile makefile-tail \ ! doc/[a-z]*.mss doc/[a-z]*.psf doc/[a-z]*.l doc/makefile doc/makefile-tail \ gnuemacs/README gnuemacs/[a-z]* \ scrt/[a-z]*.sc scrt/[a-z]*.[chs] scrt/makefile-tail \ + scrt/[a-z]*.asm scrt/*.uu \ scsc/[a-z]*.sc scsc/[a-z]*.c scsc/[a-z]*.sch scsc/makefile-tail \ test/[a-z]*.sc test/test54c.c test/makefile-tail \ cdecl/README cdecl/[a-z]* \ *** /dev/null Thu Oct 31 13:45:35 1991 --- makefile-tail Thu Oct 24 17:18:01 1991 *************** *** 0 **** --- 1,276 ---- + # + # This file is used to make the Scheme->C system for multiple processor types. + # + + #SRCDIR = /usrwrl/Gen/src/schemetoc + SRCDIR = $${PWD:=`pwd`} + + MIPSDIR = /wrl/pmax/src/schemetoc + MIPSBIN = /wrl/pmax/bin + MIPSLIB = /wrl/pmax/lib + + TITANDIR = /wrl/titan/src/schemetoc + TITANBIN = /wrl/titan/bin + TITANLIB = /wrl/titan/lib + + VAXDIR = /wrl/vax/src/schemetoc + VAXBIN = /wrl/vax/bin + VAXLIB = /wrl/vax/lib + + APOLLODIR = $(SRCDIR)/apollo + APOLLOBIN = $(SRCDIR)/bin.apollo + APOLLOLIB = $(SRCDIR)/lib.apollo + + PRISMDIR = $(SRCDIR)/prism + PRISMBIN = $(SRCDIR)/bin.prism + PRISMLIB = $(SRCDIR)/lib.prism + + SPARCDIR = ${SRCDIR}/sparc + SPARCBIN = ${SRCDIR}/bin.sparc + SPARCLIB = ${SRCDIR}/lib.sparc + + SUN3DIR = ${SRCDIR}/sun3 + SUN3BIN = ${SRCDIR}/bin.sun3 + SUN3LIB = ${SRCDIR}/lib.sun3 + + I386DIR = ${SRCDIR}/i386 + I386BIN = ${SRCDIR}/bin.i386 + I386LIB = ${SRCDIR}/lib.i386 + + NeXTDIR = ${SRCDIR}/next + NeXTBIN = /usr/local/bin + NeXTLIB = /usr/local/lib + + # This is a list of the machines/architectures that are currently supported. + # These are also the names of the necessary makefile fragements. + MACHINES = APOLLO I386 ISC386IX MIPS NeXT PRISM SPARC SUN3 TITAN VAX + + # Architecture specific directories and links to the source files are + # constructed by the following commands which follow: + + no-target: + @echo 'Use "make for", where is one of:' + @echo ' $(MACHINES)' + + forCPU: + -mkdir ${CPUDIR} + cp ${CPU} ${CPUDIR} + echo "BINDIR = ${BINDIR}" > ${CPUDIR}/makefile + echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/makefile + cat makefile-tail >> ${CPUDIR}/makefile + @-echo + @-echo '***** /doc *****' + -mkdir ${CPUDIR}/doc + echo "SRCDIR = ${SRCDIR}/doc" > ${CPUDIR}/doc/makefile + cat doc/makefile >> ${CPUDIR}/doc/makefile + -cd ${CPUDIR}/doc; make srclinks + @-echo + @-echo '***** /scrt *****' + -mkdir ${CPUDIR}/scrt + cat ${CPU} > ${CPUDIR}/scrt/makefile + echo "SRCDIR = ${SRCDIR}/scrt" >> ${CPUDIR}/scrt/makefile + echo "CPUDIR = ${CPUDIR}/scrt" >> ${CPUDIR}/scrt/makefile + echo "BINDIR = ${BINDIR}" >> ${CPUDIR}/scrt/makefile + echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/scrt/makefile + cat scrt/makefile-tail >> ${CPUDIR}/scrt/makefile + -cd ${CPUDIR}/scrt; make srclinks + @-echo + @-echo '***** /scsc *****' + -mkdir ${CPUDIR}/scsc + cat ${CPU} > ${CPUDIR}/scsc/makefile + echo "SRCDIR = ${SRCDIR}/scsc" >> ${CPUDIR}/scsc/makefile + echo "CPUDIR = ${CPUDIR}/scsc" >> ${CPUDIR}/scsc/makefile + echo "BINDIR = ${BINDIR}" >> ${CPUDIR}/scsc/makefile + echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/scsc/makefile + cat scsc/makefile-tail >> ${CPUDIR}/scsc/makefile + -cd ${CPUDIR}/scsc; make srclinks + @-echo + @-echo '***** /test *****' + -mkdir ${CPUDIR}/test + cat ${CPU} > ${CPUDIR}/test/makefile + echo "SRCDIR = ${SRCDIR}/test" >> ${CPUDIR}/test/makefile + echo "CPUDIR = ${CPUDIR}/test" >> ${CPUDIR}/test/makefile + echo "BINDIR = ${BINDIR}" >> ${CPUDIR}/test/makefile + echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/test/makefile + cat test/makefile-tail >> ${CPUDIR}/test/makefile + -cd ${CPUDIR}/test; make srclinks + + # Architecture specific makefiles are constructed by the + # following commands. + + inplaceCPU: + test -f makefile-tail || cp makefile makefile-tail + echo "BINDIR = ${BINDIR}" > makefile + echo "LIBDIR = ${LIBDIR}" >> makefile + cat makefile-tail >> makefile + test -f doc/makefile-tail || cp doc/makefile doc/makefile-tail + echo "SRCDIR = ${SRCDIR}/doc" > doc/makefile + cat doc/makefile-tail >> doc/makefile + cat ${CPU} > scrt/makefile + echo "SRCDIR = ${SRCDIR}/scrt" >> scrt/makefile + echo "CPUDIR = ${CPUDIR}/scrt" >> scrt/makefile + echo "BINDIR = ${BINDIR}" >> scrt/makefile + echo "LIBDIR = ${LIBDIR}" >> scrt/makefile + cat scrt/makefile-tail >> scrt/makefile + cat ${CPU} > scsc/makefile + echo "SRCDIR = ${SRCDIR}/scsc" >> scsc/makefile + echo "CPUDIR = ${CPUDIR}/scsc" >> scsc/makefile + echo "BINDIR = ${BINDIR}" >> scsc/makefile + echo "LIBDIR = ${LIBDIR}" >> scsc/makefile + cat scsc/makefile-tail >> scsc/makefile + cat ${CPU} > test/makefile + echo "SRCDIR = ${SRCDIR}/test" >> test/makefile + echo "CPUDIR = ${CPUDIR}/test" >> test/makefile + echo "BINDIR = ${BINDIR}" >> test/makefile + echo "LIBDIR = ${LIBDIR}" >> test/makefile + cat test/makefile-tail >> test/makefile + + forMIPS: + $(MAKE) "CPU = MIPS" "CPUDIR = ${MIPSDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${MIPSBIN}" "LIBDIR = ${MIPSLIB}" forCPU + + forTITAN: + $(MAKE) "CPU = TITAN" "CPUDIR = ${TITANDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${TITANBIN}" "LIBDIR = ${TITANLIB}" forCPU + + forVAX: + $(MAKE) "CPU = VAX" "CPUDIR = ${VAXDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${VAXBIN}" "LIBDIR = ${VAXLIB}" forCPU + + forAPOLLO: + $(MAKE) "CPU = APOLLO" "CPUDIR = ${APOLLODIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${APOLLOBIN}" "LIBDIR = ${APOLLOLIB}" forCPU + + forPRISM: + $(MAKE) "CPU = PRISM" "CPUDIR = ${PRISMDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${PRISMBIN}" "LIBDIR = ${PRISMLIB}" forCPU + + forSPARC: + $(MAKE) "CPU = SPARC" "CPUDIR = ${SPARCDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${SPARCBIN}" "LIBDIR = ${SPARCLIB}" forCPU + + + forSUN3: + $(MAKE) "CPU = SUN3" "CPUDIR = ${SUN3DIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR=${SUN3BIN}" "LIBDIR=${SUN3LIB}" forCPU + + forI386: + $(MAKE) "CPU = I386" "CPUDIR = ${I386DIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${I386BIN}" "LIBDIR = ${I386LIB}" forCPU + + forNeXT forNEXT: + $(MAKE) "CPU = NeXT" "CPUDIR = ${NeXTDIR}" "SRCDIR = ${SRCDIR}" \ + "BINDIR = ${NeXTBIN}" "LIBDIR = ${NeXTLIB}" forCPU + + forI386-inplace: + $(MAKE) "CPU = I386" "CPUDIR = /usr/local/src/24mar90" \ + "SRCDIR = /usr/local/src/24mar90" \ + "BINDIR = /usr/local/bin" "LIBDIR = /usr/local/lib" inplaceCPU + + forISC386IX-inplace: + $(MAKE) "CPU = ISC386IX" "CPUDIR = /home/28sep90" \ + "SRCDIR = /home/28sep90" \ + "BINDIR = /usr/local/bin" "LIBDIR = /usr/local/lib" inplaceCPU + + forSPARC-inplace: + $(MAKE) "CPU = SPARC" "CPUDIR = ${SRCDIR}" \ + "SRCDIR = ${SRCDIR}" \ + "BINDIR = /usr/local/bin" "LIBDIR = /usr/local/lib" inplaceCPU + + # The Scheme->C system is initially compiled from the C sources by the + # following: + + port: + cd scrt; $(MAKE) port + cd scsc; $(MAKE) port + + # A "private" working copy of the current compiler, libary, and interpreter + # is installed in a directory by the following command: + + install-private: + cd scrt; $(MAKE) "destdir = ${destdir}" install-private + cd scsc; $(MAKE) "destdir = ${destdir}" install-private + + # Clean out working files. + + clean: + rm -f *.BAK *.CKP SC-TO-C* + cd doc; $(MAKE) clean + cd scrt; $(MAKE) clean + cd scsc; $(MAKE) clean + cd test; $(MAKE) clean + + # Clean up C source files generated from Scheme source. + + clean-sc-to-c: + cd scrt; $(MAKE) clean-sc-to-c + cd scsc; $(MAKE) clean-sc-to-c + cd test; $(MAKE) clean-sc-to-c + + # Delete programs and libraries. + + noprogs: + cd scrt; $(MAKE) noprogs + cd scsc; $(MAKE) noprogs + cd test; $(MAKE) noprogs + + # All binaries and documentation files are installed by the following command + # for access by all users. + + install: + cd doc; $(MAKE) "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install + cd scrt; $(MAKE) "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install + cd scsc; $(MAKE) "BINDIR = ${BINDIR}" "LIBDIR = ${LIBDIR}" install + + # All files which must be constructed are made by the following command: + + all: + cd scrt; $(MAKE) all + cd scsc; $(MAKE) all + + # Distribute "source" files required to make the Scheme->C system. + + srcdist: + rdist -c $(MACHINES) README makefile makefile-tail ${destdir} + cd doc; $(MAKE) "destdir = ${destdir}/doc" srcdist + -cd scbenchmark; $(MAKE) "destdir = ${destdir}/scbenchmark" srcdist + cd scrt; $(MAKE) "destdir = ${destdir}/scrt" srcdist + cd scsc; $(MAKE) "destdir = ${destdir}/scsc" srcdist + -cd test; $(MAKE) "destdir = ${destdir}/test" srcdist + -cd tools; $(MAKE) "destdir = ${destdir}/tools" srcdist + + # Distribute "binary" files so that they may be installed on some other + # system. + + bindist: + rdist -c $(MACHINES) README makefile makefile-tail ${destdir} + cd doc; $(MAKE) "destdir = ${destdir}/doc" bindist + cd scrt; $(MAKE) "destdir = ${destdir}/scrt" bindist + cd scsc; $(MAKE) "destdir = ${destdir}/scsc" bindist + + # Write the tar tape for distribution. + + TARFILES = CHANGES README $(MACHINES) makefile makefile-tail \ + doc/[a-z]*.mss doc/[a-z]*.psf doc/[a-z]*.l doc/makefile doc/makefile-tail \ + gnuemacs/README gnuemacs/[a-z]* \ + scrt/[a-z]*.sc scrt/[a-z]*.[chs] scrt/makefile-tail \ + scrt/[a-z]*.asm scrt/*.uu \ + scsc/[a-z]*.sc scsc/[a-z]*.c scsc/[a-z]*.sch scsc/makefile-tail \ + test/[a-z]*.sc test/test54c.c test/makefile-tail \ + cdecl/README cdecl/[a-z]* \ + xlib/README xlib/[X-z]* + + TARFLAGS = -cl + + tartape: + tar ${TARFLAGS} ${TARFILES} + + tarlog: + tar tvf ${TARTAPE} > ${TARLOG} + + tarZ: + make "TARFLAGS=-clf tartape-${DATE}" tartape + make "TARTAPE=tartape-${DATE}" "TARLOG=tartapelog-${DATE}" tarlog + cp tartape-${DATE} tt-${DATE} + compress tt-${DATE} + *** /dev/null Thu Oct 31 13:45:52 1991 --- doc/makefile-tail Wed Oct 23 16:32:59 1991 *************** *** 0 **** --- 1,38 ---- + # + # Makefile for distributing the Scheme->C documentation. + # + + port: + + clean: + rm -f *.BAK *.CKP *.o core + + clean-sc-to-c: + rm -f *.c + + noprogs: + + install: + -install -c scc.l ${DESTROOT}/usr/local/man/man1/scc.1 + -install -c sci.l ${DESTROOT}/usr/local/man/man1/sci.1 + -mkdir ${DESTROOT}/usr/doc/local/schemetoc + -install -c intro.psf ${DESTROOT}/usr/doc/local/schemetoc/intro.psf + -install -c index.psf ${DESTROOT}/usr/doc/local/schemetoc/index.psf + + srcdist: + rdist -c README makefile-tail index.psf index.mss intro.psf intro.mss \ + scc.l sci.l ${destdir} + + bindist: + rdist -c README makefile-tail makefile index.psf intro.psf \ + scc.l sci.l ${destdir} + + srclinks: + ln -s ${SRCDIR}/index.psf index.psf + ln -s ${SRCDIR}/index.mss index.mss + ln -s ${SRCDIR}/intro.psf intro.psf + ln -s ${SRCDIR}/intro.mss intro.mss + ln -s ${SRCDIR}/scc.l scc.l + ln -s ${SRCDIR}/sci.l sci.l + + all: *** 1.1 1991/10/23 18:48:13 --- gnuemacs/README 1991/10/23 21:30:32 *************** *** 1 **** --- 1,49 ---- Gnu emacs lisp code use with the Scheme to C compiler. + + ---- NOTES from David Eckelkamp @ MCC.com ---------------- + + This directory contains 2 versions of an inferior Scheme mode for GNU + emacs. The files s2c-gnuemacs.* are the ones that came with Scheme->C + originally. The rest of the files are the latest version of the CMU + developed "General command interpreter in a window stuff", namely + comint.el and cmu*.el. The s2c-gnuemacs.el appears to have been + derived from an earlier version of comint.el and cmuscheme.el. + + You can use either of these packages to provide a better way to + interact with the Scheme->C interpreter. Some of the questions and + answers in the s2c-gnuemacs.README file relevant to cmulisp, also. + However, the installation instructions are not exactly the same. Look + at the top of cmuscheme.el for complete details on cmuscheme mode. I + have included at the bottom of this file some parts of my scheme-mode + hacks. They all work well with Scheme->C. + + I have included the file comint-fix.DE in this directory. It is a + patch of stuff from Leonard N. Zubkoff and his apollo port of GNU + Emacs. It provides what I consider to be better support for filename + completion in the comint derived modes. After you apply the patch and + recompile comint.el heres what you should see. As soon as you hit the + filename completion key a buffer will pop up on the screen if there is + not a unique completion. Then you just type more characters until the + filename is complete. After you hit return to send the command line + to the shell, the termporary buffer of completions is removed and the + screen returned to its previous state. + + ---- some usefull scheme hacks for GNU Emacs ---------------- + + (setq scheme-mode-hook + '((lambda () + (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t) + ))) + + (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t) + + ;;; Fix up the auto-mode-alist to recognize various scheme file extensions + (setq auto-mode-alist + (append + (list + (cons "\\.scm$" 'scheme-mode) + (cons "\\.sc$" 'scheme-mode) + (cons "\\.sch$" 'scheme-mode) + ) + auto-mode-alist)) + *** /dev/null Thu Oct 31 13:46:05 1991 --- gnuemacs/cmugdb.el Wed Oct 23 16:33:00 1991 *************** *** 0 **** --- 1,401 ---- + ;; Run gdb under Emacs + ;; Author: W. Schelter, University of Texas + ;; wfs@rascal.ics.utexas.edu + ;; Rewritten by rms. + + ;; Some ideas are due to Masanobu. + + ;; Modified to use comint by Dale Worley (drw@math.mit.edu). + + ;; This file is part of GNU Emacs. + ;; Copyright (C) 1988 Free Software Foundation, Inc. + + ;; GNU Emacs is distributed in the hope that it will be useful, but + ;; WITHOUT ANY WARRANTY. No author or distributor accepts responsibility + ;; to anyone for the consequences of using it or for whether it serves + ;; any particular purpose or works at all, unless he says so in writing. + ;; Refer to the GNU Emacs General Public License for full details. + + ;; Everyone is granted permission to copy, modify and redistribute GNU + ;; Emacs, but only under the conditions described in the GNU Emacs + ;; General Public License. A copy of this license is supposed to have + ;; been given to you along with GNU Emacs so you can know your rights and + ;; responsibilities. It should be in a file named COPYING. Among other + ;; things, the copyright notice and this notice must be preserved on all + ;; copies. + + ;; Description of GDB interface: + + ;; A facility is provided for the simultaneous display of the source code + ;; in one window, while using gdb to step through a function in the + ;; other. A small arrow in the source window, indicates the current + ;; line. + + ;; Starting up: + + ;; In order to use this facility, invoke the command GDB to obtain a + ;; shell window with the appropriate command bindings. You will be asked + ;; for the name of a file to run. Gdb will be invoked on this file, in a + ;; window named *gdb-foo* if the file is foo. + + ;; M-s steps by one line, and redisplays the source file and line. + + ;; You may easily create additional commands and bindings to interact + ;; with the display. For example to put the gdb command next on \M-n + ;; (def-gdb next "\M-n") + + ;; This causes the emacs command gdb-next to be defined, and runs + ;; gdb-display-frame after the command. + + ;; gdb-display-frame is the basic display function. It tries to display + ;; in the other window, the file and line corresponding to the current + ;; position in the gdb window. For example after a gdb-step, it would + ;; display the line corresponding to the position for the last step. Or + ;; if you have done a backtrace in the gdb buffer, and move the cursor + ;; into one of the frames, it would display the position corresponding to + ;; that frame. + + ;; gdb-display-frame is invoked automatically when a filename-and-line-number + ;; appears in the output. + + + (require 'cmushell) ; cmushell requires comint, so we don't + ; have to specify it ourselves + + (defvar gdb-prompt-pattern "^(.*gdb[+]?) *" + "A regexp to recognize the prompt for gdb or gdb+.") + + (defvar gdb-mode-map nil + "Keymap for gdb-mode.") + + (if gdb-mode-map + nil + (setq gdb-mode-map (copy-keymap cmushell-mode-map)) + (define-key gdb-mode-map "\C-l" 'gdb-refresh)) + + (define-key ctl-x-map " " 'gdb-break) + (define-key ctl-x-map "&" 'send-gdb-command) + + ;;Of course you may use `def-gdb' with any other gdb command, including + ;;user defined ones. + + (defmacro def-gdb (name key &optional doc) + (let* ((fun (intern (format "gdb-%s" name))) + (cstr (list 'if '(not (= 1 arg)) + (list 'format "%s %s" name 'arg) + name))) + (list 'progn + (list 'defun fun '(arg) + (or doc "") + '(interactive "p") + (list 'gdb-call cstr)) + (list 'define-key 'gdb-mode-map key (list 'quote fun))))) + + (def-gdb "step" "\M-s" "Step one source line with display") + (def-gdb "stepi" "\M-i" "Step one instruction with display") + (def-gdb "next" "\M-n" "Step one source line (skip functions)") + (def-gdb "cont" "\M-c" "Continue with display") + + (def-gdb "finish" "\C-c\C-f" "Finish executing current function") + (def-gdb "up" "\M-u" "Go up N stack frames (numeric arg) with display") + (def-gdb "down" "\M-d" "Go down N stack frames (numeric arg) with display") + + (defun gdb-mode () + "Major mode for interacting with an inferior Gdb process. + The following commands are available: + + \\{gdb-mode-map} + + \\[gdb-display-frame] displays in the other window + the last line referred to in the gdb buffer. + + \\[gdb-step],\\[gdb-next], and \\[gdb-nexti] in the gdb window, + call gdb to step,next or nexti and then update the other window + with the current file and position. + + If you are in a source file, you may select a point to break + at, by doing \\[gdb-break]. + + Commands: + Many commands are inherited from shell mode. + Additionally we have: + + \\[gdb-display-frame] display frames file in other window + \\[gdb-step] advance one line in program + \\[gdb-next] advance one line in program (skip over calls). + \\[send-gdb-command] used for special printing of an arg at the current point. + C-x SPACE sets break point at current line." + (interactive) + (kill-all-local-variables) + (comint-mode) + (setq comint-prompt-regexp "^(gdb) ") + (setq major-mode 'gdb-mode) + (setq mode-name "Inferior Gdb") + (setq mode-line-process '(": %s")) + (use-local-map gdb-mode-map) + (make-local-variable 'last-input-start) + (setq last-input-start (make-marker)) + (make-local-variable 'last-input-end) + (setq last-input-end (make-marker)) + (make-local-variable 'gdb-last-frame) + (setq gdb-last-frame nil) + (make-local-variable 'gdb-last-frame-displayed-p) + (setq gdb-last-frame-displayed-p t) + (make-local-variable 'gdb-delete-prompt-marker) + (setq gdb-delete-prompt-marker nil) + (make-local-variable 'gdb-filter-accumulator) + (setq gdb-filter-accumulator nil) + (make-local-variable 'shell-prompt-pattern) + (setq shell-prompt-pattern gdb-prompt-pattern) + (run-hooks 'cmushell-mode-hook 'gdb-mode-hook)) + + (defvar current-gdb-buffer nil) + + (defvar gdb-command-name "gdb" + "Pathname for executing gdb.") + + (defun gdb (path) + "Run gdb on program FILE in buffer *gdb-FILE*. + The directory containing FILE becomes the initial working directory + and source-file directory for GDB. If you wish to change this, use + the GDB commands `cd DIR' and `directory'." + (interactive "FRun gdb on file: ") + (setq path (expand-file-name path)) + (let ((file (file-name-nondirectory path))) + (switch-to-buffer (concat "*gdb-" file "*")) + (setq default-directory (file-name-directory path)) + (or (bolp) (newline)) + (insert "Current directory is " default-directory "\n") + (make-comint (concat "gdb-" file) gdb-command-name nil "-fullname" + "-cd" default-directory file) + (gdb-mode) + (set-process-filter (get-buffer-process (current-buffer)) 'gdb-filter) + (set-process-sentinel (get-buffer-process (current-buffer)) 'gdb-sentinel) + (gdb-set-buffer))) + + (defun gdb-set-buffer () + (cond ((eq major-mode 'gdb-mode) + (setq current-gdb-buffer (current-buffer))))) + + ;; This function is responsible for inserting output from GDB + ;; into the buffer. + ;; Aside from inserting the text, it notices and deletes + ;; each filename-and-line-number; + ;; that GDB prints to identify the selected frame. + ;; It records the filename and line number, and maybe displays that file. + (defun gdb-filter (proc string) + (let ((inhibit-quit t)) + (if gdb-filter-accumulator + (gdb-filter-accumulate-marker proc + (concat gdb-filter-accumulator string)) + (gdb-filter-scan-input proc string)))) + + (defun gdb-filter-accumulate-marker (proc string) + (setq gdb-filter-accumulator nil) + (if (> (length string) 1) + (if (= (aref string 1) ?\032) + (let ((end (string-match "\n" string))) + (if end + (progn + (let* ((first-colon (string-match ":" string 2)) + (second-colon + (string-match ":" string (1+ first-colon)))) + (setq gdb-last-frame + (cons (substring string 2 first-colon) + (string-to-int + (substring string (1+ first-colon) + second-colon))))) + (setq gdb-last-frame-displayed-p nil) + (gdb-filter-scan-input proc + (substring string (1+ end)))) + (setq gdb-filter-accumulator string))) + (gdb-filter-insert proc "\032") + (gdb-filter-scan-input proc (substring string 1))) + (setq gdb-filter-accumulator string))) + + (defun gdb-filter-scan-input (proc string) + (if (equal string "") + (setq gdb-filter-accumulator nil) + (let ((start (string-match "\032" string))) + (if start + (progn (gdb-filter-insert proc (substring string 0 start)) + (gdb-filter-accumulate-marker proc + (substring string start))) + (gdb-filter-insert proc string))))) + + (defun gdb-filter-insert (proc string) + (let ((moving (= (point) (process-mark proc))) + (output-after-point (< (point) (process-mark proc))) + (old-buffer (current-buffer)) + start) + (set-buffer (process-buffer proc)) + (unwind-protect + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark proc)) + (setq start (point)) + (insert string) + (set-marker (process-mark proc) (point)) + (gdb-maybe-delete-prompt) + ;; Check for a filename-and-line number. + (gdb-display-frame + ;; Don't display the specified file + ;; unless (1) point is at or after the position where output appears + ;; and (2) this buffer is on the screen. + (or output-after-point + (not (get-buffer-window (current-buffer)))) + ;; Display a file only when a new filename-and-line-number appears. + t)) + (set-buffer old-buffer)) + (if moving (goto-char (process-mark proc))))) + + (defun gdb-sentinel (proc msg) + (cond ((null (buffer-name (process-buffer proc))) + ;; buffer killed + ;; Stop displaying an arrow in a source file. + (setq overlay-arrow-position nil) + (set-process-buffer proc nil)) + ((memq (process-status proc) '(signal exit)) + ;; Stop displaying an arrow in a source file. + (setq overlay-arrow-position nil) + ;; Fix the mode line. + (setq mode-line-process + (concat ": " + (symbol-name (process-status proc)))) + (let* ((obuf (current-buffer))) + ;; save-excursion isn't the right thing if + ;; process-buffer is current-buffer + (unwind-protect + (progn + ;; Write something in *compilation* and hack its mode line, + (set-buffer (process-buffer proc)) + ;; Force mode line redisplay soon + (set-buffer-modified-p (buffer-modified-p)) + (if (eobp) + (insert ?\n mode-name " " msg) + (save-excursion + (goto-char (point-max)) + (insert ?\n mode-name " " msg))) + ;; If buffer and mode line will show that the process + ;; is dead, we can delete it now. Otherwise it + ;; will stay around until M-x list-processes. + (delete-process proc)) + ;; Restore old buffer, but don't restore old point + ;; if obuf is the gdb buffer. + (set-buffer obuf)))))) + + + (defun gdb-refresh () + "Fix up a possibly garbled display, and redraw the arrow." + (interactive) + (redraw-display) + (gdb-display-frame)) + + (defun gdb-display-frame (&optional nodisplay noauto) + "Find, obey and delete the last filename-and-line marker from GDB. + The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n. + Obeying it means displaying in another window the specified file and line." + (interactive) + (gdb-set-buffer) + (and gdb-last-frame (not nodisplay) + (or (not gdb-last-frame-displayed-p) (not noauto)) + (progn (gdb-display-line (car gdb-last-frame) (cdr gdb-last-frame)) + (setq gdb-last-frame-displayed-p t)))) + + ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen + ;; and that its line LINE is visible. + ;; Put the overlay-arrow on the line LINE in that buffer. + + (defun gdb-display-line (true-file line) + (let* ((buffer (find-file-noselect true-file)) + (window (display-buffer buffer t)) + (pos)) + (save-excursion + (set-buffer buffer) + (save-restriction + (widen) + (goto-line line) + (setq pos (point)) + (setq overlay-arrow-string "=>") + (or overlay-arrow-position + (setq overlay-arrow-position (make-marker))) + (set-marker overlay-arrow-position (point) (current-buffer))) + (cond ((or (< pos (point-min)) (> pos (point-max))) + (widen) + (goto-char pos)))) + (set-window-point window overlay-arrow-position))) + + (defun gdb-call (command) + "Invoke gdb COMMAND displaying source in other window." + (interactive) + (goto-char (point-max)) + (setq gdb-delete-prompt-marker (point-marker)) + (gdb-set-buffer) + (send-string (get-buffer-process current-gdb-buffer) + (concat command "\n"))) + + (defun gdb-maybe-delete-prompt () + (if (and gdb-delete-prompt-marker + (> (point-max) (marker-position gdb-delete-prompt-marker))) + (let (start) + (goto-char gdb-delete-prompt-marker) + (setq start (point)) + (beginning-of-line) + (delete-region (point) start) + (setq gdb-delete-prompt-marker nil)))) + + (defun gdb-break () + "Set GDB breakpoint at this source line." + (interactive) + (let ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (1+ (count-lines 1 (point)))))) + (send-string (get-buffer-process current-gdb-buffer) + (concat "break " file-name ":" line "\n")))) + + (defun gdb-read-address() + "Return a string containing the core-address found in the buffer at point." + (save-excursion + (let ((pt (dot)) found begin) + (setq found (if (search-backward "0x" (- pt 7) t)(dot))) + (cond (found (forward-char 2)(setq result + (buffer-substring found + (progn (re-search-forward "[^0-9a-f]") + (forward-char -1) + (dot))))) + (t (setq begin (progn (re-search-backward "[^0-9]") (forward-char 1) + (dot))) + (forward-char 1) + (re-search-forward "[^0-9]") + (forward-char -1) + (buffer-substring begin (dot))))))) + + + (defvar gdb-commands nil + "List of strings or functions used by send-gdb-command. + It is for customization by you.") + + (defun send-gdb-command (arg) + + "This command reads the number where the cursor is positioned. It + then inserts this ADDR at the end of the gdb buffer. A numeric arg + selects the ARG'th member COMMAND of the list gdb-print-command. If + COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise + (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\" + is a possible string to be a member of gdb-commands. " + + + (interactive "P") + (let (comm addr) + (if arg (setq comm (nth arg gdb-commands))) + (setq addr (gdb-read-address)) + (if (eq (current-buffer) current-gdb-buffer) + (set-mark (point))) + (cond (comm + (setq comm + (if (stringp comm) (format comm addr) (funcall comm addr)))) + (t (setq comm addr))) + (switch-to-buffer current-gdb-buffer) + (goto-char (dot-max)) + (insert-string comm))) *** /dev/null Thu Oct 31 13:46:06 1991 --- gnuemacs/cmulisp.el Wed Oct 23 16:33:01 1991 *************** *** 0 **** --- 1,595 ---- + ;;; -*-Emacs-Lisp-*- cmulisp.el + ;;; Copyright Olin Shivers (1988). + ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright + ;;; notice appearing here to the effect that you may use this code any + ;;; way you like, as long as you don't charge money for it, remove this + ;;; notice, or hold me liable for its results. + + ;;; This replaces the standard inferior-lisp mode. + ;;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88 + ;;; Please send me bug reports, bug fixes, and extensions, so that I can + ;;; merge them into the master source. + ;;; + ;;; Change log at end of file. + + ;;; This file defines a a lisp-in-a-buffer package (cmulisp mode) built on top + ;;; of comint mode. Cmulisp mode is similar to, and intended to replace, its + ;;; counterpart in the standard gnu emacs release. This replacements is more + ;;; featureful, robust, and uniform than the released version. The key + ;;; bindings are also more compatible with the bindings of Hemlock and Zwei + ;;; (the Lisp Machine emacs). + + ;;; Since this mode is built on top of the general command-interpreter-in- + ;;; a-buffer mode (comint mode), it shares a common base functionality, + ;;; and a common set of bindings, with all modes derived from comint mode. + ;;; This makes these modes easier to use. + + ;;; For documentation on the functionality provided by comint mode, and + ;;; the hooks available for customising it, see the file comint.el. + ;;; For further information on cmulisp mode, see the comments below. + + ;;; Needs fixin: + ;;; The load-file/compile-file default mechanism could be smarter -- it + ;;; doesn't know about the relationship between filename extensions and + ;;; whether the file is source or executable. If you compile foo.lisp + ;;; with compile-file, then the next load-file should use foo.bin for + ;;; the default, not foo.lisp. This is tricky to do right, particularly + ;;; because the extension for executable files varies so much (.o, .bin, + ;;; .lbin, .mo, .vo, .ao, ...). + ;;; + ;;; It would be nice if cmulisp (and inferior scheme, T, ...) modes + ;;; had a verbose minor mode wherein sending or compiling defuns, etc. + ;;; would be reflected in the transcript with suitable comments, e.g. + ;;; ";;; redefining fact". Several ways to do this. Which is right? + ;;; + ;;; When sending text from a source file to a subprocess, the process-mark can + ;;; move off the window, so you can lose sight of the process interactions. + ;;; Maybe I should ensure the process mark is in the window when I send + ;;; text to the process? Switch selectable? + + (require 'comint) + (provide 'cmulisp) + + ;; YOUR .EMACS FILE + ;;============================================================================= + ;; Some suggestions for your .emacs file. + ;; + ;; ; If cmulisp lives in some non-standard directory, you must tell emacs + ;; ; where to get it. This may or may not be necessary. + ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path)) + ;; + ;; ; Autoload cmulisp from file cmulisp.el + ;; (autoload 'cmulisp "cmulisp" + ;; "Run an inferior Lisp process." + ;; t) + ;; + ;; ; Define C-c C-t to run my favorite command in cmulisp mode: + ;; (setq cmulisp-load-hook + ;; '((lambda () + ;; (define-key cmulisp-mode-map "\C-c\C-t" 'favorite-cmd)))) + + + ;;; Brief Command Documentation: + ;;;============================================================================ + ;;; Comint Mode Commands: (common to cmulisp and all comint-derived modes) + ;;; + ;;; m-p comint-previous-input Cycle backwards in input history + ;;; m-n comint-next-input Cycle forwards + ;;; c-c r comint-previous-input-matching Search backwards in input history + ;;; return comint-send-input + ;;; c-a comint-bol Beginning of line; skip prompt. + ;;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff. + ;;; c-c c-u comint-kill-input ^u + ;;; c-c c-w backward-kill-word ^w + ;;; c-c c-c comint-interrupt-subjob ^c + ;;; c-c c-z comint-stop-subjob ^z + ;;; c-c c-\ comint-quit-subjob ^\ + ;;; c-c c-o comint-kill-output Delete last batch of process output + ;;; c-c c-r comint-show-output Show last batch of process output + ;;; send-invisible Read line w/o echo & send to proc + ;;; comint-continue-subjob Useful if you accidentally suspend + ;;; top-level job. + ;;; comint-mode-hook is the comint mode hook. + + ;;; CMU Lisp Mode Commands: + ;;; c-m-x lisp-send-defun This binding is a gnu convention. + ;;; c-c l lisp-load-file Prompt for file name; tell Lisp to load it. + ;;; c-c k lisp-compile-file Prompt for file name; tell Lisp to kompile it. + ;;; Filename completion is available, of course. + ;;; + ;;; Additionally, these commands are added to the key bindings of Lisp mode: + ;;; c-m-x lisp-eval-defun This binding is a gnu convention. + ;;; c-c e lisp-eval-defun Send the current defun to Lisp process. + ;;; c-x c-e lisp-eval-last-sexp Send the previous sexp to Lisp process. + ;;; c-c c-e lisp-eval-defun-and-go After sending the defun, switch-to-lisp. + ;;; c-c r lisp-eval-region Send the current region to Lisp process. + ;;; c-c c-r lisp-eval-region-and-go After sending the region, switch-to-lisp. + ;;; c-c c lisp-compile-defun Compile the current defun in Lisp process. + ;;; c-c c-c lisp-compile-defun-and-go After compiling defun, switch-to-lisp. + ;;; c-c z switch-to-lisp Switch to the Lisp process buffer. + ;;; c-c l lisp-load-file (See above. In a Lisp file buffer, default + ;;; c-c k lisp-compile-file is to load/compile the current file.) + ;;; c-c c-d lisp-describe-sym Query Lisp for a symbol's description. + ;;; c-c a lisp-show-arglist Query Lisp for function's arglist. + ;;; c-c f lisp-show-function-documentation Query Lisp for a function's doc. + ;;; c-c v lisp-show-variable-documentation Query Lisp for a variable's doc. + + ;;; cmulisp Fires up the Lisp process. + ;;; lisp-compile-region Compile all forms in the current region. + ;;; lisp-compile-region-and-go After compiling region, switch-to-lisp. + ;;; + ;;; CMU Lisp Mode Variables: + ;;; cmulisp-filter-regexp Match this => don't get saved on input hist + ;;; inferior-lisp-program Name of Lisp program run-lisp executes + ;;; inferior-lisp-load-command Customises lisp-load-file + ;;; cmulisp-mode-hook + ;;; inferior-lisp-prompt Initialises comint-prompt-regexp. + ;;; Backwards compatibility. + ;;; lisp-source-modes Anything loaded into a buffer that's in + ;;; one of these modes is considered Lisp + ;;; source by lisp-load/compile-file. + + ;;; Read the rest of this file for more information. + + (defvar cmulisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'" + "*What not to save on inferior Lisp's input history + Input matching this regexp is not saved on the input history in cmulisp + mode. Default is whitespace followed by 0 or 1 single-letter :keyword + (as in :a, :c, etc.)") + + (defvar cmulisp-mode-map nil) + (cond ((not cmulisp-mode-map) + (setq cmulisp-mode-map + (full-copy-sparse-keymap comint-mode-map)) + (lisp-mode-commands cmulisp-mode-map) + (define-key cmulisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) + (define-key cmulisp-mode-map "\C-cl" 'lisp-load-file) + (define-key cmulisp-mode-map "\C-ck" 'lisp-compile-file) + (define-key cmulisp-mode-map "\C-ca" 'lisp-show-arglist) + (define-key cmulisp-mode-map "\C-c\C-d" 'lisp-describe-sym) + (define-key cmulisp-mode-map "\C-cf" 'lisp-show-function-documentation) + (define-key cmulisp-mode-map "\C-cv" 'lisp-show-variable-documentation))) + + ;;; These commands augment Lisp mode, so you can process Lisp code in + ;;; the source files. + (define-key lisp-mode-map "\M-\C-x" 'lisp-eval-defun) ; Gnu convention + (define-key lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) ; Gnu convention + (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun) + (define-key lisp-mode-map "\C-c\C-e" 'lisp-eval-defun-and-go) + (define-key lisp-mode-map "\C-cr" 'lisp-eval-region) + (define-key lisp-mode-map "\C-c\C-r" 'lisp-eval-region-and-go) + (define-key lisp-mode-map "\C-cc" 'lisp-compile-defun) + (define-key lisp-mode-map "\C-c\C-c" 'lisp-compile-defun-and-go) + (define-key lisp-mode-map "\C-cz" 'switch-to-lisp) + (define-key lisp-mode-map "\C-cl" 'lisp-load-file) + (define-key lisp-mode-map "\C-ck" 'lisp-compile-file) ; "kompile" file + (define-key lisp-mode-map "\C-ca" 'lisp-show-arglist) + (define-key lisp-mode-map "\C-c\C-d" 'lisp-describe-sym) + (define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation) + (define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation) + + + (defvar inferior-lisp-program "lisp" + "*Program name for invoking an inferior Lisp with `cmulisp'.") + + (defvar inferior-lisp-load-command "(load \"%s\")\n" + "*Format-string for building a Lisp expression to load a file. + This format string should use %s to substitute a file name + and should result in a Lisp expression that will command the inferior Lisp + to load that file. The default works acceptably on most Lisps. + The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\\n\" + produces cosmetically superior output for this application, + but it works only in Common Lisp.") + + (defvar inferior-lisp-prompt "^[^> ]*>+:? *" + "Regexp to recognise prompts in the inferior Lisp. + Defaults to \"^[^> ]*>+:? *\", which works pretty good for Lucid, kcl, + and franz. This variable is used to initialise comint-prompt-regexp in the + cmulisp buffer. + + More precise choices: + Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\" + franz: \"^\\(->\\|<[0-9]*>:\\) *\" + kcl: \"^>+ *\" + + This is a fine thing to set in your .emacs file.") + + (defvar cmulisp-mode-hook '() + "*Hook for customising cmulisp mode") + + (defun cmulisp-mode () + "Major mode for interacting with an inferior Lisp process. + Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an + Emacs buffer. Variable inferior-lisp-program controls which Lisp interpreter + is run. Variables inferior-lisp-prompt, cmulisp-filter-regexp and + inferior-lisp-load-command can customize this mode for different Lisp + interpreters. + + For information on running multiple processes in multiple buffers, see + documentation for variable cmulisp-buffer. + + \\{cmulisp-mode-map} + + Customisation: Entry to this mode runs the hooks on comint-mode-hook and + cmulisp-mode-hook (in that order). + + You can send text to the inferior Lisp process from other buffers containing + Lisp source. + switch-to-lisp switches the current buffer to the Lisp process buffer. + lisp-eval-defun sends the current defun to the Lisp process. + lisp-compile-defun compiles the current defun. + lisp-eval-region sends the current region to the Lisp process. + lisp-compile-region compiles the current region. + + lisp-eval-defun-and-go, lisp-compile-defun-and-go, + lisp-eval-region-and-go, and lisp-compile-region-and-go + switch to the Lisp process buffer after sending their text. + + Commands: + Return after the end of the process' output sends the text from the + end of process to point. + Return before the end of the process' output copies the sexp ending at point + to the end of the process' output, and sends it. + Delete converts tabs to spaces as it moves back. + Tab indents for Lisp; with argument, shifts rest + of expression rigidly with the current line. + C-M-q does Tab on each line starting within following expression. + Paragraphs are separated only by blank lines. Semicolons start comments. + If you accidentally suspend your process, use \\[comint-continue-subjob] + to continue it." + (interactive) + (comint-mode) + (setq comint-prompt-regexp inferior-lisp-prompt) + (setq major-mode 'cmulisp-mode) + (setq mode-name "CMU Lisp") + (setq mode-line-process '(": %s")) + (if (string-match "^18.4" emacs-version) ; hack. + (lisp-mode-variables) ; This is right for 18.49 + (lisp-mode-variables t)) ; This is right for 18.50 + (use-local-map cmulisp-mode-map) ;c-c k for "kompile" file + (setq comint-get-old-input (function lisp-get-old-input)) + (setq comint-input-filter (function lisp-input-filter)) + (setq comint-input-sentinel 'ignore) + (run-hooks 'cmulisp-mode-hook)) + + (defun lisp-get-old-input () + "Snarf the sexp ending at point" + (save-excursion + (let ((end (point))) + (backward-sexp) + (buffer-substring (point) end)))) + + (defun lisp-input-filter (str) + "Don't save anything matching cmulisp-filter-regexp" + (not (string-match cmulisp-filter-regexp str))) + + (defun cmulisp () + "Run an inferior Lisp process, input and output via buffer *cmulisp*. + If there is a process already running in *cmulisp*, just switch to that buffer. + Takes the program name from the variable inferior-lisp-program. + \(Type \\[describe-mode] in the process buffer for a list of commands.)" + (interactive) + (cond ((not (comint-check-proc "*cmulisp*")) + (set-buffer (make-comint "cmulisp" inferior-lisp-program)) + (cmulisp-mode))) + (setq cmulisp-buffer "*cmulisp*") + (switch-to-buffer "*cmulisp*")) + + (defun lisp-eval-region (start end) + "Send the current region to the inferior Lisp process." + (interactive "r") + (comint-send-region (cmulisp-proc) start end) + (comint-send-string (cmulisp-proc) "\n")) + + (defun lisp-eval-defun () + "Send the current defun to the inferior Lisp process." + (interactive) + (save-excursion + (end-of-defun) + (let ((end (point))) + (beginning-of-defun) + (lisp-eval-region (point) end)))) + + (defun lisp-eval-last-sexp () + "Send the previous sexp to the inferior Lisp process." + (interactive) + (lisp-eval-region (save-excursion (backward-sexp) (point)) (point))) + + ;;; CommonLisp COMPILE sux. + (defun lisp-compile-region (start end) + "Compile the current region in the inferior Lisp process." + (interactive "r") + (comint-send-string (cmulisp-proc) + (format "(funcall (compile nil `(lambda () (progn 'compile %s))))\n" + (buffer-substring start end)))) + + (defun lisp-compile-defun () + "Compile the current defun in the inferior Lisp process." + (interactive) + (save-excursion + (end-of-defun) + (let ((e (point))) + (beginning-of-defun) + (lisp-compile-region (point) e)))) + + (defun switch-to-lisp (eob-p) + "Switch to the inferior Lisp process buffer. + With argument, positions cursor at end of buffer." + (interactive "P") + (if (get-buffer cmulisp-buffer) + (pop-to-buffer cmulisp-buffer) + (error "No current process buffer. See variable cmulisp-buffer.")) + (cond (eob-p + (push-mark) + (goto-char (point-max))))) + + (defun lisp-eval-region-and-go (start end) + "Send the current region to the inferior Lisp, + and switch to the process buffer." + (interactive "r") + (lisp-eval-region start end) + (switch-to-lisp t)) + + (defun lisp-eval-defun-and-go () + "Send the current defun to the inferior Lisp, + and switch to the process buffer." + (interactive) + (lisp-eval-defun) + (switch-to-lisp t)) + + (defun lisp-compile-region-and-go (start end) + "Compile the current region in the inferior Lisp, + and switch to the process buffer." + (interactive "r") + (lisp-compile-region start end) + (switch-to-lisp t)) + + (defun lisp-compile-defun-and-go () + "Compile the current defun in the inferior Lisp, + and switch to the process buffer." + (interactive) + (lisp-compile-defun) + (switch-to-lisp t)) + + ;;; A version of the form in H. Shevis' soar-mode.el package. Less robust. + ;(defun lisp-compile-sexp (start end) + ; "Compile the s-expression bounded by START and END in the inferior lisp. + ;If the sexp isn't a DEFUN form, it is evaluated instead." + ; (cond ((looking-at "(defun\\s +") + ; (goto-char (match-end 0)) + ; (let ((name-start (point))) + ; (forward-sexp 1) + ; (process-send-string "cmulisp" (format "(compile '%s #'(lambda " + ; (buffer-substring name-start + ; (point))))) + ; (let ((body-start (point))) + ; (goto-char start) (forward-sexp 1) ; Can't use end-of-defun. + ; (process-send-region "cmulisp" (buffer-substring body-start (point)))) + ; (process-send-string "cmulisp" ")\n")) + ; (t (lisp-eval-region start end))))) + ; + ;(defun lisp-compile-region (start end) + ; "Each s-expression in the current region is compiled (if a DEFUN) + ;or evaluated (if not) in the inferior lisp." + ; (interactive "r") + ; (save-excursion + ; (goto-char start) (end-of-defun) (beginning-of-defun) ; error check + ; (if (< (point) start) (error "region begins in middle of defun")) + ; (goto-char start) + ; (let ((s start)) + ; (end-of-defun) + ; (while (<= (point) end) ; Zip through + ; (lisp-compile-sexp s (point)) ; compiling up defun-sized chunks. + ; (setq s (point)) + ; (end-of-defun)) + ; (if (< s end) (lisp-compile-sexp s end))))) + ;;; + ;;; End of HS-style code + + + (defvar lisp-prev-l/c-dir/file nil + "Saves the (directory . file) pair used in the last lisp-load-file or + lisp-compile-file command. Used for determining the default in the + next one.") + + (defvar lisp-source-modes '(lisp-mode) + "*Used to determine if a buffer contains Lisp source code. + If it's loaded into a buffer that is in one of these major modes, it's + considered a Lisp source file by lisp-load-file and lisp-compile-file. + Used by these commands to determine defaults.") + + (defun lisp-load-file (file-name) + "Load a Lisp file into the inferior Lisp process." + (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file + lisp-source-modes nil)) ; NIL because LOAD + ; doesn't need an exact name + (comint-check-source file-name) ; Check to see if buffer needs saved. + (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name) + (file-name-nondirectory file-name))) + (comint-send-string (cmulisp-proc) + (format inferior-lisp-load-command file-name)) + (switch-to-lisp t)) + + + (defun lisp-compile-file (file-name) + "Compile a Lisp file in the inferior Lisp process." + (interactive (comint-get-source "Compile Lisp file: " lisp-prev-l/c-dir/file + lisp-source-modes nil)) ; NIL = don't need + ; suffix .lisp + (comint-check-source file-name) ; Check to see if buffer needs saved. + (setq lisp-prev-l/c-dir/file (cons (file-name-directory file-name) + (file-name-nondirectory file-name))) + (comint-send-string (cmulisp-proc) (concat "(compile-file \"" + file-name + "\"\)\n")) + (switch-to-lisp t)) + + + + ;;; Documentation functions: function doc, var doc, arglist, and + ;;; describe symbol. + ;;; =========================================================================== + + ;;; Command strings + ;;; =============== + + (defvar lisp-function-doc-command + "(let ((fn '%s)) + (format t \"Documentation for ~a:~&~a\" + fn (documentation fn 'function)) + (values))\n" + "Command to query inferior Lisp for a function's documentation.") + + (defvar lisp-var-doc-command + "(let ((v '%s)) + (format t \"Documentation for ~a:~&~a\" + v (documentation v 'variable)) + (values))\n" + "Command to query inferior Lisp for a variable's documentation.") + + (defvar lisp-arglist-command + "(let ((fn '%s)) + (format t \"Arglist for ~a: ~a\" fn (arglist fn)) + (values))\n" + "Command to query inferior Lisp for a function's arglist.") + + (defvar lisp-describe-sym-command + "(describe '%s)\n" + "Command to query inferior Lisp for a variable's documentation.") + + + ;;; Ancillary functions + ;;; =================== + + ;;; Reads a string from the user. + (defun lisp-symprompt (prompt default) + (list (let* ((prompt (if default + (format "%s (default %s): " prompt default) + (concat prompt ": "))) + (ans (read-string prompt))) + (if (zerop (length ans)) default ans)))) + + + ;;; Adapted from function-called-at-point in help.el. + (defun lisp-fn-called-at-pt () + "Returns the name of the function called in the current call. + Nil if it can't find one." + (condition-case nil + (save-excursion + (save-restriction + (narrow-to-region (max (point-min) (- (point) 1000)) (point-max)) + (backward-up-list 1) + (forward-char 1) + (let ((obj (read (current-buffer)))) + (and (symbolp obj) obj)))) + (error nil))) + + + ;;; Adapted from variable-at-point in help.el. + (defun lisp-var-at-pt () + (condition-case () + (save-excursion + (forward-sexp -1) + (skip-chars-forward "'") + (let ((obj (read (current-buffer)))) + (and (symbolp obj) obj))) + (error nil))) + + + ;;; Documentation functions: fn and var doc, arglist, and symbol describe. + ;;; ====================================================================== + + (defun lisp-show-function-documentation (fn) + "Send a command to the inferior Lisp to give documentation for function FN. + See variable lisp-function-doc-command." + (interactive (lisp-symprompt "Function doc" (lisp-fn-called-at-pt))) + (comint-proc-query (cmulisp-proc) (format lisp-function-doc-command fn))) + + (defun lisp-show-variable-documentation (var) + "Send a command to the inferior Lisp to give documentation for function FN. + See variable lisp-var-doc-command." + (interactive (lisp-symprompt "Variable doc" (lisp-var-at-pt))) + (comint-proc-query (cmulisp-proc) (format lisp-var-doc-command var))) + + (defun lisp-show-arglist (fn) + "Sends an query to the inferior Lisp for the arglist for function FN. + See variable lisp-arglist-command." + (interactive (lisp-symprompt "Arglist" (lisp-fn-called-at-pt))) + (comint-proc-query (cmulisp-proc) (format lisp-arglist-command fn))) + + (defun lisp-describe-sym (sym) + "Send a command to the inferior Lisp to describe symbol SYM. + See variable lisp-describe-sym-command." + (interactive (lisp-symprompt "Describe" (lisp-var-at-pt))) + (comint-proc-query (cmulisp-proc) (format lisp-describe-sym-command sym))) + + + (defvar cmulisp-buffer nil "*The current cmulisp process buffer. + + MULTIPLE PROCESS SUPPORT + =========================================================================== + Cmulisp.el supports, in a fairly simple fashion, running multiple Lisp + processes. To run multiple Lisp processes, you start the first up with + \\[cmulisp]. It will be in a buffer named *cmulisp*. Rename this buffer + with \\[rename-buffer]. You may now start up a new process with another + \\[cmulisp]. It will be in a new buffer, named *cmulisp*. You can + switch between the different process buffers with \\[switch-to-buffer]. + + Commands that send text from source buffers to Lisp processes -- + like lisp-eval-defun or lisp-show-arglist -- have to choose a process + to send to, when you have more than one Lisp process around. This + is determined by the global variable cmulisp-buffer. Suppose you + have three inferior lisps running: + Buffer Process + foo cmulisp + bar cmulisp<2> + *cmulisp* cmulisp<3> + If you do a \\[lisp-eval-defun-and-go] command on some Lisp source code, + what process do you send it to? + + - If you're in a process buffer (foo, bar, or *cmulisp*), + you send it to that process. + - If you're in some other buffer (e.g., a source file), you + send it to the process attached to buffer cmulisp-buffer. + This process selection is performed by function cmulisp-proc. + + Whenever \\[cmulisp] fires up a new process, it resets cmulisp-buffer + to be the new process's buffer. If you only run one process, this will + do the right thing. If you run multiple processes, you can change + cmulisp-buffer to another process buffer with \\[set-variable]. + + More sophisticated approaches are, of course, possible. If you find youself + needing to switch back and forth between multiple processes frequently, + you may wish to consider ilisp.el, a larger, more sophisticated package + for running inferior Lisp processes. The approach taken here is for a + minimal, simple implementation. Feel free to extend it.") + + (defun cmulisp-proc () + "Returns the current cmulisp process. See variable cmulisp-buffer." + (let ((proc (get-buffer-process (if (eq major-mode 'inferior-lisp-mode) + (current-buffer) + cmulisp-buffer)))) + (or proc + (error "No current process. See variable cmulisp-buffer")))) + + + ;;; Do the user's customisation... + ;;;=============================== + (defvar cmulisp-load-hook nil + "This hook is run when cmulisp is loaded in. + This is a good place to put keybindings.") + + (run-hooks 'cmulisp-load-hook) + + ;;; CHANGE LOG + ;;; =========================================================================== + ;;; 5/24/90 Olin + ;;; - Split cmulisp and cmushell modes into separate files. + ;;; Not only is this a good idea, it's apparently the way it'll be rel 19. + ;;; - Upgraded process sends to use comint-send-string instead of + ;;; process-send-string. + ;;; - Explicit references to process "cmulisp" have been replaced with + ;;; (cmulisp-proc). This allows better handling of multiple process bufs. + ;;; - Added process query and var/function/symbol documentation + ;;; commands. Based on code written by Douglas Roberts. + ;;; - Added lisp-eval-last-sexp, bound to C-x C-e. *** /dev/null Thu Oct 31 13:46:07 1991 --- gnuemacs/cmuscheme.el Wed Oct 23 16:33:03 1991 *************** *** 0 **** --- 1,428 ---- + ;;; cmuscheme.el -- Scheme process in a buffer. Adapted from tea.el. + ;;; Copyright Olin Shivers (1988) + ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright + ;;; notice appearing here to the effect that you may use this code any + ;;; way you like, as long as you don't charge money for it, remove this + ;;; notice, or hold me liable for its results. + ;;; + ;;; This is a customisation of comint-mode (see comint.el) + ;;; + ;;; Written by Olin Shivers (olin.shivers@cs.cmu.edu). With bits and pieces + ;;; lifted from scheme.el, shell.el, clisp.el, newclisp.el, cobol.el, et al.. + ;;; 8/88 + ;;; + ;;; Please send me bug reports, bug fixes, and extensions, so that I can + ;;; merge them into the master source. + ;;; + ;;; The changelog is at the end of this file. + ;;; + ;;; NOTE: MIT Cscheme, when invoked with the -emacs flag, has a special user + ;;; interface that communicates process state back to the superior emacs by + ;;; outputting special control sequences. The gnumacs package, xscheme.el, has + ;;; lots and lots of special purpose code to read these control sequences, and + ;;; so is very tightly integrated with the cscheme process. The cscheme + ;;; interrupt handler and debugger read single character commands in cbreak + ;;; mode; when this happens, xscheme.el switches to special keymaps that bind + ;;; the single letter command keys to emacs functions that directly send the + ;;; character to the scheme process. Cmuscheme mode does *not* provide this + ;;; functionality. If you are a cscheme user, you may prefer to use the + ;;; xscheme.el/cscheme -emacs interaction. + ;;; + ;;; Here's a summary of the pros and cons, as I see them. + ;;; xscheme: Tightly integrated with inferior cscheme process! A few commands + ;;; not in cmuscheme. But. Integration is a bit of a hack. Input + ;;; history only keeps the immediately prior input. Bizarre + ;;; keybindings. + ;;; + ;;; cmuscheme: Not tightly integrated with inferior cscheme process. But. + ;;; Carefully integrated functionality with the entire suite of + ;;; comint-derived CMU process modes. Keybindings reminiscent of + ;;; Zwei and Hemlock. Good input history. A few commands not in + ;;; xscheme. + ;;; + ;;; It's a tradeoff. Pay your money; take your choice. If you use a Scheme + ;;; that isn't Cscheme, of course, there isn't a choice. Xscheme.el is *very* + ;;; Cscheme-specific; you must use cmuscheme.el. Interested parties are + ;;; invited to port xscheme functionality on top of comint mode... + + ;; YOUR .EMACS FILE + ;;============================================================================= + ;; Some suggestions for your .emacs file. + ;; + ;; ; If cmuscheme lives in some non-standard directory, you must tell emacs + ;; ; where to get it. This may or may not be necessary. + ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path)) + ;; + ;; ; Autoload run-scheme from file cmuscheme.el + ;; (autoload 'run-scheme "cmuscheme" + ;; "Run an inferior Scheme process." + ;; t) + ;; + ;; ; Files ending in ".scm" are Scheme source, + ;; ; so put their buffers in scheme-mode. + ;; (setq auto-mode-alist + ;; (cons '("\\.scm$" . scheme-mode) + ;; auto-mode-alist)) + ;; + ;; ; Define C-c C-t to run my favorite command in inferior scheme mode: + ;; (setq cmuscheme-load-hook + ;; '((lambda () (define-key inferior-scheme-mode-map "\C-c\C-t" + ;; 'favorite-cmd)))) + ;;; + ;;; Unfortunately, scheme.el defines run-scheme to autoload from xscheme.el. + ;;; This will womp your declaration to autoload run-scheme from cmuscheme.el + ;;; if you haven't loaded cmuscheme in before scheme. Three fixes: + ;;; - Put the autoload on your scheme mode hook and in your .emacs toplevel: + ;;; (setq scheme-mode-hook + ;;; '((lambda () (autoload 'run-scheme "cmuscheme" + ;;; "Run an inferior Scheme" t)))) + ;;; (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t) + ;;; Now when scheme.el autoloads, it will restore the run-scheme autoload. + ;;; - Load cmuscheme.el in your .emacs: (load-library 'cmuscheme) + ;;; - Change autoload declaration in scheme.el to point to cmuscheme.el: + ;;; (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t) + ;;; *or* just delete the autoload declaration from scheme.el altogether, + ;;; which will allow the autoload in your .emacs to have its say. + + (provide 'cmuscheme) + (require 'scheme) + (require 'comint) + + ;;; INFERIOR SCHEME MODE STUFF + ;;;============================================================================ + + (defvar inferior-scheme-mode-hook nil + "*Hook for customising inferior-scheme mode.") + (defvar inferior-scheme-mode-map nil) + + (cond ((not inferior-scheme-mode-map) + (setq inferior-scheme-mode-map + (full-copy-sparse-keymap comint-mode-map)) + (define-key inferior-scheme-mode-map "\M-\C-x" ;gnu convention + 'scheme-send-definition) + (define-key inferior-scheme-mode-map "\C-x\C-e" 'scheme-send-last-sexp) + (define-key inferior-scheme-mode-map "\C-cl" 'scheme-load-file) + (define-key inferior-scheme-mode-map "\C-ck" 'scheme-compile-file) + (scheme-mode-commands inferior-scheme-mode-map))) + + ;; Install the process communication commands in the scheme-mode keymap. + (define-key scheme-mode-map "\M-\C-x" 'scheme-send-definition);gnu convention + (define-key scheme-mode-map "\C-x\C-e" 'scheme-send-last-sexp);gnu convention + (define-key scheme-mode-map "\C-ce" 'scheme-send-definition) + (define-key scheme-mode-map "\C-c\C-e" 'scheme-send-definition-and-go) + (define-key scheme-mode-map "\C-cr" 'scheme-send-region) + (define-key scheme-mode-map "\C-c\C-r" 'scheme-send-region-and-go) + (define-key scheme-mode-map "\C-cc" 'scheme-compile-definition) + (define-key scheme-mode-map "\C-c\C-c" 'scheme-compile-definition-and-go) + (define-key scheme-mode-map "\C-cz" 'switch-to-scheme) + (define-key scheme-mode-map "\C-cl" 'scheme-load-file) + (define-key scheme-mode-map "\C-ck" 'scheme-compile-file) ;k for "kompile" + + (defun inferior-scheme-mode () + "Major mode for interacting with an inferior Scheme process. + + The following commands are available: + \\{inferior-scheme-mode-map} + + A Scheme process can be fired up with M-x run-scheme. + + Customisation: Entry to this mode runs the hooks on comint-mode-hook and + inferior-scheme-mode-hook (in that order). + + You can send text to the inferior Scheme process from other buffers containing + Scheme source. + switch-to-scheme switches the current buffer to the Scheme process buffer. + scheme-send-definition sends the current definition to the Scheme process. + scheme-compile-definition compiles the current definition. + scheme-send-region sends the current region to the Scheme process. + scheme-compile-region compiles the current region. + + scheme-send-definition-and-go, scheme-compile-definition-and-go, + scheme-send-region-and-go, and scheme-compile-region-and-go + switch to the Scheme process buffer after sending their text. + For information on running multiple processes in multiple buffers, see + documentation for variable scheme-buffer. + + Commands: + Return after the end of the process' output sends the text from the + end of process to point. + Return before the end of the process' output copies the sexp ending at point + to the end of the process' output, and sends it. + Delete converts tabs to spaces as it moves back. + Tab indents for Scheme; with argument, shifts rest + of expression rigidly with the current line. + C-M-q does Tab on each line starting within following expression. + Paragraphs are separated only by blank lines. Semicolons start comments. + If you accidentally suspend your process, use \\[comint-continue-subjob] + to continue it." + (interactive) + (comint-mode) + ;; Customise in inferior-scheme-mode-hook + (setq comint-prompt-regexp "^[^>]*>+ *") ; OK for cscheme, oaklisp, T,... + (scheme-mode-variables) + (setq major-mode 'inferior-scheme-mode) + (setq mode-name "Inferior Scheme") + (setq mode-line-process '(": %s")) + (use-local-map inferior-scheme-mode-map) + (setq comint-input-filter (function scheme-input-filter)) + (setq comint-input-sentinel (function ignore)) + (setq comint-get-old-input (function scheme-get-old-input)) + (run-hooks 'inferior-scheme-mode-hook)) + + (defun scheme-input-filter (str) + "Don't save anything matching inferior-scheme-filter-regexp" + (not (string-match inferior-scheme-filter-regexp str))) + + (defvar inferior-scheme-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'" + "*Input matching this regexp are not saved on the history list. + Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters.") + + (defun scheme-get-old-input () + "Snarf the sexp ending at point" + (save-excursion + (let ((end (point))) + (backward-sexp) + (buffer-substring (point) end)))) + + (defun scheme-args-to-list (string) + (let ((where (string-match "[ \t]" string))) + (cond ((null where) (list string)) + ((not (= where 0)) + (cons (substring string 0 where) + (scheme-args-to-list (substring string (+ 1 where) + (length string))))) + (t (let ((pos (string-match "[^ \t]" string))) + (if (null pos) + nil + (scheme-args-to-list (substring string pos + (length string))))))))) + + (defvar scheme-program-name "scheme" + "*Program invoked by the run-scheme command") + + ;;; Obsolete + (defun scheme (&rest foo) + "Use run-scheme" + (interactive) + (message "Use run-scheme") + (ding)) + + (defun run-scheme (cmd) + "Run an inferior Scheme process, input and output via buffer *scheme*. + If there is a process already running in *scheme*, just switch to that buffer. + With argument, allows you to edit the command line (default is value + of scheme-program-name). Runs the hooks from inferior-scheme-mode-hook + \(after the comint-mode-hook is run). + \(Type \\[describe-mode] in the process buffer for a list of commands.)" + + (interactive (list (if current-prefix-arg + (read-string "Run Scheme: " scheme-program-name) + scheme-program-name))) + (if (not (comint-check-proc "*scheme*")) + (let ((cmdlist (scheme-args-to-list cmd))) + (set-buffer (apply 'make-comint "scheme" (car cmdlist) + nil (cdr cmdlist))) + (inferior-scheme-mode))) + (setq scheme-buffer "*scheme*") + (switch-to-buffer "*scheme*")) + + + (defun scheme-send-region (start end) + "Send the current region to the inferior Scheme process." + (interactive "r") + (comint-send-region (scheme-proc) start end) + (comint-send-string (scheme-proc) "\n")) + + (defun scheme-send-definition () + "Send the current definition to the inferior Scheme process." + (interactive) + (save-excursion + (end-of-defun) + (let ((end (point))) + (beginning-of-defun) + (scheme-send-region (point) end)))) + + (defun scheme-send-last-sexp () + "Send the previous sexp to the inferior Scheme process." + (interactive) + (scheme-send-region (save-excursion (backward-sexp) (point)) (point))) + + (defvar scheme-compile-exp-command "(compile '%s)" + "*Template for issuing commands to compile arbitrary Scheme expressions.") + + (defun scheme-compile-region (start end) + "Compile the current region in the inferior Scheme process + \(A BEGIN is wrapped around the region: (BEGIN ))" + (interactive "r") + (comint-send-string (scheme-proc) (format scheme-compile-exp-command + (format "(begin %s)" + (buffer-substring start end)))) + (comint-send-string (scheme-proc) "\n")) + + (defun scheme-compile-definition () + "Compile the current definition in the inferior Scheme process." + (interactive) + (save-excursion + (end-of-defun) + (let ((end (point))) + (beginning-of-defun) + (scheme-compile-region (point) end)))) + + (defun switch-to-scheme (eob-p) + "Switch to the scheme process buffer. + With argument, positions cursor at end of buffer." + (interactive "P") + (if (get-buffer scheme-buffer) + (pop-to-buffer scheme-buffer) + (error "No current process buffer. See variable scheme-buffer.")) + (cond (eob-p + (push-mark) + (goto-char (point-max))))) + + (defun scheme-send-region-and-go (start end) + "Send the current region to the inferior Scheme process, + and switch to the process buffer." + (interactive "r") + (scheme-send-region start end) + (switch-to-scheme t)) + + (defun scheme-send-definition-and-go () + "Send the current definition to the inferior Scheme, + and switch to the process buffer." + (interactive) + (scheme-send-definition) + (switch-to-scheme t)) + + (defun scheme-compile-definition-and-go () + "Compile the current definition in the inferior Scheme, + and switch to the process buffer." + (interactive) + (scheme-compile-definition) + (switch-to-scheme t)) + + (defun scheme-compile-region-and-go (start end) + "Compile the current region in the inferior Scheme, + and switch to the process buffer." + (interactive "r") + (scheme-compile-region start end) + (switch-to-scheme t)) + + (defvar scheme-source-modes '(scheme-mode) + "*Used to determine if a buffer contains Scheme source code. + If it's loaded into a buffer that is in one of these major modes, it's + considered a scheme source file by scheme-load-file and scheme-compile-file. + Used by these commands to determine defaults.") + + (defvar scheme-prev-l/c-dir/file nil + "Caches the (directory . file) pair used in the last scheme-load-file or + scheme-compile-file command. Used for determining the default in the + next one.") + + (defun scheme-load-file (file-name) + "Load a Scheme file into the inferior Scheme process." + (interactive (comint-get-source "Load Scheme file: " scheme-prev-l/c-dir/file + scheme-source-modes t)) ; T because LOAD + ; needs an exact name + (comint-check-source file-name) ; Check to see if buffer needs saved. + (setq scheme-prev-l/c-dir/file (cons (file-name-directory file-name) + (file-name-nondirectory file-name))) + (comint-send-string (scheme-proc) (concat "(load \"" + file-name + "\"\)\n")) + (switch-to-scheme t)) + + (defun scheme-compile-file (file-name) + "Compile a Scheme file in the inferior Scheme process." + (interactive (comint-get-source "Compile Scheme file: " + scheme-prev-l/c-dir/file + scheme-source-modes + nil)) ; NIL because COMPILE doesn't + ; need an exact name. + (comint-check-source file-name) ; Check to see if buffer needs saved. + (setq scheme-prev-l/c-dir/file (cons (file-name-directory file-name) + (file-name-nondirectory file-name))) + (comint-send-string (scheme-proc) (concat "(compile-file \"" + file-name + "\"\)\n")) + (switch-to-scheme t)) + + + (defvar scheme-buffer nil "*The current scheme process buffer. + + MULTIPLE PROCESS SUPPORT + =========================================================================== + Cmuscheme.el supports, in a fairly simple fashion, running multiple Scheme + processes. To run multiple Scheme processes, you start the first up with + \\[run-scheme]. It will be in a buffer named *scheme*. Rename this buffer + with \\[rename-buffer]. You may now start up a new process with another + \\[run-scheme]. It will be in a new buffer, named *scheme*. You can + switch between the different process buffers with \\[switch-to-buffer]. + + Commands that send text from source buffers to Scheme processes -- + like scheme-send-definition or scheme-compile-region -- have to choose a + process to send to, when you have more than one Scheme process around. This + is determined by the global variable scheme-buffer. Suppose you + have three inferior Schemes running: + Buffer Process + foo scheme + bar scheme<2> + *scheme* scheme<3> + If you do a \\[scheme-send-definition-and-go] command on some Scheme source + code, what process do you send it to? + + - If you're in a process buffer (foo, bar, or *scheme*), + you send it to that process. + - If you're in some other buffer (e.g., a source file), you + send it to the process attached to buffer scheme-buffer. + This process selection is performed by function scheme-proc. + + Whenever \\[run-scheme] fires up a new process, it resets scheme-buffer + to be the new process's buffer. If you only run one process, this will + do the right thing. If you run multiple processes, you can change + scheme-buffer to another process buffer with \\[set-variable]. + + More sophisticated approaches are, of course, possible. If you find youself + needing to switch back and forth between multiple processes frequently, + you may wish to consider ilisp.el, a larger, more sophisticated package + for running inferior Lisp and Scheme processes. The approach taken here is + for a minimal, simple implementation. Feel free to extend it.") + + (defun scheme-proc () + "Returns the current scheme process. See variable scheme-buffer." + (let ((proc (get-buffer-process (if (eq major-mode 'inferior-scheme-mode) + (current-buffer) + scheme-buffer)))) + (or proc + (error "No current process. See variable scheme-buffer")))) + + + ;;; Do the user's customisation... + + (defvar cmuscheme-load-hook nil + "This hook is run when cmuscheme is loaded in. + This is a good place to put keybindings.") + + (run-hooks 'cmuscheme-load-hook) + + + ;;; CHANGE LOG + ;;; =========================================================================== + ;;; 8/88 Olin + ;;; Created. + ;;; + ;;; 2/15/89 Olin + ;;; Removed -emacs flag from process invocation. It's only useful for + ;;; cscheme, and makes cscheme assume it's running under xscheme.el, + ;;; which messes things up royally. A bug. + ;;; + ;;; 5/22/90 Olin + ;;; - Upgraded to use comint-send-string and comint-send-region. + ;;; - run-scheme now offers to let you edit the command line if + ;;; you invoke it with a prefix-arg. M-x scheme is redundant, and + ;;; has been removed. + ;;; - Explicit references to process "scheme" have been replaced with + ;;; (scheme-proc). This allows better handling of multiple process bufs. + ;;; - Added scheme-send-last-sexp, bound to C-x C-e. A gnu convention. + ;;; - Have not added process query facility a la cmulisp.el's lisp-show-arglist + ;;; and friends, but interested hackers might find a useful application + ;;; of this facility. *** /dev/null Thu Oct 31 13:46:08 1991 --- gnuemacs/cmushell.el Wed Oct 23 16:33:04 1991 *************** *** 0 **** --- 1,587 ---- + ;;; -*-Emacs-Lisp-*- General command interpreter in a window stuff + ;;; Copyright Olin Shivers (1988). + ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright + ;;; notice appearing here to the effect that you may use this code any + ;;; way you like, as long as you don't charge money for it, remove this + ;;; notice, or hold me liable for its results. + + ;;; The changelog is at the end of file. + + ;;; Please send me bug reports, bug fixes, and extensions, so that I can + ;;; merge them into the master source. + ;;; - Olin Shivers (shivers@cs.cmu.edu) + + ;;; This file defines a a shell-in-a-buffer package (cmushell mode) built on + ;;; top of comint mode. Cmushell mode is similar to, and intended to replace, + ;;; its counterpart in the standard gnu emacs release. This replacement is + ;;; more featureful, robust, and uniform than the released version. + + ;;; Since this mode is built on top of the general command-interpreter-in- + ;;; a-buffer mode (comint mode), it shares a common base functionality, + ;;; and a common set of bindings, with all modes derived from comint mode. + ;;; This makes these modes easier to use. + + ;;; For documentation on the functionality provided by comint mode, and + ;;; the hooks available for customising it, see the file comint.el. + ;;; For further information on cmushell mode, see the comments below. + + ;;; Needs fixin: + ;;; When sending text from a source file to a subprocess, the process-mark can + ;;; move off the window, so you can lose sight of the process interactions. + ;;; Maybe I should ensure the process mark is in the window when I send + ;;; text to the process? Switch selectable? + + (require 'comint) + (provide 'cmushell) + + ;; YOUR .EMACS FILE + ;;============================================================================= + ;; Some suggestions for your .emacs file. + ;; + ;; ; If cmushell lives in some non-standard directory, you must tell emacs + ;; ; where to get it. This may or may not be necessary. + ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path)) + ;; + ;; ; Autoload cmushell from file cmushell.el + ;; (autoload 'cmushell "cmushell" + ;; "Run an inferior shell process." + ;; t) + ;; + ;; ; Define C-c C-t to run my favorite command in cmushell mode: + ;; (setq cmushell-load-hook + ;; '((lambda () + ;; (define-key cmushell-mode-map "\C-c\C-t" 'favorite-cmd)))) + + + ;;; Brief Command Documentation: + ;;;============================================================================ + ;;; Comint Mode Commands: (common to cmushell and all comint-derived modes) + ;;; + ;;; m-p comint-previous-input Cycle backwards in input history + ;;; m-n comint-next-input Cycle forwards + ;;; c-c r comint-previous-input-matching Search backwards in input history + ;;; return comint-send-input + ;;; c-a comint-bol Beginning of line; skip prompt. + ;;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff. + ;;; c-c c-u comint-kill-input ^u + ;;; c-c c-w backward-kill-word ^w + ;;; c-c c-c comint-interrupt-subjob ^c + ;;; c-c c-z comint-stop-subjob ^z + ;;; c-c c-\ comint-quit-subjob ^\ + ;;; c-c c-o comint-kill-output Delete last batch of process output + ;;; c-c c-r comint-show-output Show last batch of process output + ;;; send-invisible Read line w/o echo & send to proc + ;;; comint-continue-subjob Useful if you accidentally suspend + ;;; top-level job. + ;;; comint-mode-hook is the comint mode hook. + + ;;; Shell Mode Commands: + ;;; cmushell Fires up the shell process. + ;;; m-tab comint-dynamic-complete Complete a partial file name + ;;; m-? comint-dynamic-list-completions List completions in help buffer + ;;; dirs Resync the buffer's dir stack. + ;;; dirtrack-toggle Turn dir tracking on/off. + ;;; + ;;; The cmushell mode hook is cmushell-mode-hook + ;;; The cmushell-load-hook is run after this file is loaded. + ;;; comint-prompt-regexp is initialised to shell-prompt-pattern, for backwards + ;;; compatibility. + + ;;; Read the rest of this file for more information. + + ;;; SHELL.EL COMPATIBILITY + ;;;============================================================================ + ;;; In brief: this package should have no trouble coexisting with shell.el. + ;;; + ;;; Most customising variables -- e.g., explicit-shell-file-name -- are the + ;;; same, so the users shouldn't have much trouble. Hooks have different + ;;; names, however, so you can customise shell mode differently from cmushell + ;;; mode. You basically just have to remember to type M-x cmushell instead of + ;;; M-x shell. + ;;; + ;;; It would be nice if this file was completely plug-compatible with the old + ;;; shell package -- if you could just name this file shell.el, and have it + ;;; transparently replace the old one. But you can't. Several other packages + ;;; (tex-mode, background, dbx, gdb, kermit, monkey, prolog, telnet) are also + ;;; clients of shell mode. These packages assume detailed knowledge of shell + ;;; mode internals in ways that are incompatible with cmushell mode (mostly + ;;; because of cmushell mode's greater functionality). So, unless we are + ;;; willing to port all of these packages, we can't have this file be a + ;;; complete replacement for shell.el -- that is, we can't name this file + ;;; shell.el, and its main entry point (shell), because dbx.el will break + ;;; when it loads it in and tries to use it. + ;;; + ;;; There are two ways to fix this. One: rewrite these other modes to use the + ;;; new package. This is a win, but can't be assumed. The other, backwards + ;;; compatible route, is to make this package non-conflict with shell.el, so + ;;; both files can be loaded in at the same time. And *that* is why some + ;;; functions and variables have different names: (cmushell), + ;;; cmushell-mode-map, that sort of thing. All the names have been carefully + ;;; chosen so that shell.el and cmushell.el won't tromp on each other. + + ;;; Customisation and Buffer Variables + ;;; =========================================================================== + ;;; + + ;In loaddefs.el now. + ;(defconst shell-prompt-pattern + ; "^[^#$%>]*[#$%>] *" + ; "*Regexp used by Newline command to match subshell prompts. + ;;; Change the doc string for shell-prompt-pattern: + (put 'shell-prompt-pattern 'variable-documentation + "Regexp to match prompts in the inferior shell. + Defaults to \"^[^#$%>]*[#$%>] *\", which works pretty well. + This variable is used to initialise comint-prompt-regexp in the + shell buffer. + + This is a fine thing to set in your .emacs file.") + + (defvar shell-popd-regexp "popd" + "*Regexp to match subshell commands equivalent to popd.") + + (defvar shell-pushd-regexp "pushd" + "*Regexp to match subshell commands equivalent to pushd.") + + (defvar shell-cd-regexp "cd" + "*Regexp to match subshell commands equivalent to cd.") + + (defvar explicit-shell-file-name nil + "*If non-nil, is file name to use for explicitly requested inferior shell.") + + (defvar explicit-csh-args + (if (eq system-type 'hpux) + ;; -T persuades HP's csh not to think it is smarter + ;; than us about what terminal modes to use. + '("-i" "-T") + '("-i")) + "*Args passed to inferior shell by M-x cmushell, if the shell is csh. + Value is a list of strings, which may be nil.") + + ;;; All the above vars aren't prefixed "cmushell-" to make them + ;;; backwards compatible w/shell.el and old .emacs files. + + (defvar cmushell-dirstack nil + "List of directories saved by pushd in this buffer's shell.") + + (defvar cmushell-dirstack-query "dirs" + "Command used by shell-resync-dirlist to query shell.") + + (defvar cmushell-mode-map '()) + (cond ((not cmushell-mode-map) + (setq cmushell-mode-map (full-copy-sparse-keymap comint-mode-map)) + (define-key cmushell-mode-map "\M-\t" 'comint-dynamic-complete) + (define-key cmushell-mode-map "\M-?" 'comint-dynamic-list-completions))) + + (defvar cmushell-mode-hook '() + "*Hook for customising cmushell mode") + + + ;;; Basic Procedures + ;;; =========================================================================== + ;;; + + (defun cmushell-mode () + "Major mode for interacting with an inferior shell. + Return after the end of the process' output sends the text from the + end of process to the end of the current line. + Return before end of process output copies rest of line to end (skipping + the prompt) and sends it. + M-x send-invisible reads a line of text without echoing it, and sends it to + the shell. + + If you accidentally suspend your process, use \\[comint-continue-subjob] + to continue it. + + cd, pushd and popd commands given to the shell are watched by Emacs to keep + this buffer's default directory the same as the shell's working directory. + M-x dirs queries the shell and resyncs Emacs' idea of what the current + directory stack is. + M-x dirtrack-toggle turns directory tracking on and off. + + \\{cmushell-mode-map} + Customisation: Entry to this mode runs the hooks on comint-mode-hook and + cmushell-mode-hook (in that order). + + Variables shell-cd-regexp, shell-pushd-regexp and shell-popd-regexp are used + to match their respective commands." + (interactive) + (comint-mode) + (setq comint-prompt-regexp shell-prompt-pattern) + (setq major-mode 'cmushell-mode) + (setq mode-name "CMU shell") + (use-local-map cmushell-mode-map) + (make-local-variable 'cmushell-dirstack) + (setq cmushell-dirstack nil) + (make-local-variable 'cmushell-dirtrackp) + (setq cmushell-dirtrackp t) + (setq comint-input-sentinel 'cmushell-directory-tracker) + (run-hooks 'cmushell-mode-hook)) + + + (defun cmushell () + "Run an inferior shell, with I/O through buffer *cmushell*. + If buffer exists but shell process is not running, make new shell. + If buffer exists and shell process is running, + just switch to buffer *cmushell*. + Program used comes from variable explicit-shell-file-name, + or (if that is nil) from the ESHELL environment variable, + or else from SHELL if there is no ESHELL. + If a file ~/.emacs_SHELLNAME exists, it is given as initial input + (Note that this may lose due to a timing error if the shell + discards input when it starts up.) + The buffer is put in cmushell-mode, giving commands for sending input + and controlling the subjobs of the shell. See cmushell-mode. + See also variable shell-prompt-pattern. + + The shell file name (sans directories) is used to make a symbol name + such as `explicit-csh-arguments'. If that symbol is a variable, + its value is used as a list of arguments when invoking the shell. + Otherwise, one argument `-i' is passed to the shell. + + \(Type \\[describe-mode] in the shell buffer for a list of commands.)" + (interactive) + (cond ((not (comint-check-proc "*cmushell*")) + (let* ((prog (or explicit-shell-file-name + (getenv "ESHELL") + (getenv "SHELL") + "/bin/sh")) + (name (file-name-nondirectory prog)) + (startfile (concat "~/.emacs_" name)) + (xargs-name (intern-soft (concat "explicit-" name "-args")))) + (set-buffer (apply 'make-comint "cmushell" prog + (if (file-exists-p startfile) startfile) + (if (and xargs-name (boundp xargs-name)) + (symbol-value xargs-name) + '("-i")))) + (cmushell-mode)))) + (switch-to-buffer "*cmushell*")) + + + ;;; Directory tracking + ;;; =========================================================================== + ;;; This code provides the cmushell mode input sentinel + ;;; CMUSHELL-DIRECTORY-TRACKER + ;;; that tracks cd, pushd, and popd commands issued to the shell, and + ;;; changes the current directory of the shell buffer accordingly. + ;;; + ;;; This is basically a fragile hack, although it's more accurate than + ;;; the released version in shell.el. It has the following failings: + ;;; 1. It doesn't know about the cdpath shell variable. + ;;; 2. It only spots the first command in a command sequence. E.g., it will + ;;; miss the cd in "ls; cd foo" + ;;; 3. More generally, any complex command (like ";" sequencing) is going to + ;;; throw it. Otherwise, you'd have to build an entire shell interpreter in + ;;; emacs lisp. Failing that, there's no way to catch shell commands where + ;;; cd's are buried inside conditional expressions, aliases, and so forth. + ;;; + ;;; The whole approach is a crock. Shell aliases mess it up. File sourcing + ;;; messes it up. You run other processes under the shell; these each have + ;;; separate working directories, and some have commands for manipulating + ;;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have + ;;; commands that do *not* effect the current w.d. at all, but look like they + ;;; do (e.g., the cd command in ftp). In shells that allow you job + ;;; control, you can switch between jobs, all having different w.d.'s. So + ;;; simply saying %3 can shift your w.d.. + ;;; + ;;; The solution is to relax, not stress out about it, and settle for + ;;; a hack that works pretty well in typical circumstances. Remember + ;;; that a half-assed solution is more in keeping with the spirit of Unix, + ;;; anyway. Blech. + ;;; + ;;; One good hack not implemented here for users of programmable shells + ;;; is to program up the shell w.d. manipulation commands to output + ;;; a coded command sequence to the tty. Something like + ;;; ESC | | + ;;; where is the new current working directory. Then trash the + ;;; directory tracking machinery currently used in this package, and + ;;; replace it with a process filter that watches for and strips out + ;;; these messages. + + ;;; REGEXP is a regular expression. STR is a string. START is a fixnum. + ;;; Returns T if REGEXP matches STR where the match is anchored to start + ;;; at position START in STR. Sort of like LOOKING-AT for strings. + (defun cmushell-front-match (regexp str start) + (eq start (string-match regexp str start))) + + (defun cmushell-directory-tracker (str) + "Tracks cd, pushd and popd commands issued to the shell. + This function is called on each input passed to the shell. + It watches for cd, pushd and popd commands and sets the buffer's + default directory to track these commands. + + You may toggle this tracking on and off with M-x dirtrack-toggle. + If emacs gets confused, you can resync with the shell with M-x dirs. + + See variables shell-cd-regexp, shell-pushd-regexp, and shell-popd-regexp. + Environment variables are expanded, see function substitute-in-file-name." + (condition-case err + (cond (cmushell-dirtrackp + (string-match "^\\s *" str) ; skip whitespace + (let ((bos (match-end 0)) + (x nil)) + (cond ((setq x (cmushell-match-cmd-w/optional-arg shell-popd-regexp + str bos)) + (cmushell-process-popd (substitute-in-file-name x))) + ((setq x (cmushell-match-cmd-w/optional-arg shell-pushd-regexp + str bos)) + (cmushell-process-pushd (substitute-in-file-name x))) + ((setq x (cmushell-match-cmd-w/optional-arg shell-cd-regexp + str bos)) + (cmushell-process-cd (substitute-in-file-name x))))))) + (error (message (car (cdr err)))))) + + + ;;; Try to match regexp CMD to string, anchored at position START. + ;;; CMD may be followed by a single argument. If a match, then return + ;;; the argument, if there is one, or the empty string if not. If + ;;; no match, return nil. + + (defun cmushell-match-cmd-w/optional-arg (cmd str start) + (and (cmushell-front-match cmd str start) + (let ((eoc (match-end 0))) ; end of command + (cond ((cmushell-front-match "\\s *\\(\;\\|$\\)" str eoc) + "") ; no arg + ((cmushell-front-match "\\s +\\([^ \t\;]+\\)\\s *\\(\;\\|$\\)" + str eoc) + (substring str (match-beginning 1) (match-end 1))) ; arg + (t nil))))) ; something else. + ;;; The first regexp is [optional whitespace, (";" or the end of string)]. + ;;; The second regexp is [whitespace, (an arg), optional whitespace, + ;;; (";" or end of string)]. + + + ;;; popd [+n] + (defun cmushell-process-popd (arg) + (let ((num (if (zerop (length arg)) 0 ; no arg means +0 + (cmushell-extract-num arg)))) + (if (and num (< num (length cmushell-dirstack))) + (if (= num 0) ; condition-case because the CD could lose. + (condition-case nil (progn (cd (car cmushell-dirstack)) + (setq cmushell-dirstack + (cdr cmushell-dirstack)) + (cmushell-dirstack-message)) + (error (message "Couldn't cd."))) + (let* ((ds (cons nil cmushell-dirstack)) + (cell (nthcdr (- num 1) ds))) + (rplacd cell (cdr (cdr cell))) + (setq cmushell-dirstack (cdr ds)) + (cmushell-dirstack-message))) + (message "Bad popd.")))) + + + ;;; cd [dir] + (defun cmushell-process-cd (arg) + (condition-case nil (progn (cd (if (zerop (length arg)) (getenv "HOME") + arg)) + (cmushell-dirstack-message)) + (error (message "Couldn't cd.")))) + + + ;;; pushd [+n | dir] + (defun cmushell-process-pushd (arg) + (if (zerop (length arg)) + ;; no arg -- swap pwd and car of shell stack + (condition-case nil (if cmushell-dirstack + (let ((old default-directory)) + (cd (car cmushell-dirstack)) + (setq cmushell-dirstack + (cons old (cdr cmushell-dirstack))) + (cmushell-dirstack-message)) + (message "Directory stack empty.")) + (message "Couldn't cd.")) + + (let ((num (cmushell-extract-num arg))) + (if num ; pushd +n + (if (> num (length cmushell-dirstack)) + (message "Directory stack not that deep.") + (let* ((ds (cons default-directory cmushell-dirstack)) + (dslen (length ds)) + (front (nthcdr num ds)) + (back (reverse (nthcdr (- dslen num) (reverse ds)))) + (new-ds (append front back))) + (condition-case nil + (progn (cd (car new-ds)) + (setq cmushell-dirstack (cdr new-ds)) + (cmushell-dirstack-message)) + (error (message "Couldn't cd."))))) + + ;; pushd + (let ((old-wd default-directory)) + (condition-case nil + (progn (cd arg) + (setq cmushell-dirstack + (cons old-wd cmushell-dirstack)) + (cmushell-dirstack-message)) + (error (message "Couldn't cd.")))))))) + + ;; If STR is of the form +n, for n>0, return n. Otherwise, nil. + (defun cmushell-extract-num (str) + (and (string-match "^\\+[1-9][0-9]*$" str) + (string-to-int str))) + + + (defun cmushell-dirtrack-toggle () + "Turn directory tracking on and off in a cmushell buffer." + (interactive) + (setq cmushell-dirtrackp (not cmushell-dirtrackp)) + (message "directory tracking %s." + (if cmushell-dirtrackp "ON" "OFF"))) + + ;;; For your typing convenience: + (fset 'dirtrack-toggle 'cmushell-dirtrack-toggle) + + + (defun cmushell-resync-dirs () + "Resync the buffer's idea of the current directory stack. + This command queries the shell with the command bound to + cmushell-dirstack-query (default \"dirs\"), reads the next + line output and parses it to form the new directory stack. + DON'T issue this command unless the buffer is at a shell prompt. + Also, note that if some other subprocess decides to do output + immediately after the query, its output will be taken as the + new directory stack -- you lose. If this happens, just do the + command again." + (interactive) + (let* ((proc (get-buffer-process (current-buffer))) + (pmark (process-mark proc))) + (goto-char pmark) + (insert cmushell-dirstack-query) (insert "\n") + (sit-for 0) ; force redisplay + (comint-send-string proc cmushell-dirstack-query) + (comint-send-string proc "\n") + (set-marker pmark (point)) + (let ((pt (point))) ; wait for 1 line + ;; This extra newline prevents the user's pending input from spoofing us. + (insert "\n") (backward-char 1) + (while (not (looking-at ".+\n")) + (accept-process-output proc) + (goto-char pt))) + (goto-char pmark) (delete-char 1) ; remove the extra newline + ;; That's the dirlist. grab it & parse it. + (let* ((dl (buffer-substring (match-beginning 0) (- (match-end 0) 1))) + (dl-len (length dl)) + (ds '()) ; new dir stack + (i 0)) + (while (< i dl-len) + ;; regexp = optional whitespace, (non-whitespace), optional whitespace + (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir + (setq ds (cons (substring dl (match-beginning 1) (match-end 1)) + ds)) + (setq i (match-end 0))) + (let ((ds (reverse ds))) + (condition-case nil + (progn (cd (car ds)) + (setq cmushell-dirstack (cdr ds)) + (cmushell-dirstack-message)) + (error (message "Couldn't cd."))))))) + + ;;; For your typing convenience: + (fset 'dirs 'cmushell-resync-dirs) + + + ;;; Show the current dirstack on the message line. + ;;; Pretty up dirs a bit by changing "/usr/jqr/foo" to "~/foo". + ;;; (This isn't necessary if the dirlisting is generated with a simple "dirs".) + ;;; All the commands that mung the buffer's dirstack finish by calling + ;;; this guy. + (defun cmushell-dirstack-message () + (let ((msg "") + (ds (cons default-directory cmushell-dirstack))) + (while ds + (let ((dir (car ds))) + (if (string-match (format "^%s\\(/\\|$\\)" (getenv "HOME")) dir) + (setq dir (concat "~/" (substring dir (match-end 0))))) + (if (string-equal dir "~/") (setq dir "~")) + (setq msg (concat msg dir " ")) + (setq ds (cdr ds)))) + (message msg))) + + + + ;;; Interfacing to client packages (and converting them) + ;;;============================================================================ + ;;; Several gnu packages (tex-mode, background, dbx, gdb, kermit, prolog, + ;;; telnet are some) use the shell package as clients. Most of them would + ;;; be better off using the comint package directly, but they predate it. + ;;; The catch is that most of these packages (dbx, gdb, prolog, telnet) + ;;; assume total knowledge of all the local variables that shell mode + ;;; functions depend on. So they (kill-all-local-variables), then create + ;;; the few local variables that shell.el functions depend on. Alas, + ;;; cmushell.el functions depend on a different set of vars (for example, + ;;; the input history ring is a local variable in cmushell.el's shell mode, + ;;; whereas there is no input history ring in shell.el's shell mode). + ;;; So we have a situation where the greater functionality of cmushell.el + ;;; is biting us -- you can't just replace shell will cmushell. + ;;; + ;;; Altering these packages to use comint mode directly should *greatly* + ;;; improve their functionality, and is actually pretty easy. It's + ;;; mostly a matter of renaming a few variable names. See comint.el for more. + ;;; -Olin + + + + ;;; Do the user's customisation... + ;;;=============================== + (defvar cmushell-load-hook nil + "This hook is run when cmushell is loaded in. + This is a good place to put keybindings.") + + (run-hooks 'cmushell-load-hook) + + ;;; Change Log + ;;; =========================================================================== + ;;; Olin 8/88 + ;;; Created. + ;;; + ;;; Olin 5/26/90 + ;;; - Split cmulisp and cmushell modes into separate files. + ;;; Not only is this a good idea, it's apparently the way it'll be rel 19. + ;;; - Souped up the directory tracking; it now can handle pushd, pushd +n, + ;;; and popd +n. + ;;; - Added cmushell-dirtrack-toggle command to toggle the directory + ;;; tracking that cmushell tries to do. This is useful, for example, + ;;; when you are running ftp -- it prevents the ftp "cd" command from + ;;; spoofing the tracking machinery. This command is also named + ;;; dirtrack-toggle, so you need only type M-x dirtrack to run it. + ;;; - Added cmushell-resync-dirs command. This queries the shell + ;;; for the current directory stack, and resets the buffer's stack + ;;; accordingly. This command is also named dirs, so you need only type + ;;; M-x dirs to run it. + ;;; - Bits of the new directory tracking code were adapted from source + ;;; contributed by Vince Broman, Jeff Peck, and Barry Warsaw. + ;;; - See also the improvements made to comint.el at the same time. + ;;; - Renamed several variables. Mostly this comprised changing "shell" + ;;; to "cmushell" in the names. The only variables that are not prefixed + ;;; with "cmushell-" are the ones that are common with shell.el: + ;;; explicit-shell-file-name shell-prompt-pattern explicit-csh-args + ;;; and shell-cd/popd/pushd-regexp + ;;; The variables and functions that were changed to have "cmushell-" + ;;; prefixes are: + ;;; shell-directory-stack (v), shell-directory-tracker (f) + ;;; This should not affect users, only elisp hackers. Hopefully + ;;; one day shell.el will just go away, and we can drop all this + ;;; "cmushell" bullshit. + ;;; - Upgraded process sends to use comint-send-string instead of + ;;; process-send-string. + ;;; + ;;; Olin 6/14/90 + ;;; - If your shell is named , and a variable named + ;;; explicit--args exists, cmushell is supposed + ;;; to use its value as the arglist to the shell invocation. + ;;; E.g., if you define explicit-csh-args to be + ;;; ("-ifx"), then when cmushell cranks up a csh, it execs it + ;;; as "csh -ifx". This is what is documented. What has actually + ;;; been the case is that the variable checked is + ;;; explicit--arguments, not explicit--args. + ;;; The documentation has been changed to conform to the code (for + ;;; backwards compatibility with shell.el). This bug is inherited from + ;;; the same bug in shell.el. + ;;; This bug reported by Stephen Anderson. + ;;; + ;;; Olin 9/5/90 + ;;; - Arguments to cd, popd, and pushd now have their env vars expanded + ;;; out by the tracking machinery. So if you say "cd $SRCDIR/funs", the + ;;; $SRCDIR var will be replaced by its value *in emacs' process + ;;; environment*. If this is different from the shell's binding of the + ;;; variable, you lose. Several users needed this feature, fragile + ;;; though it may be. The fix was contributed by sk@thp.Uni-Koeln.DE. *** /dev/null Thu Oct 31 13:46:09 1991 --- gnuemacs/comint-fix.DE Wed Oct 23 16:33:05 1991 *************** *** 0 **** --- 1,106 ---- + *** comint.el.orig Fri Aug 3 17:02:19 1990 + --- comint.el Tue Aug 7 18:53:16 1990 + *************** + *** 669,674 **** + --- 669,675 ---- + (interactive) + ;; Note that the input string does not include its terminal newline. + (let ((proc (get-buffer-process (current-buffer)))) + + (shell-completion-cleanup) + (if (not proc) (error "Current buffer has no process") + (let* ((pmark (process-mark proc)) + (pmark-val (marker-position pmark)) + *************** + *** 854,859 **** + --- 855,861 ---- + (defun comint-kill-input () + "Kill all text from last stuff output by interpreter to point." + (interactive) + + (shell-completion-cleanup) + (let* ((pmark (process-mark (get-buffer-process (current-buffer)))) + (p-pos (marker-position pmark))) + (if (> (point) p-pos) + *************** + *** 1166,1171 **** + --- 1168,1248 ---- + ; (global-set-key "\M-?" 'comint-dynamic-list-completions) + ; (define-key shell-mode-map "\M-\t" 'comint-dynamic-complete) + + + ; Here is some new stuff that I have snarfed from Leonard N. Zubkoff. It is + + ; the file-name-completion stuff he did for shell mode. + + + + (defvar shell-completions-window nil + + "If non-nil, completion window requires cleaning up.") + + + + (defvar shell-token-pattern "[ \t\n()<>&|;]" + + "*Regexp used by shell name completion to mark path name boundries.") + + + + (defun shell-file-name-completion () + + "Preform file name completion in shell mode" + + (interactive) + + (let ((shell-expand-string nil) + + (shell-expand-begin nil) + + (shell-expand-end nil) + + (shell-expand-dir nil) + + (shell-expand-file nil) + + (shell-expand-completion nil)) + + + + ;; look back + + (re-search-backward shell-token-pattern nil t) + + (forward-char) + + (setq shell-expand-begin (point)) + + ;; look ahead + + (if (re-search-forward shell-token-pattern nil 0) (backward-char)) + + (setq shell-expand-end (point)) + + + + ;; the name requiring expansion + + (setq shell-expand-string + + (buffer-substring shell-expand-begin shell-expand-end)) + + ;; directory part of name + + (setq shell-expand-dir + + (or (file-name-directory shell-expand-string) default-directory)) + + ;; file part of name + + (setq shell-expand-file + + (file-name-nondirectory shell-expand-string)) + + + + ;; do the expansion + + (setq shell-expand-completion + + (file-name-completion shell-expand-file shell-expand-dir)) + + ;; display the results + + (if (eq shell-expand-completion t) (message "Sole completion") + + (if (eq shell-expand-completion nil) (message "No match") + + (if (equal shell-expand-completion shell-expand-file) + + (progn + + (if shell-completions-window nil + + (setq shell-completions-window + + (current-window-configuration))) + + (message "Making completion list...") + + (with-output-to-temp-buffer " *Completions*" + + (display-completion-list + + (sort (file-name-all-completions + + shell-expand-completion shell-expand-dir) + + 'string-lessp))) + + (message "")) + + ;; put in the expansion + + (search-backward shell-expand-file) + + (replace-match shell-expand-completion t t)))))) + + + + (defun shell-completion-cleanup () + + "Clean up windows after shell file name completion." + + (interactive) + + (if shell-completions-window + + (save-excursion + + (set-window-configuration shell-completions-window) + + (setq shell-completions-window nil)))) + + + + (defun kill-all-output-from-shell () + + "Kill shell buffer above current prompt." + + (interactive) + + (goto-char (point-max)) + + (re-search-backward shell-prompt-pattern nil t) + + (kill-region (point-min) (point)) + + (goto-char (point-max))) + + + ;;; Converting process modes to use comint mode + ;;; =========================================================================== + ;;; Several gnu packages (tex-mode, background, dbx, gdb, kermit, prolog, *** /dev/null Thu Oct 31 13:46:09 1991 --- gnuemacs/comint.el Wed Oct 23 16:33:07 1991 *************** *** 0 **** --- 1,1323 ---- + ;;; -*-Emacs-Lisp-*- General command interpreter in a window stuff + ;;; Copyright Olin Shivers (1988). + ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright + ;;; notice appearing here to the effect that you may use this code any + ;;; way you like, as long as you don't charge money for it, remove this + ;;; notice, or hold me liable for its results. + + ;;; The changelog is at the end of this file. + + ;;; Please send me bug reports, bug fixes, and extensions, so that I can + ;;; merge them into the master source. + ;;; - Olin Shivers (shivers@cs.cmu.edu) + + ;;; This hopefully generalises shell mode, lisp mode, tea mode, soar mode,... + ;;; This file defines a general command-interpreter-in-a-buffer package + ;;; (comint mode). The idea is that you can build specific process-in-a-buffer + ;;; modes on top of comint mode -- e.g., lisp, shell, scheme, T, soar, .... + ;;; This way, all these specific packages share a common base functionality, + ;;; and a common set of bindings, which makes them easier to use (and + ;;; saves code, implementation time, etc., etc.). + + ;;; Several packages are already defined using comint mode: + ;;; - cmushell.el defines a shell-in-a-buffer mode. + ;;; - cmulisp.el defines a simple lisp-in-a-buffer mode. + ;;; Cmushell and cmulisp mode are similar to, and intended to replace, + ;;; their counterparts in the standard gnu emacs release (in shell.el). + ;;; These replacements are more featureful, robust, and uniform than the + ;;; released versions. The key bindings in lisp mode are also more compatible + ;;; with the bindings of Hemlock and Zwei (the Lisp Machine emacs). + ;;; + ;;; - The file cmuscheme.el defines a scheme-in-a-buffer mode. + ;;; - The file tea.el tunes scheme and inferior-scheme modes for T. + ;;; - The file soar.el tunes lisp and inferior-lisp modes for Soar. + ;;; - cmutex.el defines tex and latex modes that invoke tex, latex, bibtex, + ;;; previewers, and printers from within emacs. + ;;; - background.el allows csh-like job control inside emacs. + ;;; It is pretty easy to make new derived modes for other processes. + + ;;; For documentation on the functionality provided by comint mode, and + ;;; the hooks available for customising it, see the comments below. + ;;; For further information on the standard derived modes (shell, + ;;; inferior-lisp, inferior-scheme, ...), see the relevant source files. + + ;;; For