[Top][All Lists]

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

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

From: Andreas Röhler
Subject: Re: Prefix-Arg (non-interactive!) in Info
Date: Fri, 13 Aug 2010 19:40:25 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv: Gecko/20100711 Thunderbird/3.0.6

Am 13.08.2010 19:04, schrieb Memnon Anon:
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.

(global-set-key (kbd "<F12>") (lambda () (interactive) (org-clock-in
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.



remember having that kind of diffcults too when starting with Emacs.
Somehow that issue may fit into another thread at emacs-devel "Emacs learning curve."

Difficulty was the notion of "Universal argument".
From now:

it's a kind of interface from the Emacs Lisp side providing an input facility bound to a predefined key.

Basically it's a tool to toggle, a switch taking args with it.

You must only think of it, when writing something taking user input.
There are more provisions for user input.

Universal argument is just one.


reply via email to

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