all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Interest in keymap-set + use-package (+ bind-key)?
@ 2024-11-11  3:03 Jim Porter
  2024-11-14 14:13 ` Sebastián Monía
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Porter @ 2024-11-11  3:03 UTC (permalink / raw)
  To: emacs-devel

Currently, use-package uses the "legacy" 'define-key' by way of the 
bind-key package. This trips me up sometimes, since the spellings of 
keys are slightly different between 'define-key' and the newer 
'keymap-set' (I mostly run into this when remapping a command).

Would there be any interest in adding support (somehow) to use-package 
for 'keymap-set' and friends? I'm open to options for the specifics 
here. For example, bind-key is also useful for providing 
'describe-personal-keybindings'. Maybe we could enhance bind-key to 
optionally work more like 'keymap-set'? That could be with some new 
option, like 'bind-key-use-keymap-set', or some new function, like 
'keymap-bind-key'[1].

Any thoughts? If this is something others would like, I'd be happy to 
implement this.

[1] This could use a better name, but this name should hopefully suffice 
for discussion purposes.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Interest in keymap-set + use-package (+ bind-key)?
  2024-11-11  3:03 Interest in keymap-set + use-package (+ bind-key)? Jim Porter
@ 2024-11-14 14:13 ` Sebastián Monía
  2024-11-14 21:47   ` Jim Porter
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastián Monía @ 2024-11-14 14:13 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-devel

Jim Porter <jporterbugs@gmail.com> writes:

> Currently, use-package uses the "legacy" 'define-key' by way of the
> bind-key package. This trips me up sometimes, since the spellings of
> keys are slightly different between 'define-key' and the newer
> 'keymap-set' (I mostly run into this when remapping a command).
>
> Would there be any interest in adding support (somehow) to use-package
> for 'keymap-set' and friends? I'm open to options for the specifics
> here. For example, bind-key is also useful for providing
> 'describe-personal-keybindings'. Maybe we could enhance bind-key to
> optionally work more like 'keymap-set'? That could be with some new
> option, like 'bind-key-use-keymap-set', or some new function, like
> 'keymap-bind-key'[1].
>
> Any thoughts? If this is something others would like, I'd be happy to
> implement this.
>
> [1] This could use a better name, but this name should hopefully
> suffice for discussion purposes.

I just read the NEWS entry about keymap-set, so thanks for that.

And I would say yes, it would be nice if use-package worked just like
the newer functions do.

Wouldn't it make sense to have bind-key use that syntax going forward,
though? Maybe it can't be done without breaking existing code, and
that's why we would need a new keyword?


Regards,
Seb

-- 
Sebastián Monía
https://site.sebasmonia.com/



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Interest in keymap-set + use-package (+ bind-key)?
  2024-11-14 14:13 ` Sebastián Monía
@ 2024-11-14 21:47   ` Jim Porter
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Porter @ 2024-11-14 21:47 UTC (permalink / raw)
  To: Sebastián Monía; +Cc: emacs-devel

On 11/14/2024 6:13 AM, Sebastián Monía wrote:
> Wouldn't it make sense to have bind-key use that syntax going forward,
> though? Maybe it can't be done without breaking existing code, and
> that's why we would need a new keyword?

If we can do that in a way that doesn't break existing calls, I think 
that would be ok. Maybe we could replace the calls to 'define-key' with 
something like...

   (if (key-valid-p KEY)
       (keymap-set KEYMAP KEY DEFN)
     (lwarn 'bind-key :warning "Legacy key value detected!")
     (define-key KEYMAP KEY DEFN))

That way, if KEY is valid according to the new keymap.el standards, we 
prefer 'keymap-set'. Otherwise, fall back to the old way and emit a 
warning so the user can fix their config. Then, sometime a few years 
from now, we could remove the 'define-key' fallback?



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-14 21:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11  3:03 Interest in keymap-set + use-package (+ bind-key)? Jim Porter
2024-11-14 14:13 ` Sebastián Monía
2024-11-14 21:47   ` Jim Porter

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.