Hi Philip,
Why does setup-define :global use
`(global-set-key ,key ,command)
and not something like
`(define-key global-map ,key ,command)?
My understanding is that `global-set-key' is just a thin wrapper around
`define-key' so would it not be better to use the more primitive
function within a macro definition?
No doubt there is a valid reason for your choice but I was just curious.
Kind regards,
Niall
Niall Dooley <dooleyn@gmail.com> writes:
> Hi Philip,
Hi,
> Why does setup-define :global use>> `(global-set-key ,key ,command)>> and not something like>> `(define-key global-map ,key ,command)?>> My understanding is that `global-set-key' is just a thin wrapper around> `define-key'
Just looking at the definition of global-set-key, it should be more or
less like:
(define-key (current-global-map) key command)
> so would it not be better to use the more primitive> function within a macro definition?
I don't know of any such rule when writing macros.
> No doubt there is a valid reason for your choice but I was just curious.
Pretty much just that I was adding a macro for what I was previously
writing out in my init.el, and in my case I was using the user-facing
global-set-key -- and in fact still do. IMO the :global local macro was
a mistake, since it doesn't really use any context, and admittedly was
inspired by `use-package', without sufficient introspection. Since
Emacs 29, the proper function to use is `keymap-global-set' anyway.
> Kind regards,>> Niall
On Wed, 20 Dec 2023 at 19:03, Philip Kaludercic <philipk@posteo.net> wrote:
> Just looking at the definition of global-set-key, it should be more or> less like:>> (define-key (current-global-map) key command)>> > so would it not be better to use the more primitive> > function within a macro definition?>> I don't know of any such rule when writing macros.
I didn't mean to suggest their was such a rule.
> > No doubt there is a valid reason for your choice but I was just curious.>> Pretty much just that I was adding a macro for what I was previously> writing out in my init.el, and in my case I was using the user-facing> global-set-key -- and in fact still do. IMO the :global local macro was> a mistake, since it doesn't really use any context, and admittedly was> inspired by `use-package', without sufficient introspection. Since> Emacs 29, the proper function to use is `keymap-global-set' anyway.
Interesting. Still on 27.1 myself but reading about these changes now
and `global-set-key' becoming a legacy function.
Niall Dooley <dooleyn@gmail.com> writes:
> On Wed, 20 Dec 2023 at 19:03, Philip Kaludercic <philipk@posteo.net> wrote:>> Just looking at the definition of global-set-key, it should be more or>> less like:>>>> (define-key (current-global-map) key command)>>>> > so would it not be better to use the more primitive>> > function within a macro definition?>>>> I don't know of any such rule when writing macros.>> I didn't mean to suggest their was such a rule.
Heuristic, idiom or whatever; what I meant to say is that I have never
heard of anyone arguing this point.
>> > No doubt there is a valid reason for your choice but I was just curious.>>>> Pretty much just that I was adding a macro for what I was previously>> writing out in my init.el, and in my case I was using the user-facing>> global-set-key -- and in fact still do. IMO the :global local macro was>> a mistake, since it doesn't really use any context, and admittedly was>> inspired by `use-package', without sufficient introspection. Since>> Emacs 29, the proper function to use is `keymap-global-set' anyway.>> Interesting. Still on 27.1 myself but reading about these changes now> and `global-set-key' becoming a legacy function.
The peculiar thing is that these functions all still boil down to
`define-key', which is also marked as a legacy function.