help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to bind a function with argument?


From: Pascal J. Bourguignon
Subject: Re: How to bind a function with argument?
Date: Sat, 18 Dec 2010 02:49:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

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 {}.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]