CLIM mail archive

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

Dumb question on presentation options w/ completion presentation type



    Date: Fri, 29 May 1992 14:38+0200
    From: Curt Eggemeyer <unido!eraserhead.jpl.nasa.gov!curt>

    How do I utilize presentation options with the completion presentation type?
    The doc. excels at providing nil example on this and the explanation leaves
    me scratching my head.
 
    I have instances of objects that have their own present & accept methods and
    I can't seem to get them to present themselves in a manner different from the
    standard lisp princ form of an instance for the completion presentation type.  Ie:

    (accept (list 'completion A-LIST-OF-FIVE-INSTANCES) :stream *my-stream*
		    :prompt "WHICH ONE")

    If you hit help key <c-?> in the interactor pane invoking this accept you get
    something like:

    WHICH ONE:
    #<instance-1 @ #x2389732>
    #<instance-2 @ #x2383682>
    #<instance-3 @ #x2463532>
    #<instance-4 @ #x2382873>
    #<instance-5 @ #x2272732>

    If I have a function that does a present-to-string such as:

    (defun present-my-instance (a) (present-to-string a 'my-instance-type))

    I tried:

    (accept (list (list 'completion A-LIST-OF-FIVE-INSTANCES)
	    :name-key #'present-my-instance) :stream *my-stream*
	    :prompt "WHICH ONE")

    And I get the same results@^&$%@&?  What am I missing?

Maybe you forgot to provide a PRESENT method to your presentation type?
Anyway, the following works for me (in CLIM 1.1, contact Symbolics Software Service
how to get it if you don't have it already)
;;; -*- Mode: LISP; Package: CLIM-USER -*-

(defclass foo () ((n :initarg :n)))

(defvar *five-foos* (loop for n from 1 to 5 collect (make-instance 'foo :n n)))

(define-presentation-method present (object (type foo) stream (view T) &key)
  (format stream "FOO ~A" (slot-value object 'n)))

(accept `((completion ,*five-foos*)
	  :name-key ,#'(lambda (object)
			 (format NIL "FOO ~A" (slot-value object 'n)))))

(accept `((completion ,*five-foos*)
	  :name-key ,#'present-to-string))

Markus Fischer, MF@SGER.UUCP              Mergenthaler Allee 77-81
Consulting Services                       W-6236 Eschborn, Germany
Symbolics Systemhaus GmbH                 Phone: +49 6196 47220, Fax 481116


References:

Main Index | Thread Index