* Choosing invokation of list in an interactive clause
@ 2024-04-04 14:19 Heime
2024-04-04 15:27 ` Yuri Khan
2024-04-04 15:30 ` Michael Albinus
0 siblings, 2 replies; 9+ messages in thread
From: Heime @ 2024-04-04 14:19 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
Have made an interactive function that uses two parameter options.
I can either invoke list inside the let construct, or as alternative
outside it. What would be the sensible one to choose ?
(defun ltxstix-integ-slup (grafm seltr)
"Binary Operations with explicit slant and upright versions."
(interactive
(let ( (csel '("Symbol" "Command"))
(cseq '("intsl " "iintsl" "iiintsl" "ointsl")) )
(list
(completing-read "Grapheme: " cseq nil t nil)
(completing-read "Selector: " csel nil t nil) )))
(do-this-and-that grafm seltr) )
Alternative
(defun ltxstix-integ-slup-altern (grafm seltr)
"Binary Operations with explicit slant and upright versions."
(interactive
(list
(let ( (csel '("Symbol" "Command"))
(cseq '("intsl " "iintsl" "iiintsl" "ointsl")) )
(completing-read "Grapheme: " cseq nil t nil)
(completing-read "Selector: " csel nil t nil) )))
(do-this-and-that grafm seltr) )
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Choosing invokation of list in an interactive clause
2024-04-04 14:19 Choosing invokation of list in an interactive clause Heime
@ 2024-04-04 15:27 ` Yuri Khan
2024-04-04 15:30 ` Michael Albinus
1 sibling, 0 replies; 9+ messages in thread
From: Yuri Khan @ 2024-04-04 15:27 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
On Thu, 4 Apr 2024 at 21:20, Heime <heimeborgia@protonmail.com> wrote:
> (interactive
> (let ( (csel '("Symbol" "Command"))
> (cseq '("intsl " "iintsl" "iiintsl" "ointsl")) )
> (list
> (completing-read "Grapheme: " cseq nil t nil)
> (completing-read "Selector: " csel nil t nil) )))
This calls ‘completing-read’ twice and wraps the results in a list of
two values.
> Alternative
>
> (interactive
> (list
> (let ( (csel '("Symbol" "Command"))
> (cseq '("intsl " "iintsl" "iiintsl" "ointsl")) )
>
> (completing-read "Grapheme: " cseq nil t nil)
> (completing-read "Selector: " csel nil t nil) )))
This calls ‘completing-read’ twice, discards the first result and
yields the second one as the ‘let’ result. This one gets wrapped in a
list.
If you wanted an equivalent form where ‘let’ were inside ‘list’, it
would look like this:
(interactive
(list
(let ((cseq '("intsl " "iintsl" "iiintsl" "ointsl")))
(completing-read "Grapheme: " cseq nil t nil))
(let ((csel '("Symbol" "Command")))
(completing-read "Selector: " csel nil t nil))))
However, your two bindings, ‘csel’ and ‘cseq’, are only used once
each, never reused, never modified, nor do they have useful
documenting names. You aren’t really gaining anything from them. Could
just inline them and sidestep the whole question.
(interactive
(list
(completing-read "Grapheme: " '("intsl " "iintsl" "iiintsl" "ointsl")
nil t nil)
(completing-read "Selector: " '("Symbol" "Command") nil t nil)))
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Choosing invokation of list in an interactive clause
2024-04-04 14:19 Choosing invokation of list in an interactive clause Heime
2024-04-04 15:27 ` Yuri Khan
@ 2024-04-04 15:30 ` Michael Albinus
2024-04-04 16:02 ` Heime
1 sibling, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2024-04-04 15:30 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
Heime <heimeborgia@protonmail.com> writes:
Hi,
> Have made an interactive function that uses two parameter options.
>
> I can either invoke list inside the let construct, or as alternative
> outside it. What would be the sensible one to choose ?
The second alternative is wrong. It returns a list with one element, the
result of the inner let-construct.
Best regards, Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Choosing invokation of list in an interactive clause
2024-04-04 15:30 ` Michael Albinus
@ 2024-04-04 16:02 ` Heime
2024-04-06 14:52 ` Heime
0 siblings, 1 reply; 9+ messages in thread
From: Heime @ 2024-04-04 16:02 UTC (permalink / raw)
To: Michael Albinus; +Cc: Heime via Users list for the GNU Emacs text editor
On Friday, April 5th, 2024 at 3:30 AM, Michael Albinus <michael.albinus@gmx.de> wrote:
> Heime heimeborgia@protonmail.com writes:
>
>
> Hi,
>
> > Have made an interactive function that uses two parameter options.
> >
> > I can either invoke list inside the let construct, or as alternative
> > outside it. What would be the sensible one to choose ?
>
>
> The second alternative is wrong. It returns a list with one element, the
> result of the inner let-construct.
>
> Best regards, Michael.
I want the user to input two selections either "Symbol" or "Command", than any
one of the elements in cseq. Storing in variables grafm and seltr, which will
them be used as parameters to the command do-this-and-that
(do-this-and-that grafm seltr)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Choosing invokation of list in an interactive clause
2024-04-04 16:02 ` Heime
@ 2024-04-06 14:52 ` Heime
2024-04-06 17:27 ` Michael Albinus
0 siblings, 1 reply; 9+ messages in thread
From: Heime @ 2024-04-06 14:52 UTC (permalink / raw)
To: Heime; +Cc: Michael Albinus,
Heime via Users list for the GNU Emacs text editor
On Friday, April 5th, 2024 at 4:02 AM, Heime <heimeborgia@protonmail.com> wrote:
> On Friday, April 5th, 2024 at 3:30 AM, Michael Albinus michael.albinus@gmx.de wrote:
>
> > Heime heimeborgia@protonmail.com writes:
> >
> > Hi,
> >
> > > Have made an interactive function that uses two parameter options.
> > >
> > > I can either invoke list inside the let construct, or as alternative
> > > outside it. What would be the sensible one to choose ?
> >
> > The second alternative is wrong. It returns a list with one element, the
> > result of the inner let-construct.
> >
> > Best regards, Michael.
>
>
> I want the user to input two selections either "Symbol" or "Command", than any
> one of the elements in cseq. Storing in variables grafm and seltr, which will
> them be used as parameters to the command do-this-and-that
>
> (do-this-and-that grafm seltr)
Does an interactive function that requires multiple user inputs need
the same amount of variables in the argument list of the defun ?
And would one also need the interactive clause to use a list containing
the same number of entities ?
(defun boavus-latex-zilindr (actm)
"Insert Latex Structural Construct."
(interactive
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Choosing invokation of list in an interactive clause
2024-04-06 14:52 ` Heime
@ 2024-04-06 17:27 ` Michael Albinus
2024-04-06 17:34 ` [External] : " Drew Adams
0 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2024-04-06 17:27 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
Heime <heimeborgia@protonmail.com> writes:
Hi,
> Does an interactive function that requires multiple user inputs need
> the same amount of variables in the argument list of the defun ?
> And would one also need the interactive clause to use a list containing
> the same number of entities ?
`interactive' shall return a list with exactly as many elements as the
command (funtion) has arguments.
Best regards, Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [External] : Re: Choosing invokation of list in an interactive clause
2024-04-06 17:27 ` Michael Albinus
@ 2024-04-06 17:34 ` Drew Adams
2024-04-06 21:24 ` Heime
0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2024-04-06 17:34 UTC (permalink / raw)
To: Michael Albinus, Heime; +Cc: Heime via Users list for the GNU Emacs text editor
> `interactive' shall return a list with exactly as many elements as the
> command (funtion) has arguments.
Not exactly. It must provide all of
the _required_ args. It can also
provide any or all of the optional args.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [External] : Re: Choosing invokation of list in an interactive clause
2024-04-06 17:34 ` [External] : " Drew Adams
@ 2024-04-06 21:24 ` Heime
2024-04-06 21:56 ` Drew Adams
0 siblings, 1 reply; 9+ messages in thread
From: Heime @ 2024-04-06 21:24 UTC (permalink / raw)
To: Drew Adams
Cc: Michael Albinus,
Heime via Users list for the GNU Emacs text editor
On Sunday, April 7th, 2024 at 5:34 AM, Drew Adams <drew.adams@oracle.com> wrote:
> > `interactive' shall return a list with exactly as many elements as the
> > command (funtion) has arguments.
>
>
> Not exactly. It must provide all of
> the required args. It can also
> provide any or all of the optional args.
How would it work with optional arguments, for some of the
optional arguments. Would like to see examples some examples
for illustration.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [External] : Re: Choosing invokation of list in an interactive clause
2024-04-06 21:24 ` Heime
@ 2024-04-06 21:56 ` Drew Adams
0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2024-04-06 21:56 UTC (permalink / raw)
To: Heime; +Cc: Michael Albinus,
Heime via Users list for the GNU Emacs text editor
> > [interactive] must provide all of
> > the required args. It can also
> > provide any or all of the optional args.
>
> How would it work with optional arguments, for some of the
> optional arguments. Would like to see examples some examples
> for illustration.
Whatever optional args _you want to pass_ when
the command is used interactively, you can pass.
Optional args that you don't want to pass, you
need not pass.
Obviously, if you pass the Nth arg (required or
optional) then you need to also pass args 1...
(N-1). Passing nil for an arg is equivalent to
not passing it.
How the `interactive' spec reads or otherwise
comes up with the values of the optional args
you choose to pass is entirely up to you.
For any arg (required or optional) passed to
the function body by `interactive', you can
prompt for a value or code (calculate or
hard-code) a value. Up to you.
There are hundreds of examples in the Lisp
source code in your Emacs sources. Just
grep for "(interactive ".
Try reading the "Emacs Lisp Intro" manual
(or the Elisp manual) Emacs provides you.
Pretty much everything you ask is presented
clearly to you there.
(If you have difficulty reading, maybe you
can get manuals as audio books somewhere.)
People spent years writing the manuals.
Not doing your homework just makes people
(who are, so far, willing to help), redo
that work. Over time fewer people might
be willing to continue spoon-feeding you.
Time to try biting into some solid food?
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-04-06 21:56 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-04 14:19 Choosing invokation of list in an interactive clause Heime
2024-04-04 15:27 ` Yuri Khan
2024-04-04 15:30 ` Michael Albinus
2024-04-04 16:02 ` Heime
2024-04-06 14:52 ` Heime
2024-04-06 17:27 ` Michael Albinus
2024-04-06 17:34 ` [External] : " Drew Adams
2024-04-06 21:24 ` Heime
2024-04-06 21:56 ` Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).