Ticket #45167: patch-macemacsjp-inline.diff

File patch-macemacsjp-inline.diff, 42.4 KB (added by MasakiOita, 10 years ago)
Line 
1diff -r -N -p -x '*.elc' ../emacs-24.3.org/lisp/term/common-win.el lisp/term/common-win.el
2*** ../emacs-24.3.org/lisp/term/common-win.el   2013-01-02 05:37:17.000000000 +0900
3--- lisp/term/common-win.el     2013-04-13 21:49:53.000000000 +0900
4*************** is not used)."
5*** 127,132 ****
6--- 127,133 ----
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               ))))
12      (set-terminal-parameter frame 'x-setup-function-keys t)))
13 
14diff -r -N -p -x '*.elc' ../emacs-24.3.org/lisp/term/ns-win.el lisp/term/ns-win.el
15*** ../emacs-24.3.org/lisp/term/ns-win.el       2013-01-02 05:37:17.000000000 +0900
16--- lisp/term/ns-win.el 2013-04-13 21:50:48.000000000 +0900
17*************** The properties returned may include `top
18*** 171,176 ****
19--- 171,177 ----
20  (define-key global-map [ns-new-frame] 'make-frame)
21  (define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
22  (define-key global-map [ns-show-prefs] 'customize)
23+ (define-key global-map [mac-change-input-method] 'mac-change-input-method)
24 
25 
26  ;; Set up a number of aliases and other layers to pretend we're using
27*************** The properties returned may include `top
28*** 256,269 ****
29  ;; editing window.)
30 
31  (defface ns-working-text-face
32!   '((t :underline t))
33    "Face used to highlight working text during compose sequence insert."
34    :group 'ns)
35 
36  (defvar ns-working-overlay nil
37    "Overlay used to highlight working text during compose sequence insert.
38  When text is in th echo area, this just stores the length of the working text.")
39 
40  (defvar ns-working-text)              ; nsterm.m
41 
42  ;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
43--- 257,286 ----
44  ;; editing window.)
45 
46  (defface ns-working-text-face
47!   '((((background dark)) :underline "gray80")
48!     (t :underline "gray20"))
49    "Face used to highlight working text during compose sequence insert."
50    :group 'ns)
51 
52+ (defface ns-marked-text-face
53+   '((((background dark)) :underline "gray80")
54+     (t :underline "gray20"))
55+   "Face used to highlight marked text during compose sequence insert."
56+   :group 'ns)
57+
58+ (defface ns-unmarked-text-face
59+   '((((background dark)) :underline "gray20")
60+     (t :underline "gray80"))
61+   "Face used to highlight marked text during compose sequence insert."
62+   :group 'ns)
63+
64  (defvar ns-working-overlay nil
65    "Overlay used to highlight working text during compose sequence insert.
66  When text is in th echo area, this just stores the length of the working text.")
67 
68+ (defvar ns-marked-overlay nil
69+   "Overlay used to highlight marked text during compose sequence insert.")
70+
71  (defvar ns-working-text)              ; nsterm.m
72 
73  ;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
74*************** When text is in th echo area, this just
75*** 271,287 ****
76  (defun ns-in-echo-area ()
77    "Whether, for purposes of inserting working composition text, the minibuffer
78  is currently being used."
79!   (or isearch-mode
80!       (and cursor-in-echo-area (current-message))
81!       ;; Overlay strings are not shown in some cases.
82!       (get-char-property (point) 'invisible)
83!       (and (not (bobp))
84!          (or (and (get-char-property (point) 'display)
85!                   (eq (get-char-property (1- (point)) 'display)
86!                       (get-char-property (point) 'display)))
87!              (and (get-char-property (point) 'composition)
88!                   (eq (get-char-property (1- (point)) 'composition)
89!                       (get-char-property (point) 'composition)))))))
90 
91  ;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
92  ;; always returns nil for some reason.  If this WASN'T the case, we could
93--- 288,306 ----
94  (defun ns-in-echo-area ()
95    "Whether, for purposes of inserting working composition text, the minibuffer
96  is currently being used."
97!   (setq mac-in-echo-area
98!       (or isearch-mode
99!           (and cursor-in-echo-area (current-message))
100!           ;; Overlay strings are not shown in some cases.
101!           (get-char-property (point) 'invisible)
102!           (and (not (bobp))
103!                (or (and (get-char-property (point) 'display)
104!                         (eq (get-char-property (1- (point)) 'display)
105!                             (get-char-property (point) 'display)))
106!                    (and (get-char-property (point) 'composition)
107!                         (eq (get-char-property (1- (point)) 'composition)
108!                             (get-char-property (point) 'composition)))))))
109!   mac-in-echo-area)
110 
111  ;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
112  ;; always returns nil for some reason.  If this WASN'T the case, we could
113*************** is currently being used."
114*** 290,295 ****
115--- 309,315 ----
116  (defun ns-put-working-text ()
117    (interactive)
118    (if (ns-in-echo-area) (ns-echo-working-text) (ns-insert-working-text)))
119+
120  (defun ns-unput-working-text ()
121    (interactive)
122    (ns-delete-working-text))
123*************** The overlay is assigned the face `ns-wor
124*** 311,329 ****
125  (defun ns-echo-working-text ()
126    "Echo contents of `ns-working-text' in message display area.
127  See `ns-insert-working-text'."
128-   (ns-delete-working-text)
129    (let* ((msg (current-message))
130!        (msglen (length msg))
131!        message-log-max)
132      (setq ns-working-overlay (length ns-working-text))
133      (setq msg (concat msg ns-working-text))
134      (put-text-property msglen (+ msglen ns-working-overlay)
135!                      'face 'ns-working-text-face msg)
136      (message "%s" msg)))
137 
138  (defun ns-delete-working-text()
139!   "Delete working text and clear `ns-working-overlay'."
140    (interactive)
141    (cond
142     ((and (overlayp ns-working-overlay)
143           ;; Still alive?
144--- 331,411 ----
145  (defun ns-echo-working-text ()
146    "Echo contents of `ns-working-text' in message display area.
147  See `ns-insert-working-text'."
148    (let* ((msg (current-message))
149!          (msglen (length msg))
150!          message-log-max)
151!     (if (integerp ns-working-overlay)
152!       (progn
153!         (setq msg (substring msg 0 (- (length msg) ns-working-overlay)))
154!         (setq msglen (length msg))))
155      (setq ns-working-overlay (length ns-working-text))
156      (setq msg (concat msg ns-working-text))
157      (put-text-property msglen (+ msglen ns-working-overlay)
158!                       'face 'ns-working-text-face msg)
159!      (message "%s" msg)))
160!
161! (defun ns-put-marked-text (event)
162!   (interactive "e")
163!
164!   (let ((pos (nth 1 event))
165!       (len (nth 2 event)))
166!     (if (ns-in-echo-area)
167!       (ns-echo-marked-text pos len)
168!       (ns-insert-marked-text pos len))))
169!
170! (defun ns-insert-marked-text (pos len)
171!   "Insert contents of `ns-working-text' as UTF-8 string and mark with
172! `ns-working-overlay' and `ns-marked-overlay'.  Any previously existing
173! working text is cleared first. The overlay is assigned the faces
174! `ns-working-text-face' and `ns-marked-text-face'."
175!   (ns-delete-working-text)
176!   (let ((start (point)))
177!     (if (<= pos (length ns-working-text))
178!       (progn
179!       (put-text-property pos len 'face 'ns-working-text-face ns-working-text)
180!       (insert ns-working-text)
181!       (if (= len 0)
182!           (overlay-put (setq ns-working-overlay
183!                              (make-overlay start (point) (current-buffer) nil t))
184!                        'face 'ns-working-text-face)
185!         (overlay-put (setq ns-working-overlay
186!                            (make-overlay start (point) (current-buffer) nil t))
187!                      'face 'ns-unmarked-text-face)
188!         (overlay-put (setq ns-marked-overlay
189!                            (make-overlay (+ start pos) (+ start pos len)
190!                                          (current-buffer) nil t))
191!                      'face 'ns-marked-text-face))
192!       (goto-char (+ start pos))))))
193!     
194! (defun ns-echo-marked-text (pos len)
195!   "Echo contents of `ns-working-text' in message display area.
196! See `ns-insert-working-text'."
197!   (let* ((msg (current-message))
198!          (msglen (length msg))
199!          message-log-max)
200!     (when (integerp ns-working-overlay)
201!       (setq msg (substring msg 0 (- (length msg) ns-working-overlay)))
202!       (setq msglen (length msg)))
203!     (setq ns-working-overlay (length ns-working-text))
204!     (setq msg (concat msg ns-working-text))
205!     (if (= len 0)
206!         (put-text-property msglen (+ msglen ns-working-overlay)
207!                            'face 'ns-working-text-face msg)
208!       (put-text-property msglen (+ msglen ns-working-overlay)
209!                          'face 'ns-unmarked-text-face msg)
210!       (put-text-property (+ msglen pos) (+ msglen pos len)
211!                          'face 'ns-marked-text-face msg))
212      (message "%s" msg)))
213 
214  (defun ns-delete-working-text()
215!   "Delete working text and clear `ns-working-overlay' and `ns-marked-overlay'."
216    (interactive)
217+   (when (and (overlayp ns-marked-overlay)
218+            ;; Still alive
219+            (overlay-buffer ns-marked-overlay))
220+     (with-current-buffer (overlay-buffer ns-marked-overlay)
221+       (delete-overlay ns-marked-overlay)))
222+   (setq ns-marked-overlay nil)
223    (cond
224     ((and (overlayp ns-working-overlay)
225           ;; Still alive?
226*************** See the documentation of `create-fontset
227*** 943,948 ****
228--- 1025,1490 ----
229  (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
230 
231 
232+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
233+ ;;
234+ ;; Implementation of Input Method Extension for MacOS X
235+ ;; written by Taiichi Hashimoto <taiichi2@mac.com>
236+ ;;
237+
238+ (defvar mac-input-method-parameters
239+   '(
240+     ("com.apple.inputmethod.Kotoeri.Roman"
241+      (title . "A")
242+      (cursor-color)
243+      (cursor-type))
244+     ("com.apple.inputmethod.Kotoeri.Japanese"
245+      (title . "あ")
246+      (cursor-color)
247+      (cursor-type))
248+     ("com.apple.inputmethod.Kotoeri.Japanese.Katakana"
249+      (title . "ア")
250+      (cursor-color)
251+      (cursor-type))
252+     ("com.apple.inputmethod.Kotoeri.Japanese.FullWidthRoman"
253+      (title . "A")
254+      (cursor-color)
255+      (cursor-type))
256+     ("com.apple.inputmethod.Kotoeri.Japanese.HalfWidthKana"
257+      (title . "ア")
258+      (cursor-color)
259+      (cursor-type))
260+     ("com.apple.inputmethod.kotoeri.Ainu"
261+      (title . "アイヌ")
262+      (cursor-color)
263+      (cursor-type))
264+     ("com.apple.inputmethod.Korean.2SetKorean"
265+      (title . "가2")
266+      (cursor-color)
267+      (cursor-type))
268+     ("com.apple.inputmethod.Korean.3SetKorean"
269+      (title . "가3")
270+      (cursor-color)
271+      (cursor-type))
272+     ("com.apple.inputmethod.Korean.390Sebulshik"
273+      (title . "가5")
274+      (cursor-color)
275+      (cursor-type))
276+     ("com.apple.inputmethod.Korean.GongjinCheongRomaja"
277+      (title . "가G")
278+      (cursor-color)
279+      (cursor-type))
280+     ("com.apple.inputmethod.Korean.HNCRomaja"
281+      (title . "가H")
282+      (cursor-color)
283+      (cursor-type))
284+     ("com.apple.inputmethod.Tamil.AnjalIM"
285+      (title . "Anjal")
286+      (cursor-color)
287+      (cursor-type))
288+     ("com.apple.inputmethod.Tamil.Tamil99"
289+      (title . "Tamil")
290+      (cursor-color)
291+      (cursor-type))
292+     ("com.apple.inputmethod.VietnameseIM.VietnameseSimpleTelex"
293+      (title . "ST")
294+      (cursor-color)
295+      (cursor-type))
296+     ("com.apple.inputmethod.VietnameseIM.VietnameseTelex"
297+      (title . "TX")
298+      (cursor-color)
299+      (cursor-type))
300+     ("com.apple.inputmethod.VietnameseIM.VietnameseVNI"
301+      (title . "VN")
302+      (cursor-color)
303+      (cursor-type))
304+     ("com.apple.inputmethod.VietnameseIM.VietnameseVIQR"
305+      (title . "VQ")
306+      (cursor-color)
307+      (cursor-type))
308+     ("com.apple.inputmethod.SCIM.ITABC"
309+      (title . "拼")
310+      (cursor-color)
311+      (cursor-type))
312+     ("com.apple.inputmethod.SCIM.WBX"
313+      (title . "型")
314+      (cursor-color)
315+      (cursor-type))
316+     ("com.apple.inputmethod.SCIM.WBH"
317+      (title . "画")
318+      (cursor-color)
319+      (cursor-type))
320+     ("com.apple.inputmethod.TCIM.Zhuyin"
321+      (title . "注")
322+      (cursor-color)
323+      (cursor-type))
324+     ("com.apple.inputmethod.TCIM.Pinyin"
325+      (title . "拼")
326+      (cursor-color)
327+      (cursor-type))
328+     ("com.apple.inputmethod.TCIM.Cangjie"
329+      (title . "倉")
330+      (cursor-color)
331+      (cursor-type))
332+     ("com.apple.inputmethod.TCIM.Jianyi"
333+      (title . "速")
334+      (cursor-color)
335+      (cursor-type))
336+     ("com.apple.inputmethod.TCIM.Dayi"
337+      (title . "易")
338+      (cursor-color)
339+      (cursor-type))
340+     ("com.apple.inputmethod.TCIM.Hanin"
341+      (title . "漢")
342+      (cursor-color)
343+      (cursor-type))
344+     ("com.google.inputmethod.Japanese.Roman"
345+      (title . "G")
346+      (cursor-color)
347+      (cursor-type))
348+     ("com.google.inputmethod.Japanese.base"
349+      (title . "ぐ")
350+      (cursor-color)
351+      (cursor-type))
352+     ("com.google.inputmethod.Japanese.Katakana"
353+      (title . "グ")
354+      (cursor-color)
355+      (cursor-type))
356+     ("com.google.inputmethod.Japanese.FullWidthRoman"
357+      (title . "G")
358+      (cursor-color)
359+      (cursor-type))
360+     ("com.google.inputmethod.Japanese.HalfWidthKana"
361+      (title . "グ")
362+      (cursor-color)
363+      (cursor-type))
364+     ("jp.monokakido.inputmethod.Kawasemi.Roman"
365+      (title . "K")
366+      (cursor-color)
367+      (cursor-type))
368+     ("jp.monokakido.inputmethod.Kawasemi.Japanese"
369+      (title . "か")
370+      (cursor-color)
371+      (cursor-type))
372+     ("jp.monokakido.inputmethod.Kawasemi.Japanese.Katakana"
373+      (title . "カ")
374+      (cursor-color)
375+      (cursor-type))
376+     ("jp.monokakido.inputmethod.Kawasemi.Japanese.FullWidthRoman"
377+      (title . "K")
378+      (cursor-color)
379+      (cursor-type))
380+     ("jp.monokakido.inputmethod.Kawasemi.Japanese.HalfWidthKana"
381+      (title . "カ")
382+      (cursor-color)
383+      (cursor-type))
384+     ("jp.monokakido.inputmethod.Kawasemi.Japanese.HalfWidthRoman"
385+      (title . "_K")
386+      (cursor-color)
387+      (cursor-type))
388+     ("jp.monokakido.inputmethod.Kawasemi.Japanese.Code"
389+      (title . "C")
390+      (cursor-color)
391+      (cursor-type))
392+     ("com.justsystems.inputmethod.atok21.Roman"
393+      (title . "A")
394+      (cursor-color)
395+      (cursor-type))
396+     ("com.justsystems.inputmethod.atok21.Japanese"
397+      (title . "あ")
398+      (cursor-color)
399+      (cursor-type))
400+     ("com.justsystems.inputmethod.atok21.Japanese.Katakana"
401+      (title . "ア")
402+      (cursor-color)
403+      (cursor-type))
404+     ("com.justsystems.inputmethod.atok21.Japanese.FullWidthRoman"
405+      (title . "英")
406+      (cursor-color)
407+      (cursor-type))
408+     ("com.justsystems.inputmethod.atok21.Japanese.HalfWidthEiji"
409+      (title . "半英")
410+      (cursor-color)
411+      (cursor-type))
412+     ("com.justsystems.inputmethod.atok22.Roman"
413+      (title . "A")
414+      (cursor-color)
415+      (cursor-type))
416+     ("com.justsystems.inputmethod.atok22.Japanese"
417+      (title . "あ")
418+      (cursor-color)
419+      (cursor-type))
420+     ("com.justsystems.inputmethod.atok22.Japanese.Katakana"
421+      (title . "ア")
422+      (cursor-color)
423+      (cursor-type))
424+     ("com.justsystems.inputmethod.atok22.Japanese.FullWidthRoman"
425+      (title . "英")
426+      (cursor-color)
427+      (cursor-type))
428+     ("com.justsystems.inputmethod.atok22.Japanese.HalfWidthEiji"
429+      (title . "半英")
430+      (cursor-color)
431+      (cursor-type))
432+     ("com.justsystems.inputmethod.atok23.Roman"
433+      (title . "A")
434+      (cursor-color)
435+      (cursor-type))
436+     ("com.justsystems.inputmethod.atok23.Japanese"
437+      (title . "あ")
438+      (cursor-color)
439+      (cursor-type))
440+     ("com.justsystems.inputmethod.atok23.Japanese.Katakana"
441+      (title . "ア")
442+      (cursor-color)
443+      (cursor-type))
444+     ("com.justsystems.inputmethod.atok23.Japanese.FullWidthRoman"
445+      (title . "英")
446+      (cursor-color)
447+      (cursor-type))
448+     ("com.justsystems.inputmethod.atok23.Japanese.HalfWidthEiji"
449+      (title . "半英")
450+      (cursor-color)
451+      (cursor-type))
452+     ("com.justsystems.inputmethod.atok24.Roman"
453+      (title . "A")
454+      (cursor-color)
455+      (cursor-type))
456+     ("com.justsystems.inputmethod.atok24.Japanese"
457+      (title . "あ")
458+      (cursor-color)
459+      (cursor-type))
460+     ("com.justsystems.inputmethod.atok24.Japanese.Katakana"
461+      (title . "ア")
462+      (cursor-color)
463+      (cursor-type))
464+     ("com.justsystems.inputmethod.atok24.Japanese.FullWidthRoman"
465+      (title . "英")
466+      (cursor-color)
467+      (cursor-type))
468+     ("com.justsystems.inputmethod.atok24.Japanese.HalfWidthEiji"
469+      (title . "半英")
470+      (cursor-color)
471+      (cursor-type))
472+     ("com.justsystems.inputmethod.atok25.Roman"
473+      (title . "A")
474+      (cursor-color)
475+      (cursor-type))
476+     ("com.justsystems.inputmethod.atok25.Japanese"
477+      (title . "あ")
478+      (cursor-color)
479+      (cursor-type))
480+     ("com.justsystems.inputmethod.atok25.Japanese.Katakana"
481+      (title . "ア")
482+      (cursor-color)
483+      (cursor-type))
484+     ("com.justsystems.inputmethod.atok25.Japanese.FullWidthRoman"
485+      (title . "英")
486+      (cursor-color)
487+      (cursor-type))
488+     ("com.justsystems.inputmethod.atok25.Japanese.HalfWidthEiji"
489+      (title . "半英")
490+      (cursor-color)
491+      (cursor-type))
492+     )
493+   "Alist of Mac script code vs parameters for input method on MacOSX.")
494+
495+
496+ (defun mac-get-input-method-parameter (is key)
497+   "Function to get a parameter of a input method."
498+   (interactive)
499+   (assq key (cdr (assoc is mac-input-method-parameters))))
500+
501+ (defun mac-get-input-method-title (&optional input-source)
502+   "Return input method title of input source.
503+    If input-source is nil, return one of current frame."
504+   (if input-source
505+       (cdr (mac-get-input-method-parameter input-source 'title))
506+     current-input-method-title))
507+
508+ (defun mac-get-cursor-type (&optional input-source)
509+   "Return cursor type of input source.
510+    If input-source is nil, return one of current frame."
511+   (if input-source
512+       (or (cdr (mac-get-input-method-parameter input-source 'cursor-type))
513+         (cdr (assq 'cursor-type default-frame-alist))
514+         cursor-type)
515+     (cdr (assq 'cursor-type (frame-parameters (selected-frame))))))
516+
517+ (defun mac-get-cursor-color (&optional input-source)
518+   "Return cursor color of input source.
519+    If input-source is nil, return one of current frame."
520+   (if input-source
521+       (or (cdr (mac-get-input-method-parameter input-source 'cursor-color))
522+         (cdr (assq 'cursor-color default-frame-alist)))
523+     (cdr (assq 'cursor-color (frame-parameters (selected-frame))))))
524+
525+
526+ (defun mac-set-input-method-parameter (is key value)
527+   "Function to set a parameter of a input method."
528+   (let* ((is-param (assoc is mac-input-method-parameters))
529+          (param (assq key is-param)))
530+     (if is-param
531+       (if param
532+           (setcdr param value)
533+         (setcdr is-param (cons (cons key value) (cdr is-param))))
534+       (setq mac-input-method-parameters
535+           (cons (list is (cons key value))
536+                 mac-input-method-parameters)))))
537+
538+
539+ (defun mac-input-method-update (is)
540+   "Funtion to update parameters of a input method."
541+   (interactive)
542+
543+   (let ((title (mac-get-input-method-title is))
544+         (type (mac-get-cursor-type is))
545+         (color (mac-get-cursor-color is)))
546+     (if (and title (not (equal title (mac-get-input-method-title))))
547+       (setq current-input-method-title title))
548+     (if (and type (not (equal type (mac-get-cursor-type))))
549+       (setq cursor-type type))
550+     (if (and color (not (equal color (mac-get-cursor-color))))
551+       (set-cursor-color color))
552+     (force-mode-line-update)
553+     (if isearch-mode (isearch-update))))
554+
555+
556+ (defun mac-toggle-input-method (&optional arg)
557+   "Function to toggle input method on MacOSX."
558+   (interactive)
559+   
560+   (if arg
561+       (progn
562+       (make-local-variable 'input-method-function)
563+       (setq inactivate-current-input-method-function 'mac-toggle-input-method)
564+       (setq input-method-function nil)
565+       (setq describe-current-input-method-function nil)
566+       (mac-toggle-input-source t))
567+     (kill-local-variable 'input-method-function)
568+     (setq describe-current-input-method-function nil)
569+     (mac-toggle-input-source nil)))
570+
571+
572+ (defun mac-change-language-to-us ()
573+   "Function to change language to us."
574+   (interactive)
575+   (mac-toggle-input-method nil))
576+
577+
578+ (defun mac-handle-input-method-change ()
579+   "Function run when a input method change."
580+   (interactive)
581+
582+   (if (equal default-input-method "MacOSX")
583+       (let ((input-source (mac-get-current-input-source))
584+         (ascii-capable (mac-input-source-is-ascii-capable)))
585+       
586+       (cond ((and (not current-input-method) (not ascii-capable))
587+              (set-input-method "MacOSX"))
588+             ((and (equal current-input-method "MacOSX") ascii-capable)
589+              (toggle-input-method nil)))
590+       (mac-input-method-update input-source))))
591+
592+ ;;
593+ ;; Emacs input method for input method on MacOSX.
594+ ;;
595+ (register-input-method "MacOSX" "MacOSX" 'mac-toggle-input-method
596+                      "Mac" "Input Method on MacOSX System")
597+
598+
599+ ;;
600+ ;; Minor mode of using input methods on MacOS X
601+ ;;
602+ (define-minor-mode mac-input-method-mode
603+   "Use input methods on MacOSX."
604+   :init-value nil
605+   :group 'ns
606+   :global t
607+
608+   (if mac-input-method-mode
609+       (progn
610+       (setq default-input-method "MacOSX")
611+       (add-hook 'minibuffer-setup-hook 'mac-change-language-to-us)
612+       (mac-translate-from-yen-to-backslash))
613+     (setq default-input-method nil)))
614+
615+ ;;
616+ ;; Valiable and functions to pass key(shortcut) to system.
617+ ;;
618+ (defvar mac-keys-passed-to-system nil
619+   "A list of keys passed to system on MacOSX.")
620+
621+ (defun mac-add-key-passed-to-system (key)
622+   (let ((shift   '(shift shft))
623+       (control '(control ctrl ctl))
624+       (option  '(option opt alternate alt))
625+       (command '(command cmd)))
626+
627+     (add-to-list 'mac-keys-passed-to-system
628+                (cond ((symbolp key)
629+                       (cond ((memq key shift)
630+                              (cons ns-shift-key-mask nil))
631+                             ((memq key control)
632+                              (cons ns-control-key-mask nil))
633+                             ((memq key option)
634+                              (cons ns-alternate-key-mask nil))
635+                             ((memq key command)
636+                              (cons ns-command-key-mask nil))
637+                             (t (cons nil nil))))
638+                      ((numberp key) (cons 0 key))
639+                      ((listp key)
640+                       (let ((l key) (k nil) (m 0))
641+                         (while l
642+                           (cond ((memq (car l) shift)
643+                                  (setq m (logior m ns-shift-key-mask)))
644+                                 ((memq (car l) control)
645+                                  (setq m (logior m ns-control-key-mask)))
646+                                 ((memq (car l) option)
647+                                  (setq m (logior m ns-alternate-key-mask)))
648+                                 ((memq (car l) command)
649+                                      (setq m (logior m ns-command-key-mask)))
650+                                 ((numberp (car l))
651+                                  (if (not k) (setq k (car l)))))
652+                           (setq l (cdr l)))
653+                         (cons m k)))
654+                      (t (cons nil nil))))))
655+
656+
657+ ;;
658+ ;; Entry Emacs event for inline input method on MacOSX.
659+ ;;
660+ (define-key special-event-map
661+   [mac-change-input-method] 'mac-handle-input-method-change)
662+       
663+ ;;
664+ ;; Convert yen to backslash for JIS keyboard.
665+ ;;
666+ (defun mac-translate-from-yen-to-backslash ()
667+   ;; Convert yen to backslash for JIS keyboard.
668+   (interactive)
669+
670+   (define-key global-map [165] nil)
671+   (define-key global-map [2213] nil)
672+   (define-key global-map [3420] nil)
673+   (define-key global-map [67109029] nil)
674+   (define-key global-map [67111077] nil)
675+   (define-key global-map [8388773] nil)
676+   (define-key global-map [134219941] nil)
677+   (define-key global-map [75497596] nil)
678+   (define-key global-map [201328805] nil)
679+   (define-key function-key-map [165] [?\\])
680+   (define-key function-key-map [2213] [?\\]) ;; for Intel
681+   (define-key function-key-map [3420] [?\\]) ;; for PowerPC
682+   (define-key function-key-map [67109029] [?\C-\\])
683+   (define-key function-key-map [67111077] [?\C-\\])
684+   (define-key function-key-map [8388773] [?\M-\\])
685+   (define-key function-key-map [134219941] [?\M-\\])
686+   (define-key function-key-map [75497596] [?\C-\M-\\])
687+   (define-key function-key-map [201328805] [?\C-\M-\\])
688+ )
689+
690+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
691+
692  (provide 'ns-win)
693 
694  ;;; ns-win.el ends here
695diff -r -N -p ../emacs-24.3.org/src/Makefile.in src/Makefile.in
696*** ../emacs-24.3.org/src/Makefile.in   2013-01-02 05:37:17.000000000 +0900
697--- src/Makefile.in     2013-04-13 21:49:53.000000000 +0900
698*************** obj = $(base_obj) $(NS_OBJC_OBJ)
699*** 356,362 ****
700  SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
701    xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
702    fontset.o dbusbind.o cygw32.o \
703!   nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
704    w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
705    w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
706    w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
707--- 356,362 ----
708  SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
709    xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
710    fontset.o dbusbind.o cygw32.o \
711!   nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o \
712    w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
713    w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
714    w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
715diff -r -N -p ../emacs-24.3.org/src/keyboard.c src/keyboard.c
716*** ../emacs-24.3.org/src/keyboard.c    2013-02-13 13:25:53.000000000 +0900
717--- src/keyboard.c      2013-04-13 21:49:53.000000000 +0900
718*************** kbd_buffer_get_event (KBOARD **kbp,
719*** 3862,3869 ****
720          {
721            if (event->code == KEY_NS_PUT_WORKING_TEXT)
722              obj = Fcons (intern ("ns-put-working-text"), Qnil);
723!           else
724              obj = Fcons (intern ("ns-unput-working-text"), Qnil);
725          kbd_fetch_ptr = event + 1;
726            if (used_mouse_menu)
727              *used_mouse_menu = 1;
728--- 3862,3871 ----
729          {
730            if (event->code == KEY_NS_PUT_WORKING_TEXT)
731              obj = Fcons (intern ("ns-put-working-text"), Qnil);
732!           else if (event->code == KEY_NS_UNPUT_WORKING_TEXT)
733              obj = Fcons (intern ("ns-unput-working-text"), Qnil);
734+         else if (event->code == KEY_NS_PUT_MARKED_TEXT)
735+           obj = Fcons (intern ("ns-put-marked-text"), event->arg);
736          kbd_fetch_ptr = event + 1;
737            if (used_mouse_menu)
738              *used_mouse_menu = 1;
739*************** keys_of_keyboard (void)
740*** 12088,12093 ****
741--- 12090,12097 ----
742                            "ns-put-working-text");
743    initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",
744                            "ns-unput-working-text");
745+   initial_define_lispy_key (Vspecial_event_map, "ns-put-marked-text",
746+                           "ns-put-marked-text");
747    /* Here we used to use `ignore-event' which would simple set prefix-arg to
748       current-prefix-arg, as is done in `handle-switch-frame'.
749       But `handle-switch-frame is not run from the special-map.
750diff -r -N -p ../emacs-24.3.org/src/macim.m src/macim.m
751*** ../emacs-24.3.org/src/macim.m       1970-01-01 09:00:00.000000000 +0900
752--- src/macim.m 2013-04-13 21:50:24.000000000 +0900
753***************
754*** 0 ****
755--- 1,184 ----
756+ /* Implementation of Input Method Extension for MacOS X.
757+    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
758+    Taiichi Hashimoto <taiichi2@mac.com>.
759+ */
760+
761+ #include "config.h"
762+
763+ #ifdef NS_IMPL_COCOA
764+
765+ #include <math.h>
766+ #include <sys/types.h>
767+ #include <time.h>
768+ #include <signal.h>
769+ #include <unistd.h>
770+
771+ #include <Carbon/Carbon.h>
772+
773+ #include "lisp.h"
774+ #include "blockinput.h"
775+
776+ enum output_method
777+ {
778+   output_initial,
779+   output_termcap,
780+   output_x_window,
781+   output_msdos_raw,
782+   output_w32,
783+   output_mac,
784+   output_ns
785+ } output_method;
786+
787+ #include "termhooks.h"
788+ #include "keyboard.h"
789+ #include "buffer.h"
790+
791+ //extern Lisp_Object Qcurrent_input_method;
792+ //extern int cursor_in_echo_area;
793+ static Lisp_Object Qmac_keys_passed_to_system;
794+
795+ void mac_init_input_method ();
796+ int mac_pass_key_to_system (int code, int modifiers);
797+ int mac_pass_key_directly_to_emacs ();
798+ int mac_store_change_input_method_event ();
799+
800+ DEFUN ("mac-input-source-is-ascii-capable", Fmac_input_source_is_ascii_capable, Smac_input_source_is_ascii_capable,
801+        0, 0, 0,
802+        doc: /* Is current input source ascii capable? */)
803+      (void)
804+ {
805+   TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
806+   CFBooleanRef ret = TISGetInputSourceProperty(is, kTISPropertyInputSourceIsASCIICapable);
807+   
808+   return CFBooleanGetValue(ret)? Qt : Qnil;
809+ }
810+
811+ DEFUN ("mac-get-input-source-list", Fmac_get_input_source_list, Smac_get_input_source_list,
812+        0, 0, 0,
813+        doc: /* get input source list on MacOSX */)
814+      (void)
815+ {
816+   NSArray *is_list = (NSArray *)TISCreateInputSourceList(NULL, false);
817+   int list_size = [is_list count];
818+   Lisp_Object list[list_size];
819+   int i;
820+
821+   for (i = 0; i < list_size; i++) {
822+     TISInputSourceRef is = (TISInputSourceRef)[is_list objectAtIndex:i];
823+     NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
824+     list[i] = make_string([id UTF8String],
825+                         [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
826+   }
827+
828+   return Flist(list_size, list);
829+ }
830+
831+ DEFUN ("mac-get-current-input-source", Fmac_get_current_input_source, Smac_get_current_input_source,
832+        0, 0, 0,
833+        doc: /* get current input source on MacOSX */)
834+      (void)
835+ {
836+   TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
837+   NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
838+
839+   return make_string([id UTF8String],
840+                    [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
841+ }
842+
843+ DEFUN ("mac-toggle-input-source", Fmac_toggle_input_source, Smac_toggle_input_source,
844+        1, 1, 0,
845+        doc: /* toggle input source on MacOSX */)
846+      (arg)
847+      Lisp_Object arg;
848+ {
849+   TISInputSourceRef is = NULL;
850+
851+   if (NILP (arg))
852+     {
853+       is = TISCopyCurrentASCIICapableKeyboardInputSource();
854+     }
855+   else
856+     {
857+       NSString *locale;
858+       NSArray *languages = [NSLocale preferredLanguages];
859+       if (languages != nil) {
860+         locale = [languages objectAtIndex:0];
861+       } else {
862+         locale = [[NSLocale currentLocale]
863+                       objectForKey:NSLocaleLanguageCode];
864+       }
865+       is = TISCopyInputSourceForLanguage((CFStringRef)locale);
866+     }
867+   if (is) TISSelectInputSource(is);
868+
869+   return arg;
870+ }
871+
872+ int
873+ mac_store_change_input_method_event ()
874+ {
875+   Lisp_Object dim;
876+   int ret = FALSE;
877+   
878+   dim = Fsymbol_value (intern ("default-input-method"));
879+   if (STRINGP (dim) && strcmp(SDATA (dim), "MacOSX") == 0)
880+     {
881+       ret = TRUE;
882+     }
883+
884+   return ret;
885+ }
886+
887+ int
888+ mac_pass_key_to_system (int code, int modifiers)
889+ {
890+   Lisp_Object keys = Fsymbol_value (Qmac_keys_passed_to_system);
891+   Lisp_Object m, k;
892+
893+   while (!NILP (keys))
894+     {
895+       m = XCAR (XCAR (keys));
896+       k = XCDR (XCAR (keys));
897+       keys = XCDR (keys);
898+
899+       if (NUMBERP (m) && modifiers == XINT (m))
900+       if (NILP (k)
901+           || (NUMBERP (k) && code == XINT (k)))
902+         return TRUE;
903+     }
904+   
905+   return FALSE;
906+ }
907+
908+ int
909+ mac_pass_key_directly_to_emacs (void)
910+ {
911+
912+   if (NILP (Fmac_input_source_is_ascii_capable()))
913+     {
914+       if (NILP (Vmac_use_input_method_on_system)
915+         || this_command_key_count
916+         || cursor_in_echo_area
917+         || !NILP (BVAR (current_buffer, read_only)))
918+       return TRUE;
919+     }
920+
921+   return FALSE;
922+ }
923+
924+
925+ void mac_init_input_method (void)
926+ {
927+   Qmac_keys_passed_to_system = intern ("mac-keys-passed-to-system");
928+   staticpro (&Qmac_keys_passed_to_system);
929+
930+   DEFVAR_LISP ("mac-use-input-method-on-system", Vmac_use_input_method_on_system,
931+                doc: /* If it is non-nil, use input method on system. */);
932+   Vmac_use_input_method_on_system = Qt;
933+
934+   defsubr (&Smac_input_source_is_ascii_capable);
935+   defsubr (&Smac_get_input_source_list);
936+   defsubr (&Smac_get_current_input_source);
937+   defsubr (&Smac_toggle_input_source);
938+ }
939+ #endif
940diff -r -N -p ../emacs-24.3.org/src/nsfns.m src/nsfns.m
941*** ../emacs-24.3.org/src/nsfns.m       2013-01-02 05:37:17.000000000 +0900
942--- src/nsfns.m 2013-04-13 21:49:53.000000000 +0900
943*************** static ptrdiff_t image_cache_refcount;
944*** 107,113 ****
945 
946     ========================================================================== */
947 
948-
949  void
950  check_ns (void)
951  {
952--- 107,112 ----
953*************** be used as the image of the icon represe
954*** 2702,2707 ****
955--- 2701,2724 ----
956                 doc: /* Toolkit version for NS Windowing.  */);
957    Vns_version_string = ns_appkit_version_str ();
958 
959+
960+   DEFVAR_LISP ("ns-shift-key-mask", Vns_shift_key_mask,
961+                doc: /* Shift key mask defined in system. */);
962+   Vns_shift_key_mask = make_number (NSShiftKeyMask);
963+
964+   DEFVAR_LISP ("ns-control-key-mask", Vns_control_key_mask,
965+                doc: /* Control key mask defined in system. */);
966+   Vns_control_key_mask = make_number (NSControlKeyMask);
967+
968+   DEFVAR_LISP ("ns-alternate-key-mask", Vns_alternate_key_mask,
969+                doc: /* Alternate key mask defined in system. */);
970+   Vns_alternate_key_mask = make_number (NSAlternateKeyMask);
971+
972+   DEFVAR_LISP ("ns-command-key-mask", Vns_command_key_mask,
973+                doc: /* Command key mask defined in system. */);
974+   Vns_command_key_mask = make_number (NSCommandKeyMask);
975+
976+
977    defsubr (&Sns_read_file_name);
978    defsubr (&Sns_get_resource);
979    defsubr (&Sns_set_resource);
980*************** be used as the image of the icon represe
981*** 2746,2751 ****
982--- 2763,2772 ----
983    defsubr (&Sx_show_tip);
984    defsubr (&Sx_hide_tip);
985 
986+ #ifdef NS_IMPL_COCOA
987+   mac_init_input_method ();
988+ #endif
989+
990    /* used only in fontset.c */
991    check_window_system_func = check_ns;
992 
993diff -r -N -p ../emacs-24.3.org/src/nsterm.h src/nsterm.h
994*** ../emacs-24.3.org/src/nsterm.h      2013-01-02 05:37:17.000000000 +0900
995--- src/nsterm.h        2013-04-13 21:49:53.000000000 +0900
996*************** typedef unsigned int NSUInteger;
997*** 420,425 ****
998--- 420,427 ----
999  #define KEY_NS_NEW_FRAME               ((1<<28)|(0<<16)|12)
1000  #define KEY_NS_TOGGLE_TOOLBAR          ((1<<28)|(0<<16)|13)
1001  #define KEY_NS_SHOW_PREFS              ((1<<28)|(0<<16)|14)
1002+ #define KEY_MAC_CHANGE_INPUT_METHOD    ((1<<28)|(0<<16)|15)
1003+ #define KEY_NS_PUT_MARKED_TEXT         ((1<<28)|(0<<16)|16)
1004 
1005  /* could use list to store these, but rest of emacs has a big infrastructure
1006     for managing a table of bitmap "records" */
1007diff -r -N -p ../emacs-24.3.org/src/nsterm.m src/nsterm.m
1008*** ../emacs-24.3.org/src/nsterm.m      2013-01-04 18:38:13.000000000 +0900
1009--- src/nsterm.m        2013-04-13 21:53:51.000000000 +0900
1010*************** ns_term_init (Lisp_Object display_name)
1011*** 4049,4054 ****
1012--- 4049,4057 ----
1013    /*   [[NSNotificationCenter defaultCenter] addObserver: NSApp
1014                                           selector: @selector (logNotification:)
1015                                               name: nil object: nil]; */
1016+   [[NSDistributedNotificationCenter defaultCenter] addObserver: NSApp
1017+                                       selector: @selector (changeInputMethod:)
1018+                                                  name: @"AppleSelectedInputSourcesChangedNotification" object: nil];
1019 
1020    dpyinfo = xzalloc (sizeof *dpyinfo);
1021 
1022*************** ns_term_shutdown (int sig)
1023*** 4278,4283 ****
1024--- 4281,4301 ----
1025      NSLog (@"notification: '%@'", [notification name]);
1026  }
1027 
1028+ - (void)changeInputMethod: (NSNotification *)notification
1029+ {
1030+
1031+   struct frame *emacsframe = SELECTED_FRAME ();
1032+
1033+   if (mac_store_change_input_method_event())
1034+     {
1035+       if (!emacs_event)
1036+       return;
1037+       emacs_event->kind = NS_NONKEY_EVENT;
1038+       emacs_event->code = KEY_MAC_CHANGE_INPUT_METHOD;
1039+       emacs_event->modifiers = 0;
1040+       EV_TRAILER ((id)nil);
1041+     }
1042+ }
1043 
1044  - (void)sendEvent: (NSEvent *)theEvent
1045  /* --------------------------------------------------------------------------
1046*************** not_in_argv (NSString *arg)
1047*** 4957,4963 ****
1048               code, fnKeysym, flags, emacs_event->modifiers);
1049 
1050        /* if it was a function key or had modifiers, pass it directly to emacs */
1051!       if (fnKeysym || (emacs_event->modifiers
1052                         && (emacs_event->modifiers != shift_modifier)
1053                         && [[theEvent charactersIgnoringModifiers] length] > 0))
1054  /*[[theEvent characters] length] */
1055--- 4975,4982 ----
1056               code, fnKeysym, flags, emacs_event->modifiers);
1057 
1058        /* if it was a function key or had modifiers, pass it directly to emacs */
1059!       if (mac_pass_key_directly_to_emacs ()
1060!         ||fnKeysym || (emacs_event->modifiers
1061                         && (emacs_event->modifiers != shift_modifier)
1062                         && [[theEvent charactersIgnoringModifiers] length] > 0))
1063  /*[[theEvent characters] length] */
1064*************** not_in_argv (NSString *arg)
1065*** 4972,4979 ****
1066                ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
1067 
1068            emacs_event->code = code;
1069!           EV_TRAILER (theEvent);
1070!           return;
1071          }
1072      }
1073 
1074--- 4991,5008 ----
1075                ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
1076 
1077            emacs_event->code = code;
1078!         /* The function mac_pass_key_to_system decides
1079!            whether it is passed directly to emacs or not. */
1080!         if (emacs_event->kind == NON_ASCII_KEYSTROKE_EVENT
1081!             || !mac_pass_key_to_system (code, flags
1082!                                         & (NSShiftKeyMask
1083!                                            | NSControlKeyMask
1084!                                            | NSAlternateKeyMask
1085!                                            | NSCommandKeyMask)))
1086!           {
1087!             EV_TRAILER (theEvent);
1088!             return;
1089!           }
1090          }
1091      }
1092 
1093*************** not_in_argv (NSString *arg)
1094*** 5067,5076 ****
1095      NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
1096             selRange.length, selRange.location);
1097 
1098-   if (workingText != nil)
1099-     [self deleteWorkingText];
1100    if ([str length] == 0)
1101!     return;
1102 
1103    if (!emacs_event)
1104      return;
1105--- 5096,5114 ----
1106      NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
1107             selRange.length, selRange.location);
1108 
1109    if ([str length] == 0)
1110!     {
1111!       [self deleteWorkingText];
1112!       return;
1113!     }
1114!   else
1115!     {
1116!       if (workingText != nil) {
1117!       [workingText release];
1118!       workingText = nil;
1119!       processingCompose = NO;
1120!       }
1121!     }
1122 
1123    if (!emacs_event)
1124      return;
1125*************** not_in_argv (NSString *arg)
1126*** 5080,5086 ****
1127    ns_working_text = build_string ([workingText UTF8String]);
1128 
1129    emacs_event->kind = NS_TEXT_EVENT;
1130!   emacs_event->code = KEY_NS_PUT_WORKING_TEXT;
1131    EV_TRAILER ((id)nil);
1132  }
1133 
1134--- 5118,5126 ----
1135    ns_working_text = build_string ([workingText UTF8String]);
1136 
1137    emacs_event->kind = NS_TEXT_EVENT;
1138!   emacs_event->code = KEY_NS_PUT_MARKED_TEXT;
1139!   emacs_event->arg = Fcons (make_number (selRange.location),
1140!                           Fcons (make_number (selRange.length), Qnil));
1141    EV_TRAILER ((id)nil);
1142  }
1143 
1144*************** not_in_argv (NSString *arg)
1145*** 5135,5149 ****
1146  {
1147    NSRect rect;
1148    NSPoint pt;
1149!   struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
1150    if (NS_KEYLOG)
1151      NSLog (@"firstRectForCharRange request");
1152 
1153    rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
1154    rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
1155    pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
1156    pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
1157!                                        +FRAME_LINE_HEIGHT (emacsframe));
1158 
1159    pt = [self convertPoint: pt toView: nil];
1160    pt = [[self window] convertBaseToScreen: pt];
1161--- 5175,5197 ----
1162  {
1163    NSRect rect;
1164    NSPoint pt;
1165!   //  struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
1166!   struct window *win;
1167    if (NS_KEYLOG)
1168      NSLog (@"firstRectForCharRange request");
1169+     
1170+   if (NILP (Vmac_in_echo_area))
1171+     win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
1172+     else if (WINDOWP (echo_area_window))
1173+     win = XWINDOW (echo_area_window);
1174+   else
1175+     win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
1176 
1177    rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
1178    rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
1179    pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
1180    pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
1181!                                        +FRAME_LINE_HEIGHT (emacsframe)+2);
1182 
1183    pt = [self convertPoint: pt toView: nil];
1184    pt = [[self window] convertBaseToScreen: pt];
1185*************** variable `x-use-underline-position-prope
1186*** 7173,7178 ****
1187--- 7221,7230 ----
1188  baseline level.  The default value is nil.  */);
1189    x_underline_at_descent_line = 0;
1190 
1191+   DEFVAR_LISP ("mac-in-echo-area", Vmac_in_echo_area,
1192+                doc: /* state of cursor in echo area. */);
1193+   Vmac_in_echo_area = Qnil;
1194+
1195    /* Tell emacs about this window system. */
1196    Fprovide (intern ("ns"), Qnil);
1197  }
1198*** ../emacs-24.3.org/configure 2013-03-08 17:13:36.000000000 +0900
1199--- configure   2013-04-13 23:11:56.000000000 +0900
1200*************** if test "${HAVE_NS}" = yes; then
1201*** 9650,9656 ****
1202       leimdir="\${ns_appresdir}/leim"
1203       INSTALL_ARCH_INDEP_EXTRA=
1204    fi
1205!   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
1206  fi
1207  CFLAGS="$tmp_CFLAGS"
1208  CPPFLAGS="$tmp_CPPFLAGS"
1209--- 9650,9656 ----
1210       leimdir="\${ns_appresdir}/leim"
1211       INSTALL_ARCH_INDEP_EXTRA=
1212    fi
1213!   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o"
1214  fi
1215  CFLAGS="$tmp_CFLAGS"
1216  CPPFLAGS="$tmp_CPPFLAGS"
1217*************** case "$opsys" in
1218*** 24618,24624 ****
1219     ## 0x690 is the total size of 30 segment load commands (at 56
1220     ## each); under Cocoa 31 commands are required.
1221     if test "$HAVE_NS" = "yes"; then
1222!      libs_nsgui="-framework AppKit"
1223       headerpad_extra=6C8
1224     else
1225       libs_nsgui=
1226--- 24618,24624 ----
1227     ## 0x690 is the total size of 30 segment load commands (at 56
1228     ## each); under Cocoa 31 commands are required.
1229     if test "$HAVE_NS" = "yes"; then
1230!      libs_nsgui="-framework AppKit -framework Carbon -framework Cocoa"
1231       headerpad_extra=6C8
1232     else
1233       libs_nsgui=
1234*** ../emacs-24.3.org/configure.ac      2013-03-05 17:24:59.000000000 +0900
1235--- configure.ac        2013-04-13 23:11:56.000000000 +0900
1236*************** if test "${HAVE_NS}" = yes; then
1237*** 1571,1577 ****
1238       leimdir="\${ns_appresdir}/leim"
1239       INSTALL_ARCH_INDEP_EXTRA=
1240    fi
1241!   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
1242  fi
1243  CFLAGS="$tmp_CFLAGS"
1244  CPPFLAGS="$tmp_CPPFLAGS"
1245--- 1571,1577 ----
1246       leimdir="\${ns_appresdir}/leim"
1247       INSTALL_ARCH_INDEP_EXTRA=
1248    fi
1249!   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o"
1250  fi
1251  CFLAGS="$tmp_CFLAGS"
1252  CPPFLAGS="$tmp_CPPFLAGS"
1253*************** case "$opsys" in
1254*** 4322,4328 ****
1255     ## 0x690 is the total size of 30 segment load commands (at 56
1256     ## each); under Cocoa 31 commands are required.
1257     if test "$HAVE_NS" = "yes"; then
1258!      libs_nsgui="-framework AppKit"
1259       headerpad_extra=6C8
1260     else
1261       libs_nsgui=
1262--- 4322,4328 ----
1263     ## 0x690 is the total size of 30 segment load commands (at 56
1264     ## each); under Cocoa 31 commands are required.
1265     if test "$HAVE_NS" = "yes"; then
1266!      libs_nsgui="-framework AppKit -framework Carbon -framework Cocoa"
1267       headerpad_extra=6C8
1268     else
1269       libs_nsgui=