aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley2004-10-29 00:00:43 +0000
committerJohn Wiegley2004-10-29 00:00:43 +0000
commita36f16800658fad88804e87dc7fba170e847d61c (patch)
treea2c7a457bc17f9ae0638d8fb3687d80b209d9973 /src
parent2d5864780c735e5ec88c609435a35177b052ccc3 (diff)
downloademacs-a36f16800658fad88804e87dc7fba170e847d61c.tar.gz
emacs-a36f16800658fad88804e87dc7fba170e847d61c.zip
2004-10-28 Will <will@glozer.net>
* macterm.c: allow user to assign key modifiers to the Mac Option key via a 'mac-option-modifier' variable.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/macterm.c40
2 files changed, 44 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3b327c24548..8479a0f94ce 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12004-10-28 Will <will@glozer.net>
2
3 * macterm.c: allow user to assign key modifiers to the Mac Option
4 key via a 'mac-option-modifier' variable.
5
12004-10-28 Stefan <monnier@iro.umontreal.ca> 62004-10-28 Stefan <monnier@iro.umontreal.ca>
2 7
3 * xselect.c (Vx_lost_selection_functions, Vx_sent_selection_functions): 8 * xselect.c (Vx_lost_selection_functions, Vx_sent_selection_functions):
diff --git a/src/macterm.c b/src/macterm.c
index 3616ac95672..eae892fb7fc 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -228,6 +228,10 @@ extern int errno;
228 228
229extern int extra_keyboard_modifiers; 229extern int extra_keyboard_modifiers;
230 230
231/* The keysyms to use for the various modifiers. */
232
233static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value;
234
231static Lisp_Object Qvendor_specific_keysyms; 235static Lisp_Object Qvendor_specific_keysyms;
232 236
233#if 0 237#if 0
@@ -6988,6 +6992,9 @@ Lisp_Object Qreverse;
6988/* True if using command key as meta key. */ 6992/* True if using command key as meta key. */
6989Lisp_Object Vmac_command_key_is_meta; 6993Lisp_Object Vmac_command_key_is_meta;
6990 6994
6995/* Modifier associated with the option key, or nil for normal behavior. */
6996Lisp_Object Vmac_option_modifier;
6997
6991/* True if the ctrl and meta keys should be reversed. */ 6998/* True if the ctrl and meta keys should be reversed. */
6992Lisp_Object Vmac_reverse_ctrl_meta; 6999Lisp_Object Vmac_reverse_ctrl_meta;
6993 7000
@@ -7069,6 +7076,12 @@ mac_to_emacs_modifiers (EventModifiers mods)
7069 result |= meta_modifier; 7076 result |= meta_modifier;
7070 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) 7077 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey))
7071 result |= alt_modifier; 7078 result |= alt_modifier;
7079 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) {
7080 Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value);
7081 if (!NILP(val))
7082 result |= XUINT(val);
7083 }
7084
7072 return result; 7085 return result;
7073} 7086}
7074 7087
@@ -8549,7 +8562,18 @@ XTread_socket (sd, expected, hold_quit)
8549 unsigned long some_state = 0; 8562 unsigned long some_state = 0;
8550 inev.code = KeyTranslate (kchr_ptr, new_keycode, 8563 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8551 &some_state) & 0xff; 8564 &some_state) & 0xff;
8552 } 8565 } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey))
8566 {
8567 /* When using the option key as an emacs modifier, convert
8568 the pressed key code back to one without the Mac option
8569 modifier applied. */
8570 int new_modifiers = er.modifiers & ~optionKey;
8571 int new_keycode = keycode | new_modifiers;
8572 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8573 unsigned long some_state = 0;
8574 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8575 &some_state) & 0xff;
8576 }
8553 else 8577 else
8554 inev.code = er.message & charCodeMask; 8578 inev.code = er.message & charCodeMask;
8555 inev.kind = ASCII_KEYSTROKE_EVENT; 8579 inev.kind = ASCII_KEYSTROKE_EVENT;
@@ -9248,6 +9272,14 @@ syms_of_macterm ()
9248 x_error_message_string = Qnil; 9272 x_error_message_string = Qnil;
9249#endif 9273#endif
9250 9274
9275 Qmodifier_value = intern ("modifier-value");
9276 Qalt = intern ("alt");
9277 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
9278 Qhyper = intern ("hyper");
9279 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
9280 Qsuper = intern ("super");
9281 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
9282
9251 Fprovide (intern ("mac-carbon"), Qnil); 9283 Fprovide (intern ("mac-carbon"), Qnil);
9252 9284
9253 staticpro (&Qreverse); 9285 staticpro (&Qreverse);
@@ -9304,6 +9336,12 @@ to 4.1, set this to nil. */);
9304Otherwise the option key is used. */); 9336Otherwise the option key is used. */);
9305 Vmac_command_key_is_meta = Qt; 9337 Vmac_command_key_is_meta = Qt;
9306 9338
9339 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
9340 doc: /* Modifier to use for the Mac alt/option key. The value can
9341be alt, hyper, or super for the respective modifier. If the value is
9342nil then the key will act as the normal Mac option modifier. */);
9343 Vmac_option_modifier = Qnil;
9344
9307 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, 9345 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta,
9308 doc: /* Non-nil means that the control and meta keys are reversed. This is 9346 doc: /* Non-nil means that the control and meta keys are reversed. This is
9309 useful for non-standard keyboard layouts. */); 9347 useful for non-standard keyboard layouts. */);