Skip to content

Instantly share code, notes, and snippets.

@takaxp
Last active September 24, 2019 15:54
Show Gist options
  • Save takaxp/d884e91af3970d0923c3186f8f7188e2 to your computer and use it in GitHub Desktop.
Save takaxp/d884e91af3970d0923c3186f8f7188e2 to your computer and use it in GitHub Desktop.
Emacs NS build for mojave googleime patch (master@6217746dd6) (see also https://qiita.com/takaxp/items/e07bb286d80fa9dd8e05)
diff -crN emacs-26/src/macim.m emacs-26-mojave/src/macim.m
*** emacs-26/src/macim.m 2018-10-01 00:57:49.000000000 +0900
--- emacs-26-mojave/src/macim.m 2018-10-01 00:59:06.000000000 +0900
***************
*** 96,101 ****
--- 96,122 ----
locale = [[NSLocale currentLocale]
objectForKey:NSLocaleLanguageCode];
}
+ if ( [locale hasPrefix:@"ja"] ) {
+ is = TISCopyInputSourceForLanguage((CFStringRef)locale);
+ } else {
+ NSString *targetID = [NSString stringWithUTF8String:"com.google.inputmethod.Japanese.base"];
+ if ( targetID == nil) {
+ return arg;
+ }
+
+ NSArray *is_list = (NSArray *)TISCreateInputSourceList(NULL, false);
+ int list_size = [is_list count];
+ for(int i=0; i< list_size; i++) {
+ NSString *id = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[is_list objectAtIndex:i], kTISPropertyInputSourceID);
+ // NSLog(@"%d: %@", i, [is_list objectAtIndex:i]);
+ if ( [id compare:targetID] == NSOrderedSame ) {
+ is = (TISInputSourceRef)[is_list objectAtIndex:i];
+ break;
+ }
+ }
+ // NSLog(@"%@", locale);
+ // NSLog(@"%@", is);
+ }
}
if (is) TISSelectInputSource(is);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment