diff options
| author | Jan Djärv | 2012-07-30 22:10:31 +0200 |
|---|---|---|
| committer | Jan Djärv | 2012-07-30 22:10:31 +0200 |
| commit | adff3182ba51523423ce15cf26347c2b8b130826 (patch) | |
| tree | 1c252b9524f2fe920ce92b733072aca917ffb4a3 /src | |
| parent | 1f45e27eb651f5d13d83b1916470fc32fc8769ab (diff) | |
| download | emacs-adff3182ba51523423ce15cf26347c2b8b130826.tar.gz emacs-adff3182ba51523423ce15cf26347c2b8b130826.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/nsterm.m | 30 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5354c6e29ba..a7e6cb52eae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-07-30 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsterm.m (ns_do_open_file): New variable. | ||
| 4 | (ns_term_init): Set ns_do_open_file to NO after run returns. | ||
| 5 | (openFile, openTempFile, openFileWithoutUI, openFiles): Open | ||
| 6 | files only if ns_do_open_file. | ||
| 7 | |||
| 1 | 2012-07-30 Paul Eggert <eggert@cs.ucla.edu> | 8 | 2012-07-30 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 9 | ||
| 3 | * lisp.h (SWITCH_ENUM_CAST): Remove. All uses removed. | 10 | * lisp.h (SWITCH_ENUM_CAST): Remove. All uses removed. |
diff --git a/src/nsterm.m b/src/nsterm.m index 1f06d49c5b9..4e181e9d1d2 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -195,6 +195,7 @@ static int n_emacs_events_pending = 0; | |||
| 195 | static NSMutableArray *ns_pending_files, *ns_pending_service_names, | 195 | static NSMutableArray *ns_pending_files, *ns_pending_service_names, |
| 196 | *ns_pending_service_args; | 196 | *ns_pending_service_args; |
| 197 | static BOOL inNsSelect = 0; | 197 | static BOOL inNsSelect = 0; |
| 198 | static BOOL ns_do_open_file = NO; | ||
| 198 | 199 | ||
| 199 | /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ | 200 | /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ |
| 200 | #define NS_FUNCTION_KEY_MASK 0x800000 | 201 | #define NS_FUNCTION_KEY_MASK 0x800000 |
| @@ -4025,7 +4026,7 @@ ns_term_init (Lisp_Object display_name) | |||
| 4025 | ns_pending_service_names = [[NSMutableArray alloc] init]; | 4026 | ns_pending_service_names = [[NSMutableArray alloc] init]; |
| 4026 | ns_pending_service_args = [[NSMutableArray alloc] init]; | 4027 | ns_pending_service_args = [[NSMutableArray alloc] init]; |
| 4027 | 4028 | ||
| 4028 | /* Start app and create the main menu, window, view. | 4029 | /* Start app and create the main menu, window, view. |
| 4029 | Needs to be here because ns_initialize_display_info () uses AppKit classes. | 4030 | Needs to be here because ns_initialize_display_info () uses AppKit classes. |
| 4030 | The view will then ask the NSApp to stop and return to Emacs. */ | 4031 | The view will then ask the NSApp to stop and return to Emacs. */ |
| 4031 | [EmacsApp sharedApplication]; | 4032 | [EmacsApp sharedApplication]; |
| @@ -4205,7 +4206,7 @@ ns_term_init (Lisp_Object display_name) | |||
| 4205 | #endif /* MAC OS X menu setup */ | 4206 | #endif /* MAC OS X menu setup */ |
| 4206 | 4207 | ||
| 4207 | [NSApp run]; | 4208 | [NSApp run]; |
| 4208 | 4209 | ns_do_open_file = YES; | |
| 4209 | return dpyinfo; | 4210 | return dpyinfo; |
| 4210 | } | 4211 | } |
| 4211 | 4212 | ||
| @@ -4446,7 +4447,8 @@ ns_term_shutdown (int sig) | |||
| 4446 | /* Notification from the Workspace to open a file */ | 4447 | /* Notification from the Workspace to open a file */ |
| 4447 | - (BOOL)application: sender openFile: (NSString *)file | 4448 | - (BOOL)application: sender openFile: (NSString *)file |
| 4448 | { | 4449 | { |
| 4449 | [ns_pending_files addObject: file]; | 4450 | if (ns_do_open_file) |
| 4451 | [ns_pending_files addObject: file]; | ||
| 4450 | return YES; | 4452 | return YES; |
| 4451 | } | 4453 | } |
| 4452 | 4454 | ||
| @@ -4454,7 +4456,8 @@ ns_term_shutdown (int sig) | |||
| 4454 | /* Open a file as a temporary file */ | 4456 | /* Open a file as a temporary file */ |
| 4455 | - (BOOL)application: sender openTempFile: (NSString *)file | 4457 | - (BOOL)application: sender openTempFile: (NSString *)file |
| 4456 | { | 4458 | { |
| 4457 | [ns_pending_files addObject: file]; | 4459 | if (ns_do_open_file) |
| 4460 | [ns_pending_files addObject: file]; | ||
| 4458 | return YES; | 4461 | return YES; |
| 4459 | } | 4462 | } |
| 4460 | 4463 | ||
| @@ -4462,7 +4465,8 @@ ns_term_shutdown (int sig) | |||
| 4462 | /* Notification from the Workspace to open a file noninteractively (?) */ | 4465 | /* Notification from the Workspace to open a file noninteractively (?) */ |
| 4463 | - (BOOL)application: sender openFileWithoutUI: (NSString *)file | 4466 | - (BOOL)application: sender openFileWithoutUI: (NSString *)file |
| 4464 | { | 4467 | { |
| 4465 | [ns_pending_files addObject: file]; | 4468 | if (ns_do_open_file) |
| 4469 | [ns_pending_files addObject: file]; | ||
| 4466 | return YES; | 4470 | return YES; |
| 4467 | } | 4471 | } |
| 4468 | 4472 | ||
| @@ -4470,11 +4474,17 @@ ns_term_shutdown (int sig) | |||
| 4470 | /* Notification from the Workspace to open multiple files */ | 4474 | /* Notification from the Workspace to open multiple files */ |
| 4471 | - (void)application: sender openFiles: (NSArray *)fileList | 4475 | - (void)application: sender openFiles: (NSArray *)fileList |
| 4472 | { | 4476 | { |
| 4473 | NSEnumerator *files = [fileList objectEnumerator]; | 4477 | /* Don't open files from the command line, Cocoa parses the command line |
| 4474 | NSString *file; | 4478 | wrong anyway, --option value tries to open value if --option is the last |
| 4475 | while ((file = [files nextObject]) != nil) | 4479 | option. */ |
| 4476 | [ns_pending_files addObject: file]; | 4480 | if (ns_ignore_open_file) |
| 4477 | 4481 | { | |
| 4482 | NSEnumerator *files = [fileList objectEnumerator]; | ||
| 4483 | NSString *file; | ||
| 4484 | while ((file = [files nextObject]) != nil) | ||
| 4485 | [ns_pending_files addObject: file]; | ||
| 4486 | } | ||
| 4487 | |||
| 4478 | [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; | 4488 | [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; |
| 4479 | 4489 | ||
| 4480 | } | 4490 | } |