From: Drew Adams <drew.adams@oracle.com>
To: Christopher Dimech <dimech@gmx.com>, Yuri Khan <yuri.v.khan@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: Making a function than can only be used interactively
Date: Fri, 8 Jul 2022 20:29:35 +0000 [thread overview]
Message-ID: <SJ0PR10MB5488CE18F221D545E5880A62F3829@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <trinity-cc303b6d-71db-4876-9e73-da2cf1a2f7f3-1657296897895@3c-app-mailcom-bs14>
> It looks as if the easiest understanding of mandatory versus optional
> function arguments occurs when using a function interactively.
>
> For the interactive case, it is quite complicated, depending on whether
> the function uses code characters or a list.
>
> My proposition would be to include the corresponding explanation on
> using in either the "Emacs Lisp Reference Manual" or the "Introduction to
> Programming in Emacs Lisp".
Dunno whether it's a coincidence (I'm guessing no),
but in the past couple of weeks there've been a
boatload of similar questions on emacs.SE. Here
are some of them:
What is a raw prefix argument?
https://emacs.stackexchange.com/q/13886
Numeric prefix argument for use with interactive command
https://emacs.stackexchange.com/q/72365
Changing of function arguments
https://emacs.stackexchange.com/q/72393
Using current prefix argument value
https://emacs.stackexchange.com/q/72425
Function arguments and interactive
https://emacs.stackexchange.com/q/72428
Getting prefix as argument
https://emacs.stackexchange.com/q/72454
_____
(I voted to close some of them as duplicates.)
Anyway, (I think) I see confusion there similar to
what (I think) I'm seeing here now.
FWIW, here are some comments I wrote to the last of
those questions. That doesn't seem to have done
much good. But maybe they'll help here.
____
1. There's no connection between an argument being
optional and it being provided as a prefix
argument - none.
2. The only implication of an arg being mandatory or
optional is for calling the function. If it's
mandatory then omitting it raises an error;
otherwise, no error. That's all.
3. Using a prefix arg does not necessarily pass an
argument to the function.
A prefix arg is not necessarily an arg to the
function, and vice versa.
A prefix arg need not be optional.
And you can use C-u with M-x.
I suggest you read the Emacs manual about prefix
args:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html
Start by `C-h k C-u'.
A prefix arg is used (can be used) by the
following command. It is not necessarily
associated with any argument to that function.
You can think of it as a global variable, if you
like - the function has access to it, but it
need not be one of the function's arguments.
____
Back to this mail thread...
Instead of looking for some general guideline for
when to use a prefix arg, or when to make this or
that argument optional, my advice is to just learn
what each thingie is/_does_.
Learn how a prefix arg behaves (raw and numeric).
Learn how an optional arg behaves. Learn some of
the predefined chars for a string arg to
`interactive'. Learn how to give a list arg to
`interactive'.
Play with those things. Once you know what each
does you'll know what you can do with them. And
you'll know when you might want to use this or
that thingie. Only you know what you want, but
you need to know what the tools in your toolbox
look like and do.
This whole discussion feels like a quest for
advice about when to use the number one or zero -
or a negative number or a positive number or ...
There is no single "when". There's just knowing
the properties/behaviors of things.
____
tl;dr (too late, I know):
Don't ask when to use X. Just get to know X.
When and how and why to use it will come to you
when you know it.
(Just one opinion.)
next prev parent reply other threads:[~2022-07-08 20:29 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-03 19:16 Making a function than can only be used interactively carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 19:28 ` Bruno Barbier
[not found] ` <N64WnlX--3-2@missing-mail-id>
2022-07-03 19:36 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 19:53 ` Tassilo Horn
2022-07-03 20:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 4:51 ` Tassilo Horn
2022-07-05 23:13 ` Emanuel Berg
2022-07-03 20:14 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-03 20:27 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 20:51 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 21:18 ` Stefan Monnier
2022-07-03 21:29 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-03 22:01 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-03 22:45 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 1:13 ` Stefan Monnier
[not found] ` <jwvczelllyq.fsf-monnier+emacs@gnu.org-N65lQ2m----2>
2022-07-04 10:36 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 10:55 ` Tassilo Horn
2022-07-04 11:43 ` Christopher Dimech
2022-07-04 13:21 ` Stefan Monnier
2022-07-04 14:08 ` Robert Pluim
2022-07-04 21:40 ` Christopher Dimech
2022-07-05 17:35 ` Jean Louis
2022-07-04 19:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 19:40 ` Stefan Monnier
2022-07-04 19:50 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-04 20:45 ` Stefan Monnier
2022-07-06 0:07 ` Jean Louis
2022-07-06 20:00 ` Christopher Dimech
2022-07-06 20:29 ` Jean Louis
2022-07-07 11:03 ` Christopher Dimech
2022-07-07 21:06 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-07 21:28 ` Emanuel Berg
2022-07-07 22:14 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08 3:40 ` Emanuel Berg
2022-07-08 6:08 ` Yuri Khan
2022-07-08 6:30 ` Emanuel Berg
2022-07-08 6:55 ` Yuri Khan
2022-07-08 11:44 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-09 2:05 ` Emanuel Berg
2022-07-10 4:33 ` Emanuel Berg
2022-07-08 12:06 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08 12:11 ` Christopher Dimech
[not found] ` <N6Sh4jm--3-2@tutanota.com-N6ShCt5----2>
2022-07-08 12:18 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08 16:14 ` Christopher Dimech
2022-07-08 20:29 ` Drew Adams [this message]
2022-07-08 21:09 ` [External] : " carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-08 22:17 ` Drew Adams
2022-07-08 22:34 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-09 14:53 ` Drew Adams
2022-08-09 2:24 ` Emanuel Berg
2022-07-09 2:06 ` Emanuel Berg
2022-07-08 23:19 ` Emanuel Berg
2022-07-04 20:53 ` Drew Adams
2022-07-05 23:30 ` no difference between interactive and "from Lisp" (was: Re: Making a function than can only be used interactively) Emanuel Berg
2022-07-06 2:28 ` no difference between interactive and "from Lisp" Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-06 3:42 ` Emanuel Berg
2022-07-04 1:06 ` Making a function than can only be used interactively Po Lu
-- strict thread matches above, loose matches on Subject: below --
2022-07-04 21:07 Christopher Dimech
2022-07-04 21:45 ` Stefan Monnier
2022-07-04 22:05 ` Christopher Dimech
2022-07-04 22:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-05 14:02 ` [External] : " Drew Adams
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=SJ0PR10MB5488CE18F221D545E5880A62F3829@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=dimech@gmx.com \
--cc=help-gnu-emacs@gnu.org \
--cc=yuri.v.khan@gmail.com \
/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.