all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to bind a function with argument?
@ 2010-12-18  0:35 Rafael
  2010-12-18  1:31 ` LanX
  2010-12-18  1:49 ` Pascal J. Bourguignon
  0 siblings, 2 replies; 7+ messages in thread
From: Rafael @ 2010-12-18  0:35 UTC (permalink / raw)
  To: help-gnu-emacs


I would like to bind a key to the function that results from

C-u M-x org-insert-link

From 4.6 of http://www.nongnu.org/emacs-tiny-tools/keybindings/, I
thought that 

  (global-set-key [(super f)]
                   '(lambda () (interactive) (org-insert-link 4)))

would do the trick. But it doesn't, the effect is no different than just
doing 

  (global-set-key [(super f)] 'org-insert-link)

which is not what I want. Any help, please?


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

* Re: How to bind a function with argument?
  2010-12-18  0:35 How to bind a function with argument? Rafael
@ 2010-12-18  1:31 ` LanX
  2010-12-18  1:43   ` Rafael
  2010-12-18  1:52   ` LanX
  2010-12-18  1:49 ` Pascal J. Bourguignon
  1 sibling, 2 replies; 7+ messages in thread
From: LanX @ 2010-12-18  1:31 UTC (permalink / raw)
  To: help-gnu-emacs

 (global-set-key [(super f)]
                  '(lambda () (interactive) (org-insert-link '4)))


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

* Re: How to bind a function with argument?
  2010-12-18  1:31 ` LanX
@ 2010-12-18  1:43   ` Rafael
  2010-12-18  1:52   ` LanX
  1 sibling, 0 replies; 7+ messages in thread
From: Rafael @ 2010-12-18  1:43 UTC (permalink / raw)
  To: help-gnu-emacs

LanX <lanx.perl@googlemail.com> writes:

>  (global-set-key [(super f)]
>                   '(lambda () (interactive) (org-insert-link '4)))

Hmm, thanks for your answer, but again it has the same effect as not
quoting the 4...


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

* Re: How to bind a function with argument?
  2010-12-18  0:35 How to bind a function with argument? Rafael
  2010-12-18  1:31 ` LanX
@ 2010-12-18  1:49 ` Pascal J. Bourguignon
  2010-12-18  2:00   ` LanX
  2010-12-18  2:03   ` Rafael
  1 sibling, 2 replies; 7+ messages in thread
From: Pascal J. Bourguignon @ 2010-12-18  1:49 UTC (permalink / raw)
  To: help-gnu-emacs

Rafael <rvf0068@gmail.com> writes:

> I would like to bind a key to the function that results from
>
> C-u M-x org-insert-link
>
> From 4.6 of http://www.nongnu.org/emacs-tiny-tools/keybindings/, I
> thought that 
>
>   (global-set-key [(super f)]
>                    '(lambda () (interactive) (org-insert-link 4)))
>
> would do the trick. But it doesn't, the effect is no different than just
> doing 
>
>   (global-set-key [(super f)] 'org-insert-link)
>
> which is not what I want. Any help, please?

Read the documentation of org-insert-link.  Follow the link to the
source.  See that it has a (interactive "P") declaration.  Read the
documentation of interactive.  See that "P" means prefix arg in raw
form.

If you don't know it, search in emacs lisp documentation, and you'll
find that the prefix arg in raw form, for a single C-u, is passed as
(4), not 4, and for C-u C-u, it's (16).

So it should be:

(global-set-key [(super f)]  (lambda () (interactive) (org-insert-link '(4))))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


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

* Re: How to bind a function with argument?
  2010-12-18  1:31 ` LanX
  2010-12-18  1:43   ` Rafael
@ 2010-12-18  1:52   ` LanX
  1 sibling, 0 replies; 7+ messages in thread
From: LanX @ 2010-12-18  1:52 UTC (permalink / raw)
  To: help-gnu-emacs

hmm this seems to work for me:

(global-set-key [(super f)]
		'(lambda () (interactive) (org-insert-link (quote (4)))))


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

* Re: How to bind a function with argument?
  2010-12-18  1:49 ` Pascal J. Bourguignon
@ 2010-12-18  2:00   ` LanX
  2010-12-18  2:03   ` Rafael
  1 sibling, 0 replies; 7+ messages in thread
From: LanX @ 2010-12-18  2:00 UTC (permalink / raw)
  To: help-gnu-emacs

> Read the documentation of org-insert-link.  Follow the link to the
> source.  See that it has a (interactive "P") declaration.  Read the
> documentation of interactive.  See that "P" means prefix arg in raw
> form.
>
> If you don't know it, search in emacs lisp documentation, and you'll
> find that the prefix arg in raw form, for a single C-u, is passed as
> (4), not 4, and for C-u C-u, it's (16).

or just do M-x repeat-complex-command to see the lisp code of your
last command. :)


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

* Re: How to bind a function with argument?
  2010-12-18  1:49 ` Pascal J. Bourguignon
  2010-12-18  2:00   ` LanX
@ 2010-12-18  2:03   ` Rafael
  1 sibling, 0 replies; 7+ messages in thread
From: Rafael @ 2010-12-18  2:03 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> Rafael <rvf0068@gmail.com> writes:
>
>> I would like to bind a key to the function that results from
>>
>> C-u M-x org-insert-link
>>
>> From 4.6 of http://www.nongnu.org/emacs-tiny-tools/keybindings/, I
>> thought that 
>>
>>   (global-set-key [(super f)]
>>                    '(lambda () (interactive) (org-insert-link 4)))
>>
>> would do the trick. But it doesn't, the effect is no different than just
>> doing 
>>
>>   (global-set-key [(super f)] 'org-insert-link)
>>
>> which is not what I want. Any help, please?
>
> Read the documentation of org-insert-link.  Follow the link to the
> source.  See that it has a (interactive "P") declaration.  Read the
> documentation of interactive.  See that "P" means prefix arg in raw
> form.
>
> If you don't know it, search in emacs lisp documentation, and you'll
> find that the prefix arg in raw form, for a single C-u, is passed as
> (4), not 4, and for C-u C-u, it's (16).
>
> So it should be:
>
> (global-set-key [(super f)]  (lambda () (interactive) (org-insert-link '(4))))

Indeed it should. Thanks Pascal, for your detailed answer, and LanX!


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

end of thread, other threads:[~2010-12-18  2:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-18  0:35 How to bind a function with argument? Rafael
2010-12-18  1:31 ` LanX
2010-12-18  1:43   ` Rafael
2010-12-18  1:52   ` LanX
2010-12-18  1:49 ` Pascal J. Bourguignon
2010-12-18  2:00   ` LanX
2010-12-18  2:03   ` Rafael

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.