diff options
| author | Jan Djärv | 2012-08-11 11:10:08 +0200 |
|---|---|---|
| committer | Jan Djärv | 2012-08-11 11:10:08 +0200 |
| commit | 3d29b2ce5cd5909441ec849f89a7b4a39273ef09 (patch) | |
| tree | 1e4d6ac83053dce97d42a5ee201c712c8a1c48e7 /src | |
| parent | 32bcadb4763c2b57a6587e0daf95c421d5391526 (diff) | |
| download | emacs-3d29b2ce5cd5909441ec849f89a7b4a39273ef09.tar.gz emacs-3d29b2ce5cd5909441ec849f89a7b4a39273ef09.zip | |
* nsterm.m (not_in_argv): New function.
(application:openFile, application:openTempFile:):
(application:openFileWithoutUI:, application:openFiles:): Open file
if not_in_argv returns non-zero.
Fixes: debbugs:12171
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/nsterm.m | 34 |
2 files changed, 25 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b60ab6ec56f..7f89fcbe867 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2012-08-11 Jan Djärv <jan.h.d@swipnet.se> | 1 | 2012-08-11 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 2 | ||
| 3 | * nsterm.m (not_in_argv): New function. | ||
| 4 | (application:openFile, application:openTempFile:): | ||
| 5 | (application:openFileWithoutUI:, application:openFiles:): Open file | ||
| 6 | if not_in_argv returns non-zero (bug#12171). | ||
| 7 | |||
| 3 | * gtkutil.c (gtk_font_chooser_dialog_new, GTK_FONT_CHOOSER) | 8 | * gtkutil.c (gtk_font_chooser_dialog_new, GTK_FONT_CHOOSER) |
| 4 | (gtk_font_chooser_set_font, gtk_font_chooser_get_font): Define | 9 | (gtk_font_chooser_set_font, gtk_font_chooser_get_font): Define |
| 5 | for Gtk+ versions less than 3.2. | 10 | for Gtk+ versions less than 3.2. |
diff --git a/src/nsterm.m b/src/nsterm.m index 807ff564213..b99241f4e15 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -4448,11 +4448,20 @@ ns_term_shutdown (int sig) | |||
| 4448 | return NSTerminateNow; /* just in case */ | 4448 | return NSTerminateNow; /* just in case */ |
| 4449 | } | 4449 | } |
| 4450 | 4450 | ||
| 4451 | static int | ||
| 4452 | not_in_argv (NSString *arg) | ||
| 4453 | { | ||
| 4454 | int k; | ||
| 4455 | const char *a = [arg UTF8String]; | ||
| 4456 | for (k = 1; k < initial_argc; ++k) | ||
| 4457 | if (strcmp (a, initial_argv[k]) == 0) return 0; | ||
| 4458 | return 1; | ||
| 4459 | } | ||
| 4451 | 4460 | ||
| 4452 | /* Notification from the Workspace to open a file */ | 4461 | /* Notification from the Workspace to open a file */ |
| 4453 | - (BOOL)application: sender openFile: (NSString *)file | 4462 | - (BOOL)application: sender openFile: (NSString *)file |
| 4454 | { | 4463 | { |
| 4455 | if (ns_do_open_file) | 4464 | if (ns_do_open_file || not_in_argv (file)) |
| 4456 | [ns_pending_files addObject: file]; | 4465 | [ns_pending_files addObject: file]; |
| 4457 | return YES; | 4466 | return YES; |
| 4458 | } | 4467 | } |
| @@ -4461,7 +4470,7 @@ ns_term_shutdown (int sig) | |||
| 4461 | /* Open a file as a temporary file */ | 4470 | /* Open a file as a temporary file */ |
| 4462 | - (BOOL)application: sender openTempFile: (NSString *)file | 4471 | - (BOOL)application: sender openTempFile: (NSString *)file |
| 4463 | { | 4472 | { |
| 4464 | if (ns_do_open_file) | 4473 | if (ns_do_open_file || not_in_argv (file)) |
| 4465 | [ns_pending_files addObject: file]; | 4474 | [ns_pending_files addObject: file]; |
| 4466 | return YES; | 4475 | return YES; |
| 4467 | } | 4476 | } |
| @@ -4470,25 +4479,22 @@ ns_term_shutdown (int sig) | |||
| 4470 | /* Notification from the Workspace to open a file noninteractively (?) */ | 4479 | /* Notification from the Workspace to open a file noninteractively (?) */ |
| 4471 | - (BOOL)application: sender openFileWithoutUI: (NSString *)file | 4480 | - (BOOL)application: sender openFileWithoutUI: (NSString *)file |
| 4472 | { | 4481 | { |
| 4473 | if (ns_do_open_file) | 4482 | if (ns_do_open_file || not_in_argv (file)) |
| 4474 | [ns_pending_files addObject: file]; | 4483 | [ns_pending_files addObject: file]; |
| 4475 | return YES; | 4484 | return YES; |
| 4476 | } | 4485 | } |
| 4477 | 4486 | ||
| 4478 | |||
| 4479 | /* Notification from the Workspace to open multiple files */ | 4487 | /* Notification from the Workspace to open multiple files */ |
| 4480 | - (void)application: sender openFiles: (NSArray *)fileList | 4488 | - (void)application: sender openFiles: (NSArray *)fileList |
| 4481 | { | 4489 | { |
| 4482 | /* Don't open files from the command line, Cocoa parses the command line | 4490 | NSEnumerator *files = [fileList objectEnumerator]; |
| 4483 | wrong anyway, --option value tries to open value if --option is the last | 4491 | NSString *file; |
| 4484 | option. */ | 4492 | /* Don't open files from the command line unconditionally, |
| 4485 | if (ns_do_open_file) | 4493 | Cocoa parses the command line wrong, --option value tries to open value |
| 4486 | { | 4494 | if --option is the last option. */ |
| 4487 | NSEnumerator *files = [fileList objectEnumerator]; | 4495 | while ((file = [files nextObject]) != nil) |
| 4488 | NSString *file; | 4496 | if (ns_do_open_file || not_in_argv (file)) |
| 4489 | while ((file = [files nextObject]) != nil) | 4497 | [ns_pending_files addObject: file]; |
| 4490 | [ns_pending_files addObject: file]; | ||
| 4491 | } | ||
| 4492 | 4498 | ||
| 4493 | [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; | 4499 | [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess]; |
| 4494 | 4500 | ||