Changeset 94319 for trunk/dports/aqua


Ignore:
Timestamp:
Jun 15, 2012, 11:58:20 AM (7 years ago)
Author:
hum@…
Message:

emacs-app: update to 24.1; update patches for inline, fullscreen; remove patches for clang, jpfont, title-bar.

Location:
trunk/dports/aqua/emacs-app
Files:
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/aqua/emacs-app/Portfile

    r90242 r94319  
    55
    66name                emacs-app
    7 version             23.4
    8 revision            1
     7version             24.1
    98categories          aqua editors
    109maintainers         css hum openmaintainer
     
    2928distname            emacs-${version}
    3029dist_subdir         emacs
    31 checksums           rmd160  5fb7e4cd4270a524b8723ad86a145a0e47336bf7 \
    32                     sha256  b9a2b8434052771f797d2032772eba862ff9aa143029efc72295170607289c18
     30checksums           rmd160  0fed00042339f46b29449bd561d2f881d13d8d38 \
     31                    sha256  60d26dd1d9c0b955543ae83a2f4dd7c8b6af59e16a06822cfb175f1bf97c8bab
    3332
    3433depends_lib         port:ncurses
    3534
    3635patchfiles          patch-src_emacs.c.diff
    37 
    38 if {${configure.compiler} == "clang"} {
    39     patchfiles-append   patch-clang.diff
    40 }
    4136
    4237post-patch {
     
    4641configure.args      --with-ns --without-x --without-dbus
    4742
    48 use_parallel_build  yes
    49 
    5043destroot {
    51     system "cd ${worksrcpath} && make install"
     44    system -W ${worksrcpath} "make install"
    5245    xinstall -m 755 -d ${destroot}${applications_dir}
    5346    file copy ${worksrcpath}/nextstep/Emacs.app \
     
    5548    file copy ${filespath}/site-start.el \
    5649        ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp
    57 }
    58 
    59 post-destroot {
    6050    reinplace "s|__PREFIX__|${prefix}|g" \
    6151        ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
    6252}
    6353
    64 # patch-fullscreen.diff
    65 #   http://gist.github.com/291150
    66 #   http://www.sanityinc.com/full-screen-support-for-cocoa-emacs-on-osx
    6754variant fullscreen description {Add fullscreen patch} {
    68     patchfiles-append   patch-fullscreen.diff
     55    if {${os.major} < 11} {
     56        # patch-fullscreen.diff
     57        # http://cloud.github.com/downloads/hh/emacs/feature-fullscreen.patch
     58        # http://untree.com/post/7649492902/building-a-fullscreen-enabled-emacs-24-on-mac-os-x-snow
     59        patchfiles-append   patch-fullscreen.diff
     60    } else {
     61        # patch-lion-fullscreen.diff
     62        # https://gist.github.com/1355895
     63        # http://techresearchinfo.blogspot.jp/2011/12/emacs-24-on-lion-mention-top-right.html
     64        patchfiles-append   patch-lion-fullscreen.diff
     65    }
    6966}
    7067
    71 # inline and font patches are fetched from MacEmacsJP.
    72 #   http://svn.sourceforge.jp/svnroot/macemacsjp/inline_patch/trunk/
    73 #   revision 579 (2012/01/13).
    74 # patch-macemacsjp-inline.diff <= emacs-inline.patch
    75 # patch-macemacsjp-jpfont.diff <= font.patch
    7668variant inline description {Add inline patch from MacEmacsJP} {
     69    # inline patch fetched from MacEmacsJP.
     70    # patch-macemacsjp-inline.diff
     71    # http://svn.sourceforge.jp/svnroot/macemacsjp/inline_patch/trunk/emacs-inline.patch
     72    # revision 582 (2012/05/20).
    7773    patchfiles-append   patch-macemacsjp-inline.diff
    7874}
    7975
    80 variant jpfont description {Add Japanese font patch from MacEmacsJP} {
    81     patchfiles-append   patch-macemacsjp-jpfont.diff
    82 }
     76variant jpfont requires inline description {Obsolete compatibility variant} {}
    8377
    84 variant patches requires fullscreen inline jpfont description {Add all patches: fullscreen, inline and jpfont} {}
    85 
    86 platform darwin 11 {
    87    patchfiles-append    patch-fix-title-bar.diff
    88    # patch-lion-fullscreen.diff
    89    #   https://github.com/downloads/typester/emacs/emacs-23-lion-fullscreen-test.patch
    90    if {[variant_isset fullscreen]} {
    91        patchfiles-append   patch-lion-fullscreen.diff
    92    }
    93    configure.cflags-append   -fno-pie -O2
    94    configure.ldflags-append  -fno-pie
    95 }
     78variant patches requires fullscreen inline description {Add all patches: fullscreen and inline} {}
    9679
    9780livecheck.type      regex
  • trunk/dports/aqua/emacs-app/files/patch-fullscreen.diff

    r76517 r94319  
    1 --- lisp/term/ns-win.el.orig    2011-01-29 15:01:48.000000000 -0500
    2 +++ lisp/term/ns-win.el 2011-01-29 15:01:52.000000000 -0500
    3 @@ -1263,6 +1263,11 @@
     1--- lisp/term/ns-win.el
     2+++ lisp/term/ns-win.el
     3@@ -1263,6 +1263,11 @@ the operating system.")
    44 (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
    55 
     
    1313 
    1414 ;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644
    15 --- src/nsfns.m.orig    2011-01-29 15:01:48.000000000 -0500
    16 +++ src/nsfns.m 2011-01-29 15:01:52.000000000 -0500
    17 @@ -2599,6 +2599,34 @@
     15--- src/nsfns.m
     16+++ src/nsfns.m
     17@@ -2589,6 +2589,34 @@ Value is t if tooltip was open, nil otherwise.  */)
    1818 
    1919 #endif
     
    5050 /* ==========================================================================
    5151 
    52 @@ -2684,6 +2712,8 @@
     52@@ -2676,6 +2704,8 @@ be used as the image of the icon representing the frame.  */);
    5353   defsubr (&Sx_show_tip);
    5454   defsubr (&Sx_hide_tip);
     
    5959   check_window_system_func = check_ns;
    6060 
    61 --- src/nsterm.h.orig   2011-01-29 15:01:48.000000000 -0500
    62 +++ src/nsterm.h        2011-01-29 15:01:52.000000000 -0500
    63 @@ -95,8 +95,25 @@
     61--- src/nsterm.h
     62+++ src/nsterm.h
     63@@ -95,8 +95,25 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    6464 {
    6565   NSPoint grabOffset;
     
    8787 /* ==========================================================================
    8888 
    89 --- src/nsterm.m.orig   2011-01-29 15:01:48.000000000 -0500
    90 +++ src/nsterm.m        2011-01-29 15:01:52.000000000 -0500
    91 @@ -685,6 +685,13 @@
     89--- src/nsterm.m
     90+++ src/nsterm.m
     91@@ -686,6 +686,13 @@ ns_focus (struct frame *f, NSRect *r, int n)
    9292 /*debug_lock--; */
    9393             }
     
    103103 #ifdef NS_IMPL_GNUSTEP
    104104             r ? [view lockFocusInRect: u] : [view lockFocus];
    105 @@ -1130,8 +1137,14 @@
     105@@ -1131,8 +1138,14 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
    106106   f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f);
    107107   compute_fringe_widths (f, 0);
     
    120120   /* If we have a toolbar, take its height into account. */
    121121   if (tb)
    122 @@ -1149,7 +1162,7 @@
    123                    + FRAME_NS_TOOLBAR_HEIGHT (f);
    124  
    125    /* constrain to screen if we can */
    126 -  if (screen)
    127 +  if (screen && ![window isKindOfClass:[EmacsFullWindow class]])
    128      {
    129        NSSize sz = [screen visibleFrame].size;
    130        NSSize ez = { wr.size.width - sz.width, wr.size.height - sz.height };
    131 @@ -1196,7 +1209,7 @@
     122@@ -1197,7 +1210,7 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
    132123   change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */
    133124   FRAME_PIXEL_WIDTH (f) = pixelwidth;
     
    138129   mark_window_cursors_off (XWINDOW (f->root_window));
    139130   cancel_mouse_face (f);
    140 @@ -5589,6 +5602,59 @@
     131@@ -5609,6 +5622,59 @@ extern void update_window_cursor (struct window *w, int on);
    141132 
    142133 @implementation EmacsWindow
     
    198189 - (void)mouseDown: (NSEvent *)theEvent
    199190 {
    200 @@ -5647,6 +5713,32 @@
     191@@ -5667,6 +5733,32 @@ extern void update_window_cursor (struct window *w, int on);
    201192 
    202193 @end /* EmacsWindow */
     
    230221 
    231222 /* ==========================================================================
    232  
     223                                  
  • trunk/dports/aqua/emacs-app/files/patch-lion-fullscreen.diff

    r87876 r94319  
    1 --- src/nsterm.m.old    2011-11-25 22:36:38.000000000 +0900
    2 +++ src/nsterm.m        2011-11-25 22:59:56.000000000 +0900
    3 @@ -5182,6 +5182,7 @@
    4    [win setAcceptsMouseMovedEvents: YES];
    5    [win setDelegate: self];
    6    [win useOptimizedDrawing: YES];
    7 +  [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    8  
    9    sz.width = FRAME_COLUMN_WIDTH (f);
    10    sz.height = FRAME_LINE_HEIGHT (f);
    11 @@ -5671,6 +5672,43 @@
    12    cols = c;
    13  }
    14  
    15 +- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions {
     1=== modified file 'lisp/term/ns-win.el'
     2--- lisp/term/ns-win.el 2011-10-01 20:32:01 +0000
     3+++ lisp/term/ns-win.el 2011-11-10 16:22:51 +0000
     4@@ -928,6 +928,10 @@
     5 (add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
     6 (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
     7 
     8+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
     9+(defun ns-toggle-fullscreen ()
     10+  (interactive)
     11+  (ns-toggle-fullscreen-internal))
     12 
     13 (provide 'ns-win)
     14 
     15
     16=== modified file 'src/nsfns.m'
     17--- src/nsfns.m 2011-11-05 12:25:01 +0000
     18+++ src/nsfns.m 2011-11-10 18:54:31 +0000
     19@@ -2567,6 +2567,22 @@
     20 }
     21 
     22 
     23+DEFUN ("ns-toggle-fullscreen-internal", Fns_toggle_fullscreen_internal, Sns_toggle_fullscreen_internal,
     24+        0, 0, 0,
     25+        doc: /* Toggle fulscreen mode */)
     26+()
     27+{
     28+  struct frame *f = SELECTED_FRAME();
     29+  EmacsWindow *window = ns_get_window(f);
     30+
     31+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     32+  [window toggleFullScreen:nil];
     33+#endif
     34+
     35+  return Qnil;
     36+}
     37+
     38+
     39 /* ==========================================================================
     40 
     41     Class implementations
     42@@ -2724,6 +2740,8 @@
     43   defsubr (&Sx_show_tip);
     44   defsubr (&Sx_hide_tip);
     45 
     46+  defsubr (&Sns_toggle_fullscreen_internal);
     47+
     48   /* used only in fontset.c */
     49   check_window_system_func = check_ns;
     50 
     51
     52=== modified file 'src/nsmenu.m'
     53--- src/nsmenu.m        2011-07-29 05:31:12 +0000
     54+++ src/nsmenu.m        2011-11-10 16:22:51 +0000
     55@@ -986,7 +986,7 @@
     56    -------------------------------------------------------------------------- */
     57 {
     58   BLOCK_INPUT;
     59-  [[FRAME_NS_VIEW (f) toolbar] setVisible: NO];
     60+  [[FRAME_NS_VIEW (f) window] setToolbar: nil];
     61   FRAME_TOOLBAR_HEIGHT (f) = 0;
     62   UNBLOCK_INPUT;
     63 }
     64@@ -1003,6 +1003,8 @@
     65   EmacsToolbar *toolbar = [view toolbar];
     66 
     67   BLOCK_INPUT;
     68+  [window setToolbar: toolbar];
     69+
     70   [toolbar clearActive];
     71 
     72   /* update EmacsToolbar as in GtkUtils, build items list */
     73
     74=== modified file 'src/nsterm.h'
     75--- src/nsterm.h        2011-09-09 01:06:52 +0000
     76+++ src/nsterm.h        2011-11-10 18:39:22 +0000
     77@@ -38,6 +38,9 @@
     78 #ifndef MAC_OS_X_VERSION_10_6
     79 #define MAC_OS_X_VERSION_10_6 1060
     80 #endif
     81+#ifndef MAC_OS_X_VERSION_10_7
     82+#define MAC_OS_X_VERSION_10_7 1070
     83+#endif
     84 #endif /* NS_IMPL_COCOA */
     85 
     86 #ifdef __OBJC__
     87
     88=== modified file 'src/nsterm.m'
     89--- src/nsterm.m        2011-11-05 12:25:01 +0000
     90+++ src/nsterm.m        2011-11-10 18:54:02 +0000
     91@@ -5299,39 +5299,7 @@
     92 #endif
     93   if (rows < MINHEIGHT)
     94     rows = MINHEIGHT;
     95-#ifdef NS_IMPL_COCOA
     96-  {
     97-    /* this sets window title to have size in it; the wm does this under GS */
     98-    NSRect r = [[self window] frame];
     99-    if (r.size.height == frameSize.height && r.size.width == frameSize.width)
     100-      {
     101-        if (old_title != 0)
     102-          {
     103-            xfree (old_title);
     104-            old_title = 0;
     105-          }
     106-      }
     107-    else
     108-      {
     109-        char *size_title;
     110-        NSWindow *window = [self window];
     111-        if (old_title == 0)
     112-          {
     113-            const char *t = [[[self window] title] UTF8String];
     114-            char *pos = strstr (t, "  —  ");
     115-            if (pos)
     116-              *pos = '\0';
     117-            old_title = (char *) xmalloc (strlen (t) + 1);
     118-            strcpy (old_title, t);
     119-          }
     120-        size_title = xmalloc (strlen (old_title) + 40);
     121-       esprintf (size_title, "%s  —  (%d x %d)", old_title, cols, rows);
     122-        [window setTitle: [NSString stringWithUTF8String: size_title]];
     123-        [window display];
     124-        xfree (size_title);
     125-      }
     126-  }
     127-#endif /* NS_IMPL_COCOA */
     128+
     129 /*fprintf (stderr,"    ...size became %.0f x %.0f  (%d x %d)\n",frameSize.width,frameSize.height,cols,rows); */
     130 
     131   return frameSize;
     132@@ -5353,14 +5321,6 @@
     133   NSTRACE (windowDidResize);
     134 /*fprintf (stderr,"windowDidResize: %.0f\n",[theWindow frame].size.height); */
     135 
     136-#ifdef NS_IMPL_COCOA
     137-  if (old_title != 0)
     138-    {
     139-      xfree (old_title);
     140-      old_title = 0;
     141-    }
     142-#endif /* NS_IMPL_COCOA */
     143-
     144   /* Avoid loop under GNUstep due to call at beginning of this function.
     145      (x_set_window_size causes a resize which causes
     146      a "windowDidResize" which calls x_set_window_size).  */
     147@@ -5388,6 +5348,60 @@
     148   ns_send_appdefined (-1);
     149 }
     150 
     151+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     152+- (void)windowDidEnterFullScreen:(NSNotification *)notification
     153+{
     154+    NSTRACE (windowDidEnterFullScreen);
     155+    /* NSLog(@"Calling windowDidEnterFullScreen"); */
     156+   
     157+    NSWindow *window = [self window];
     158+    NSRect wr = [window frame];
     159+    int w = (int)wr.size.width - emacsframe->border_width;
     160+    int h = (int)wr.size.height;
     161+    cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, w);
     162+    rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, h);
     163+    /* NSLog(@"window_size=%dx%d (%dx%d)", w, h, cols, rows); */
     164+    FRAME_PIXEL_WIDTH (emacsframe) = w;
     165+    FRAME_PIXEL_HEIGHT (emacsframe) = h;
     166+    change_frame_size (emacsframe, rows, cols, 0, 1, 0);
     167+    SET_FRAME_GARBAGED (emacsframe);
     168+    cancel_mouse_face (emacsframe);
     169+    ns_send_appdefined (-1);
     170+}
     171+#endif
     172+
     173+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     174+- (void)windowDidExitFullScreen:(NSNotification *)notification
     175+{
     176+    NSTRACE (windowDidExitFullScreen);
     177+    /* NSLog(@"Calling windowDidExitFullScreen"); */
     178+   
     179+    NSWindow *window = [self window];
     180+    NSRect wr = [window frame];
     181+    int w = (int)wr.size.width - emacsframe->border_width;
     182+    int h = (int)wr.size.height
     183+    - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
     184+    - FRAME_TOOLBAR_HEIGHT (emacsframe);
     185+    cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, w);
     186+    rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, h);
     187+    /* NSLog(@"window_size=%dx%d (%dx%d)", w, h, cols, rows); */
     188+    FRAME_PIXEL_WIDTH (emacsframe) = w;
     189+    FRAME_PIXEL_HEIGHT (emacsframe) = h;
     190+    change_frame_size (emacsframe, rows, cols, 0, 1, 0);
     191+    SET_FRAME_GARBAGED (emacsframe);
     192+    cancel_mouse_face (emacsframe);
     193+    ns_send_appdefined (-1);
     194+}
     195+#endif
     196+
     197+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     198+- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
     199+{
     200+    /* NSLog(@"Calling window:willUseFullScreenPresentationOptions: %d", proposedOptions); */
    16201+    return proposedOptions | NSApplicationPresentationAutoHideToolbar;
    17202+}
    18 +
    19 +- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize {
    20 +    NSRect r = NSMakeRect(0.f, 0.f, proposedSize.width, proposedSize.height);
    21 +    int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, r.size.width);
    22 +    int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, r.size.height);
    23 +
    24 +    change_frame_size (emacsframe, rows, cols, 0, 1, 0); /* pretend, delay, safe */
    25 +    FRAME_PIXEL_WIDTH (emacsframe) = (int)r.size.width;
    26 +    FRAME_PIXEL_HEIGHT (emacsframe) = (int)r.size.height;
    27 +
    28 +    emacsframe->border_width = [window frame].size.width - r.size.width;
    29 +    FRAME_NS_TITLEBAR_HEIGHT (emacsframe) = 0;
    30 +
    31 +    return proposedSize;
    32 +}
    33 +
    34 +- (void)windowDidExitFullScreen:(NSNotification *)notification {
    35 +    NSWindow* window = [notification object];
    36 +
    37 +    NSRect r = [window contentRectForFrameRect:[window frame]];
    38 +    int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, r.size.width);
    39 +    int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, r.size.height);
    40 +
    41 +    change_frame_size (emacsframe, rows, cols, 0, 1, 0); /* pretend, delay, safe */
    42 +    FRAME_PIXEL_WIDTH (emacsframe) = (int)r.size.width;
    43 +    FRAME_PIXEL_HEIGHT (emacsframe) = (int)r.size.height;
    44 +
    45 +    emacsframe->border_width = [window frame].size.width - r.size.width;
    46 +    FRAME_NS_TITLEBAR_HEIGHT (emacsframe) =
    47 +        [window frame].size.height - r.size.height;
    48 +
    49 +    [[window delegate] windowDidMove:nil];
    50 +}
    51 +
    52  @end  /* EmacsView */
    53  
    54  
     203+#endif
     204+
     205 
     206 - (void)windowDidBecomeKey: (NSNotification *)notification
     207 /* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
     208@@ -5559,6 +5573,14 @@
     209   [NSApp registerServicesMenuSendTypes: ns_send_types
     210                            returnTypes: nil];
     211 
     212+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     213+  if (NSApp != nil)
     214+  {
     215+    [NSApp setPresentationOptions: NSApplicationPresentationFullScreen | [NSApp presentationOptions] ];
     216+    [win setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary | [win collectionBehavior] ];
     217+  }
     218+#endif
     219+
     220   ns_window_num++;
     221   return self;
     222 }
  • trunk/dports/aqua/emacs-app/files/patch-macemacsjp-inline.diff

    r90242 r94319  
    1 diff -r -p -x '*.elc' ../emacs-23.3-0-lion/lisp/term/ns-win.el lisp/term/ns-win.el
    2 *** ../emacs-23.3-0-lion/lisp/term/ns-win.el    2011-12-05 16:49:13.000000000 +0900
    3 --- lisp/term/ns-win.el 2012-01-13 08:55:10.000000000 +0900
     1diff -N -p ../emacs-24.0.97/configure.in ./configure.in
     2*** ../emacs-24.0.97/configure.in       2012-05-17 11:19:50.000000000 +0900
     3--- ./configure.in      2012-05-20 17:01:19.000000000 +0900
     4*************** if test "${HAVE_NS}" = yes; then
     5*** 1582,1588 ****
     6    fi
     7    ns_frag=$srcdir/src/ns.mk
     8    NS_OBJ="fontset.o fringe.o image.o"
     9!   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
     10  fi
     11  CFLAGS="$tmp_CFLAGS"
     12  CPPFLAGS="$tmp_CPPFLAGS"
     13--- 1582,1588 ----
     14    fi
     15    ns_frag=$srcdir/src/ns.mk
     16    NS_OBJ="fontset.o fringe.o image.o"
     17!   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o"
     18  fi
     19  CFLAGS="$tmp_CFLAGS"
     20  CPPFLAGS="$tmp_CPPFLAGS"
     21*************** case "$opsys" in
     22*** 3416,3422 ****
     23     ## 0x690 is the total size of 30 segment load commands (at 56
     24     ## each); under Cocoa 31 commands are required.
     25     if test "$HAVE_NS" = "yes"; then
     26!      libs_nsgui="-framework AppKit"
     27       headerpad_extra=6C8
     28     else
     29       libs_nsgui=
     30--- 3416,3422 ----
     31     ## 0x690 is the total size of 30 segment load commands (at 56
     32     ## each); under Cocoa 31 commands are required.
     33     if test "$HAVE_NS" = "yes"; then
     34!      libs_nsgui="-framework AppKit -framework Carbon"
     35       headerpad_extra=6C8
     36     else
     37       libs_nsgui=
     38diff -r -N -p ../emacs-24.0.96/src/Makefile.in src/Makefile.in
     39*** ../emacs-24.0.96/src/Makefile.in    2012-04-08 12:03:02.000000000 +0900
     40--- src/Makefile.in     2012-05-03 22:23:59.000000000 +0900
     41*************** obj = $(base_obj) $(NS_OBJC_OBJ)
     42*** 350,356 ****
     43  SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
     44    xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
     45    fontset.o dbusbind.o \
     46!   nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
     47    w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
     48    w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
     49    w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
     50--- 350,356 ----
     51  SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
     52    xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
     53    fontset.o dbusbind.o \
     54!   nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o\
     55    w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
     56    w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
     57    w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
     58diff -r -N -p ../emacs-24.0.96/src/keyboard.c src/keyboard.c
     59*** ../emacs-24.0.96/src/keyboard.c     2012-04-08 12:03:02.000000000 +0900
     60--- src/keyboard.c      2012-05-03 22:23:59.000000000 +0900
     61*************** kbd_buffer_get_event (KBOARD **kbp,
     62*** 3915,3922 ****
     63          {
     64            if (event->code == KEY_NS_PUT_WORKING_TEXT)
     65              obj = Fcons (intern ("ns-put-working-text"), Qnil);
     66!           else
     67              obj = Fcons (intern ("ns-unput-working-text"), Qnil);
     68          kbd_fetch_ptr = event + 1;
     69            if (used_mouse_menu)
     70              *used_mouse_menu = 1;
     71--- 3915,3924 ----
     72          {
     73            if (event->code == KEY_NS_PUT_WORKING_TEXT)
     74              obj = Fcons (intern ("ns-put-working-text"), Qnil);
     75!           else if (event->code == KEY_NS_UNPUT_WORKING_TEXT)
     76              obj = Fcons (intern ("ns-unput-working-text"), Qnil);
     77+         else if (event->code == KEY_NS_PUT_MARKED_TEXT)
     78+           obj = Fcons (intern ("ns-put-marked-text"), event->arg);
     79          kbd_fetch_ptr = event + 1;
     80            if (used_mouse_menu)
     81              *used_mouse_menu = 1;
     82*************** keys_of_keyboard (void)
     83*** 12332,12337 ****
     84--- 12334,12341 ----
     85                            "ns-put-working-text");
     86    initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",
     87                            "ns-unput-working-text");
     88+   initial_define_lispy_key (Vspecial_event_map, "ns-put-marked-text",
     89+                           "ns-put-marked-text");
     90    /* Here we used to use `ignore-event' which would simple set prefix-arg to
     91       current-prefix-arg, as is done in `handle-switch-frame'.
     92       But `handle-switch-frame is not run from the special-map.
     93diff -r -N -p ../emacs-24.0.96/src/macim.m src/macim.m
     94*** ../emacs-24.0.96/src/macim.m        1970-01-01 09:00:00.000000000 +0900
     95--- src/macim.m 2012-05-03 22:23:59.000000000 +0900
     96***************
     97*** 0 ****
     98--- 1,177 ----
     99+ /* Implementation of Input Method Extension for MacOS X.
     100+    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
     101+    Taiichi Hashimoto <taiichi2@mac.com>.
     102+ */
     103+
     104+ #include "config.h"
     105+
     106+ #ifdef NS_IMPL_COCOA
     107+
     108+ #include <math.h>
     109+ #include <sys/types.h>
     110+ #include <time.h>
     111+ #include <signal.h>
     112+ #include <unistd.h>
     113+
     114+ #include <Carbon/Carbon.h>
     115+
     116+ #include "lisp.h"
     117+ #include "blockinput.h"
     118+
     119+ enum output_method
     120+ {
     121+   output_initial,
     122+   output_termcap,
     123+   output_x_window,
     124+   output_msdos_raw,
     125+   output_w32,
     126+   output_mac,
     127+   output_ns
     128+ } output_method;
     129+
     130+ #include "termhooks.h"
     131+ #include "keyboard.h"
     132+ #include "buffer.h"
     133+
     134+ //extern Lisp_Object Qcurrent_input_method;
     135+ //extern int cursor_in_echo_area;
     136+ static Lisp_Object Qmac_keys_passed_to_system;
     137+
     138+ void mac_init_input_method ();
     139+ int mac_pass_key_to_system (int code, int modifiers);
     140+ int mac_pass_key_directly_to_emacs ();
     141+ int mac_store_change_input_method_event ();
     142+
     143+ DEFUN ("mac-input-source-is-ascii-capable", Fmac_input_source_is_ascii_capable, Smac_input_source_is_ascii_capable,
     144+        0, 0, 0,
     145+        doc: /* Is current input source ascii capable? */)
     146+      (void)
     147+ {
     148+   TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
     149+   CFBooleanRef ret = TISGetInputSourceProperty(is, kTISPropertyInputSourceIsASCIICapable);
     150+   
     151+   return CFBooleanGetValue(ret)? Qt : Qnil;
     152+ }
     153+
     154+ DEFUN ("mac-get-input-source-list", Fmac_get_input_source_list, Smac_get_input_source_list,
     155+        0, 0, 0,
     156+        doc: /* get input source list on MacOSX */)
     157+      (void)
     158+ {
     159+   NSArray *is_list = (NSArray *)TISCreateInputSourceList(NULL, false);
     160+   int list_size = [is_list count];
     161+   Lisp_Object list[list_size];
     162+   int i;
     163+
     164+   for (i = 0; i < list_size; i++) {
     165+     TISInputSourceRef is = (TISInputSourceRef)[is_list objectAtIndex:i];
     166+     NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
     167+     list[i] = make_string([id UTF8String],
     168+                         [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
     169+   }
     170+
     171+   return Flist(list_size, list);
     172+ }
     173+
     174+ DEFUN ("mac-get-current-input-source", Fmac_get_current_input_source, Smac_get_current_input_source,
     175+        0, 0, 0,
     176+        doc: /* get current input source on MacOSX */)
     177+      (void)
     178+ {
     179+   TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
     180+   NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
     181+
     182+   return make_string([id UTF8String],
     183+                    [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
     184+ }
     185+
     186+ DEFUN ("mac-toggle-input-source", Fmac_toggle_input_source, Smac_toggle_input_source,
     187+        1, 1, 0,
     188+        doc: /* toggle input source on MacOSX */)
     189+      (arg)
     190+      Lisp_Object arg;
     191+ {
     192+   TISInputSourceRef is = NULL;
     193+
     194+   if (NILP (arg))
     195+     {
     196+       is = TISCopyCurrentASCIICapableKeyboardInputSource();
     197+     }
     198+   else
     199+     {
     200+       NSString *locale = [[NSLocale currentLocale] localeIdentifier];
     201+       is = TISCopyInputSourceForLanguage((CFStringRef)locale);
     202+     }
     203+   if (is) TISSelectInputSource(is);
     204+
     205+   return arg;
     206+ }
     207+
     208+ int
     209+ mac_store_change_input_method_event ()
     210+ {
     211+   Lisp_Object dim;
     212+   int ret = FALSE;
     213+   
     214+   dim = Fsymbol_value (intern ("default-input-method"));
     215+   if (STRINGP (dim) && strcmp(SDATA (dim), "MacOSX") == 0)
     216+     {
     217+       ret = TRUE;
     218+     }
     219+
     220+   return ret;
     221+ }
     222+
     223+ int
     224+ mac_pass_key_to_system (int code, int modifiers)
     225+ {
     226+   Lisp_Object keys = Fsymbol_value (Qmac_keys_passed_to_system);
     227+   Lisp_Object m, k;
     228+
     229+   while (!NILP (keys))
     230+     {
     231+       m = XCAR (XCAR (keys));
     232+       k = XCDR (XCAR (keys));
     233+       keys = XCDR (keys);
     234+
     235+       if (NUMBERP (m) && modifiers == XINT (m))
     236+       if (NILP (k)
     237+           || (NUMBERP (k) && code == XINT (k)))
     238+         return TRUE;
     239+     }
     240+   
     241+   return FALSE;
     242+ }
     243+
     244+ int
     245+ mac_pass_key_directly_to_emacs (void)
     246+ {
     247+
     248+   if (NILP (Fmac_input_source_is_ascii_capable()))
     249+     {
     250+       if (NILP (Vmac_use_input_method_on_system)
     251+         || this_command_key_count
     252+         || cursor_in_echo_area
     253+         || !NILP (BVAR (current_buffer, read_only)))
     254+       return TRUE;
     255+     }
     256+
     257+   return FALSE;
     258+ }
     259+
     260+
     261+ void mac_init_input_method (void)
     262+ {
     263+   Qmac_keys_passed_to_system = intern ("mac-keys-passed-to-system");
     264+   staticpro (&Qmac_keys_passed_to_system);
     265+
     266+   DEFVAR_LISP ("mac-use-input-method-on-system", Vmac_use_input_method_on_system,
     267+                doc: /* If it is non-nil, use input method on system. */);
     268+   Vmac_use_input_method_on_system = Qt;
     269+
     270+   defsubr (&Smac_input_source_is_ascii_capable);
     271+   defsubr (&Smac_get_input_source_list);
     272+   defsubr (&Smac_get_current_input_source);
     273+   defsubr (&Smac_toggle_input_source);
     274+ }
     275+ #endif
     276diff -r -N -p ../emacs-24.0.96/src/nsfns.m src/nsfns.m
     277*** ../emacs-24.0.96/src/nsfns.m        2012-04-08 12:03:02.000000000 +0900
     278--- src/nsfns.m 2012-05-04 00:05:24.000000000 +0900
     279*************** static ptrdiff_t image_cache_refcount;
     280*** 111,117 ****
     281 
     282     ========================================================================== */
     283 
     284-
     285  void
     286  check_ns (void)
     287  {
     288--- 111,116 ----
     289*************** be used as the image of the icon represe
     290*** 2722,2727 ****
     291--- 2721,2744 ----
     292                 doc: /* Toolkit version for NS Windowing.  */);
     293    Vns_version_string = ns_appkit_version_str ();
     294 
     295+
     296+   DEFVAR_LISP ("ns-shift-key-mask", Vns_shift_key_mask,
     297+                doc: /* Shift key mask defined in system. */);
     298+   Vns_shift_key_mask = make_number (NSShiftKeyMask);
     299+
     300+   DEFVAR_LISP ("ns-control-key-mask", Vns_control_key_mask,
     301+                doc: /* Control key mask defined in system. */);
     302+   Vns_control_key_mask = make_number (NSControlKeyMask);
     303+
     304+   DEFVAR_LISP ("ns-alternate-key-mask", Vns_alternate_key_mask,
     305+                doc: /* Alternate key mask defined in system. */);
     306+   Vns_alternate_key_mask = make_number (NSAlternateKeyMask);
     307+
     308+   DEFVAR_LISP ("ns-command-key-mask", Vns_command_key_mask,
     309+                doc: /* Command key mask defined in system. */);
     310+   Vns_command_key_mask = make_number (NSCommandKeyMask);
     311+
     312+
     313    defsubr (&Sns_read_file_name);
     314    defsubr (&Sns_get_resource);
     315    defsubr (&Sns_set_resource);
     316*************** be used as the image of the icon represe
     317*** 2766,2771 ****
     318--- 2783,2792 ----
     319    defsubr (&Sx_show_tip);
     320    defsubr (&Sx_hide_tip);
     321 
     322+ #ifdef NS_IMPL_COCOA
     323+   mac_init_input_method ();
     324+ #endif
     325+
     326    /* used only in fontset.c */
     327    check_window_system_func = check_ns;
     328 
     329diff -r -N -p ../emacs-24.0.96/src/nsterm.h src/nsterm.h
     330*** ../emacs-24.0.96/src/nsterm.h       2012-04-08 12:03:02.000000000 +0900
     331--- src/nsterm.h        2012-05-03 22:23:59.000000000 +0900
     332*************** typedef unsigned int NSUInteger;
     333*** 398,403 ****
     334--- 398,405 ----
     335  #define KEY_NS_NEW_FRAME               ((1<<28)|(0<<16)|12)
     336  #define KEY_NS_TOGGLE_TOOLBAR          ((1<<28)|(0<<16)|13)
     337  #define KEY_NS_SHOW_PREFS              ((1<<28)|(0<<16)|14)
     338+ #define KEY_MAC_CHANGE_INPUT_METHOD    ((1<<28)|(0<<16)|15)
     339+ #define KEY_NS_PUT_MARKED_TEXT         ((1<<28)|(0<<16)|16)
     340 
     341  /* could use list to store these, but rest of emacs has a big infrastructure
     342     for managing a table of bitmap "records" */
     343diff -r -N -p ../emacs-24.0.96/src/nsterm.m src/nsterm.m
     344*** ../emacs-24.0.96/src/nsterm.m       2012-04-09 22:08:55.000000000 +0900
     345--- src/nsterm.m        2012-05-04 00:12:13.000000000 +0900
     346*************** ns_term_init (Lisp_Object display_name)
     347*** 4040,4045 ****
     348--- 4040,4048 ----
     349    /*   [[NSNotificationCenter defaultCenter] addObserver: NSApp
     350                                           selector: @selector (logNotification:)
     351                                               name: nil object: nil]; */
     352+   [[NSDistributedNotificationCenter defaultCenter] addObserver: NSApp
     353+                                       selector: @selector (changeInputMethod:)
     354+                                                  name: @"AppleSelectedInputSourcesChangedNotification" object: nil];
     355 
     356    dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info));
     357    memset (dpyinfo, 0, sizeof (struct ns_display_info));
     358*************** ns_term_shutdown (int sig)
     359*** 4255,4260 ****
     360--- 4258,4276 ----
     361      NSLog (@"notification: '%@'", [notification name]);
     362  }
     363 
     364+ - (void)changeInputMethod: (NSNotification *)notification
     365+ {
     366+
     367+   struct frame *emacsframe = SELECTED_FRAME ();
     368+
     369+   if (mac_store_change_input_method_event())
     370+     {
     371+       emacs_event->kind = NS_NONKEY_EVENT;
     372+       emacs_event->code = KEY_MAC_CHANGE_INPUT_METHOD;
     373+       emacs_event->modifiers = 0;
     374+       EV_TRAILER ((id)nil);
     375+     }
     376+ }
     377 
     378  - (void)sendEvent: (NSEvent *)theEvent
     379  /* --------------------------------------------------------------------------
     380*************** ns_term_shutdown (int sig)
     381*** 4857,4863 ****
     382               code, fnKeysym, flags, emacs_event->modifiers);
     383 
     384        /* if it was a function key or had modifiers, pass it directly to emacs */
     385!       if (fnKeysym || (emacs_event->modifiers
     386                         && (emacs_event->modifiers != shift_modifier)
     387                         && [[theEvent charactersIgnoringModifiers] length] > 0))
     388  /*[[theEvent characters] length] */
     389--- 4872,4879 ----
     390               code, fnKeysym, flags, emacs_event->modifiers);
     391 
     392        /* if it was a function key or had modifiers, pass it directly to emacs */
     393!       if (mac_pass_key_directly_to_emacs ()
     394!         ||fnKeysym || (emacs_event->modifiers
     395                         && (emacs_event->modifiers != shift_modifier)
     396                         && [[theEvent charactersIgnoringModifiers] length] > 0))
     397  /*[[theEvent characters] length] */
     398*************** ns_term_shutdown (int sig)
     399*** 4872,4879 ****
     400                ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
     401 
     402            emacs_event->code = code;
     403!           EV_TRAILER (theEvent);
     404!           return;
     405          }
     406      }
     407 
     408--- 4888,4905 ----
     409                ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
     410 
     411            emacs_event->code = code;
     412!         /* The function mac_pass_key_to_system decides
     413!            whether it is passed directly to emacs or not. */
     414!         if (emacs_event->kind == NON_ASCII_KEYSTROKE_EVENT
     415!             || !mac_pass_key_to_system (code, flags
     416!                                         & (NSShiftKeyMask
     417!                                            | NSControlKeyMask
     418!                                            | NSAlternateKeyMask
     419!                                            | NSCommandKeyMask)))
     420!           {
     421!             EV_TRAILER (theEvent);
     422!             return;
     423!           }
     424          }
     425      }
     426 
     427*************** ns_term_shutdown (int sig)
     428*** 4966,4975 ****
     429      NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
     430             selRange.length, selRange.location);
     431 
     432-   if (workingText != nil)
     433-     [self deleteWorkingText];
     434    if ([str length] == 0)
     435!     return;
     436 
     437    if (!emacs_event)
     438      return;
     439--- 4992,5010 ----
     440      NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
     441             selRange.length, selRange.location);
     442 
     443    if ([str length] == 0)
     444!     {
     445!       [self deleteWorkingText];
     446!       return;
     447!     }
     448!   else
     449!     {
     450!       if (workingText != nil) {
     451!       [workingText release];
     452!       workingText = nil;
     453!       processingCompose = NO;
     454!       }
     455!     }
     456 
     457    if (!emacs_event)
     458      return;
     459*************** ns_term_shutdown (int sig)
     460*** 4979,4985 ****
     461    ns_working_text = build_string ([workingText UTF8String]);
     462 
     463    emacs_event->kind = NS_TEXT_EVENT;
     464!   emacs_event->code = KEY_NS_PUT_WORKING_TEXT;
     465    EV_TRAILER ((id)nil);
     466  }
     467 
     468--- 5014,5022 ----
     469    ns_working_text = build_string ([workingText UTF8String]);
     470 
     471    emacs_event->kind = NS_TEXT_EVENT;
     472!   emacs_event->code = KEY_NS_PUT_MARKED_TEXT;
     473!   emacs_event->arg = Fcons (make_number (selRange.location),
     474!                           Fcons (make_number (selRange.length), Qnil));
     475    EV_TRAILER ((id)nil);
     476  }
     477 
     478*************** ns_term_shutdown (int sig)
     479*** 5034,5048 ****
     480  {
     481    NSRect rect;
     482    NSPoint pt;
     483!   struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
     484    if (NS_KEYLOG)
     485      NSLog (@"firstRectForCharRange request");
     486 
     487    rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
     488    rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
     489    pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
     490    pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
     491!                                        +FRAME_LINE_HEIGHT (emacsframe));
     492 
     493    pt = [self convertPoint: pt toView: nil];
     494    pt = [[self window] convertBaseToScreen: pt];
     495--- 5071,5093 ----
     496  {
     497    NSRect rect;
     498    NSPoint pt;
     499!   //  struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
     500!   struct window *win;
     501    if (NS_KEYLOG)
     502      NSLog (@"firstRectForCharRange request");
     503+     
     504+   if (NILP (Vmac_in_echo_area))
     505+     win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
     506+     else if (WINDOWP (echo_area_window))
     507+     win = XWINDOW (echo_area_window);
     508+   else
     509+     win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
     510 
     511    rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
     512    rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
     513    pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
     514    pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
     515!                                        +FRAME_LINE_HEIGHT (emacsframe)+2);
     516 
     517    pt = [self convertPoint: pt toView: nil];
     518    pt = [[self window] convertBaseToScreen: pt];
     519*************** variable `x-use-underline-position-prope
     520*** 6764,6769 ****
     521--- 6809,6818 ----
     522  baseline level.  The default value is nil.  */);
     523    x_underline_at_descent_line = 0;
     524 
     525+   DEFVAR_LISP ("mac-in-echo-area", Vmac_in_echo_area,
     526+                doc: /* state of cursor in echo area. */);
     527+   Vmac_in_echo_area = Qnil;
     528+
     529    /* Tell emacs about this window system. */
     530    Fprovide (intern ("ns"), Qnil);
     531  }
     532diff -r -N -p ../emacs-24.0.96/lisp/term/common-win.el lisp/term/common-win.el
     533*** ../emacs-24.0.96/lisp/term/common-win.el    2012-04-08 12:03:02.000000000 +0900
     534--- lisp/term/common-win.el     2012-05-03 22:23:59.000000000 +0900
     535*************** is not used)."
     536*** 127,132 ****
     537--- 127,133 ----
     538               (cons (logior (lsh 0 16)  12) 'ns-new-frame)
     539               (cons (logior (lsh 0 16)  13) 'ns-toggle-toolbar)
     540               (cons (logior (lsh 0 16)  14) 'ns-show-prefs)
     541+              (cons (logior (lsh 0 16)  15) 'mac-change-input-method)
     542               ))))
     543      (set-terminal-parameter frame 'x-setup-function-keys t)))
     544 
     545diff -r -N -p ../emacs-24.0.96/lisp/term/ns-win.el lisp/term/ns-win.el
     546*** ../emacs-24.0.96/lisp/term/ns-win.el        2012-04-08 12:03:02.000000000 +0900
     547--- lisp/term/ns-win.el 2012-05-03 23:57:14.000000000 +0900
    4548*************** The properties returned may include `top
    5 *** 317,322 ****
    6 --- 317,323 ----
    7              (cons (logior (lsh 0 16)  12) 'ns-new-frame)
    8              (cons (logior (lsh 0 16)  13) 'ns-toggle-toolbar)
    9              (cons (logior (lsh 0 16)  14) 'ns-show-prefs)
    10 +            (cons (logior (lsh 0 16)  15) 'mac-change-input-method)
    11              (cons (logior (lsh 1 16)  32) 'f1)
    12                (cons (logior (lsh 1 16)  33) 'f2)
    13                (cons (logior (lsh 1 16)  34) 'f3)
     549*** 173,178 ****
     550--- 173,179 ----
     551  (define-key global-map [ns-new-frame] 'make-frame)
     552  (define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
     553  (define-key global-map [ns-show-prefs] 'customize)
     554+ (define-key global-map [mac-change-input-method] 'mac-change-input-method)
     555 
     556 
     557  ;; Set up a number of aliases and other layers to pretend we're using
    14558*************** The properties returned may include `top
    15 *** 549,562 ****
     559*** 259,272 ****
    16560  ;; editing window.)
    17561 
     
    28572 
    29573  ;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
    30 --- 550,579 ----
     574--- 260,289 ----
    31575  ;; editing window.)
    32576 
     
    59603 
    60604  ;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
     605*************** When text is in th echo area, this just
     606*** 274,290 ****
     607  (defun ns-in-echo-area ()
     608    "Whether, for purposes of inserting working composition text, the minibuffer
     609  is currently being used."
     610!   (or isearch-mode
     611!       (and cursor-in-echo-area (current-message))
     612!       ;; Overlay strings are not shown in some cases.
     613!       (get-char-property (point) 'invisible)
     614!       (and (not (bobp))
     615!          (or (and (get-char-property (point) 'display)
     616!                   (eq (get-char-property (1- (point)) 'display)
     617!                       (get-char-property (point) 'display)))
     618!              (and (get-char-property (point) 'composition)
     619!                   (eq (get-char-property (1- (point)) 'composition)
     620!                       (get-char-property (point) 'composition)))))))
     621 
     622  ;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
     623  ;; always returns nil for some reason.  If this WASN'T the case, we could
     624--- 291,309 ----
     625  (defun ns-in-echo-area ()
     626    "Whether, for purposes of inserting working composition text, the minibuffer
     627  is currently being used."
     628!   (setq mac-in-echo-area
     629!       (or isearch-mode
     630!           (and cursor-in-echo-area (current-message))
     631!           ;; Overlay strings are not shown in some cases.
     632!           (get-char-property (point) 'invisible)
     633!           (and (not (bobp))
     634!                (or (and (get-char-property (point) 'display)
     635!                         (eq (get-char-property (1- (point)) 'display)
     636!                             (get-char-property (point) 'display)))
     637!                    (and (get-char-property (point) 'composition)
     638!                         (eq (get-char-property (1- (point)) 'composition)
     639!                             (get-char-property (point) 'composition)))))))
     640!   mac-in-echo-area)
     641 
     642  ;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
     643  ;; always returns nil for some reason.  If this WASN'T the case, we could
    61644*************** is currently being used."
    62 *** 583,588 ****
    63 --- 600,606 ----
     645*** 293,298 ****
     646--- 312,318 ----
    64647  (defun ns-put-working-text ()
    65648    (interactive)
     
    70653    (ns-delete-working-text))
    71654*************** The overlay is assigned the face `ns-wor
    72 *** 604,622 ****
     655*** 314,332 ****
    73656  (defun ns-echo-working-text ()
    74657    "Echo contents of `ns-working-text' in message display area.
     
    90673     ((and (overlayp ns-working-overlay)
    91674           ;; Still alive?
    92 --- 622,700 ----
     675--- 334,414 ----
    93676  (defun ns-echo-working-text ()
    94677    "Echo contents of `ns-working-text' in message display area.
     
    123706!   (ns-delete-working-text)
    124707!   (let ((start (point)))
    125 !     (put-text-property pos len 'face 'ns-working-text-face ns-working-text)
    126 !     (insert ns-working-text)
    127 !     (if (= len 0)
    128 !         (overlay-put (setq ns-working-overlay
    129 !                            (make-overlay start (point) (current-buffer) nil t))
    130 !                      'face 'ns-working-text-face)
    131 !       (overlay-put (setq ns-working-overlay
    132 !                          (make-overlay start (point) (current-buffer) nil t))
    133 !                    'face 'ns-unmarked-text-face)
    134 !       (overlay-put (setq ns-marked-overlay
    135 !                          (make-overlay (+ start pos) (+ start pos len)
    136 !                                        (current-buffer) nil t))
    137 !                    'face 'ns-marked-text-face))
    138 !     (goto-char (+ start pos))))
     708!     (if (<= pos (length ns-working-text))
     709!       (progn
     710!       (put-text-property pos len 'face 'ns-working-text-face ns-working-text)
     711!       (insert ns-working-text)
     712!       (if (= len 0)
     713!           (overlay-put (setq ns-working-overlay
     714!                              (make-overlay start (point) (current-buffer) nil t))
     715!                        'face 'ns-working-text-face)
     716!         (overlay-put (setq ns-working-overlay
     717!                            (make-overlay start (point) (current-buffer) nil t))
     718!                      'face 'ns-unmarked-text-face)
     719!         (overlay-put (setq ns-marked-overlay
     720!                            (make-overlay (+ start pos) (+ start pos len)
     721!                                          (current-buffer) nil t))
     722!                      'face 'ns-marked-text-face))
     723!       (goto-char (+ start pos))))))
    139724!     
    140725! (defun ns-echo-marked-text (pos len)
     
    149734!     (setq ns-working-overlay (length ns-working-text))
    150735!     (setq msg (concat msg ns-working-text))
    151 !     (if (> len 0)
     736!     (if (= len 0)
    152737!         (put-text-property msglen (+ msglen ns-working-overlay)
    153738!                            'face 'ns-working-text-face msg)
     
    170755     ((and (overlayp ns-working-overlay)
    171756           ;; Still alive?
    172 *************** the operating system.")
    173 *** 1267,1272 ****
    174 --- 1345,1771 ----
     757*************** See the documentation of `create-fontset
     758*** 931,936 ****
     759--- 1013,1438 ----
    175760  (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
    176761 
     
    279864+      (title . "速")
    280865+      (cursor-color)
    281 +      (Cursor-type))
     866+      (cursor-type))
    282867+     ("com.apple.inputmethod.TCIM.Dayi"
    283868+      (title . "易")
     
    5161101+       (setq default-input-method "MacOSX")
    5171102+       (add-hook 'minibuffer-setup-hook 'mac-change-language-to-us)
    518 +       (mac-translate-from-yen-to-backslash)
    519 +       (mac-add-key-passed-to-system 'shift))
     1103+       (mac-translate-from-yen-to-backslash))
    5201104+     (setq default-input-method nil)))
    5211105+
     
    5991183  (provide 'ns-win)
    6001184 
    601   ;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644
    602 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/Makefile.in src/Makefile.in
    603 *** ../emacs-23.3-0-lion/src/Makefile.in        2011-12-05 16:49:13.000000000 +0900
    604 --- src/Makefile.in     2012-01-13 08:53:57.000000000 +0900
    605 *************** ns_appresdir=@ns_appresdir@/
    606 *** 545,551 ****
    607   ns_appsrc=@ns_appsrc@
    608   /* Object files for NeXTstep */
    609   NS_OBJ= nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
    610 !       fontset.o fringe.o image.o
    611   #endif  /* HAVE_NS */
    612  
    613   #ifdef HAVE_WINDOW_SYSTEM
    614 --- 545,551 ----
    615   ns_appsrc=@ns_appsrc@
    616   /* Object files for NeXTstep */
    617   NS_OBJ= nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
    618 !       fontset.o fringe.o image.o macim.o
    619   #endif  /* HAVE_NS */
    620  
    621   #ifdef HAVE_WINDOW_SYSTEM
    622 *************** obj=    dispnew.o frame.o scroll.o xdisp
    623 *** 583,589 ****
    624   SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
    625     xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
    626     fontset.o dbusbind.o \
    627 !   nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
    628     w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
    629     w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONT_DRIVERS)
    630  
    631 --- 583,589 ----
    632   SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
    633     xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
    634     fontset.o dbusbind.o \
    635 !   nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o\
    636     w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
    637     w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONT_DRIVERS)
    638  
    639 *************** nsterm.o: nsterm.m blockinput.h atimer.h
    640 *** 1168,1173 ****
    641 --- 1168,1174 ----
    642     termopts.h termchar.h disptab.h buffer.h window.h keyboard.h \
    643     $(INTERVALS_H) process.h coding.h lisp.h $(config_h)
    644   nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h lisp.h $(config_h)
    645 + macim.o: macim.m lisp.h blockinput.h termhooks.h keyboard.h buffer.h $(config_h)
    646   process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
    647      commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \
    648      blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \
    649 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/keyboard.c src/keyboard.c
    650 *** ../emacs-23.3-0-lion/src/keyboard.c 2011-12-05 16:49:13.000000000 +0900
    651 --- src/keyboard.c      2012-01-13 08:53:57.000000000 +0900
    652 *************** kbd_buffer_get_event (kbp, used_mouse_me
    653 *** 4243,4250 ****
    654           {
    655             if (event->code == KEY_NS_PUT_WORKING_TEXT)
    656               obj = Fcons (intern ("ns-put-working-text"), Qnil);
    657 !           else
    658               obj = Fcons (intern ("ns-unput-working-text"), Qnil);
    659           kbd_fetch_ptr = event + 1;
    660             if (used_mouse_menu)
    661               *used_mouse_menu = 1;
    662 --- 4243,4252 ----
    663           {
    664             if (event->code == KEY_NS_PUT_WORKING_TEXT)
    665               obj = Fcons (intern ("ns-put-working-text"), Qnil);
    666 !           else if (event->code == KEY_NS_UNPUT_WORKING_TEXT)
    667               obj = Fcons (intern ("ns-unput-working-text"), Qnil);
    668 +         else if (event->code == KEY_NS_PUT_MARKED_TEXT)
    669 +           obj = Fcons (intern ("ns-put-marked-text"), event->arg);
    670           kbd_fetch_ptr = event + 1;
    671             if (used_mouse_menu)
    672               *used_mouse_menu = 1;
    673 *************** keys_of_keyboard ()
    674 *** 12611,12616 ****
    675 --- 12613,12620 ----
    676                             "ns-put-working-text");
    677     initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",
    678                             "ns-unput-working-text");
    679 +   initial_define_lispy_key (Vspecial_event_map, "ns-put-marked-text",
    680 +                           "ns-put-marked-text");
    681     /* Here we used to use `ignore-event' which would simple set prefix-arg to
    682        current-prefix-arg, as is done in `handle-switch-frame'.
    683        But `handle-switch-frame is not run from the special-map.
    684 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/macim.m src/macim.m
    685 *** ../emacs-23.3-0-lion/src/macim.m    1970-01-01 09:00:00.000000000 +0900
    686 --- src/macim.m 2012-01-13 08:53:57.000000000 +0900
    687 ***************
    688 *** 0 ****
    689 --- 1,178 ----
    690 + /* Implementation of Input Method Extension for MacOS X.
    691 +    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    692 +    Taiichi Hashimoto <taiichi2@mac.com>.
    693 + */
    694 +
    695 + #include "config.h"
    696 +
    697 + #ifdef NS_IMPL_COCOA
    698 +
    699 + #include <math.h>
    700 + #include <sys/types.h>
    701 + #include <time.h>
    702 + #include <signal.h>
    703 + #include <unistd.h>
    704 +
    705 + #include <Carbon/Carbon.h>
    706 +
    707 + #include "lisp.h"
    708 + #include "blockinput.h"
    709 +
    710 + enum output_method
    711 + {
    712 +   output_initial,
    713 +   output_termcap,
    714 +   output_x_window,
    715 +   output_msdos_raw,
    716 +   output_w32,
    717 +   output_mac,
    718 +   output_ns
    719 + } output_method;
    720 +
    721 + #include "termhooks.h"
    722 + #include "keyboard.h"
    723 + #include "buffer.h"
    724 +
    725 + extern Lisp_Object Qcurrent_input_method;
    726 + extern int cursor_in_echo_area;
    727 + static Lisp_Object Qmac_keys_passed_to_system;
    728 + static Lisp_Object Vmac_use_input_method_on_system;
    729 +
    730 + void mac_init_input_method ();
    731 + int mac_pass_key_to_system (int code, int modifiers);
    732 + int mac_pass_key_directly_to_emacs ();
    733 + int mac_store_change_input_method_event ();
    734 +
    735 + DEFUN ("mac-input-source-is-ascii-capable", Fmac_input_source_is_ascii_capable,
    736 +        Smac_input_source_is_ascii_capable, 0, 0, 0,
    737 +        doc: /* Is current input source ascii capable? */)
    738 +      ()
    739 + {
    740 +   TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
    741 +   CFBooleanRef ret = TISGetInputSourceProperty(is, kTISPropertyInputSourceIsASCIICapable);
    742 +   
    743 +   return CFBooleanGetValue(ret)? Qt : Qnil;
    744 + }
    745 +
    746 + DEFUN ("mac-get-input-source-list", Fmac_get_input_source_list,
    747 +        Smac_get_input_source_list, 0, 0, 0,
    748 +        doc: /* get input source list on MacOSX */)
    749 +      ()
    750 + {
    751 +   NSArray *is_list = (NSArray *)TISCreateInputSourceList(NULL, false);
    752 +   int list_size = [is_list count];
    753 +   Lisp_Object list[list_size];
    754 +   int i;
    755 +
    756 +   for (i = 0; i < list_size; i++) {
    757 +     TISInputSourceRef is = [is_list objectAtIndex:i];
    758 +     NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
    759 +     list[i] = make_string([id UTF8String],
    760 +                         [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
    761 +   }
    762 +
    763 +   return Flist(list_size, list);
    764 + }
    765 +
    766 + DEFUN ("mac-get-current-input-source", Fmac_get_current_input_source,
    767 +        Smac_get_current_input_source, 0, 0, 0,
    768 +        doc: /* get current input source on MacOSX */)
    769 +      ()
    770 + {
    771 +   TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
    772 +   NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
    773 +
    774 +   return make_string([id UTF8String],
    775 +                    [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
    776 + }
    777 +
    778 + DEFUN ("mac-toggle-input-source", Fmac_toggle_input_source,
    779 +        Smac_toggle_input_source, 1, 1, 0,
    780 +        doc: /* toggle input source on MacOSX */)
    781 +      (arg)
    782 +      Lisp_Object arg;
    783 + {
    784 +   TISInputSourceRef is = NULL;
    785 +
    786 +   if (NILP (arg))
    787 +     {
    788 +       is = TISCopyCurrentASCIICapableKeyboardInputSource();
    789 +     }
    790 +   else
    791 +     {
    792 +       NSString *locale = [[NSLocale currentLocale] localeIdentifier];
    793 +       is = TISCopyInputSourceForLanguage(locale);
    794 +     }
    795 +   if (is) TISSelectInputSource(is);
    796 +
    797 +   return arg;
    798 + }
    799 +
    800 + int
    801 + mac_store_change_input_method_event ()
    802 + {
    803 +   Lisp_Object dim;
    804 +   int ret = FALSE;
    805 +   
    806 +   dim = Fsymbol_value (intern ("default-input-method"));
    807 +   if (STRINGP (dim) && strcmp(SDATA (dim), "MacOSX") == 0)
    808 +     {
    809 +       ret = TRUE;
    810 +     }
    811 +
    812 +   return ret;
    813 + }
    814 +
    815 + int
    816 + mac_pass_key_to_system (int code, int modifiers)
    817 + {
    818 +   Lisp_Object keys = Fsymbol_value (Qmac_keys_passed_to_system);
    819 +   Lisp_Object m, k;
    820 +
    821 +   while (!NILP (keys))
    822 +     {
    823 +       m = XCAR (XCAR (keys));
    824 +       k = XCDR (XCAR (keys));
    825 +       keys = XCDR (keys);
    826 +
    827 +       if (NUMBERP (m) && modifiers == XINT (m))
    828 +       if (NILP (k)
    829 +           || (NUMBERP (k) && code == XINT (k)))
    830 +         return TRUE;
    831 +     }
    832 +   
    833 +   return FALSE;
    834 + }
    835 +
    836 + int
    837 + mac_pass_key_directly_to_emacs ()
    838 + {
    839 +
    840 +   if (NILP (Fmac_input_source_is_ascii_capable()))
    841 +     {
    842 +       if (NILP (Vmac_use_input_method_on_system)
    843 +         || this_command_key_count
    844 +         || cursor_in_echo_area
    845 +         || !NILP (current_buffer->read_only))
    846 +       return TRUE;
    847 +     }
    848 +
    849 +   return FALSE;
    850 + }
    851 +
    852 +
    853 + void mac_init_input_method ()
    854 + {
    855 +   Qmac_keys_passed_to_system = intern ("mac-keys-passed-to-system");
    856 +   staticpro (&Qmac_keys_passed_to_system);
    857 +
    858 +   DEFVAR_LISP ("mac-use-input-method-on-system", &Vmac_use_input_method_on_system,
    859 +                doc: /* If it is non-nil, use input method on system. */);
    860 +   Vmac_use_input_method_on_system = Qt;
    861 +
    862 +   defsubr (&Smac_input_source_is_ascii_capable);
    863 +   defsubr (&Smac_get_input_source_list);
    864 +   defsubr (&Smac_get_current_input_source);
    865 +   defsubr (&Smac_toggle_input_source);
    866 + }
    867 + #endif
    868 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/nsfns.m src/nsfns.m
    869 *** ../emacs-23.3-0-lion/src/nsfns.m    2011-12-05 16:49:13.000000000 +0900
    870 --- src/nsfns.m 2012-01-13 08:53:57.000000000 +0900
    871 *************** Lisp_Object Fx_open_connection (Lisp_Obj
    872 *** 103,108 ****
    873 --- 103,113 ----
    874  
    875   extern BOOL ns_in_resize;
    876  
    877 + /* key masks */
    878 + static Lisp_Object Vns_shift_key_mask;
    879 + static Lisp_Object Vns_control_key_mask;
    880 + static Lisp_Object Vns_alternate_key_mask;
    881 + static Lisp_Object Vns_command_key_mask;
    882  
    883   /* ==========================================================================
    884  
    885 *************** be used as the image of the icon represe
    886 *** 2632,2637 ****
    887 --- 2637,2660 ----
    888                  doc: /* Toolkit version for NS Windowing.  */);
    889     Vns_version_string = ns_appkit_version_str ();
    890  
    891 +
    892 +   DEFVAR_LISP ("ns-shift-key-mask", &Vns_shift_key_mask,
    893 +                doc: /* Shift key mask defined in system. */);
    894 +   Vns_shift_key_mask = make_number (NSShiftKeyMask);
    895 +
    896 +   DEFVAR_LISP ("ns-control-key-mask", &Vns_control_key_mask,
    897 +                doc: /* Control key mask defined in system. */);
    898 +   Vns_control_key_mask = make_number (NSControlKeyMask);
    899 +
    900 +   DEFVAR_LISP ("ns-alternate-key-mask", &Vns_alternate_key_mask,
    901 +                doc: /* Alternate key mask defined in system. */);
    902 +   Vns_alternate_key_mask = make_number (NSAlternateKeyMask);
    903 +
    904 +   DEFVAR_LISP ("ns-command-key-mask", &Vns_command_key_mask,
    905 +                doc: /* Command key mask defined in system. */);
    906 +   Vns_command_key_mask = make_number (NSCommandKeyMask);
    907 +
    908 +
    909     defsubr (&Sns_read_file_name);
    910     defsubr (&Sns_get_resource);
    911     defsubr (&Sns_set_resource);
    912 *************** be used as the image of the icon represe
    913 *** 2676,2681 ****
    914 --- 2699,2708 ----
    915     defsubr (&Sx_show_tip);
    916     defsubr (&Sx_hide_tip);
    917  
    918 + #ifdef NS_IMPL_COCOA
    919 +   mac_init_input_method ();
    920 + #endif
    921 +
    922     /* used only in fontset.c */
    923     check_window_system_func = check_ns;
    924  
    925 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/nsterm.h src/nsterm.h
    926 *** ../emacs-23.3-0-lion/src/nsterm.h   2011-12-05 16:49:13.000000000 +0900
    927 --- src/nsterm.h        2012-01-13 08:53:57.000000000 +0900
    928 *************** typedef unsigned int NSUInteger;
    929 *** 365,370 ****
    930 --- 365,372 ----
    931   #define KEY_NS_NEW_FRAME               ((1<<28)|(0<<16)|12)
    932   #define KEY_NS_TOGGLE_TOOLBAR          ((1<<28)|(0<<16)|13)
    933   #define KEY_NS_SHOW_PREFS              ((1<<28)|(0<<16)|14)
    934 + #define KEY_MAC_CHANGE_INPUT_METHOD    ((1<<28)|(0<<16)|15)
    935 + #define KEY_NS_PUT_MARKED_TEXT         ((1<<28)|(0<<16)|16)
    936  
    937   /* could use list to store these, but rest of emacs has a big infrastructure
    938      for managing a table of bitmap "records" */
    939 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/nsterm.m src/nsterm.m
    940 *** ../emacs-23.3-0-lion/src/nsterm.m   2011-12-05 16:50:06.000000000 +0900
    941 --- src/nsterm.m        2012-01-13 08:53:57.000000000 +0900
    942 *************** ns_term_init (Lisp_Object display_name)
    943 *** 3730,3735 ****
    944 --- 3730,3738 ----
    945     /*   [[NSNotificationCenter defaultCenter] addObserver: NSApp
    946                                            selector: @selector (logNotification:)
    947                                                name: nil object: nil]; */
    948 +   [[NSDistributedNotificationCenter defaultCenter] addObserver: NSApp
    949 +                                       selector: @selector (changeInputMethod:)
    950 +                                                  name: @"AppleSelectedInputSourcesChangedNotification" object: nil];
    951  
    952     dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info));
    953     bzero (dpyinfo, sizeof (struct ns_display_info));
    954 *************** ns_term_shutdown (int sig)
    955 *** 3935,3940 ****
    956 --- 3938,3955 ----
    957       NSLog (@"notification: '%@'", [notification name]);
    958   }
    959  
    960 + - (void)changeInputMethod: (NSNotification *)notification
    961 + {
    962 +
    963 +   struct frame *emacsframe = SELECTED_FRAME ();
    964 +
    965 +   if (mac_store_change_input_method_event())
    966 +     {
    967 +       emacs_event->kind = NS_NONKEY_EVENT;
    968 +       emacs_event->code = KEY_MAC_CHANGE_INPUT_METHOD;
    969 +       EV_TRAILER ((id)nil);
    970 +     }
    971 + }
    972  
    973   - (void)sendEvent: (NSEvent *)theEvent
    974   /* --------------------------------------------------------------------------
    975 *************** ns_term_shutdown (int sig)
    976 *** 4488,4510 ****
    977                code, fnKeysym, flags, emacs_event->modifiers);
    978  
    979         /* if it was a function key or had modifiers, pass it directly to emacs */
    980 !       if (fnKeysym || (emacs_event->modifiers
    981 !                        && [[theEvent charactersIgnoringModifiers] length] > 0))
    982 ! /*[[theEvent characters] length] */
    983 !         {
    984 !           emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
    985 !           if (code < 0x20)
    986 !             code |= (1<<28)|(3<<16);
    987 !           else if (code == 0x7f)
    988 !             code |= (1<<28)|(3<<16);
    989 !           else if (!fnKeysym)
    990 !             emacs_event->kind = code > 0xFF
    991 !               ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
    992  
    993 !           emacs_event->code = code;
    994 !           EV_TRAILER (theEvent);
    995 !           return;
    996 !         }
    997       }
    998  
    999     /* if we get here we should send the key for input manager processing */
    1000 --- 4503,4540 ----
    1001                code, fnKeysym, flags, emacs_event->modifiers);
    1002  
    1003         /* if it was a function key or had modifiers, pass it directly to emacs */
    1004 !       /* The function mac_pass_key_directly_to_emacs check special case
    1005 !          to pass it directly to emacs, such as passwd, read-only buffer, etc. */
    1006  
    1007 !         if (mac_pass_key_directly_to_emacs ()
    1008 !           || fnKeysym
    1009 !           || (emacs_event->modifiers
    1010 !               && [[theEvent charactersIgnoringModifiers] length] > 0))
    1011 !         {
    1012 !           emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
    1013 !           if (code < 0x20)
    1014 !             code |= (1<<28)|(3<<16);
    1015 !           else if (code == 0x7f)
    1016 !             code |= (1<<28)|(3<<16);
    1017 !           else if (!fnKeysym)
    1018 !             emacs_event->kind = code > 0xFF
    1019 !               ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
    1020 !           
    1021 !           emacs_event->code = code;
    1022 !
    1023 !           /* The function mac_pass_key_to_system decides whether it is
    1024 !              passed directly to emacs or not. */
    1025 !           if (emacs_event->kind == NON_ASCII_KEYSTROKE_EVENT
    1026 !               || !mac_pass_key_to_system (code, flags
    1027 !                                           & (NSShiftKeyMask
    1028 !                                              | NSControlKeyMask
    1029 !                                              | NSAlternateKeyMask
    1030 !                                              | NSCommandKeyMask)))
    1031 !             {
    1032 !               EV_TRAILER (theEvent);
    1033 !               return;
    1034 !             }
    1035 !         }
    1036       }
    1037  
    1038     /* if we get here we should send the key for input manager processing */
    1039 *************** ns_term_shutdown (int sig)
    1040 *** 4594,4603 ****
    1041       NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
    1042              selRange.length, selRange.location);
    1043  
    1044 -   if (workingText != nil)
    1045 -     [self deleteWorkingText];
    1046     if ([str length] == 0)
    1047 !     return;
    1048  
    1049     if (!emacs_event)
    1050       return;
    1051 --- 4624,4642 ----
    1052       NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
    1053              selRange.length, selRange.location);
    1054  
    1055     if ([str length] == 0)
    1056 !     {
    1057 !       [self deleteWorkingText];
    1058 !       return;
    1059 !     }
    1060 !   else
    1061 !     {
    1062 !       if (workingText != nil) {
    1063 !       [workingText release];
    1064 !       workingText = nil;
    1065 !       processingCompose = NO;
    1066 !       }
    1067 !     }
    1068  
    1069     if (!emacs_event)
    1070       return;
    1071 *************** ns_term_shutdown (int sig)
    1072 *** 4607,4613 ****
    1073     ns_working_text = build_string ([workingText UTF8String]);
    1074  
    1075     emacs_event->kind = NS_TEXT_EVENT;
    1076 !   emacs_event->code = KEY_NS_PUT_WORKING_TEXT;
    1077     EV_TRAILER ((id)nil);
    1078   }
    1079  
    1080 --- 4646,4654 ----
    1081     ns_working_text = build_string ([workingText UTF8String]);
    1082  
    1083     emacs_event->kind = NS_TEXT_EVENT;
    1084 !   emacs_event->code = KEY_NS_PUT_MARKED_TEXT;
    1085 !   emacs_event->arg = Fcons (make_number (selRange.location),
    1086 !                           Fcons (make_number (selRange.length), Qnil));
    1087     EV_TRAILER ((id)nil);
    1088   }
    1089  
    1090 *************** ns_term_shutdown (int sig)
    1091 *** 4662,4676 ****
    1092   {
    1093     NSRect rect;
    1094     NSPoint pt;
    1095 !   struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
    1096     if (NS_KEYLOG)
    1097       NSLog (@"firstRectForCharRange request");
    1098  
    1099     rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
    1100     rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
    1101     pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
    1102     pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
    1103 !                                        +FRAME_LINE_HEIGHT (emacsframe));
    1104  
    1105     pt = [self convertPoint: pt toView: nil];
    1106     pt = [[self window] convertBaseToScreen: pt];
    1107 --- 4703,4725 ----
    1108   {
    1109     NSRect rect;
    1110     NSPoint pt;
    1111 !   //  struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
    1112 !   struct window *win;
    1113     if (NS_KEYLOG)
    1114       NSLog (@"firstRectForCharRange request");
    1115 +     
    1116 +   if (NILP (Feval (Fcons (intern ("ns-in-echo-area"), Qnil))))
    1117 +     win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
    1118 +   else if (WINDOWP (echo_area_window))
    1119 +     win = XWINDOW (echo_area_window);
    1120 +   else
    1121 +     win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
    1122  
    1123     rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
    1124     rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
    1125     pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
    1126     pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
    1127 !                                        +FRAME_LINE_HEIGHT (emacsframe)+2);
    1128  
    1129     pt = [self convertPoint: pt toView: nil];
    1130     pt = [[self window] convertBaseToScreen: pt];
    1131 diff -r -p -N -x '*.o' ../emacs-23.3-0-lion/src/s/darwin.h src/s/darwin.h
    1132 *** ../emacs-23.3-0-lion/src/s/darwin.h 2011-12-05 16:49:29.000000000 +0900
    1133 --- src/s/darwin.h      2012-01-13 08:53:57.000000000 +0900
    1134 *************** along with GNU Emacs.  If not, see <http
    1135 *** 163,169 ****
    1136   /* Definitions for how to compile & link.  */
    1137  
    1138   #ifdef HAVE_NS
    1139 ! #define LIBS_NSGUI -framework AppKit
    1140   #define SYSTEM_PURESIZE_EXTRA 200000
    1141   #define HEADERPAD_EXTRA 6C8
    1142   #else /* !HAVE_NS */
    1143 --- 163,169 ----
    1144   /* Definitions for how to compile & link.  */
    1145  
    1146   #ifdef HAVE_NS
    1147 ! #define LIBS_NSGUI -framework AppKit -framework Carbon
    1148   #define SYSTEM_PURESIZE_EXTRA 200000
    1149   #define HEADERPAD_EXTRA 6C8
    1150   #else /* !HAVE_NS */
     1185  ;;; ns-win.el ends here
     1186
Note: See TracChangeset for help on using the changeset viewer.