all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Prefix-Arg (non-interactive!) in Info
Date: Fri, 13 Aug 2010 19:40:25 +0200	[thread overview]
Message-ID: <4C658389.4000901@easy-emacs.de> (raw)
In-Reply-To: <87fwyitrgv.fsf@mean.albasani.net>

Am 13.08.2010 19:04, schrieb Memnon Anon:
> Eli Zaretskii<eliz@gnu.org>  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
>
>

Hi,

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.


Andreas













  reply	other threads:[~2010-08-13 17:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13 14:37 Prefix-Arg (non-interactive!) in Info Memnon Anon
2010-08-13 15:17 ` Eli Zaretskii
2010-08-13 15:50   ` Memnon Anon
2010-08-13 16:09     ` Eli Zaretskii
2010-08-13 16:21       ` Drew Adams
2010-08-13 18:36         ` Memnon Anon
2010-08-13 20:33           ` Drew Adams
2010-08-13 17:04       ` Memnon Anon
2010-08-13 17:40         ` Andreas Röhler [this message]
2010-08-13 21:04           ` Memnon Anon
2010-08-13 19:33         ` Eli Zaretskii
2010-08-13 20:58           ` [Solved] (was: Prefix-Arg (non-interactive!) in Info) Memnon Anon
2010-08-14  8:05             ` Eli Zaretskii
2010-08-14 21:18               ` [Solved] Memnon Anon
2010-08-14 22:27                 ` [Solved] Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C658389.4000901@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.