From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Subject: keyboard-coding-system in Carbon Emacs
Date: Wed, 06 Apr 2005 12:26:57 +0900 [thread overview]
Message-ID: <wlbr8sbn5q.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
I think the default value of keyboard-coding-system in Carbon Emacs
has been source of annoyance. Users have to set an appropriate value
to input non-ASCII characters using external input methods or
combinations with the option key.
The patch below is an attempt to solve such a problem by dynamically
changing the value of keyboard-coding-system by detecting keyboard
layout changes. Because I can test this only in limited environments,
I'd like to ask Carbon Emacs users, especially non-US keyboard users,
to test this patch in various environments. It makes the variable
`mac-keyboard-text-encoding' and related constants (kTextEncoding...)
obsolete, so please comment out the setting of this variable if you
have one in your ~/.emacs before testing.
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
Index: lisp/term/mac-win.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/mac-win.el,v
retrieving revision 1.36
diff -c -r1.36 mac-win.el
*** lisp/term/mac-win.el 6 Apr 2005 02:15:29 -0000 1.36
--- lisp/term/mac-win.el 6 Apr 2005 03:23:05 -0000
***************
*** 1085,1097 ****
(put 'escape 'ascii-character ?\e)
\f
! ;;;; Keysyms
! ;; Define constant values to be set to mac-keyboard-text-encoding
! (defconst kTextEncodingMacRoman 0)
! (defconst kTextEncodingISOLatin1 513 "0x201")
! (defconst kTextEncodingISOLatin2 514 "0x202")
\f
;;;; Selections and cut buffers
--- 1085,1110 ----
(put 'escape 'ascii-character ?\e)
\f
! ;;;; Keyboard layout/language change events
! (defconst mac-script-code-coding-systems
! '((0 . mac-roman) ; smRoman
! (1 . sjis) ; smJapanese
! (2 . big5) ; smTradChinese
! (3 . euc-kr) ; smKorean
! (25 . cn-gb) ; smSimpChinese
! )
! "Alist of Mac script codes vs Emacs coding systems.")
! (defun mac-set-keyboard-coding-system (event)
! (interactive "e")
! (let ((coding-system
! (cdr (assq (nth 1 (cadr event)) mac-script-code-coding-systems))))
! (set-keyboard-coding-system (or coding-system 'mac-roman))
! ;; MacJapanese maps reverse solidus to ?\x80.
! (if (eq coding-system 'sjis)
! (define-key key-translation-map [?\x80] "\\"))))
+ (global-set-key [language-change] 'mac-set-keyboard-coding-system)
\f
;;;; Selections and cut buffers
Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.817
diff -c -r1.817 keyboard.c
*** src/keyboard.c 31 Mar 2005 10:11:14 -0000 1.817
--- src/keyboard.c 6 Apr 2005 03:23:05 -0000
***************
*** 530,536 ****
/* Symbols to denote kinds of events. */
Lisp_Object Qfunction_key;
Lisp_Object Qmouse_click;
! #ifdef WINDOWSNT
Lisp_Object Qlanguage_change;
#endif
Lisp_Object Qdrag_n_drop;
--- 530,536 ----
/* Symbols to denote kinds of events. */
Lisp_Object Qfunction_key;
Lisp_Object Qmouse_click;
! #if defined (WINDOWSNT) || defined (MAC_OS)
Lisp_Object Qlanguage_change;
#endif
Lisp_Object Qdrag_n_drop;
***************
*** 4028,4038 ****
x_activate_menubar (XFRAME (event->frame_or_window));
}
#endif
! #ifdef WINDOWSNT
else if (event->kind == LANGUAGE_CHANGE_EVENT)
{
/* Make an event (language-change (FRAME CHARSET LCID)). */
obj = Fcons (event->frame_or_window, Qnil);
obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
kbd_fetch_ptr = event + 1;
}
--- 4028,4044 ----
x_activate_menubar (XFRAME (event->frame_or_window));
}
#endif
! #if defined (WINDOWSNT) || defined (MAC_OS)
else if (event->kind == LANGUAGE_CHANGE_EVENT)
{
+ #ifdef MAC_OS
+ /* Make an event (language-change (FRAME KEY_SCRIPT)). */
+ obj = Fcons (make_number (event->code), Qnil);
+ obj = Fcons (event->frame_or_window, obj);
+ #else
/* Make an event (language-change (FRAME CHARSET LCID)). */
obj = Fcons (event->frame_or_window, Qnil);
+ #endif
obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
kbd_fetch_ptr = event + 1;
}
***************
*** 10837,10843 ****
staticpro (&Qfunction_key);
Qmouse_click = intern ("mouse-click");
staticpro (&Qmouse_click);
! #ifdef WINDOWSNT
Qlanguage_change = intern ("language-change");
staticpro (&Qlanguage_change);
#endif
--- 10843,10849 ----
staticpro (&Qfunction_key);
Qmouse_click = intern ("mouse-click");
staticpro (&Qmouse_click);
! #if defined (WINDOWSNT) || defined (MAC_OS)
Qlanguage_change = intern ("language-change");
staticpro (&Qlanguage_change);
#endif
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.106
diff -c -r1.106 macterm.c
*** src/macterm.c 16 Mar 2005 08:08:06 -0000 1.106
--- src/macterm.c 6 Apr 2005 03:23:05 -0000
***************
*** 7148,7155 ****
--- 7148,7157 ----
/* convert input from Mac keyboard (assumed to be in Mac Roman coding)
to this text encoding */
+ #if 0
int mac_keyboard_text_encoding;
int current_mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ #endif
/* Set in term/mac-win.el to indicate that event loop can now generate
drag and drop events. */
***************
*** 8964,8969 ****
--- 8966,8991 ----
break;
}
#endif
+ {
+ static SInt16 last_key_script = -1;
+ SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
+
+ if (last_key_script != current_key_script)
+ {
+ struct input_event event;
+
+ EVENT_INIT (event);
+ event.kind = LANGUAGE_CHANGE_EVENT;
+ event.arg = Qnil;
+ XSETFRAME (event.frame_or_window,
+ mac_window_to_frame (front_emacs_window ()));
+ event.timestamp = er.when * (1000 / 60);
+ event.code = current_key_script;
+ kbd_buffer_store_event_hold (&event, hold_quit);
+ count++;
+ }
+ last_key_script = current_key_script;
+ }
ObscureCursor ();
***************
*** 9016,9021 ****
--- 9038,9044 ----
}
}
+ #if 0
/* If variable mac-convert-keyboard-input-to-latin-1 is
non-nil, convert non-ASCII characters typed at the Mac
keyboard (presumed to be in the Mac Roman encoding) to
***************
*** 9079,9084 ****
--- 9102,9108 ----
}
}
}
+ #endif
#if USE_CARBON_EVENTS
inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
***************
*** 9893,9898 ****
--- 9917,9923 ----
may anti-alias the text. */);
Vmac_use_core_graphics = Qnil;
+ #if 0
DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding,
doc: /* One of the Text Encoding Base constant values defined in the
Basic Text Constants section of Inside Macintosh - Text Encoding
***************
*** 9907,9912 ****
--- 9932,9938 ----
command, this enables the Mac keyboard to be used to enter non-ASCII
characters directly. */);
mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ #endif
}
/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
Index: src/termhooks.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/termhooks.h,v
retrieving revision 1.67
diff -c -r1.67 termhooks.h
*** src/termhooks.h 27 Feb 2004 23:48:49 -0000 1.67
--- src/termhooks.h 6 Apr 2005 03:23:06 -0000
***************
*** 252,261 ****
the wheel event occurred in.
.timestamp gives a timestamp (in
milliseconds) for the event. */
! #ifdef WINDOWSNT
! LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is generated
! on WINDOWSNT when the keyboard layout
! or input language is changed by the
user. */
#endif
SCROLL_BAR_CLICK_EVENT, /* .code gives the number of the mouse button
--- 252,262 ----
the wheel event occurred in.
.timestamp gives a timestamp (in
milliseconds) for the event. */
! #if defined (WINDOWSNT) || defined (MAC_OS)
! LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is
! generated on WINDOWSNT or Mac OS
! when the keyboard layout or input
! language is changed by the
user. */
#endif
SCROLL_BAR_CLICK_EVENT, /* .code gives the number of the mouse button
next reply other threads:[~2005-04-06 3:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-06 3:26 YAMAMOTO Mitsuharu [this message]
2005-04-08 5:18 ` keyboard-coding-system in Carbon Emacs YAMAMOTO Mitsuharu
2005-04-09 3:38 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wlbr8sbn5q.wl%mituharu@math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).