[plt-dev] searching for bitmap% via f1 on mac os x

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Feb 28 09:42:28 EST 2009

On Feb 28, Thomas Chust wrote:
> 2009-02-28 Eli Barzilay <eli at barzilay.org>:
> > On Feb 28, Thomas Chust wrote:
> >> [...]
> >> out of curiosity: Is there any particular reason why PLT Scheme
> >> doesn't use the LaunchServices API to open the URL instead of
> >> executing an external command?
> >
> > Much easier to implement, and extremely negligible cost (compared to
> > starting your browser and making it render a documentation page).
> > [...]
> Hello,
> using LaunchServices, you would need exactly two C API calls: One to
> create the URL object
> (http://developer.apple.com/documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html#//apple_ref/c/func/CFURLCreateWithBytes)
> and one to open the URL
> (http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html#//apple_ref/c/func/LSOpenCFURLRef)

???  On a very brief look, I need to read about and represent
`CFURLRef', `CFAllocatorRef', `CFIndex', and `CFStringEncoding'.  IMO
this is significantly more complex than "run an osascript command and
plug the url here".

> -- this is hardly more complicated to implement than creating a
> command line with proper escaping and launching an external program.

These needs to be done in any case.

> You are right, though, that the cost is negligible and as long as it
> works correctly nobody cares about the implementation. I was just
> curious why the special OS API is used to open URLs on Windows but
> not on MacOS X.

That's easy: `shell-execute' on Windows is not one random function, it
is a generic way to "start stuff", so it's part of mred.  But you
really don't want to know about Windows problems (see the comments if
you're tempted).

> Using a C API directly often saves you from nasty shell quoting
> issues and the problem described by the OP looked to me like it
> could have been such an issue.

Since this is about the 4th time I'm saying this, I'll try to be very

* osascript is invoked directly -- there are no nasty shell quoting
  issues.  (The only issue about that is tcsh being the default shell,
  which leads to such discussions in irrelevant directions.)

* Assuming that osascript is doing a simple call for the same
  functions, I wouldn't be surprised if the exact same problem is
  still there.  (Possibly less obscure, but possibly manifested as a

> However, since the further discussion in this thread showed that the
> problem is probably not PLT Scheme's fault, it is questionable
> whether using the C API would make the problem go away.
> Unfortunately I can't boot my installation of MacOS X at the moment
> to give it a try :-(

BTW, I'm not using OSX, so I personally can't do anything about this.
I think that there will not be much objection to writing this code to
use the osx api -- but this kind of a change will need to be tested
very thoroughly, since it is doing a rather important job.

Actually, the last part is another argument for osascript -- using the
"invoke it this way" interface is (IMO) much less likely to change
than the C api.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the dev mailing list.