emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109304: Don't open files from Cocoa-


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109304: Don't open files from Cocoa-parsed command line.
Date: Mon, 30 Jul 2012 22:10:31 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109304
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Mon 2012-07-30 22:10:31 +0200
message:
  Don't open files from Cocoa-parsed command line.
  
  --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.
modified:
  src/ChangeLog
  src/nsterm.m
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-30 18:56:42 +0000
+++ b/src/ChangeLog     2012-07-30 20:10:31 +0000
@@ -1,3 +1,10 @@
+2012-07-30  Jan Djärv  <address@hidden>
+
+       * 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  <address@hidden>
 
        * lisp.h (SWITCH_ENUM_CAST): Remove.  All uses removed.

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2012-07-25 17:31:34 +0000
+++ b/src/nsterm.m      2012-07-30 20:10:31 +0000
@@ -195,6 +195,7 @@
 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_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 @@
 #endif /* MAC OS X menu setup */
 
   [NSApp run];
-
+  ns_do_open_file = YES;
   return dpyinfo;
 }
 
@@ -4446,7 +4447,8 @@
 /*   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 @@
 /*   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 @@
 /*   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 @@
 /*   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];
 
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]