emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Keybinding doubt about ARG
@ 2022-06-19 15:50 Ypo
  2022-06-19 16:49 ` Bruno Barbier
       [not found] ` <62af533d.1c69fb81.96299.c52dSMTPIN_ADDED_MISSING@mx.google.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Ypo @ 2022-06-19 15:50 UTC (permalink / raw)
  To: Org-mode

[-- 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 --]

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

* Re: Keybinding doubt about ARG
  2022-06-19 15:50 Keybinding doubt about ARG Ypo
@ 2022-06-19 16:49 ` Bruno Barbier
  2022-06-19 17:21   ` Juan Manuel Macías
       [not found] ` <62af533d.1c69fb81.96299.c52dSMTPIN_ADDED_MISSING@mx.google.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Bruno Barbier @ 2022-06-19 16:49 UTC (permalink / raw)
  To: Ypo, Org-mode

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)



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

* Re: Keybinding doubt about ARG
       [not found] ` <62af533d.1c69fb81.96299.c52dSMTPIN_ADDED_MISSING@mx.google.com>
@ 2022-06-19 16:56   ` Ypo
  2022-06-19 17:24     ` Bruno Barbier
  0 siblings, 1 reply; 5+ messages in thread
From: Ypo @ 2022-06-19 16:56 UTC (permalink / raw)
  To: Bruno Barbier, Org-mode

[-- 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 --]

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

* Re: Keybinding doubt about ARG
  2022-06-19 16:49 ` Bruno Barbier
@ 2022-06-19 17:21   ` Juan Manuel Macías
  0 siblings, 0 replies; 5+ messages in thread
From: Juan Manuel Macías @ 2022-06-19 17:21 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: orgmode

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


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

* Re: Keybinding doubt about ARG
  2022-06-19 16:56   ` Ypo
@ 2022-06-19 17:24     ` Bruno Barbier
  0 siblings, 0 replies; 5+ messages in thread
From: Bruno Barbier @ 2022-06-19 17:24 UTC (permalink / raw)
  To: Ypo, Org-mode

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)
>>


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

end of thread, other threads:[~2022-06-19 17:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-19 15:50 Keybinding doubt about ARG Ypo
2022-06-19 16:49 ` Bruno Barbier
2022-06-19 17:21   ` Juan Manuel Macías
     [not found] ` <62af533d.1c69fb81.96299.c52dSMTPIN_ADDED_MISSING@mx.google.com>
2022-06-19 16:56   ` Ypo
2022-06-19 17:24     ` Bruno Barbier

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).