unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Making alist that executes multiple commands
Date: Mon, 25 Nov 2024 20:45:22 +0000	[thread overview]
Message-ID: <HYU1gPfoYScizqH2vqvC75qOTtbmDxywqMoXnWiqdXGFOHFRvi2-zJnDENAZvY_2VpGb_YJJiLUU08zEMsDoUYjdHO1aRI3wlinaGyHs0to=@protonmail.com> (raw)
In-Reply-To: <87jzcr6ooe.fsf@rub.de>


> > Would be good to allow arguments to be freely combined.
> > But how does one loop over lists of these arguments from the
> > code you posted?
> 
> 
> Something like this, for example:
> 
> (dolist (f '(+ - list))
> (dolist (a '(1 2 3))
> (funcall f a)))
> 
> > I could have the following, but got some difficulties about
> > how to execute each command with its arguments, in the way you
> > suggest.
> > 
> > (defun fpln-test (symbol-list)
> > (let ( (lookup-alist '((ar ((alkotr-ar arg-this)
> > (alkotr-af arg-that arg-other)))
> > (go ((alkotr-go arg-dim)
> > (alkotr-gc arg-dum arg-sum))) )) )
> > 
> > (dolist (actm symbol-list)
> > (let ((commands (cdr (assoc actm lookup-alist))))
> > (while commands
> > (dolist (cmd commands)
> > (apply (car cmd) (cdr cmd)))
> > (message "Key '%s' not found in lookup-alist" key))))))
> 
> 
> When I wrote "using a list of function calls as the value of each alist
> element seems reasonable" I was assuming you wanted them in lambda
> expressions, where they are evaluated, as in the example you gave
> previously. You can't use a function call as the first argument of
> `apply' or` funcall' because a function call (which is just a list whose
> first element is a function) is not a function.

Have been trying to handle your suggestion not to use a lambda, but to
handle the general case of executing a sequence of commands in a list,
each element being a command to run.
 
> On Mon, 25 Nov 2024 17:59:22 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > I get error when calling (marnap '(armg go))
> > 
> > That is I get message "ACTM Unrecognised: 'armg"
> > 
> > (defun marnap (&optional actm-service)
> > 
> > (let ( (lookup-alist '((armg ((add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN"))
> > (require 'napyon)))
> > 
> > (go ((napyon 'go))) )) )
> > 
> > (dolist (actm actm-service)
> > (let ((fnlist (cdr (assoc actm lookup-alist))))
> > (while fnlist
> > (dolist (cmd fnlist)
> > (if (functionp (car cmd))
> > (apply (car cmd) (cdr cmd))
> > (message "ACTM Unrecognised: '%s\n" actm)))))) ))
> 
> 
> This is for the same reason as above: the first invocation of `(car cmd)' returns` (add-to-list 'load-path (marnap-sec-fpln-waypt
> "NAPLN"))', which is a function call, not a function.
> 
> Steve Berman

Have put another question to not complicate this discussion. 
Would it make sense to execute the function calls with eval.

Still that is also giving me problems with  

(invalid-function (add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN")))




  reply	other threads:[~2024-11-25 20:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-24 21:51 Making alist that executes multiple commands Heime via Users list for the GNU Emacs text editor
2024-11-24 22:56 ` Stephen Berman
2024-11-24 23:13   ` Heime via Users list for the GNU Emacs text editor
2024-11-24 23:28     ` Stephen Berman
2024-11-24 23:39       ` Heime via Users list for the GNU Emacs text editor
2024-11-25  1:05         ` Heime via Users list for the GNU Emacs text editor
2024-11-25  9:40           ` Stephen Berman
2024-11-25 13:10             ` Heime via Users list for the GNU Emacs text editor
2024-11-25 14:58               ` Stephen Berman
2024-11-25 16:36                 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 17:59                   ` Heime via Users list for the GNU Emacs text editor
2024-11-25 20:31                   ` Stephen Berman
2024-11-25 20:45                     ` Heime via Users list for the GNU Emacs text editor [this message]
2024-11-25 21:05                       ` Stephen Berman
2024-11-25 21:18                         ` Heime via Users list for the GNU Emacs text editor
2024-11-25 21:27                           ` Stephen Berman
2024-11-25 21:37                             ` Heime via Users list for the GNU Emacs text editor
2024-11-25 21:45                               ` Stephen Berman
2024-11-25 21:59                                 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 22:09                                   ` Stephen Berman
2024-11-25 22:50                                     ` Heime via Users list for the GNU Emacs text editor
2024-11-25 23:11                                       ` Stephen Berman
2024-11-26  8:46                                         ` Heime via Users list for the GNU Emacs text editor
2024-11-25  3:00     ` Stefan Monnier via Users list for the GNU Emacs text editor

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='HYU1gPfoYScizqH2vqvC75qOTtbmDxywqMoXnWiqdXGFOHFRvi2-zJnDENAZvY_2VpGb_YJJiLUU08zEMsDoUYjdHO1aRI3wlinaGyHs0to=@protonmail.com' \
    --to=help-gnu-emacs@gnu.org \
    --cc=heimeborgia@protonmail.com \
    --cc=stephen.berman@gmx.net \
    /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.
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).