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

  1. ;;; Date: Mon, 17 Dec 90 16:46:39 -0500
  2. ;;; From: rsw@cs.brown.edu (Bob Weiner)
  3. ;;; Message-Id: <9012172146.AA06790@fiddle.cs.brown.edu>
  4. ;;; To: mayer@hplnpm.hpl.hp.com
  5. ;;; Subject: Generalization of winterp.el code.
  6. ;;; 
  7. ;;; The generalization I include here substitutes an eval-last-sexp type function
  8. ;;; for your send-defun.  The send-defun function may be left around but really is
  9. ;;; not needed since all one need do is move to the end of the function and
  10. ;;; evaluate it.  This makes the interface so much simpler when one wants to do
  11. ;;; bottom up testing via the interpreter.
  12. ;;; 
  13. ;;; I've included only the one function and the key binding, so you should
  14. ;;; substitute it into your winterp.el file.
  15.  
  16. (defun winterp-eval-last-sexp ()
  17.   "A version of eval-last-sexp that talks to WINTERP's lisp server via the
  18. winterp client program 'wl' (which must be on your search path).  Evaluates
  19. sexp immediately preceding point."
  20.   (interactive)
  21.   (if (not (get-process "winterp-client-shell"))
  22.       (make-shell "winterp-client-shell" winterp-client-shell)
  23.     )
  24.   (let ((loadfile (format "/tmp/wl%d.lsp"
  25.               (process-id (get-process "winterp-client-shell"))))
  26.     (stab (syntax-table)))
  27.     (write-region
  28.      (unwind-protect
  29.      (save-excursion
  30.        (set-syntax-table emacs-lisp-mode-syntax-table)
  31.        (forward-sexp -1)
  32.        (point))
  33.        (set-syntax-table stab))
  34.      (point)
  35.      loadfile nil 'nomessage)
  36.     (process-send-string "winterp-client-shell"
  37.              (format "%s %s '(load \"%s\" :verbose nil
  38.                                   :print t)'\n" 
  39.                   winterp-client-program
  40.                   winterp-client-program-args
  41.                   loadfile))
  42.     )
  43.   )
  44.  
  45. (define-key lisp-mode-map "\e\C-x" 'winterp-eval-last-sexp)
  46.  
  47. ;;; 
  48. ;;; Date: Mon, 17 Dec 90 16:56:32 -0500
  49. ;;; From: rsw@cs.brown.edu (Bob Weiner)
  50. ;;; Message-Id: <9012172156.AA06799@fiddle.cs.brown.edu>
  51. ;;; To: mayer@hplnpm.hpl.hp.com
  52. ;;; Subject: Further generalization of winterp.el code.
  53. ;;; 
  54. ;;; We can further simplify the interface by combinding the expression evaluation
  55. ;;; command with the buffer evaluation command.  The latter is called when a prefix
  56. ;;; argument is sent to the 'winterp-eval' command.  Thus, only one key is needed,
  57. ;;; but both functions are accessible.  Try it.
  58. ;;;
  59.  
  60. (defun winterp-eval (&optional arg)
  61.   "Evaluate last sexpression.  With prefix ARG, evaluate visible portion of buffer."
  62.   (interactive "P")
  63.   (if arg
  64.       (winterp-send-buffer)
  65.     (winterp-eval-last-sexp)))
  66.  
  67. (define-key lisp-mode-map "\M-\C-x" 'winterp-eval)
  68.  
  69.  
  70. ;;; To: mayer@hplabs.hpl.hp.com
  71. ;;; Cc: gildea@alexander.bbn.com
  72. ;;; Subject: XLisp comments
  73. ;;; Date: Tue, 02 Oct 90 11:45:16 EDT
  74. ;;; From: Stephen Gildea <gildea@alexander.bbn.com>
  75. ;;; 
  76. ;;; I found I needed the function winterp-send-region, so I added it to
  77. ;;; winterp.el.  Here it is:
  78.  
  79. (defun winterp-send-region (start end)
  80.   "Send the current region off to WINTERP for evaluation.
  81. This routine talks to WINTERP's lisp server via the winterp client
  82. program 'wl' (which must be on your search path)."
  83.   (interactive "r")
  84.   (if (not (get-process "winterp-client-shell"))
  85.       (make-shell "winterp-client-shell" winterp-client-shell))
  86.   (let ((loadfile (format "/tmp/wl%d.lsp"
  87.               (process-id (get-process "winterp-client-shell")))))
  88.     (save-excursion (write-region start end loadfile nil 'nomessage))
  89.     (process-send-string "winterp-client-shell"
  90.              (format
  91.               "%s %s '(load \"%s\" :verbose nil :print t)'\n"
  92.               winterp-client-program winterp-client-program-args
  93.               loadfile))))
  94.