Sorry. Let me be more clear (or at least more specific).
I have an application that is an MDP (Markov Decision Problem)
solver.
I have a command that loads a file with an MDP description in it.
So I want to ACCEPT a pathname that corresponds to an existing MDP
description file. So I want ACCEPT to reject any pathname that
doesn't (at least) correspond to a file that really exists.
It's a bit of a nuisance, when I use the current UI (which doesn't
enforce file existence), to type in a filename, find out that I
mistyped, and then have to start over. I would prefer to have ACCEPT
help me out by rejecting my input and allowing me to revise it.
Does that help?
The best test example I could find was the following:
(in-package :CLIM-USER)
;;; this stuff doesn't work as well as I would like, unfortunately. [2005/08/10:rpg]
(define-presentation-type extant-pathname ()
:inherit-from 'pathname)
(define-presentation-method presentation-typep (object (type extant-pathname))
(and (presentation-typep object 'pathname)
(probe-file object)))
(define-presentation-method accept ((type extant-pathname) stream view &rest args &key)
(let ((raw-value (call-next-method)))
(when (probe-file raw-value)
(return-from accept (values raw-value 'extant-pathname)))
(format stream "~&No directory entry for ~A ~%" raw-value)
(apply #'accept type :stream stream :view view args)))
But when I try to do this, and type in a pathname that does not
correspond to an extant file, it seems to return some odd default.
McCLIM correctly rejects the bad value, and prints my format string,
but instead of giving me a chance to enter a good value, it just
returns the current working directory! (I'd show the results, but I
tested in the clim-listener, whence I cannot cut-and-paste :-/).
I'm hoping that I've just done something dopey here, and that's why
this doesn't work.
[BTW, I was poking around at the CLIMACS code base to see if I could
pull out a completing-pathname type, but I thought I would see if I
could get the existence constraint to work first...]