Skip to content

Instantly share code, notes, and snippets.

@amuramatsu
Created January 5, 2019 13:46
Show Gist options
  • Save amuramatsu/be816bfc4dd15bc5cc098d1c115a3ced to your computer and use it in GitHub Desktop.
Save amuramatsu/be816bfc4dd15bc5cc098d1c115a3ced to your computer and use it in GitHub Desktop.
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el
index de87bc4ba7..c99ebdfcd0 100644
--- a/lisp/term/mac-win.el
+++ b/lisp/term/mac-win.el
@@ -996,6 +996,7 @@ mac-startup-options
(put 'core-event 'mac-apple-event-class "aevt") ; kCoreEventClass
(put 'internet-event 'mac-apple-event-class "GURL") ; kAEInternetEventClass
(put 'odb-editor-suite 'mac-apple-event-class "R*ch") ; kODBEditorSuite
+(put 'emp-event 'mac-apple-event-class "EMAx") ; kEmacsMacPortEventClass
;;; Event IDs
;; kCoreEventClass
@@ -1014,6 +1015,8 @@ mac-startup-options
;; kODBEditorSuite
(put 'modified-file 'mac-apple-event-id "FMod") ; kAEModifiedFile
(put 'closed-file 'mac-apple-event-id "FCls") ; kAEClosedFile
+;; kEmacsMacPortEventClass
+(put 'new-frame 'mac-apple-event-id "NWfw") ; kAENewFrame
(defmacro mac-event-spec (event)
`(nth 1 ,event))
@@ -1411,6 +1414,7 @@ mac-apple-event-map
(define-key mac-apple-event-map [core-event quit-application]
'mac-ae-quit-application)
(define-key mac-apple-event-map [core-event answer] 'mac-ae-answer)
+(define-key mac-apple-event-map [emp-event new-frame] 'make-frame)
(define-key mac-apple-event-map [internet-event get-url] 'mac-ae-get-url)
diff --git a/src/macappkit.m b/src/macappkit.m
index c0291400e6..82fd17e928 100644
--- a/src/macappkit.m
+++ b/src/macappkit.m
@@ -41,6 +41,9 @@
#import "macappkit.h"
#import <objc/runtime.h>
+#define kEmacsMacPortEventClass 'EMAx'
+#define kAENewFrame 'NWfw'
+
#if USE_ARC
#define MRC_RETAIN(receiver) ((id) (receiver))
#define MRC_RELEASE(receiver)
@@ -1265,6 +1268,23 @@ - (void)setMainMenu:(NSMenu *)mainMenu
}
}
+- (void)newFrame: (id)sender
+{
+ OSErr err;
+ NSAppleEventManager *manager = [NSAppleEventManager sharedAppleEventManager];
+ AppleEvent appleEvent, reply;
+
+ err = create_apple_event (kEmacsMacPortEventClass, kAENewFrame, &appleEvent);
+ if (err == noErr)
+ {
+ AEInitializeDesc (&reply);
+ [manager dispatchRawAppleEvent:&appleEvent withRawReply:&reply
+ handlerRefCon:0];
+ AEDisposeDesc (&reply);
+ AEDisposeDesc (&appleEvent);
+ }
+}
+
@end // EmacsApplication
@implementation EmacsController
@@ -11085,7 +11105,9 @@ - (NSMenu *)applicationDockMenu:(NSApplication *)sender
[menu addItem:item];
MRC_RELEASE (item);
}
-
+ [menu addItemWithTitle: @"New Frame"
+ action: @selector (newFrame:)
+ keyEquivalent: @""];
return MRC_AUTORELEASE (menu);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment