emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Concern about new binding.


From: Karl Fogel
Subject: Re: Concern about new binding.
Date: Tue, 02 Feb 2021 12:51:11 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On 02 Feb 2021, Thibaut Verron wrote:
2021-02-02 17:50 UTC+01:00, Karl Fogel <kfogel@red-bean.com>:
On 02 Feb 2021, Ergus wrote:
1) In general `C-x g` is used by magit; I know this is not a priority (cause magit is an external package), but magit is a very popular package.

While Magit is indeed very popular and valuable, shouldn't it still adhere to convention and avoid binding things in the `C-x' space? That's really a point to be made on the Magit development mailing list, not here, but what I'm saying here is that Emacs shouldn't make special efforts to avoid interfering with package keybindings that violate Emacs's conventions anyway. Magit should instead suggest `C-c g' as an entry point for `magit-status', though a user can bind it however they want of course. I doubt there are any Magit users who would be daunted by the need to set up a keybinding for Magit's entry point.
To be clear, Magit itself does not bind anything by default. It suggests "C-x g" as a binding, and I see now that it also offers an option to enable that binding for the user.

Actually, Magit does bind `C-x g' by default.

There is a defcustom, `magit-define-global-key-bindings', and it defaults to `t' in magit.el since October 2020 -- see [1] for the history of that decision. When that variable is true, then that keybinding (and two others) are made automatically by Magit at load time.

It is not the only high-level package using "C-x letter" as an entry point, another example coming to mind is projectile ("C-x p"). As for the conventions, as far as I can tell, they explicitly require to steer clear of "C-c letter", but they don't have anything about "C-x letter": https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html

Uh, I mean... sure, okay, those guidelines don't say anything explicit about not binding `C-x LETTER' in your 3rd-party package, but does that kind of guidance really have to be made explicit? This is Emacs: everyone who develops for Emacs knows that the `C-x' map is crowded and used heavily by Emacs. If everyone's packages started binding things under there, they'd simply collide with *each other* all the time, as well as (eventually) with Emacs when Emacs decides to add a new `C-x' binding, as happened here.

I mean, the guidelines don't say to avoid rebinding the letter `a' either, but people know not to do that :-).

Magit should explicitly advise users to use `C-c LETTER' for Magit's entry points. The user-reserved space is there under `C-c LETTER' precisely so users can bind entry points to their favorite functionality.

In other words, while Magit itself should "steer clear" of binding things under either `C-x' or `C-c LETTER', Magit is perfectly free to make recommendations. Right now, Magit's three main entry points are:

C-x g `magit-status' C-x M-g `magit-dispatch' C-c M-g `magit-file-dispatch' And the doc string for `magit-define-global-key-bindings' even says the following: > We recommend that you bind "C-c g" instead of "C-c M-g" to > `magit-file-dispatch'. The former is a much better binding > but the "C-c <letter>" namespace is strictly reserved for > users; preventing Magit from using it by default. Now, clearly Magit's developers knew about the convention and decided to clobber the Emacs-reserved space anyway. I totally understand why they did so, even though I disagree with the decision.

One solution to this would be for Emacs to reserve some keyspace for those three Magit entry points explicitly, outside the `C-c WHATEVER' conventions. Maybe it would be under `C-x', or maybe somewhere else. Magit is so popular that this might make sense -- essentially, bring Magit back into keybinding compliance by creating a reserved space for it.

I'm not sure why Magit doesn't ship with Emacs; I presume it has something to do with copyright assignment issues. But I think the question of whether a package ships with Emacs can be, in principle, be independent of the question of whether Emacs reserves some keybinding space for that package. That might sound like a weird idea, but Magit is a good example of a situation where it could make sense.

Best regards, -Karl
[1] commit 5a38e1bb0fffa0326a1b5073c0ce9b05386e5109
   Author:     Jonas Bernoulli <jonas@bernoul.li>
   AuthorDate: Sat Oct 31 20:16:01 2020 +0100
   Commit:     Jonas Bernoulli <jonas@bernoul.li>
   CommitDate: Fri Nov 6 21:40:17 2020 +0100
Add three global key bindings by default For the longest time we have tried hard to avoid doing this but
       it is just not worth the effort and leads to an inferior result.
Now we add three bindings by default. ;;;###autoload
         (when magit-define-global-key-bindings
           (let ((map (current-global-map)))
             (define-key map (kbd "C-x g")   'magit-status)
             (define-key map (kbd "C-x M-g") 'magit-dispatch)
             (define-key map (kbd "C-c M-g") 'magit-file-dispatch)))
As you can see is easy to prevent these bindings from being added
       and I hope having to do so won't upset anyone too much.  While we
       did not add global bindings we already added these bindings in all
       file-visiting buffers and we did not get any complaints about that.
This completely replaces `magit-file-mode' and the global variant,
       which we define as an alias of the new variable.
See #4237. M Documentation/magit.org
   M    Documentation/magit.texi
   M    lisp/magit-files.el
   M    lisp/magit.el



reply via email to

[Prev in Thread] Current Thread [Next in Thread]