emacs-devel
[Top][All Lists]
Advanced

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

Re: master 859190f 2/3: Convert some keymaps to defvar-keymap


From: Stefan Kangas
Subject: Re: master 859190f 2/3: Convert some keymaps to defvar-keymap
Date: Tue, 12 Oct 2021 14:34:02 -0700

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> In the current Emacs tree, we have >7K instances of define-key with a
>> string as a parameter, and 441 with (kbd ...).
>
> And 258 on the [(control ?+)].

Right, but how much of that is preloaded code, how much is unchanged
since the 1990's, how much is written by core developers who can't use
`kbd' due to bootstrap and just got out of the habit, etc.?

In my case, I would definitely prefer to use kbd everywhere, but it
feels out of place to convert an entire string of bindings to my
preferred style just because I'm adding a keybinding.  So I don't do
that.

IOW, I don't think that counting instances in core will necessarily lead
to a very representative sample of current Emacs Lisp in this case.

For comparison, here are the top packages on MELPA, excluding dash.el
and other library packages without keybindings:

https://github.com/magit/magit/blob/348d9b98614c824be3e2f05eef5ab91d67f6695e/lisp/magit.el#L283
https://github.com/emacs-helm/helm/blob/b2bd8a2a938030c70e7da84bd49cadcc095ec2b9/helm.el#L212
https://github.com/flycheck/flycheck/blob/784f184cdd9f9cb4e3dbb997c09d93e954142842/flycheck.el#L1096
https://github.com/bbatsov/projectile/blob/7f64570d3e6829d767d340c8584f3e4f3472ee81/projectile.el#L5377
https://github.com/company-mode/company-mode/blob/4c08ef468678bbf3b3c9e750f6e694eea1aa8423/company.el#L807
https://github.com/jrblevin/markdown-mode/blob/862ae8addd29bf6affca1a35fd0176cb0c1392da/markdown-mode.el#L5316

Six different principal authors, but all of them use kbd.  I stopped
checking after markdown-mode, but all I checked before that uses kbd.

> (And as Eli said, `kbd' isn't something that we currently can use
> everywhere, because the implementation depends on (basically)
> everything.  If the `kbd' syntax is to be used in keymaps everywhere,
> somebody has to re-implement it to be self contained.)

Yeah, that would need fixing if we want to use it in preloaded code.

>From a quick glance, it looks like the meat of this is in
`edmacro-parse-keys'.  From there, you have a ton of calls to `cl-lib',
regexps and what have you.  But nothing in there looks like it should be
impossible to get in shape, even for early bootstrap, does it?

Personally though, I'd be quite happy even if we could just do what Juri
said and add a :kbd keyword to defvar-keymap (t by default), and use
:kbd nil in our preloaded code.  I'm pretty sure that at least the above
package authors (the "kbd" users) would also be happy.  It's too nice of
an addition to Emacs Lisp to not get it all the way over the finish
line when we have the chance.



reply via email to

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