Commit 215f678c authored by Mattias Engdegård's avatar Mattias Engdegård

Fine-grained NS modifier key settings (bug#38296)

For the ns-KEY-modifier and ns-right-KEY-modifier variables, KEY
being 'control', 'command', 'alternate' and 'function', allow
values on the form (:ordinary SYMBOL :function :SYMBOL :mouse SYMBOL),
so that the key can be used for different modifiers (or none) in
different contexts.  This is particularly useful for using the macOS
Option key for extended character entry while still using it as an
Emacs modifier for function keys and mouse clicks.

* src/nsterm.m (mod_of_kind, right_mod, nil_or_none): Helper functions.
(EV_MODIFIERS2): Add KIND argument.
(EV_MODIFIERS): Adapt call to EV_MODIFIERS2.
(ns_get_shifted_character): Use correct event kind for modifiers.
(ns-alternate-modifier, ns-right-alternate-modifier)
(ns-command-modifier, ns-right-command-modifier)
(ns-control-modifier, ns-right-control-modifier)
(ns-function-modifier): Rewrite doc strings for new data format.
(QCordinary, QCfunction, QCmouse): Define symbols.
* lisp/cus-start.el: Conform to new data types.
* doc/emacs/macos.texi (Mac / GNUstep Basics)
(Mac / GNUstep Customization): Improved documentation.
* etc/NEWS: Mention the change.
parent aa89c84e
Pipeline #4176 failed with stage
in 55 minutes and 47 seconds
......@@ -48,18 +48,8 @@ Support}), but we hope to improve it in the future.
Emacs provides a set of key bindings using this modifier key that mimic
other Mac / GNUstep applications (@pxref{Mac / GNUstep Events}). You
can change these bindings in the usual way (@pxref{Key Bindings}).
@vindex ns-alternate-modifier
@vindex ns-right-alternate-modifier
The variable @code{ns-right-alternate-modifier} controls the
behavior of the right @key{Alt} and @key{Option} keys. These keys
behave like the left-hand keys if the value is @code{left} (the
default). A value of @code{control}, @code{meta}, @code{alt},
@code{super}, or @code{hyper} makes them behave like the corresponding
modifier keys; a value of @code{left} means be the same key as
@code{ns-alternate-modifier}; a value of @code{none} tells Emacs to
ignore them, in which case you get the default behavior of macOS
accentuation system from the right @key{Option} key.
The modifiers themselves can be customized;
@pxref{Mac / GNUstep Customization}.
@kbd{S-mouse-1} adjusts the region to the click position,
just like @kbd{mouse-3} (@code{mouse-save-then-kill}); it does not pop
......@@ -107,6 +97,52 @@ Nextstep port. For example, they affect things such as the modifier
keys and the fullscreen behavior. To see all such options, use
@kbd{M-x customize-group @key{RET} ns @key{RET}}.
@subsection Modifier keys
The following variables control the behaviour of the actual modifier
keys:
@table @code
@vindex ns-alternate-modifier
@vindex ns-right-alternate-modifier
@item ns-alternate-modifier
@itemx ns-right-alternate-modifier
The left and right @key{Option} or @key{Alt} keys.
@vindex ns-command-modifier
@vindex ns-right-command-modifier
@item ns-command-modifier
@itemx ns-right-command-modifier
The left and right @key{Command} keys.
@vindex ns-control-modifier
@vindex ns-right-control-modifier
@item ns-control-modifier
@itemx ns-right-control-modifier
The left and right @key{Control} keys.
@vindex ns-function-modifier
@item ns-function-modifier
The @key{Function} (fn) key.
@end table
The value of each variable is either a symbol, describing the key for
any purpose, or a list of the form
@code{(:ordinary @var{symbol} :function @var{symbol} :mouse @var{symbol})},
which describes the modifier when used with ordinary keys, function keys
(that do not produce a character, such as arrow keys), and mouse clicks.
If the @var{symbol} is one of @code{control}, @code{meta}, @code{alt},
@code{super} or @code{hyper}, this describes the Emacs modifier it
represents. If @var{symbol} is @code{none}, Emacs does not use the
key, which retains its standard behaviour. For instance, the
@key{Option} key in macOS is then used for composing additional
characters.
The variables for right-hand keys, like @code{ns-right-alternate-modifier},
may also be set to @code{left}, which means to use the same behaviour as
the corresponding left-hand key.
@subsection Font Panel
@findex ns-popup-font-panel
......
......@@ -3273,6 +3273,12 @@ Previously it was supported only in the Cygwin-w32 build.
** Emacs now handles key combinations involving the macOS "command"
and "option" modifier keys more correctly.
** MacOS modifier key behaviour is now more adjustable.
The behaviour of the macOS "Option", "Command", "Control" and
"Function" keys can now be specified separately for use with
ordinary keys, function keys and mouse clicks. This allows using them
in their standard macOS way for composing characters.
** The special handling of 'frame-title-format' on NS where setting it
to 't' would enable the macOS proxy icon has been replaced with a
separate variable, 'ns-use-proxy-icon'. 'frame-title-format' will now
......
......@@ -424,16 +424,23 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
;; msdos.c
(dos-unsupported-char-glyph display integer)
;; nsterm.m
;;
;; FIXME: Why does ⌃ use nil instead of none? Also the
;; description is confusing; setting it to nil disables ⌃
;; entirely.
(ns-control-modifier
ns
(choice (const :tag "No modifier" nil)
(choice (const :tag "No modifier" none)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "23.1")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"23.1")
(ns-right-control-modifier
ns
(choice (const :tag "No modifier (work as control)" none)
......@@ -441,13 +448,35 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
left)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "24.1")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"24.1")
(ns-command-modifier
ns
(choice (const :tag "No modifier (work as layout switch)" none)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "23.1")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"23.1")
(ns-right-command-modifier
ns
(choice (const :tag "No modifier (work as layout switch)" none)
......@@ -455,13 +484,35 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
left)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "24.1")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"24.1")
(ns-alternate-modifier
ns
(choice (const :tag "No modifier (work as alternate/option)" none)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "23.1")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"23.1")
(ns-right-alternate-modifier
ns
(choice (const :tag "No modifier (work as alternate/option)" none)
......@@ -469,13 +520,35 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
left)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "23.3")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"23.3")
(ns-function-modifier
ns
(choice (const :tag "No modifier (work as function)" none)
(const control) (const meta)
(const alt) (const hyper)
(const super)) "23.1")
(const super)
(plist :key-type (choice (const :ordinary)
(const :function)
(const :mouse))
:value-type (choice (const control)
(const meta)
(const alt)
(const hyper)
(const super)
(const :tag "No modifier"
none))))
"23.1")
(ns-antialias-text ns boolean "23.1")
(ns-auto-hide-menu-bar ns boolean "24.1")
(ns-confirm-quit ns boolean "25.1")
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment