[plt-scheme] obtaining list of opened files in DrScheme

From: pedro pinto (pedro.e.pinto at gmail.com)
Date: Fri Oct 13 11:30:24 EDT 2006

I finally had some time to dedicate to this. You are right there are
problems under Windows. Try this: on DrScheme, on Windows XP, open the
same file twice. Instead of reusing the already opened frame DrScheme
opens a new frame each time. The problem lies in the definition of
`pathname-equal?' in unit.ss which is used to determine if the loaded
file in the tab is the same one we are trying to open. Here is the

 (define/private (pathname-equal? p1 p2)
   (with-handlers ([exn:fail:filesystem? (lambda (x) #f)])
      (string=? (path->string (normalize-path p1))
            (path->string (normalize-path p2)))))

The issue is the case insensitive comparison. On Windows case is not
significant for file names. The buffer name retrieved from the frame
is always downcased while the one freshly retrieved from the file
system is not. So we have false negatives. Ironically the docs for
`normalize-path' warn against this exact problem:

"Letter case is not normalized by normalize-path. For this and other
 reasons, the result of normalize-path is not suitable for comparisons
 that determine whether two paths refer to the same file (i.e., the
 comparison may produce false negatives)."

Normalizing the case seems to take care of the problem:

  (define/private (pathname-equal? p1 p2)
    (with-handlers ([exn:fail:filesystem? (? (x) #f)])
       (string=? (path->string (normal-case-path (normalize-path p1)))
                 (path->string (normal-case-path (normalize-path p2))))))


On 10/8/06, Robby Findler <robby at cs.uchicago.edu> wrote:
> handler:edit-file should just bring the appropriate frame/tab to the
> front when the file is already open for editing. There have been
> problems with path comparisons in the past, however (especially with
> some of the strange things that can happen under windows). Maybe you're
> running into that?
> If you want to see, try adding some printouts in the locate-file method
> in group.ss.
> Robby
> At Sat, 7 Oct 2006 21:39:08 -0500, "pedro pinto" wrote:
> > handler:edit-file seems to either always open a new frame or always load
> the
> > file in the current frame depending on the user preferences. What I want
> is
> > to bring to the front the frame that has the file already loaded. Is
> there a
> > way do to that?
> >
> > TIA,
> > -pp
> >
> >
> >
> > On 10/4/06, Robby Findler <robby at cs.uchicago.edu> wrote:
> >
> >  [...]
> >
> > To actually bring a different file to be editing, use handler:edit-file.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20061013/1cb80e6f/attachment.html>

Posted on the users mailing list.