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

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

Re: Prefix-Arg (non-interactive!) in Info


From: Memnon Anon
Subject: Re: Prefix-Arg (non-interactive!) in Info
Date: Fri, 13 Aug 2010 19:04:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

> Let's try a different approach: which function would you like to call
> non-interactively, passing it some value of the prefix arg?  (Please
> don't say "it's not important which function": my point is _precisely_
> that it _is_ important, because the answer to your question is
> specific to the function you want to invoke.)

The function asked for was org-clock-in.

,----[ org-clock-in ]
| org-clock-in is an interactive compiled Lisp function.
| 
| (org-clock-in &optional SELECT START-TIME)
| 
| Start the clock on the current item.
| If necessary, clock-out of the currently active clock.
| With a prefix argument SELECT (C-u), offer a list of recently clocked tasks to
| clock into.  When SELECT is C-u C-u, clock into the current task and mark
| is as the default task, a special task that will always be offered in
| the clocking selection, associated with the letter `d'.
`----

I knew `C-u' = 4 (and not "t" as someone suggested), so I tried 
(global-set-key (kbd "<F12>") (lambda () (interactive) (org-clock-in 4)))
                                                        ^^^^^^^^^^^^^^^
This did not work, but I was hardly surprised.
It never does on the first approach :)

===
(Well, I had this example in mind: (info "(eintr)Interactive 
multiply-by-seven") 

(defun multiply-by-seven (number)       ; Interactive version.
       "Multiply NUMBER by seven."
       (interactive "p")
       (message "The result is %d" (* 7 number)))

(multiply-by-seven 2) --> 14
M-8 M-x multiply-by-seven --> 56
C-u M-x multiply-by-seven --> 28
Works for this function...
===

So I tried to figure out in what form org-clock-in wanted its argument
of 4 passed in.

And I found nothing, until I turned to google.

...

Now I am really confused:
I expected this to work, but it does not:
(multiply-by-seven '(4)).

Oh well, I still don't get it.

But 
(global-set-key (kbd "<F12>") (lambda () (interactive) (org-clock-in
'(4))))
works, the questioner has an answer; problem solved. And I will 
dedicate some time to learn elisp some, soon (at least the basics); 
and I will start with a thorough reading of the elisp intro.

Up to now, I could fix my and others problems by looking at working code
and fiddling until mine worked finally, too ... somehow; but I am
getting the impression this takes way more time on the long run than
learning the beast properly.

Memnon










reply via email to

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