home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / winterp-1.13 / src-client / winterp.el < prev    next >
Encoding:
Text File  |  1991-10-06  |  6.0 KB  |  131 lines

  1. ; -*-Emacs-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         winterp.el
  5. ; RCS:          $Header: winterp.el,v 1.2 89/12/15 17:48:27 mayer Exp $
  6. ; Description:  GNUEMACS lisp-mode interface to WINTERP.
  7. ; Author:       Niels Mayer, HPLabs
  8. ; Created:      Tue Nov 14 23:14:54 1989
  9. ; Modified:     Sat Oct  5 22:44:53 1991 (Niels Mayer) mayer@hplnpm
  10. ; Language:     Emacs-Lisp
  11. ; Package:      N/A
  12. ; Status:       X11r5 contrib tape release
  13. ;
  14. ; WINTERP Copyright 1989-1991 Hewlett-Packard Company (by Niels Mayer).
  15. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. ;
  17. ; Permission to use, copy, modify, distribute, and sell this software and its
  18. ; documentation for any purpose is hereby granted without fee, provided that
  19. ; the above copyright notice appear in all copies and that both that
  20. ; copyright notice and this permission notice appear in supporting
  21. ; documentation, and that the name of Hewlett-Packard and David Betz not be
  22. ; used in advertising or publicity pertaining to distribution of the software
  23. ; without specific, written prior permission.  Hewlett-Packard and David Betz
  24. ; make no representations about the suitability of this software for any
  25. ; purpose. It is provided "as is" without express or implied warranty.
  26. ;
  27. ; HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. ; SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. ; IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. ; INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. ; PERFORMANCE OF THIS SOFTWARE.
  34. ;
  35. ; See ./winterp/COPYRIGHT for information on contacting the authors.
  36. ; Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. ; Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. ;
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40.  
  41.  
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ;; Make sure shell.el is loaded, since this file uses stuff defined there.
  44. ;; None of this will work unless you load shell.el from emacs
  45. ;; versions >= 18.54. I also expect that lisp-mode has been preloaded into
  46. ;; gnuemacs (it is automatically loaded by default in "normal" gnuemacsen)
  47. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  48. (require 'shell)
  49.  
  50. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  51. (defvar winterp-client-shell "sh" 
  52.   "A shell in which to run the winterp-server client 'wl' any shell will do
  53. e.g. sh, csh, ksh....")
  54.  
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. (defvar winterp-client-program "wl"
  57.   "The name of the client program that sends lisp expressions to the
  58. winterp lisp server. You may want to change this if you use a different
  59. client program, or if you  don't have 'wl' on your search path, you
  60. may want to specify a full path to 'wl'.") 
  61.  
  62. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  63. (defvar winterp-client-program-args ""
  64.   "This sets the arguments sent to 'wl'. You may want to set this to
  65. \"-h <hostname> -p <portnum>\" if you are running  winterp on a different
  66. host than gnuemacs, or if you want to run winterp on a TCP port other than
  67. the default, which is 23751.")
  68.  
  69. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  70. (defun winterp-send-defun ()
  71.   "A version of lisp-send-defun that talks to WINTERP's lisp server via the
  72. winterp client program 'wl' (which must be on your search path)."
  73.   (interactive)
  74.   (if (not (get-process "winterp-client-shell"))
  75.       (make-shell "winterp-client-shell" winterp-client-shell)
  76.     )
  77.   (let ((loadfile (format "/tmp/wl%d.lsp"
  78.               (process-id (get-process "winterp-client-shell")))))
  79.     (save-excursion (write-region
  80.              (progn (beginning-of-defun) (point))
  81.              (progn (end-of-defun) (point))
  82.              loadfile nil 'nomessage))
  83.     (process-send-string "winterp-client-shell"
  84.              (format "%s %s '(load \"%s\" :verbose nil :print t)'\n"
  85.                  winterp-client-program winterp-client-program-args
  86.                  loadfile))
  87.     )
  88.   )
  89.  
  90. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  91. (defun winterp-send-exit ()
  92.   "Calling this function will send WINTERP a command to exit the current
  93. breaklevel. If not at a breaklevel, then WINTERP will exit."
  94.   (interactive)
  95.   (if (not (get-process "winterp-client-shell"))
  96.       (make-shell "winterp-client-shell" winterp-client-shell)
  97.     )
  98.   ;;sending wl with no args sends an EOF to WINTERP which signals XLISP to
  99.   ;;exit the current breaklevel, or exit if not in the breakloop.
  100.   (process-send-string "winterp-client-shell" 
  101.                (format "%s %s\n"
  102.                    winterp-client-program winterp-client-program-args))
  103.   )
  104.  
  105. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  106. (defun winterp-send-buffer ()
  107.   "A version of winterp-send-defun that sends the entire buffer off to WINTERP
  108. for evaluation. This routine talks to WINTERP's lisp server via the winterp client
  109. program 'wl' (which must be on your search path)."
  110.   (interactive)
  111.   (if (not (get-process "winterp-client-shell"))
  112.       (make-shell "winterp-client-shell" winterp-client-shell)
  113.     )
  114.   (let ((loadfile (format "/tmp/wl%d.lsp"
  115.               (process-id (get-process "winterp-client-shell")))))
  116.     (save-excursion (write-region (point-min) (point-max)
  117.              loadfile nil 'nomessage))
  118.     (process-send-string "winterp-client-shell"
  119.              (format "%s %s '(load \"%s\" :verbose nil :print t)'\n"
  120.                  winterp-client-program winterp-client-program-args
  121.                  loadfile))
  122.     )
  123.   )
  124.  
  125. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  126. ;; rebind some keys in lisp-mode-map (assumed preloaded in gnuemacs).
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. (define-key lisp-mode-map "\C-c\C-d" 'winterp-send-exit)
  129. (define-key lisp-mode-map "\e\C-x" 'winterp-send-defun)
  130.