CLIM mail archive


Re: accept expressions and eof

  Date: Wed, 3 Nov 93 10:40:20 -0800
  From: Carolyn Banda <>

  (CLIM 1.1, ACL 4.1 on SGI)

  I'm modifying an existing expression using:

      (clim:accept 'expression :stream stream :default default
		    :prompt "Modify expression "
		    :display-default nil
		    :insert-default t)

  - with stream and default bound to appropriate values.

  This works fine most of the time.  However, if I don't type in enough right
  parentheses before hitting return, it breaks with:

  Error: eof encountered on stream #<EXCL::STRING-INPUT-STREAM @ #x11eef38a>
    [condition type: END-OF-FILE]

  My question:  Is there a way to trap this error so that I can prompt the
  user to correct the input by adding more right parens?

This has been recently fixed in Allegro CLIM 2. I've converted part of the
fix for CLIM 1.1 - this code hasn't been tested so the usual caveats apply

Hope this helps

Colin Meldrum, Franz Inc.	1995 University Avenue, Suite 275         
colin@Franz.COM (internet)	Berkeley, CA 94704                       
uunet!franz!colin (uucp)	Phone: (510) 548-3600; FAX: (510) 548-8253

(in-package :clim)

(define-presentation-method accept ((type expression) stream (view textual-view) &key)
  (let ((*read-recursive-objects* nil))
    (with-temporary-string (string)
      (read-recursive stream string nil)
      (when (interactive-stream-p stream)
	(rescan-for-activation stream))
      (multiple-value-bind (expression index)
	      (read-from-string string)
	    (error ()
	      (simple-parse-error "The input ~S is not a complete Lisp expression."
				  (evacuate-temporary-string string))))
	;; Too bad READ-FROM-STRING doesn't take a :JUNK-ALLOWED argument.
	;; Simulate what it would do
	(unless (>= index (length string))
	  (when (find-if-not #'whitespace-char-p string :start index)
	    (simple-parse-error "Extra junk ~S found after the expression."
				(subseq string index))))


Main Index | Thread Index