svnno****@sourc*****
svnno****@sourc*****
2010年 3月 4日 (木) 15:05:29 JST
Revision: 563 http://sourceforge.jp/projects/macemacsjp/svn/view?view=rev&revision=563 Author: taiichi Date: 2010-03-04 15:05:29 +0900 (Thu, 04 Mar 2010) Log Message: ----------- Modified Paths: -------------- inline_patch/trunk/ChangeLog inline_patch/trunk/emacs-inline.patch -------------- next part -------------- Modified: inline_patch/trunk/ChangeLog =================================================================== --- inline_patch/trunk/ChangeLog 2010-01-15 05:13:29 UTC (rev 562) +++ inline_patch/trunk/ChangeLog 2010-03-04 06:05:29 UTC (rev 563) @@ -1,3 +1,10 @@ +2010-03-04 HASHIMOTO Taiichi <taiic****@mac*****> + + * src/nsterm.m (KeyDown): system Én·L[(V[gJbg)ðÝèÂ\É·éDftHgÅÍCCüL[(shiftðÜÞ)ªÂêÍEmacsDæD»êð³·éæ¤ÉÝèÂ\É·éD + * src/macim.m (pass-key-to-system, pass-key-directly-to-emacs): system â emacs Én·L[(V[gJbg)ð»è·éÖðÇÁD + * lisp/term/ns-win.el (mac-add-key-passed-to-system): system Én·L[(V[gJbg)ðo^·éÖðÇÁ + * lisp/term/ns-win.el (mac-add-ignore-shortcut): í + 2010-01-15 HASHIMOTO Taiichi <taiic****@mac*****> * lisp/term/ns-win.el (mac-toggle-input-method): system Æ Emacs ÌIMÌóÔð¯ú·é@\ð» Modified: inline_patch/trunk/emacs-inline.patch =================================================================== --- inline_patch/trunk/emacs-inline.patch 2010-01-15 05:13:29 UTC (rev 562) +++ inline_patch/trunk/emacs-inline.patch 2010-03-04 06:05:29 UTC (rev 563) @@ -1,5 +1,6 @@ -*** ../emacs-23.1.91/lisp/term/ns-win.el 2009-12-31 02:14:11.000000000 +0900 ---- lisp/term/ns-win.el 2010-01-15 13:52:23.000000000 +0900 +diff -p -N -r -x '*.elc' ../emacs-23.1.93/lisp/term/ns-win.el lisp/term/ns-win.el +*** ../emacs-23.1.93/lisp/term/ns-win.el 2010-01-14 03:32:16.000000000 +0900 +--- lisp/term/ns-win.el 2010-03-03 10:46:35.000000000 +0900 *************** The properties returned may include `top *** 315,320 **** --- 315,321 ---- @@ -155,7 +156,7 @@ ;; Still alive? *************** the operating system.") *** 1263,1268 **** ---- 1326,1708 ---- +--- 1326,1711 ---- (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system)) @@ -463,39 +464,42 @@ + (setq default-input-method nil))) + + ;; -+ ;; Valiable and functions to ignore system shortcut. ++ ;; Valiable and functions to pass key(shortcut) to system. + ;; -+ (defvar mac-ignore-shortcut nil -+ "A list of ignore shortcut on MacOSX.") ++ (defvar mac-keys-passed-to-system nil ++ "A list of keys passed to system on MacOSX.") + -+ (defun mac-add-ignore-shortcut (key) -+ (let ((command '(command cmd)) -+ (option '(option opt)) -+ (control '(control ctrl ctl))) -+ (add-to-list 'mac-ignore-shortcut ++ (defun mac-add-key-passed-to-system (key) ++ (let ((shift '(shift shft)) ++ (control '(control ctrl ctl)) ++ (option '(option opt alternate alt)) ++ (command '(command cmd))) ++ ++ (add-to-list 'mac-keys-passed-to-system + (cond ((symbolp key) -+ (cond ((memq key command) (cons #x100 nil)) -+ ((memq key option) (cons #x800 nil)) -+ ((memq key control) (cons #x1000 nil)) ++ (cond ((memq key shift) ++ (cons ns-shift-key-mask nil)) ++ ((memq key control) ++ (cons ns-control-key-mask nil)) ++ ((memq key option) ++ (cons ns-alternate-key-mask nil)) ++ ((memq key command) ++ (cons ns-command-key-mask nil)) + (t (cons nil nil)))) + ((numberp key) (cons 0 key)) -+ ((listp key) -+ (let ((l key) -+ (k nil) -+ (m 0)) ++ ((listp key) ++ (let ((l key) (k nil) (m 0)) + (while l -+ (cond ((memq (car l) command) -+ (if (= (logand m #x100) 0) -+ (setq m (logior m #x100)))) ++ (cond ((memq (car l) shift) ++ (setq m (logior m ns-shift-key-mask))) ++ ((memq (car l) control) ++ (setq m (logior m ns-control-key-mask))) + ((memq (car l) option) -+ (if (= (logand m #x800) 0) -+ (setq m (logior m #x800)))) -+ ((memq (car l) control) -+ (if (= (logand m #x1000) 0) -+ (setq m (logior m #x1000)))) ++ (setq m (logior m ns-alternate-key-mask))) ++ ((memq (car l) command) ++ (setq m (logior m ns-command-key-mask))) + ((numberp (car l)) -+ (if (not k) -+ (setq k (car l))))) ++ (if (not k) (setq k (car l))))) + (setq l (cdr l))) + (cons m k))) + (t (cons nil nil)))))) @@ -539,9 +543,9 @@ (provide 'ns-win) ;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644 -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/Makefile.in src/Makefile.in -*** ../emacs-23.1.91/src/Makefile.in 2009-12-31 02:14:09.000000000 +0900 ---- src/Makefile.in 2010-01-04 21:05:27.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/Makefile.in src/Makefile.in +*** ../emacs-23.1.93/src/Makefile.in 2010-01-17 02:35:57.000000000 +0900 +--- src/Makefile.in 2010-03-01 14:19:34.000000000 +0900 *************** ns_appresdir=@ns_appresdir@/ *** 542,548 **** ns_appsrc=@ns_appsrc@ @@ -586,11 +590,11 @@ process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \ commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \ blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \ -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/keyboard.c src/keyboard.c -*** ../emacs-23.1.91/src/keyboard.c 2009-12-31 02:14:07.000000000 +0900 ---- src/keyboard.c 2010-01-04 21:05:27.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/keyboard.c src/keyboard.c +*** ../emacs-23.1.93/src/keyboard.c 2010-02-27 09:03:16.000000000 +0900 +--- src/keyboard.c 2010-03-01 17:31:40.000000000 +0900 *************** kbd_buffer_get_event (kbp, used_mouse_me -*** 4185,4192 **** +*** 4195,4202 **** { if (event->code == KEY_NS_PUT_WORKING_TEXT) obj = Fcons (intern ("ns-put-working-text"), Qnil); @@ -599,20 +603,20 @@ kbd_fetch_ptr = event + 1; if (used_mouse_menu) *used_mouse_menu = 1; ---- 4185,4194 ---- +--- 4195,4204 ---- { if (event->code == KEY_NS_PUT_WORKING_TEXT) obj = Fcons (intern ("ns-put-working-text"), Qnil); ! else if (event->code == KEY_NS_UNPUT_WORKING_TEXT) obj = Fcons (intern ("ns-unput-working-text"), Qnil); -+ else if (event->code == 1000000) ++ else if (event->code == KEY_NS_PUT_MARKED_TEXT) + obj = Fcons (intern ("ns-put-marked-text"), event->arg); kbd_fetch_ptr = event + 1; if (used_mouse_menu) *used_mouse_menu = 1; *************** keys_of_keyboard () -*** 12540,12545 **** ---- 12542,12549 ---- +*** 12556,12561 **** +--- 12558,12565 ---- "ns-put-working-text"); initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text", "ns-unput-working-text"); @@ -621,12 +625,12 @@ /* Here we used to use `ignore-event' which would simple set prefix-arg to current-prefix-arg, as is done in `handle-switch-frame'. But `handle-switch-frame is not run from the special-map. -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/macim.m src/macim.m -*** ../emacs-23.1.91/src/macim.m 1970-01-01 09:00:00.000000000 +0900 ---- src/macim.m 2010-01-15 13:25:09.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/macim.m src/macim.m +*** ../emacs-23.1.93/src/macim.m 1970-01-01 09:00:00.000000000 +0900 +--- src/macim.m 2010-03-03 11:20:28.000000000 +0900 *************** *** 0 **** ---- 1,165 ---- +--- 1,176 ---- + /* Implementation of Input Method Extension for MacOS X. + Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Taiichi Hashimoto <taiic****@mac*****>. @@ -664,10 +668,12 @@ + + extern Lisp_Object Qcurrent_input_method; + extern int cursor_in_echo_area; -+ static Lisp_Object Qmac_ignore_shortcut; ++ static Lisp_Object Qmac_keys_passed_to_system; ++ static Lisp_Object Vmac_use_input_method_on_system; + + void mac_init_input_method (); + int mac_pass_key_to_system (int code, UInt32 modifiers); ++ int mac_pass_key_directly_to_emacs (); + int mac_store_change_input_method_event (); + + DEFUN ("mac-input-source-is-ascii-capable", Fmac_input_source_is_ascii_capable, @@ -748,56 +754,106 @@ + return ret; + } + -+ + int -+ mac_pass_key_to_system (int code, UInt32 modifiers) ++ mac_pass_key_to_system (int code, unsigned modifiers) + { -+ Lisp_Object ascii_capable = Fmac_input_source_is_ascii_capable(); -+ Lisp_Object keys = Fsymbol_value (Qmac_ignore_shortcut); -+ Lisp_Object m, k; ++ Lisp_Object keys = Fsymbol_value (Qmac_keys_passed_to_system); ++ Lisp_Object m, k; + -+ if (NILP (ascii_capable)) -+ { -+ if (this_command_key_count -+ || cursor_in_echo_area -+ || !NILP (current_buffer->read_only)) -+ return FALSE; -+ } -+ + while (!NILP (keys)) + { + m = XCAR (XCAR (keys)); + k = XCDR (XCAR (keys)); + keys = XCDR (keys); -+ ++ + if (NUMBERP (m) && modifiers == XINT (m)) + if (NILP (k) + || (NUMBERP (k) && code == XINT (k))) -+ return FALSE; ++ return TRUE; + } + -+ return TRUE; ++ return FALSE; + } + ++ int ++ mac_pass_key_directly_to_emacs () ++ { + ++ if (NILP (Fmac_input_source_is_ascii_capable())) ++ { ++ if (NILP (Vmac_use_input_method_on_system) ++ || this_command_key_count ++ || cursor_in_echo_area ++ || !NILP (current_buffer->read_only)) ++ return TRUE; ++ } ++ ++ return FALSE; ++ } ++ ++ + void mac_init_input_method () + { -+ Qmac_ignore_shortcut = intern ("mac-ignore-shortcut"); -+ staticpro (&Qmac_ignore_shortcut); ++ Qmac_keys_passed_to_system = intern ("mac-keys-passed-to-system"); ++ staticpro (&Qmac_keys_passed_to_system); + ++ DEFVAR_LISP ("mac-use-input-method-on-system", &Vmac_use_input_method_on_system, ++ doc: /* If it is non-nil, use input method on system. */); ++ Vmac_use_input_method_on_system = Qt; ++ + defsubr (&Smac_input_source_is_ascii_capable); + defsubr (&Smac_get_input_source_list); + defsubr (&Smac_get_current_input_source); + defsubr (&Smac_toggle_input_source); + } -+ + #endif -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/nsfns.m src/nsfns.m -*** ../emacs-23.1.91/src/nsfns.m 2009-12-31 02:14:11.000000000 +0900 ---- src/nsfns.m 2010-01-04 21:05:27.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/nsfns.m src/nsfns.m +*** ../emacs-23.1.93/src/nsfns.m 2010-01-15 10:44:40.000000000 +0900 +--- src/nsfns.m 2010-03-02 18:06:20.000000000 +0900 +*************** Lisp_Object Fx_open_connection (Lisp_Obj +*** 102,107 **** +--- 102,112 ---- + + extern BOOL ns_in_resize; + ++ /* key masks */ ++ static Lisp_Object Vns_shift_key_mask; ++ static Lisp_Object Vns_control_key_mask; ++ static Lisp_Object Vns_alternate_key_mask; ++ static Lisp_Object Vns_command_key_mask; + + /* ========================================================================== + *************** be used as the image of the icon represe -*** 2676,2681 **** ---- 2676,2685 ---- +*** 2634,2639 **** +--- 2639,2662 ---- + doc: /* Toolkit version for NS Windowing. */); + Vns_version_string = ns_appkit_version_str (); + ++ ++ DEFVAR_LISP ("ns-shift-key-mask", &Vns_shift_key_mask, ++ doc: /* Shift key mask defined in system. */); ++ Vns_shift_key_mask = make_number (NSShiftKeyMask); ++ ++ DEFVAR_LISP ("ns-control-key-mask", &Vns_control_key_mask, ++ doc: /* Control key mask defined in system. */); ++ Vns_control_key_mask = make_number (NSControlKeyMask); ++ ++ DEFVAR_LISP ("ns-alternate-key-mask", &Vns_alternate_key_mask, ++ doc: /* Alternate key mask defined in system. */); ++ Vns_alternate_key_mask = make_number (NSAlternateKeyMask); ++ ++ DEFVAR_LISP ("ns-command-key-mask", &Vns_command_key_mask, ++ doc: /* Command key mask defined in system. */); ++ Vns_command_key_mask = make_number (NSCommandKeyMask); ++ ++ + defsubr (&Sns_read_file_name); + defsubr (&Sns_get_resource); + defsubr (&Sns_set_resource); +*************** be used as the image of the icon represe +*** 2678,2683 **** +--- 2701,2710 ---- defsubr (&Sx_show_tip); defsubr (&Sx_hide_tip); @@ -808,25 +864,26 @@ /* used only in fontset.c */ check_window_system_func = check_ns; -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/nsterm.h src/nsterm.h -*** ../emacs-23.1.91/src/nsterm.h 2009-12-31 02:14:11.000000000 +0900 ---- src/nsterm.h 2010-01-04 21:05:27.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/nsterm.h src/nsterm.h +*** ../emacs-23.1.93/src/nsterm.h 2010-01-14 03:32:19.000000000 +0900 +--- src/nsterm.h 2010-03-01 17:50:02.000000000 +0900 *************** typedef unsigned int NSUInteger; *** 365,370 **** ---- 365,371 ---- +--- 365,372 ---- #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12) #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13) #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14) + #define KEY_MAC_CHANGE_INPUT_METHOD ((1<<28)|(0<<16)|15) ++ #define KEY_NS_PUT_MARKED_TEXT ((1<<28)|(0<<16)|16) /* could use list to store these, but rest of emacs has a big infrastructure for managing a table of bitmap "records" */ -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/nsterm.m src/nsterm.m -*** ../emacs-23.1.91/src/nsterm.m 2009-12-31 02:14:11.000000000 +0900 ---- src/nsterm.m 2010-01-15 13:26:00.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/nsterm.m src/nsterm.m +*** ../emacs-23.1.93/src/nsterm.m 2010-02-18 16:18:29.000000000 +0900 +--- src/nsterm.m 2010-03-04 09:29:01.000000000 +0900 *************** ns_term_init (Lisp_Object display_name) -*** 3721,3726 **** ---- 3721,3729 ---- +*** 3705,3710 **** +--- 3705,3713 ---- /* [[NSNotificationCenter defaultCenter] addObserver: NSApp selector: @selector (logNotification:) name: nil object: nil]; */ @@ -837,8 +894,8 @@ dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info)); bzero (dpyinfo, sizeof (struct ns_display_info)); *************** ns_term_shutdown (int sig) -*** 3928,3933 **** ---- 3931,3948 ---- +*** 3910,3915 **** +--- 3913,3930 ---- NSLog (@"notification: '%@'", [notification name]); } @@ -858,37 +915,77 @@ - (void)sendEvent: (NSEvent *)theEvent /* -------------------------------------------------------------------------- *************** extern void update_window_cursor (struct -*** 4478,4483 **** ---- 4493,4499 ---- +*** 4459,4481 **** + code, fnKeysym, flags, emacs_event->modifiers); /* if it was a function key or had modifiers, pass it directly to emacs */ - if (fnKeysym || (emacs_event->modifiers -+ && emacs_event->modifiers != shift_modifier - && [[theEvent charactersIgnoringModifiers] length] > 0)) - /*[[theEvent characters] length] */ - { -*************** extern void update_window_cursor (struct -*** 4494,4499 **** ---- 4510,4526 ---- - EV_TRAILER (theEvent); - return; - } -+ -+ #ifdef NS_IMPL_COCOA -+ if (!mac_pass_key_to_system (code, flags)) -+ { -+ emacs_event->kind = code > 0xFF -+ ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT; -+ emacs_event->code = code; -+ EV_TRAILER (theEvent); -+ return; -+ } -+ #endif +! if (fnKeysym || (emacs_event->modifiers +! && [[theEvent charactersIgnoringModifiers] length] > 0)) +! /*[[theEvent characters] length] */ +! { +! emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT; +! if (code < 0x20) +! code |= (1<<28)|(3<<16); +! else if (code == 0x7f) +! code |= (1<<28)|(3<<16); +! else if (!fnKeysym) +! emacs_event->kind = code > 0xFF +! ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT; +! +! emacs_event->code = code; +! EV_TRAILER (theEvent); +! return; +! } } /* if we get here we should send the key for input manager processing */ +--- 4474,4507 ---- + code, fnKeysym, flags, emacs_event->modifiers); + + /* if it was a function key or had modifiers, pass it directly to emacs */ +! /* The function mac_pass_key_to_system decides whether it is +! passed directly to emacs or not. */ +! /* The function mac_pass_key_directly_to_emacs check special case +! to pass it directly to emacs, such as passwd, read-only buffer, etc. */ +! if (!mac_pass_key_to_system (code, flags +! & (NSShiftKeyMask +! | NSControlKeyMask +! | NSAlternateKeyMask +! | NSCommandKeyMask))) { +! if (mac_pass_key_directly_to_emacs () +! || fnKeysym +! || (emacs_event->modifiers +! && [[theEvent charactersIgnoringModifiers] length] > 0)) +! { +! emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT; +! if (code < 0x20) +! code |= (1<<28)|(3<<16); +! else if (code == 0x7f) +! code |= (1<<28)|(3<<16); +! else if (!fnKeysym) +! emacs_event->kind = code > 0xFF +! ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT; +! +! emacs_event->code = code; +! EV_TRAILER (theEvent); +! return; +! } +! } + } + + /* if we get here we should send the key for input manager processing */ *************** extern void update_window_cursor (struct -*** 4583,4592 **** +*** 4494,4500 **** + [nsEvArray removeObject: theEvent]; + } + +- + #ifdef NS_IMPL_COCOA + /* Needed to pick up Ctrl-tab and possibly other events that OS X has + decided not to send key-down for. +--- 4520,4525 ---- +*************** extern void update_window_cursor (struct +*** 4565,4574 **** NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length], selRange.length, selRange.location); @@ -899,7 +996,7 @@ if (!emacs_event) return; ---- 4610,4628 ---- +--- 4590,4608 ---- NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length], selRange.length, selRange.location); @@ -920,7 +1017,7 @@ if (!emacs_event) return; *************** extern void update_window_cursor (struct -*** 4596,4602 **** +*** 4578,4584 **** ns_working_text = build_string ([workingText UTF8String]); emacs_event->kind = NS_TEXT_EVENT; @@ -928,18 +1025,18 @@ EV_TRAILER ((id)nil); } ---- 4632,4640 ---- +--- 4612,4620 ---- ns_working_text = build_string ([workingText UTF8String]); emacs_event->kind = NS_TEXT_EVENT; -! emacs_event->code = 1000000; +! emacs_event->code = KEY_NS_PUT_MARKED_TEXT; ! emacs_event->arg = Fcons (make_number (selRange.location), ! Fcons (make_number (selRange.length), Qnil)); EV_TRAILER ((id)nil); } *************** extern void update_window_cursor (struct -*** 4651,4665 **** +*** 4633,4647 **** { NSRect rect; NSPoint pt; @@ -955,7 +1052,7 @@ pt = [self convertPoint: pt toView: nil]; pt = [[self window] convertBaseToScreen: pt]; ---- 4689,4711 ---- +--- 4669,4691 ---- { NSRect rect; NSPoint pt; @@ -979,9 +1076,9 @@ pt = [self convertPoint: pt toView: nil]; pt = [[self window] convertBaseToScreen: pt]; -diff -p -N -r -x '*.orig' ../emacs-23.1.91/src/s/darwin.h src/s/darwin.h -*** ../emacs-23.1.91/src/s/darwin.h 2009-12-31 02:13:53.000000000 +0900 ---- src/s/darwin.h 2010-01-04 21:05:27.000000000 +0900 +diff -p -N -r -x '*.orig' ../emacs-23.1.93/src/s/darwin.h src/s/darwin.h +*** ../emacs-23.1.93/src/s/darwin.h 2010-01-14 03:32:21.000000000 +0900 +--- src/s/darwin.h 2010-03-01 14:19:34.000000000 +0900 *************** along with GNU Emacs. If not, see <http *** 145,151 **** /* Definitions for how to compile & link. */