+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.
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
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];
#endif /* MAC OS X menu setup */
[NSApp run];
-
+ ns_do_open_file = YES;
return dpyinfo;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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];
}