unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* OS X: using emacs as default mailer?
@ 2005-06-28  0:30 John Owens
  2005-06-28  2:00 ` Sean O'Rourke
  2005-06-29 10:55 ` YAMAMOTO Mitsuharu
  0 siblings, 2 replies; 8+ messages in thread
From: John Owens @ 2005-06-28  0:30 UTC (permalink / raw)


I'd like to use emacs as my default mailer in OS X. When I click on a mailto:
link, I'd like gnuclient to call compose-mail. I have this working manually
from the command line no problem. What I believe I need to do is to run
OS X's Mail.app and then select the default mailer within the preferences.
However, a small shell script I wrote to call gnuclient does NOT appear
(or rather, it's greyed out, not valid) in the select-a-new-application
dialog that allows me to select a new app default. Surely this is a
problem others have run into ... any advice would be appreciated on
what sort of app would work.

(One suggestion: http://sourceforge.net/projects/mailtomutt , but that's
pretty mutt-specific.)

JDO

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  0:30 OS X: using emacs as default mailer? John Owens
@ 2005-06-28  2:00 ` Sean O'Rourke
  2005-06-28  3:51   ` John Owens
                     ` (2 more replies)
  2005-06-29 10:55 ` YAMAMOTO Mitsuharu
  1 sibling, 3 replies; 8+ messages in thread
From: Sean O'Rourke @ 2005-06-28  2:00 UTC (permalink / raw)


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;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  2:00 ` Sean O'Rourke
@ 2005-06-28  3:51   ` John Owens
  2005-06-28  5:43     ` Sean O'Rourke
  2005-06-28  5:47     ` Sean O'Rourke
  2005-06-28  5:19   ` John Owens
  2005-11-30  9:54   ` YAMAMOTO Mitsuharu
  2 siblings, 2 replies; 8+ messages in thread
From: John Owens @ 2005-06-28  3:51 UTC (permalink / raw)


Sean O'Rourke <sorourke <at> cs.ucsd.edu> writes:
>       mac_add_drag ("url", "open", url);

This whole post was spot-on except for this call above.
I am presuming it relates to your drag-and-drop ... can it
be safely deleted if I'm neither dragging nor dropping?

JDO

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  2:00 ` Sean O'Rourke
  2005-06-28  3:51   ` John Owens
@ 2005-06-28  5:19   ` John Owens
  2005-11-30  9:54   ` YAMAMOTO Mitsuharu
  2 siblings, 0 replies; 8+ messages in thread
From: John Owens @ 2005-06-28  5:19 UTC (permalink / raw)


Sean O'Rourke <sorourke <at> cs.ucsd.edu> writes:

> 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).

And how might I persuade emacs to call a specific function when
it's url'ed e.g. compose-mail (with proper argument)?

JDO

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  3:51   ` John Owens
@ 2005-06-28  5:43     ` Sean O'Rourke
  2005-06-28  5:47     ` Sean O'Rourke
  1 sibling, 0 replies; 8+ messages in thread
From: Sean O'Rourke @ 2005-06-28  5:43 UTC (permalink / raw)


John Owens <john_owens@yahoo.com> writes:

> Sean O'Rourke <sorourke <at> cs.ucsd.edu> writes:
>>       mac_add_drag ("url", "open", url);
>
> This whole post was spot-on except for this call above.
> I am presuming it relates to your drag-and-drop ... can it
> be safely deleted if I'm neither dragging nor dropping?

Unfortunately no, since the way I got this to work was by going
through the drag-n-drop machinery and treating the GURL event as a
dropped URL.  Once it gets to the dnd functions (dnd.el) as a
"mailto:" url, you can then add a mail handler to your
browse-url-browser-function alist (or let w3m-browse-url do the right
thing).  Sorry this is so sketchy -- I'll try to make a cleaned-up
patch for it (both DnD and mailto: handling) soonish.

/s

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  3:51   ` John Owens
  2005-06-28  5:43     ` Sean O'Rourke
@ 2005-06-28  5:47     ` Sean O'Rourke
  1 sibling, 0 replies; 8+ messages in thread
From: Sean O'Rourke @ 2005-06-28  5:47 UTC (permalink / raw)


John Owens <john_owens@yahoo.com> writes:

> Sean O'Rourke <sorourke <at> cs.ucsd.edu> writes:
>>       mac_add_drag ("url", "open", url);
>
> This whole post was spot-on except for this call above.
> I am presuming it relates to your drag-and-drop ... can it
> be safely deleted if I'm neither dragging nor dropping?

Unfortunately no, since the way I got this to work was by going
through the drag-n-drop machinery and treating the GURL event as a
dropped URL.  Once it gets to the dnd functions (dnd.el) as a
"mailto:" url, you can then add a mail handler to your
browse-url-browser-function alist (or let w3m-browse-url do the right
thing).  Sorry this is so sketchy -- I'll try to make a cleaned-up
patch for it (both DnD and mailto: handling) soonish.

/s

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  0:30 OS X: using emacs as default mailer? John Owens
  2005-06-28  2:00 ` Sean O'Rourke
@ 2005-06-29 10:55 ` YAMAMOTO Mitsuharu
  1 sibling, 0 replies; 8+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-06-29 10:55 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> On Tue, 28 Jun 2005 00:30:45 +0000 (UTC), John Owens <john_owens@yahoo.com> said:

> I'd like to use emacs as my default mailer in OS X. When I click on
> a mailto: link, I'd like gnuclient to call compose-mail.

Handling an apple event is already shown, so here's an alternative way
using the "Services" menu.  Unfortunately it is not as easy as
clicking a mailto: link.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

Index: lisp/term/mac-win.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/mac-win.el,v
retrieving revision 1.47
diff -c -r1.47 mac-win.el
*** lisp/term/mac-win.el	16 May 2005 11:27:56 -0000	1.47
--- lisp/term/mac-win.el	29 Jun 2005 10:36:09 -0000
***************
*** 1377,1382 ****
--- 1377,1393 ----
    (save-buffer) ; It pops up the save dialog.
    )
  
+ (defun mac-services-mail-selection ()
+   (interactive)
+   (compose-mail)
+   (rfc822-goto-eoh)
+   (forward-line 1)
+   (insert (x-selection-value mac-services-selection) "\n"))
+ 
+ (defun mac-services-mail-to ()
+   (interactive)
+   (compose-mail (x-selection-value mac-services-selection)))
+ 
  (defun mac-services-insert-text ()
    (interactive)
    (let ((text (x-selection-value mac-services-selection)))
***************
*** 1393,1398 ****
--- 1404,1413 ----
    'mac-services-open-file)
  (define-key mac-application-menu-map [services perform open-selection]
    'mac-services-open-selection)
+ (define-key mac-application-menu-map [services perform mail-selection]
+   'mac-services-mail-selection)
+ (define-key mac-application-menu-map [services perform mail-to]
+   'mac-services-mail-to)
  (define-key mac-application-menu-map [services paste]
    'mac-services-insert-text)
  (define-key mac-application-menu-map [preferences] 'customize)
Index: mac/Emacs.app/Contents/Info.plist
===================================================================
RCS file: /cvsroot/emacs/emacs/mac/Emacs.app/Contents/Info.plist,v
retrieving revision 1.5
diff -c -r1.5 Info.plist
*** mac/Emacs.app/Contents/Info.plist	24 Apr 2005 06:00:57 -0000	1.5
--- mac/Emacs.app/Contents/Info.plist	29 Jun 2005 10:36:09 -0000
***************
*** 75,80 ****
--- 75,118 ----
  				<string>NSStringPboardType</string>
  			</array>
  		</dict>
+ 		<dict>
+ 			<key>NSKeyEquivalent</key>
+ 			<dict/>
+ 			<key>NSMenuItem</key>
+ 			<dict>
+ 				<key>default</key>
+ 				<string>Emacs/Send Selection</string>
+ 			</dict>
+ 			<key>NSMessage</key>
+ 			<string>mail-selection</string>
+ 			<key>NSPortName</key>
+ 			<string>Emacs</string>
+ 			<key>NSReturnTypes</key>
+ 			<array/>
+ 			<key>NSSendTypes</key>
+ 			<array>
+ 				<string>NSStringPboardType</string>
+ 			</array>
+ 		</dict>
+ 		<dict>
+ 			<key>NSKeyEquivalent</key>
+ 			<dict/>
+ 			<key>NSMenuItem</key>
+ 			<dict>
+ 				<key>default</key>
+ 				<string>Emacs/Send To</string>
+ 			</dict>
+ 			<key>NSMessage</key>
+ 			<string>mail-to</string>
+ 			<key>NSPortName</key>
+ 			<string>Emacs</string>
+ 			<key>NSReturnTypes</key>
+ 			<array/>
+ 			<key>NSSendTypes</key>
+ 			<array>
+ 				<string>NSStringPboardType</string>
+ 			</array>
+ 		</dict>
  	</array>
  </dict>
  </plist>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OS X: using emacs as default mailer?
  2005-06-28  2:00 ` Sean O'Rourke
  2005-06-28  3:51   ` John Owens
  2005-06-28  5:19   ` John Owens
@ 2005-11-30  9:54   ` YAMAMOTO Mitsuharu
  2 siblings, 0 replies; 8+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-11-30  9:54 UTC (permalink / raw)
  Cc: John Owens, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

>>>>> On Mon, 27 Jun 2005 19:00:16 -0700, "Sean O'Rourke" <sorourke@cs.ucsd.edu> said:

> 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.

How about the attached patch?  It enables us to register Apple event
handlers at the Lisp level as follows: (the code is included in the
patch)

  (put 'internet-event 'mac-apple-event-class "GURL")
  (put 'get-url        'mac-apple-event-id    "GURL")

  (defun mac-ae-get-url (event)
    (interactive "e")
    (let* ((ae (mac-event-ae event))
	   (parsed-url (url-generic-parse-url (mac-ae-text ae))))
      (if (string= (url-type parsed-url) "mailto")
	  (url-mailto parsed-url)
        (error "Unsupported URL scheme: %s" (url-type parsed-url)))))

  (define-key mac-apple-event-map [internet-event get-url] 'mac-ae-get-url)

Then Emacs can receive kAEInternetEventClass/kAEGetURL Apple events as
in the following form, and it is handled by the command
`mac-ae-get-url' above.

  (mac-apple-event [internet-event get-url] ("aevt" ("----" "TEXT" . "mailto:mituharu@math.s.chiba-u.ac.jp?In-Reply-To=wl8y0tjuti.wl%25mituharu%40math.s.chiba-u.ac.jp&Subject=Re%3A%20OS%20X%3A%20using%20emacs%20as%20default%20mailer%3F")))

The patch is also trying to avoid Lisp object allocations (with
respect to Apple events) during asynchronous input handling.

  http://lists.gnu.org/archive/html/emacs-devel/2005-11/msg01457.html

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

[-- Attachment #2: diff-apple-events.gz --]
[-- Type: application/octet-stream, Size: 7668 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-30  9:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-28  0:30 OS X: using emacs as default mailer? John Owens
2005-06-28  2:00 ` Sean O'Rourke
2005-06-28  3:51   ` John Owens
2005-06-28  5:43     ` Sean O'Rourke
2005-06-28  5:47     ` Sean O'Rourke
2005-06-28  5:19   ` John Owens
2005-11-30  9:54   ` YAMAMOTO Mitsuharu
2005-06-29 10:55 ` YAMAMOTO Mitsuharu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).