emacs-devel
[Top][All Lists]
Advanced

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

Re: OS X: using emacs as default mailer?


From: Sean O'Rourke
Subject: Re: OS X: using emacs as default mailer?
Date: Mon, 27 Jun 2005 19:00:16 -0700
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (darwin)

I've got Emacs directly accepting URLs locally, and I've been meaning
to contribute it when I get some time (unless someone beats me to it).
Unfortunately, it's tangled with my local drag-n-drop changes, which
need some work to better cooperate with X DnD.  What you need to do
is:

  * add a CFBundleURLTypes entry to Emacs.app's Info.plist, like so:

        <key>CFBundleURLTypes</key>
        <array>
                <dict>
                        <key>CFBundleURLName</key>
                        <string>Email Address URL</string>
                        <key>CFBundleURLSchemes</key>
                        <array>
                                <string>mailto</string>
                        </array>
                </dict>
              <!-- ... -->
        </array>

  * Handle the 'GURL' event in src/macterm.c (see code at end for an
    example which handles the Mac-specific bits), adding this to
    init_required_apple_events:

      err = AEInstallEventHandler('GURL', 'GURL',
                                  NewAEEventHandlerUPP
                              ((AEEventHandlerProcPtr) do_ae_geturl),
                                  0L, false);


  * As you suggested, go into Mail.app and change your default mail
    application.

You might be able to do this with a shell script or applescript ("on
GetURL do ...", I think) by making it into an app and adding the
appropriate entries to its Info.plist, but I couldn't get that to work
when I tried it before.  Good luck.

/s

static pascal OSErr
do_ae_geturl (const AppleEvent *pAE, AppleEvent *reply, long refcon)
{
  OSErr err;
  AEDesc desc;
  int i, nitems;

  err = AEGetParamDesc (pAE, '----', 'list', &desc);
  if (err != noErr)
    return err;
  err = AECountItems (&desc, &nitems);
  if (err != noErr)
    goto err_count;
  for (i = 1; i <= nitems; i++)
    {
      Size size;
      DescType type;
      Lisp_Object url;
      if (AESizeOfNthItem (&desc, i, &type, &size) != noErr)
        continue;
      url = make_uninit_string (size);
      if (AEGetNthPtr (&desc, i, typeChar, NULL, NULL, SDATA (url), size, NULL)
          != noErr)
        continue;
      mac_add_drag ("url", "open", url);
    }
err_count:
  AEDisposeDesc (&desc);
  return err;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]