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

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

Re: Calling function as if it had a C-u prefix


From: Emanuel Berg
Subject: Re: Calling function as if it had a C-u prefix
Date: Fri, 27 Feb 2015 22:51:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

address@hidden (Tory S. Anderson) writes:

> I'm playing around with hydra and am trying to bind
> a key to do the equivalent of `C-u org-clock-in`.
> I've tried following a related question on SO[1] but
> it doesn't seem to be working. Can anyone tell me
> where I'm off?

I don't have hydra (?) or `org-clock-in' but usually
those functions have an optional argument. For
example, the docstring of `forward-char':

    (forward-char &optional N)

In such a case, simply put an invocation with an
explicit argument in a wrapper (an interactive defun)
and bind that to the desired command (shortcut).

If you cannot use the optional argument try this:

    (defun forward-fourteen ()
      (interactive)
      (let ((current-prefix-arg 14))
        (call-interactively 'forward-char) ))

    (forward-fourteen) ; evaluate me and see how far

    (global-set-key "\C-x\M-o" 'forward-fourteen)

-- 
underground experts united


reply via email to

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