-
-
Notifications
You must be signed in to change notification settings - Fork 315
Closed
Description
While looking into issue #912 I noticed three aspect of symbolic UI key names that needs some discussion. Here I'm talking about a binding map assignment in a statement such as edit:insert:binding[Alt-Left] = { echo alt-left >/dev/tty }
.
- The modifier prefix letter-case doesn't matter. You can use
Alt-
,alt-
,aLt-
, etc.
*) I think this behavior is desirable and should be retained. It also needs to be documented but non-canonical letter-case should be discouraged. - There are undocumented modifiers. For example, you can use
a-
(orA-
) instead ofAlt-
.
*) Whether these shortened aliases should be retained is an open question. When I proposed allowing[d]
or[type:d]
as shorter forms of the[type:dir]
wildcard modifier @xiaq rejected adding those aliases. It seems like the symbolic key names should also, if we're going to be consistent, not allow single letter modifiers; i.e.,A-
should not be an alias forAlt-
. - Function key names must match the letter case exactly. For example,
Left
is okay whileleft
is not.
*) I think the behavior should be modified to perform case insensitive matching of those names.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
krader1961 commentedon Sep 30, 2020
Note that point three above applies to both the
functionKeyNames
andkeyNames
arrays in file pkg/ui/key.go. Which also means, for example, thatenter
,eNtEr
andEnter
would all be legal if a case-insensitive match of those tokens was performed.Honestly, I have very mixed feelings about the case-insensitive matching. It is "friendly". It also enables obfuscation. It could even be a security hole. Consider Unicode letter aliasing to mislead readers of a URL (or other text). I'm leaning towards making matching a modifier prefix case-sensitive. That is, you have to write
Alt-
rather thanalt-
oraLt-
.pjanx commentedon Oct 14, 2020
I'm in support of case sensitivity, if only for aesthetic reasons. So long as documentation for bindings lists the proper form of
Alt-Left
as an example, it will be obvious what is expected. Given the relative rarity of configuring bindings, I'm unsure of this leniency's usefulness. Honestly, as a beginner, your typical Elvish user will have much worse problems (coming from POSIX compatibles or even fish, scripting is a nightmare here).The Alt key is typically represented by an
M-
prefix, e.g. in GNU Bash, EditLine and Emacs. (Elvish has inherited this mapping from Meta to Alt.) A prefix of\e
also often works. Similarly for Ctrl, the standard happens to beC-
, with an alternative of^
that is only really suitable for a range of ASCII characters.The aforementioned software does not even understand
Alt-
,Meta-
orCtrl-
. So it could be said that the full-length names are excess friendliness. Or that the one-letter prefixes act as backwards compatibility, whichever you prefer.xiaq commentedon Oct 14, 2020
Case insensitivity and short modifier names are useful when typing out key names in the CLI, and that's likely the only place it's useful.
If there is a mode to insert the name of a key in the CLI - say pressing Ctrl-L inserts
Ctrl-L
, we can get rid of case insensitivity and short modifier names.krader1961 commentedon Oct 15, 2020
Converting literal key sequences to the symbolic name would be cool and useful. The fish shell ships with
the
fish_key_reader
program that does just that. However, I don't think there is any reason simplifying the implementation to remove the short modifier names and/or make the matching case sensitive has to be predicated on that capability. Consider that there is probably no one other than yourself, @xiaq, who has been using the current behavior since it is undocumented. Too, the key name must still be spelled with the proper case; e.g.,Backspace
notbackspace
.I am equally happy with making the key name case insensitive and documenting the behavior. This is simply about consistency and documenting behavior.
P.S., This is an example of the fish_key_reader behavior where I pressed Alt-K:
krader1961 commentedon Oct 21, 2020
/facepalm on my part since I just realized that the reason the key modifier can be case-insensitive but the key cannot (at least by default) is because we need to distinguish between letters such as
x
andX
. However, that is easy to finesse by testing if the key name (without the modifier prefix) is a single character or symbolic key name which will always be longer than a single character. In the single char case perform a case-sensitive match else a case-insensitive match.Make key binding syntax more consistent