[racket] application-file-handler problem on OS X

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Sep 9 10:56:03 EDT 2011

Command-line treatment of startup files on Mac OS X was a casualty of
the v5.1 GUI rewrite. Unfortunately, I don't see a way to get startup
files into the command line with the current implementation. I'll have
to fix the docs, but also add something new to recover the startup-file

How about a new `application-started-empty-handler' parameter for a
function that is called only when the `application-file-handler'
function *isn't* going to be called for startup files. That doesn't
quite give you the same information as before (because it doesn't tell
you which files were for startup and which were sent later), but it
fits into the current implementation easily, and I think it gives your
application the information it needs.

At Fri, 09 Sep 2011 12:35:41 +0100, Erich Rast wrote:
> Hi all,
> I have a problem getting application-file-handler to work as I would
> have expected on OS X 10.7 ("Lion"). This seems to be a bug/misfeature.
> The problem is that when a file of the right file type is opened by
> double-clicking it in the Finder, the application does not receive it as
> a command line argument but instead application-file-handler is called
> much later. Consequently, I cannot reliably detect whether a file has
> been provided or not during application startup; my default handler
> (open new document) is called and only afterward the
> application-file-handler is triggered.
> The only workaround I can think of right now is to delay the default
> handler for several seconds and use a global flag/parameter to check
> whether some files have been opened. However, this would unnecessarily
> increase ordinary application startup time.
> Does anyone have a better suggestion? Is this a bug/misfeature? Is there
> a way to test for available files during application start before
> application-file-handler is called? 
> Best,
> Erich

Posted on the users mailing list.