[-- Attachment #1: Type: text/plain, Size: 257 bytes --] Is it possible to use ARG when defining keybindings? For the command (scroll-up-command &optional ARG) I want to define this keybind: (define-key global-map (kbd "M-n") 'scroll-up-command 1) But: eval-region: Wrong number of arguments: define-key, 4 [-- Attachment #2: Type: text/html, Size: 855 bytes --]
Ypo <ypuntot@gmail.com> writes:
> Is it possible to use ARG when defining keybindings?
>
> For the command (scroll-up-command &optional ARG) I want to define this
> keybind:
>
>
> (define-key global-map (kbd "M-n") 'scroll-up-command 1)
>
>
> But:
>
> eval-region: Wrong number of arguments: define-key, 4
I don't think that 'define-key' allows to specify extra arguments.
But, you can easily define your own command.
(defun my-scroll-up-of-1 ()
(interactive)
(scroll-up-command 1))
(define-key global-map (kbd "M-n") 'my-scroll-up-of-1)
[-- Attachment #1: Type: text/plain, Size: 1033 bytes --] Working, thanks Bruno! I needed it, because what I was using is not working well: (global-set-key (kbd "M-n") (kbd "C-u 1 C-v")) From some time ago, it doesn't work in .org buffers, although it works in elisp buffers. In .org buffers I receive this message: After 0 kbd macro iterations: command-execute: Keyboard macro terminated by a command ringing the bell Best regards El 19/06/2022 a las 18:49, Bruno Barbier escribió: > Ypo<ypuntot@gmail.com> writes: > >> Is it possible to use ARG when defining keybindings? >> >> For the command (scroll-up-command &optional ARG) I want to define this >> keybind: >> >> >> (define-key global-map (kbd "M-n") 'scroll-up-command 1) >> >> >> But: >> >> eval-region: Wrong number of arguments: define-key, 4 > I don't think that 'define-key' allows to specify extra arguments. > > But, you can easily define your own command. > > (defun my-scroll-up-of-1 () > (interactive) > (scroll-up-command 1)) > > (define-key global-map (kbd "M-n") 'my-scroll-up-of-1) > [-- Attachment #2: Type: text/html, Size: 1797 bytes --]
Bruno Barbier writes:
> But, you can easily define your own command.
>
> (defun my-scroll-up-of-1 ()
> (interactive)
> (scroll-up-command 1))
>
> (define-key global-map (kbd "M-n") 'my-scroll-up-of-1)
Or simply doing something like:
(define-key global-map (kbd "M-n") (lambda ()
(interactive)
(scroll-up-command 1)))
Best regards,
Juan Manuel
Ypo <ypuntot@gmail.com> writes: > Working, thanks Bruno! > Thanks for the feedback. > I needed it, because what I was using is not working well: > > (global-set-key (kbd "M-n") (kbd "C-u 1 C-v")) FWIW, your previous method works for me in org mode buffers (emacs 28 -Q and my custom emacs 29 with custom org). And: (define-key global-map (kbd "M-n") (kbd "C-u 1 C-v")) works too. Best regards, > From some time ago, it doesn't work in .org buffers, although it works > in elisp buffers. > > In .org buffers I receive this message: > > After 0 kbd macro iterations: command-execute: Keyboard macro terminated > by a command ringing the bell > > Best regards > > El 19/06/2022 a las 18:49, Bruno Barbier escribió: >> Ypo<ypuntot@gmail.com> writes: >> >>> Is it possible to use ARG when defining keybindings? >>> >>> For the command (scroll-up-command &optional ARG) I want to define this >>> keybind: >>> >>> >>> (define-key global-map (kbd "M-n") 'scroll-up-command 1) >>> >>> >>> But: >>> >>> eval-region: Wrong number of arguments: define-key, 4 >> I don't think that 'define-key' allows to specify extra arguments. >> >> But, you can easily define your own command. >> >> (defun my-scroll-up-of-1 () >> (interactive) >> (scroll-up-command 1)) >> >> (define-key global-map (kbd "M-n") 'my-scroll-up-of-1) >>