]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't open files from Cocoa-parsed command line.
authorJan Djärv <jan.h.d@swipnet.se>
Mon, 30 Jul 2012 20:10:31 +0000 (22:10 +0200)
committerJan Djärv <jan.h.d@swipnet.se>
Mon, 30 Jul 2012 20:10:31 +0000 (22:10 +0200)
--eval '(whatever)' will open '(whatever)' if --eval is the last option.

* src/nsterm.m (ns_do_open_file): New variable.
(ns_term_init): Set ns_do_open_file to NO after run returns.
(openFile, openTempFile, openFileWithoutUI, openFiles): Open
files only if ns_do_open_file.

src/ChangeLog
src/nsterm.m

index 5354c6e29ba7fe6ae76a21f449327810515579a5..a7e6cb52eae5bf96b66212aa5d41dc368ccc587a 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-30  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * nsterm.m (ns_do_open_file): New variable.
+       (ns_term_init): Set ns_do_open_file to NO after run returns.
+       (openFile, openTempFile, openFileWithoutUI, openFiles): Open
+       files only if ns_do_open_file.
+
 2012-07-30  Paul Eggert  <eggert@cs.ucla.edu>
 
        * lisp.h (SWITCH_ENUM_CAST): Remove.  All uses removed.
index 1f06d49c5b9d6b4585f3334869d178ba310b41a4..4e181e9d1d28243121cf0d0d9bde2060629cb432 100644 (file)
@@ -195,6 +195,7 @@ static int n_emacs_events_pending = 0;
 static NSMutableArray *ns_pending_files, *ns_pending_service_names,
   *ns_pending_service_args;
 static BOOL inNsSelect = 0;
+static BOOL ns_do_open_file = NO;
 
 /* Convert modifiers in a NeXTstep event to emacs style modifiers.  */
 #define NS_FUNCTION_KEY_MASK 0x800000
@@ -4025,7 +4026,7 @@ ns_term_init (Lisp_Object display_name)
   ns_pending_service_names = [[NSMutableArray alloc] init];
   ns_pending_service_args = [[NSMutableArray alloc] init];
 
-  /* Start app and create the main menu, window, view.
+/* Start app and create the main menu, window, view.
      Needs to be here because ns_initialize_display_info () uses AppKit classes.
      The view will then ask the NSApp to stop and return to Emacs. */
   [EmacsApp sharedApplication];
@@ -4205,7 +4206,7 @@ ns_term_init (Lisp_Object display_name)
 #endif /* MAC OS X menu setup */
 
   [NSApp run];
-
+  ns_do_open_file = YES;
   return dpyinfo;
 }
 
@@ -4446,7 +4447,8 @@ ns_term_shutdown (int sig)
 /*   Notification from the Workspace to open a file */
 - (BOOL)application: sender openFile: (NSString *)file
 {
-  [ns_pending_files addObject: file];
+  if (ns_do_open_file)
+    [ns_pending_files addObject: file];
   return YES;
 }
 
@@ -4454,7 +4456,8 @@ ns_term_shutdown (int sig)
 /*   Open a file as a temporary file */
 - (BOOL)application: sender openTempFile: (NSString *)file
 {
-  [ns_pending_files addObject: file];
+  if (ns_do_open_file)
+    [ns_pending_files addObject: file];
   return YES;
 }
 
@@ -4462,7 +4465,8 @@ ns_term_shutdown (int sig)
 /*   Notification from the Workspace to open a file noninteractively (?) */
 - (BOOL)application: sender openFileWithoutUI: (NSString *)file
 {
-  [ns_pending_files addObject: file];
+  if (ns_do_open_file)
+    [ns_pending_files addObject: file];
   return YES;
 }
 
@@ -4470,11 +4474,17 @@ ns_term_shutdown (int sig)
 /*   Notification from the Workspace to open multiple files */
 - (void)application: sender openFiles: (NSArray *)fileList
 {
-  NSEnumerator *files = [fileList objectEnumerator];
-  NSString *file;
-  while ((file = [files nextObject]) != nil)
-    [ns_pending_files addObject: file];
-
+  /* Don't open files from the command line, Cocoa parses the command line
+     wrong anyway, --option value tries to open value if --option is the last
+     option.  */
+  if (ns_ignore_open_file)
+    {
+      NSEnumerator *files = [fileList objectEnumerator];
+      NSString *file;
+      while ((file = [files nextObject]) != nil)
+        [ns_pending_files addObject: file];
+    }
+  
   [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
 
 }