summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2010-10-11 21:18:08 +0200
committerJan Djärv <jan.h.d@swipnet.se>2010-10-11 21:18:08 +0200
commita2e35ef5d52031e0fa184d1863fe7cb7043ef637 (patch)
tree0e4178b0a917a2ed632776bb769b07482af2ab9a
parent9386ae128af79d61278bd3686d56f3624f9cc5bd (diff)
downloademacs-a2e35ef5d52031e0fa184d1863fe7cb7043ef637.tar.gz
Bug#7150: Distinguishing between left and right Alt keys on NextStep/OSX.
* lisp/cus-start.el (all): ns-right-alternate-modifier is new. * lisp/term/ns-win.el (ns-right-alternate-modifier): New defvar. (ns-right-option-modifier): New alias for ns-right-alternate-modifier. (mac-right-option-modifier): New alias for ns-right-option-modifier. * src/nsterm.m (Qleft): Declare. (ns_right_alternate_modifier): New variable (NSRightAlternateKeyMask): New define. (EV_MODIFIERS): Parse NSRightAlternateKeyMask if ns_right_alternate_modifier isn't Qleft. (keyDown): If ns_right_alternate_modifier isn't Qleft, use it as emacs modifier for NSRightAlternateKeyMask. (syms_of_nsterm): DEFVAR_LISP ns-right-alternate-modifier.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/cus-start.el8
-rw-r--r--lisp/term/ns-win.el3
-rw-r--r--src/ChangeLog11
-rw-r--r--src/nsterm.m32
6 files changed, 61 insertions, 4 deletions
diff --git a/etc/NEWS b/etc/NEWS
index bee89d368b5..25236d0f3d2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -21,6 +21,9 @@ with a prefix argument or by typing C-u C-h C-n.
* Changes in Emacs 23.3
+** The nextstep port can have different modifiers for the left and right
+alt/option key by customizing the value for ns-right-alternate-modifier.
+
* Editing Changes in Emacs 23.3
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 867972ed140..f3275116a9b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+ 2010-10-10 Jan Djärv <jan.h.d@swipnet.se>
+
+ * term/ns-win.el (ns-right-alternate-modifier): New defvar.
+ (ns-right-option-modifier): New alias for ns-right-alternate-modifier.
+ (mac-right-option-modifier): New alias for ns-right-option-modifier.
+
+ * cus-start.el (all): ns-right-alternate-modifier is new.
+
2010-10-10 Andreas Schwab <schwab@linux-m68k.org>
* Makefile.in (ELCFILES): Update.
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 30678a09bb8..0f686a434e0 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -266,6 +266,14 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
(const control) (const meta)
(const alt) (const hyper)
(const super)) "23.1")
+ (ns-right-alternate-modifier
+ ns
+ (choice (const :tag "No modifier (work as alternate/option)" none)
+ (const :tag "Use the value of ns-alternate-modifier"
+ left)
+ (const control) (const meta)
+ (const alt) (const hyper)
+ (const super)) "23.3")
(ns-function-modifier
ns
(choice (const :tag "No modifier (work as function)" none)
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index a53d0346d94..b9177b2b432 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -66,6 +66,7 @@
;; nsterm.m
(defvar ns-version-string)
(defvar ns-alternate-modifier)
+(defvar ns-right-alternate-modifier)
;;;; Command line argument handling.
@@ -286,6 +287,7 @@ The properties returned may include `top', `left', `height', and `width'."
(defvaralias 'mac-command-modifier 'ns-command-modifier)
(defvaralias 'mac-control-modifier 'ns-control-modifier)
(defvaralias 'mac-option-modifier 'ns-option-modifier)
+(defvaralias 'mac-right-option-modifier 'ns-right-option-modifier)
(defvaralias 'mac-function-modifier 'ns-function-modifier)
(declare-function ns-do-applescript "nsfns.m" (script))
(defalias 'do-applescript 'ns-do-applescript)
@@ -817,6 +819,7 @@ unless the current buffer is a scratch buffer."
;; You say tomAYto, I say tomAHto..
(defvaralias 'ns-option-modifier 'ns-alternate-modifier)
+(defvaralias 'ns-right-option-modifier 'ns-right-alternate-modifier)
(defun ns-do-hide-emacs ()
(interactive)
diff --git a/src/ChangeLog b/src/ChangeLog
index d63f417ed42..9ce5007d3b3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2010-10-10 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsterm.m (Qleft): Declare.
+ (ns_right_alternate_modifier): New variable
+ (NSRightAlternateKeyMask): New define.
+ (EV_MODIFIERS): Parse NSRightAlternateKeyMask if
+ ns_right_alternate_modifier isn't Qleft.
+ (keyDown): If ns_right_alternate_modifier isn't Qleft, use it
+ as emacs modifier for NSRightAlternateKeyMask.
+ (syms_of_nsterm): DEFVAR_LISP ns-right-alternate-modifier.
+
2010-10-08 Michael Albinus <michael.albinus@gmx.de>
* dbusbind.c (xd_get_dispatch_status): Return a Lisp_Object.
diff --git a/src/nsterm.m b/src/nsterm.m
index 7c70b2ae698..fc933c099e8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -142,13 +142,18 @@ Lisp_Object ns_input_spi_name, ns_input_spi_arg;
Lisp_Object Vx_toolkit_scroll_bars;
static Lisp_Object Qmodifier_value;
Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone;
-extern Lisp_Object Qcursor_color, Qcursor_type, Qns;
+extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft;
/* Specifies which emacs modifier should be generated when NS receives
the Alternate modifer. May be Qnone or any of the modifier lisp symbols. */
Lisp_Object ns_alternate_modifier;
/* Specifies which emacs modifier should be generated when NS receives
+ the right Alternate modifer. Has same values as ns_alternate_modifier plus
+ the value Qleft which means whatever value ns_alternate_modifier has. */
+Lisp_Object ns_right_alternate_modifier;
+
+/* Specifies which emacs modifier should be generated when NS receives
the Command modifer. May be any of the modifier lisp symbols. */
Lisp_Object ns_command_modifier;
@@ -218,12 +223,17 @@ static BOOL inNsSelect = 0;
/* Convert modifiers in a NeXTSTEP event to emacs style modifiers. */
#define NS_FUNCTION_KEY_MASK 0x800000
+#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
#define EV_MODIFIERS(e) \
((([e modifierFlags] & NSHelpKeyMask) ? \
hyper_modifier : 0) \
- | (([e modifierFlags] & NSAlternateKeyMask) ? \
+ | (!EQ (ns_right_alternate_modifier, Qleft) && \
+ (([e modifierFlags] & NSRightAlternateKeyMask) \
+ == NSRightAlternateKeyMask) ? \
+ parse_solitary_modifier (ns_right_alternate_modifier) : 0) \
+ | (([e modifierFlags] & NSAlternateKeyMask) ? \
parse_solitary_modifier (ns_alternate_modifier) : 0) \
- | (([e modifierFlags] & NSShiftKeyMask) ? \
+ | (([e modifierFlags] & NSShiftKeyMask) ? \
shift_modifier : 0) \
| (([e modifierFlags] & NSControlKeyMask) ? \
parse_solitary_modifier (ns_control_modifier) : 0) \
@@ -4423,7 +4433,13 @@ ns_term_shutdown (int sig)
emacs_event->modifiers |=
parse_solitary_modifier (ns_function_modifier);
- if (flags & NSAlternateKeyMask) /* default = meta */
+ if (!EQ (ns_right_alternate_modifier, Qleft)
+ && ((flags & NSRightAlternateKeyMask) == NSRightAlternateKeyMask))
+ {
+ emacs_event->modifiers |= parse_solitary_modifier
+ (ns_right_alternate_modifier);
+ }
+ else if (flags & NSAlternateKeyMask) /* default = meta */
{
if ((NILP (ns_alternate_modifier) || EQ (ns_alternate_modifier, Qnone))
&& !fnKeysym)
@@ -6185,6 +6201,14 @@ Set to none means that the alternate / option key is not interpreted by Emacs\n\
at all, allowing it to be used at a lower level for accented character entry.");
ns_alternate_modifier = Qmeta;
+ DEFVAR_LISP ("ns-right-alternate-modifier", &ns_right_alternate_modifier,
+ "This variable describes the behavior of the right alternate or option key.\n\
+Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\
+Set to left means be the same key as `ns-alternate-modifier'.\n\
+Set to none means that the alternate / option key is not interpreted by Emacs\n\
+at all, allowing it to be used at a lower level for accented character entry.");
+ ns_right_alternate_modifier = Qleft;
+
DEFVAR_LISP ("ns-command-modifier", &ns_command_modifier,
"This variable describes the behavior of the command key.\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.");