From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Making alist that executes multiple commands Date: Mon, 25 Nov 2024 20:45:22 +0000 Message-ID: References: <87sergrz2j.fsf@gmx.net> <87mshn8xd8.fsf@gmx.net> <87wmgr742q.fsf@rub.de> <87jzcr6ooe.fsf@rub.de> Reply-To: Heime Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="601"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 25 21:46:14 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tFfyI-000AWs-Cv for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 21:46:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFfxe-0003qt-H3; Mon, 25 Nov 2024 15:45:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFfxc-0003qW-Fp for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 15:45:32 -0500 Original-Received: from mail-43167.protonmail.ch ([185.70.43.167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFfxa-0003ip-AE for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 15:45:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732567526; x=1732826726; bh=cBDSOXkPlZFDKn7BX6uownq0UhvEglzqcnFtBvtv2bA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=FkSrb+QfrD45cTR4DNhgOj6D+q01pY9nEaH8TEPN/MoWM0sGJ20uRaWiOIqbEUZt4 BJ8aUcqDTSukzizRzNcnGzVn5sTZYzkhkiXniPm1/uCvAqQtD1AeLLgKUCsYZGKMDc xImr8rCXklccDh87/5cL8xMdcP+hdJ6aM8n6PxSa5lMMlimKxizHj/0n1o7JBEyHod gjwnnmXvJuxDJA9itqELGpQMm/yP5CyIzLqgGD7xbgLb/CI9LtWmN6fZzEtBo42HUe AwkLOJjS2FSlnGebDfiJ7AIfr+/6dfI38whc7eaw9Z8WgzSXCqLNmMjRmH5ivR3Z5t PQIrYnA9XOXSA== In-Reply-To: <87jzcr6ooe.fsf@rub.de> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 9171e3ef0594a3c1af230328acd89af116a45626 Received-SPF: pass client-ip=185.70.43.167; envelope-from=heimeborgia@protonmail.com; helo=mail-43167.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148395 Archived-At: > > 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? >=20 >=20 > Something like this, for example: >=20 > (dolist (f '(+ - list)) > (dolist (a '(1 2 3)) > (funcall f a))) >=20 > > I could have the following, but got some difficulties about > > how to execute each command with its arguments, in the way you > > suggest. > >=20 > > (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))) )) ) > >=20 > > (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)))))) >=20 >=20 > 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. =20 > On Mon, 25 Nov 2024 17:59:22 +0000 Heime heimeborgia@protonmail.com wrote= : >=20 > > I get error when calling (marnap '(armg go)) > >=20 > > That is I get message "ACTM Unrecognised: 'armg" > >=20 > > (defun marnap (&optional actm-service) > >=20 > > (let ( (lookup-alist '((armg ((add-to-list 'load-path (marnap-sec-fpln-= waypt "NAPLN")) > > (require 'napyon))) > >=20 > > (go ((napyon 'go))) )) ) > >=20 > > (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)))))) )) >=20 >=20 > 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. >=20 > Steve Berman Have put another question to not complicate this discussion.=20 Would it make sense to execute the function calls with eval. Still that is also giving me problems with =20 (invalid-function (add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN")))