# HG changeset patch
# User YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
# Date 1168848622 0
# Node ID 975531dd9b08f4360ef11c9e300ebd3dd19fff37
# Parent  2855dcf47442f51cfe1fb1135e5769197944988a
(mac-ae-quit-application): New function.
(mac-apple-event-map): Bind "quit application" Apple event to it.

diff -r 2855dcf47442 -r 975531dd9b08 lisp/term/mac-win.el
--- a/lisp/term/mac-win.el	Sun Jan 14 23:17:59 2007 +0000
+++ b/lisp/term/mac-win.el	Mon Jan 15 08:10:22 2007 +0000
@@ -1714,6 +1714,15 @@
 	      nil t)))))
   (select-frame-set-input-focus (selected-frame)))
 
+(defun mac-ae-quit-application (event)
+  "Quit the application Emacs with the Apple event EVENT."
+  (interactive "e")
+  (let ((ae (mac-event-ae event)))
+    (unwind-protect
+	(save-buffers-kill-emacs)
+      ;; Reaches here if the user has canceled the quit.
+      (mac-resume-apple-event ae -128)))) ; userCanceledErr
+
 (defun mac-ae-get-url (event)
   "Open the URL specified by the Apple event EVENT.
 Currently the `mailto' scheme is supported."
@@ -1740,7 +1749,7 @@
   'mac-ae-open-documents)
 (define-key mac-apple-event-map [core-event show-preferences] 'customize)
 (define-key mac-apple-event-map [core-event quit-application]
-  'save-buffers-kill-emacs)
+  'mac-ae-quit-application)
 
 (define-key mac-apple-event-map [internet-event get-url] 'mac-ae-get-url)