Skip to content

Instantly share code, notes, and snippets.

@informationsea
Last active December 11, 2015 17:28
Show Gist options
  • Save informationsea/4634401 to your computer and use it in GitHub Desktop.
Save informationsea/4634401 to your computer and use it in GitHub Desktop.
Japanese input method
=== modified file 'configure.ac'
--- configure.ac 2013-01-16 08:08:34 +0000
+++ configure.ac 2013-01-25 13:05:34 +0000
@@ -4322,7 +4322,7 @@
## 0x690 is the total size of 30 segment load commands (at 56
## each); under Cocoa 31 commands are required.
if test "$HAVE_NS" = "yes"; then
- libs_nsgui="-framework AppKit"
+ libs_nsgui="-framework AppKit -framework Carbon"
headerpad_extra=6C8
else
libs_nsgui=
=== modified file 'lisp/term/ns-win.el'
--- lisp/term/ns-win.el 2013-01-01 09:11:05 +0000
+++ lisp/term/ns-win.el 2013-01-25 13:05:34 +0000
@@ -541,6 +541,15 @@
(interactive)
(ns-hide-others))
+(declare-function ns-inputmethod-change "nsfns.m" ())
+(defun ns-inputmethod-change-us ()
+ (interactive)
+ (ns-inputmethod-change nil))
+(defun ns-inputmethod-change-jp ()
+ (interactive)
+ (ns-inputmethod-change t))
+
+
(declare-function ns-emacs-info-panel "nsfns.m" ())
(defun ns-do-emacs-info-panel ()
=== modified file 'src/nsfns.m'
--- src/nsfns.m 2013-01-01 09:11:05 +0000
+++ src/nsfns.m 2013-01-25 13:27:10 +0000
@@ -33,6 +33,8 @@
#include <math.h>
#include <c-strcase.h>
+#include <Carbon/Carbon.h>
+
#include "lisp.h"
#include "blockinput.h"
#include "nsterm.h"
@@ -2661,6 +2663,30 @@
}
@end
+
+DEFUN ("ns-inputmethod-change", Fns_inputmethod_change, Sns_inputmethod_change,
+ 1, 1, 0,
+ doc: /* inputmethod on/off */)
+ (Lisp_Object arg)
+{
+ check_ns ();
+
+ TISInputSourceRef is = NULL;
+
+ if (NILP (arg))
+ {
+ is = TISCopyCurrentASCIICapableKeyboardInputSource();
+ }
+ else
+ {
+ NSString *locale = [[NSLocale currentLocale] localeIdentifier];
+ is = TISCopyInputSourceForLanguage(locale);
+ }
+ if (is) TISSelectInputSource(is);
+
+ return arg;
+}
+
#endif
@@ -2711,6 +2737,7 @@
defsubr (&Sns_list_colors);
#ifdef NS_IMPL_COCOA
defsubr (&Sns_do_applescript);
+ defsubr (&Sns_inputmethod_change);
#endif
defsubr (&Sxw_color_defined_p);
defsubr (&Sxw_color_values);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment