Skip to content

Instantly share code, notes, and snippets.

@informationsea
Created September 18, 2016 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save informationsea/d8799c84718444d35e55f998322aee58 to your computer and use it in GitHub Desktop.
Save informationsea/d8799c84718444d35e55f998322aee58 to your computer and use it in GitHub Desktop.
Emacs 25.1 Small IME patch for OS X
diff --git a/configure.ac b/configure.ac
index cd4d1c0..fcc96d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5123,7 +5123,7 @@ case "$opsys" in
## only costs about 1.5K of wasted binary space.
headerpad_extra=1000
if test "$HAVE_NS" = "yes"; then
- libs_nsgui="-framework AppKit"
+ libs_nsgui="-framework AppKit -framework Carbon"
if test "$NS_IMPL_COCOA" = "yes"; then
libs_nsgui="$libs_nsgui -framework IOKit"
fi
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index e737131..380a10f 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -558,6 +558,15 @@ ns-do-hide-others
(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 ()
diff --git a/src/nsfns.m b/src/nsfns.m
index 9bc6c1d..b6815a8 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -33,6 +33,8 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
#include <math.h>
#include <c-strcase.h>
+#include <Carbon/Carbon.h>
+
#include "lisp.h"
#include "blockinput.h"
#include "nsterm.h"
@@ -3094,6 +3096,29 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
}
@end
+
+DEFUN ("ns-inputmethod-change", Fns_inputmethod_change, Sns_inputmethod_change,
+ 1, 1, 0,
+ doc: /* inputmethod on/off */)
+ (Lisp_Object arg)
+{
+
+ TISInputSourceRef is = NULL;
+
+ if (NILP (arg))
+ {
+ is = TISCopyCurrentASCIICapableKeyboardInputSource();
+ }
+ else
+ {
+ NSString *locale = [[NSLocale currentLocale] localeIdentifier];
+ is = TISCopyInputSourceForLanguage(locale);
+ }
+ if (is) TISSelectInputSource(is);
+
+ return arg;
+}
+
#endif
@@ -3145,6 +3170,7 @@ be used as the image of the icon representing the frame. */);
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