changeset 70870:e5af358ce93a

Set idle timer to clean up expired Apple events. (mac-ae-get-url): Redispatch Apple event on unknown scheme. (mac-dispatch-apple-event): Resume Apple event if it is suspended. Optionally set error message in reply.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Wed, 24 May 2006 08:06:27 +0000
parents 7e291c130ae7
children 815f914dcf9b
files lisp/term/mac-win.el
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/term/mac-win.el	Wed May 24 07:57:00 2006 +0000
+++ b/lisp/term/mac-win.el	Wed May 24 08:06:27 2006 +0000
@@ -1649,7 +1649,7 @@
 	 (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)))))
+      (mac-resume-apple-event ae t))))
 
 (setq mac-apple-event-map (make-sparse-keymap))
 
@@ -1800,9 +1800,9 @@
   "Dispatch EVENT according to the keymap `mac-apple-event-map'."
   (interactive "e")
   (let* ((binding (lookup-key mac-apple-event-map (mac-event-spec event)))
-	 (service-message
-	  (and (keymapp binding)
-	       (cdr (mac-ae-parameter (mac-event-ae event) "svmg")))))
+	 (ae (mac-event-ae event))
+	 (service-message (and (keymapp binding)
+			       (cdr (mac-ae-parameter ae "svmg")))))
     (when service-message
       (setq service-message
 	    (intern (decode-coding-string service-message 'utf-8)))
@@ -1810,7 +1810,16 @@
     ;; Replace (cadr event) with a dummy position so that event-start
     ;; returns it.
     (setcar (cdr event) (list (selected-window) (point) '(0 . 0) 0))
-    (call-interactively binding)))
+    (if (null (mac-ae-parameter ae 'emacs-suspension-id))
+	(call-interactively binding)
+      (condition-case err
+	  (progn
+	    (call-interactively binding)
+	    (mac-resume-apple-event ae))
+	(error
+	 (mac-ae-set-reply-parameter ae "errs"
+				     (cons "TEXT" (error-message-string err)))
+	 (mac-resume-apple-event ae -10000)))))) ; errAEEventFailed
 
 (global-set-key [mac-apple-event] 'mac-dispatch-apple-event)
 
@@ -1820,6 +1829,8 @@
 ;; the files should be opened.
 (add-hook 'after-init-hook 'mac-process-deferred-apple-events)
 
+(run-with-idle-timer 5 t 'mac-cleanup-expired-apple-events)
+
 
 ;;;; Drag and drop