[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bridge error in clisp-hs in lisp-interface program



I have some code which sets up a bridge in my ilisp buffer so that my
lisp code can communicate with emacs.  Thus I have a nifty
emacs-interface to my lisp program so that emacs key-bindings send
commands to the inferior lisp and the inferior lisp sends pretty
output to various emacs buffers.  The idea and some of the code I
borrowed from David McAllester's Ontic program.

Anyway, it works with lucid, allegro and gcl but not clisp-hs.  I have
has similar experiences with clisp-hs doing things with strings that
other lisps don't.  I would really like it to work with clisp-hs but I
can't figure out the problem.  It is one short .el file and a short
.lisp file.  I append the files to this message and give instructions
for installing it.  I have actually pared the files down to the bare
necessities.  If anyone is interested in more of this code, let me
know.  If anyone has similar code working for clisp-hs and is willing
to share it, please let me know.

Instructions for installation:

load emacs-eval.el into emacs

  M-x load-file[Return]emacs-eval.el

load ilisp:

  M-x [allegro|lucid|gcl|clisp-hs|whatever]

load emacs-eval.lisp into your ilisp

lisp-prompt> (load "emacs-eval.lisp")

If you use allegro or a lisp that handles packages according to ANSI,
you have to fix an error here but just do :continue 0 in allegro.

Try it out.  You should get "it works" printed in the minibuffer.

lisp-prompt> (in-package :util)
lisp-prompt> (emacs-eval `(message ,(quote-string "it works")))

This works in allegro and gcl (and lucid, I think).  This does not
work in clisp-hs (on my system).  If you get it to work with clisp-hs,
please let me know.

--------------(Begin emacs-eval.el)--------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Emacs Eval independent module
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;(require 'ilisp)
(require 'bridge)
(provide 'emacs-eval)

(defvar *lisp-eval-buffer* "")

;; Always install bridge.
(add-hook 'clisp-hook '(lambda ()
			(add-hook 'ilisp-init-hook
			 '(lambda () (install-bridge)))))

;; Set up bridge properly.
(setq bridge-hook 
      '(lambda ()
	;; Don't insert in source or destination buffer
	(setq bridge-source-insert nil)
	(setq bridge-destination-insert nil)
;;;	(setq bridge-chunk-size 250)
	;; Set up bridge handler
	(setq bridge-handlers
	 '((".*" . catch-lisp-eval)))))

;; Process info that comes to emacs from the bridge.
(defun catch-lisp-eval (process string)
  (if string
      (setq *lisp-eval-buffer* (concat *lisp-eval-buffer* string))
      (let ((buffer (current-buffer))
	    (eval-string *lisp-eval-buffer*))
	(setq *lisp-eval-buffer* "")
	(condition-case err
	    (eval (read eval-string))
	  (error 
	   (with-output-to-temp-buffer "*Ipr-messages*"
	     (print 
	      (format "Bridge Error: %s on eval of: %s" err eval-string)))))
	(set-buffer buffer))))

--------------(End emacs-eval.el)--------------
--------------(Begin emacs-eval.lisp)--------------
(in-package :util)

;; Doesn't bother to check for quotes in a string.
(defun simple-downcase (string)
  (let ((in-string nil) (next nil))
    (dotimes (x (length string))
      (setq next (aref string x))
      (cond ((and (not in-string) (char= next #\"))
	     (setq in-string t))
	    ((and in-string (char= next #\"))
	     (setq in-string nil))
	    ((not in-string)
	     (setf (aref string x) (char-downcase next)))))
    string))

(export 'emacs-eval)

(defvar *message-prefix* (format nil "~a" (character 27)))

(defvar *message-suffix* (format nil "~a" (character 29)))

;; If things stop working, exchange simple-downcase with string-downcase.
(defun emacs-eval (exp)
  "This sends output in a form which will be picked up by the bridge."
  (format t "~a~a~a"
	  *message-prefix*
	  (string-downcase (format nil "~a" exp))
;;	  (simple-downcase (format nil "~a" exp))
	  *message-suffix*))

(export 'quote-string)

(defun quote-string (string)
  (format nil "\"~a\"" string))

--------------(End emacs-eval.lisp)--------------
-- 
Benjamin Shults                 Email:  bshults@math.utexas.edu
Department of Mathematics       Phone:  (512) 471-7711 ext. 208
University of Texas at Austin   WWW:    http://www.ma.utexas.edu/users/bshults
Austin, TX  78712   USA         Office: RLM 10.142