unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "T.V Raman" <raman@google.com>,
	Thibaut Verron <thibaut.verron@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Emacs default key bindings    [was: Opening Up More Keymaps Re: Standardizing more key bindings?]
Date: Fri, 2 Oct 2020 11:14:48 -0700 (PDT)	[thread overview]
Message-ID: <364afb35-1cf9-4bd8-a34d-370dc428f950@default> (raw)

> Perhaps it's time we opened up some additional keymaps...

Stayed out of this thread so far, hoping it would die
a healthy natural death. ;-)  But here are my general
thoughts on the matter, FWIW.
___


1. Keyboard keys are scarce.  Many are already "taken"
by default by Emacs.  (Yes, of course, users and
libraries can always _override_ any default bindings.)

Some of the keys Emacs has "taken" could fruitfully
be revisited.

Some are easily repeatable keys that are bound by
default to nonrepeatable commands, i.e., commands
that it makes no sense to hold the key down to repeat.

Some are particularly easy/quick to type, and are
bound to commands that might not be used that often.

Some were perhaps taken only because a key seemed to
be free at the time (often long ago), regardless of
how much a default binding was needed.  (Recently F2
has come up, as having been sacrificed for the
relatively unused/not-so-useful `2C-*' commands.)

Any such keys could be looked at as keys we might
possibly want to "open up".

(And no, I'm not saying that there aren't other
things to take into account when deciding on a
default key binding.  Ease/speed of finger access,
for example.)


2. But what do we mean by "open up" or "free" a
default key binding?  _I_ mean free it for use by
users and 3rd-party libraries.  Have Emacs give it
up - let it go.

I don't mean for Emacs to just bind it to something
different by default.  That's _not_ freeing it up;
that's just rearranging.  Rearranging can be useful
sometimes, but it doesn't help with the problem of
Emacs binding too many keys by default.

Some here feel the pinch as Emacs not having enough
free keys to bind to more commands by default.  I
feel the problem is the opposite: the pinch is on
users and 3rd-party libraries, and Emacs is doing
the pinching.  Some here see a "free" key and want
to bind it by default, sometimes to their shiny
new command.


3. There's been a tendency recently to give Emacs
even more default key bindings.  Two cases come
to mind, both in 2020:

a. `C-x p' was taken by Emacs as a prefix key for
   `project.el' commands.
b. `C-x t' was taken by Emacs as a prefix key for
   `tabbar.el' commands.

Maybe those deserve prefix keys (?).  But you see
the tendency - less and less for users; more taken
by default bindings.

That's 2 excellent prefix keys just removed, in
effect, from the user/3rd-party space.  Poof!

For example, in my code I've used `C-x p' and
`C-x 4 p' as prefix keys for Bookmark+ for over
10 years, but I changed them (`C-x x', `C-x 4 x')
in 2020 because of (a).

(I have 86 key bindings organized onto those two
prefix keys - some on submaps: `C-x x a',
`C-x x b', `C-x x c', `C-x x t', `C-x x t +',...)

And I've used `C-x t' as a suggested prefix key
for library DoReMi for 16 years.  But I'll have to
change that in 2020 because of (b).

I pointed this out here at the time.  Response was,
in effect, "tough tiddlywinks".  OK.

https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00085.html

The point is that instead of Emacs trying to reserve
_more_ keys as free for its users (without having to
override default bindings), the impetus here has
been to sacrifice ever more keys to default bindings.


4. When Emacs does decide to bind a key by default,
these two general guidelines (at least) should be
considered, IMO.  (This applies to rearranging, as
well as to binding a previously free key.)  

1. Save naturally repeatable keys for commands that
   can be repeated, i.e., commands that it makes
   sense to be able to hold down a key to repeat.

2. Save some keys for prefix keys, as opposed to
   just sacrificing them for a single command.  A
   prefix key gives you a whole keyboard of
   possibilities for a single key.  Think of all
   the mileage we get out of the prefix key `C-x'!
   Of course, adding a prefix key makes a key
   sequence longer, more complex.  Tradeoff.


___________________

That point (#4) and the rest of this message
were part of a post of mine to help-gnu-emacs
on 9/23/2020, on pretty much this same topic:

https://lists.gnu.org/archive/html/help-gnu-emacs/2020-09/msg00273.html

I tend to define lots of keys for features I write,
and put them, by groups, on their own keymaps, and
then put those keymaps on prefix keys.

Even if such a prefix key appears complicated or
slow, the fact of using a separate keymap means
that a user can easily put it on a different,
shorter key, or remap it to a more global keymap.

Now imagine that keys aren't reserved by Emacs this
way - repeatable keys for repeatable commands, and
some keys available to be used as prefix keys.

Imagine if Emacs just predefined `C-x' for a single
command (e.g. `cut').  _Zillions_ of keys bound now
under `C-x' would be sacrificed.

At the very least, when a new key is decided to be
sacrificed by default (vanilla Emacs), it had better
be bound to a repeatable command, not one (such as
`cut') that it makes no sense to repeat.

And even a repeatable key is a sacrifice - consider
if `C-x' were bound to, say, `forward-word'.
Repeatable, yes, but think of all the bindings now
under `C-x' that would be lost.

Keyboard keys are precious - scarce.  Too many have
already been sacrificed to default bindings, IMO.
Sure, any user or library can redefine any keys.
But once blessed as a default vanilla-Emacs key
binding, a key is, for practical purposes, kinda
off limits for a library.

The point is that (1) it's easy to move a keymap
from one prefix key to another, and (2) there need
to be some prefix keys available to move maps to.

Eventually, I imagine (hope) that some simple,
repeatable keys that have been assigned default
Emacs bindings for commands that aren't repeatable,
or that aren't super useful, or that don't really
need a single-key binding, will be recycled and
put to better use: for repeatable commands, as
prefix keys, or just unbound by default and left
available for libraries.

No, I don't have particular suggestions, and no,
it's not urgent.

But consider `M-!', for example.  Sure, `!' is
mnemonic for shell.  But `M-!' is repeatable
(just hold it down), and it makes no sense to
repeat `shell-command'.  There are other default
key bindings like this - essentially wasted wrt
easy repetition.

Some nonrepeatable commands bound to repeatable
keys should be replaced by repeatable versions.
I do that for `C-a' and `C-e', for example, so
they're similar to `C-n' and `C-p' (repeatable).
That kind of change is minimal - it's the least
we can do to make things a little saner.

Take a look at `C-h b', and see which repeatable
keys are bound to nonrepeatable commands.  Not
too many, but there are some.

Even `C-w' is "wasted" on a nonrepeatable command.
Am I suggesting that `C-w' should not be bound by
default to `kill-region'?  Not really.  That's not
urgent, at least.  But hey, keys are limited - the
keyboard's a small planet. ;-)

And `beginning-of-buffer'.  That nonrepeatable
command's bound by default to two repeatable keys,
`M-<' and `C-home'.  Both mnemonic (good).  But...



             reply	other threads:[~2020-10-02 18:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 18:14 Drew Adams [this message]
2020-10-02 19:21 ` Emacs default key bindings [was: Opening Up More Keymaps Re: Standardizing more key bindings?] Philip K.
2020-10-02 20:41   ` Drew Adams
2020-10-02 19:24 ` Ergus
2020-10-02 20:45   ` Drew Adams
2020-10-02 22:31   ` Philip K.
2020-10-02 22:50     ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2020-10-02 18:46 arthur miller

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=364afb35-1cf9-4bd8-a34d-370dc428f950@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=raman@google.com \
    --cc=thibaut.verron@gmail.com \
    /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).