From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Making alist that executes multiple commands Date: Mon, 25 Nov 2024 22:05:54 +0100 Message-ID: <87frnf6n2l.fsf@rub.de> References: <87sergrz2j.fsf@gmx.net> <87mshn8xd8.fsf@gmx.net> <87wmgr742q.fsf@rub.de> <87jzcr6ooe.fsf@rub.de> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1262"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 25 22:06:40 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 1tFgI2-00009a-Rh for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 22:06:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFgHY-00025T-Ob; Mon, 25 Nov 2024 16:06:10 -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 1tFgHQ-00024V-Oi for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:06:00 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFgHO-0007fA-CK for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:06:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1732568754; x=1733173554; i=stephen.berman@gmx.net; bh=Qbfc8aozW5la3m3sL5DyoWeW54eoTAlMUMfPjGyFD/Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=fUe90ZAs83UPaKefWnkL53k99Tc87QyFLTatkYO9WvTvrtmM2QAd+DqFAWJbVzYT dFiMzkOy2ZuiRIHfrQ+Tq3nwOjqrAr9Mk532RKtzyer/4bvEcoZlAZcQUSbaLEnNS XW9dJesACeoEiefcbqbM1uuZjsw7Ylw8HzY2mKi+/tTn4ehR3vR+zqPUHzzeD/d6T sfD2DZi2EGsuiyKjxDknTSzDvD11eJ565kdz4c0nxD5z51P/1J8dmBkC2DtohDqwf qRCZ8n2gZl+5O9xRXIkeXvYzK5l+cjB/Qt0Pgs14jI1xVXRr0rzrcJou8pOfdx2d0 aspPTMAfANbGwNHe1g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.50.169]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MXGrE-1tCqbM2dva-00OsIE; Mon, 25 Nov 2024 22:05:54 +0100 In-Reply-To: (Heime's message of "Mon, 25 Nov 2024 20:45:22 +0000") X-Provags-ID: V03:K1:/ZQPmst5hJSsUolN/VFzwDshT8bYBOvCZ7Ag6LK28X0LIlzJGWi SKDl/luZLgxKbF3aK9y9MQLoxVwdSVOQrD41w/WAULH+JjwCn+ogTQNsOw0V98l6agyPQyK uXpUN4iMEekfHTVFx/vhmj7dnLg2C64XmgFPT9PH7K6Ec00Y7Or9Gc8SH9vYmOK43VGNh0v 3MKbjmHhBFp+m2WgfqVFw== UI-OutboundReport: notjunk:1;M01:P0:OCkSas3iLy4=;9mORuAx2i/w0CMHrez7n2DIbQNt OLsuwDKjhP7CyW0mElmdou5hXAZOtjVe+aYu+tpWoZQiqHvb67RtPGduNlj9xcY0zbDmDNxL9 PfYJ83+Gfivmac/v/ad9mNkKiZwa8GGeVjDGLokRmHZDIiJcQ3aiVgxxpSN8xPuVYZU+sfRyI Csz3QAy7Werg33evU/vPiAIofLQ5LgrSlpd9sklz1aixurv43nBZRZLEd8cH275OPtJyWUxtt ApmD0tbRoaEefcPhFkdN9WNEo7vmBP9hyoG+wOZ9O+fFlDIcEwep+PaBhgAHtIdrZ8F7eiSjN XJV9bBU1jigMPE77j1uQyrS4jBYKyyE8au+DhsCzTLI/Gnc/fqQLnBtrJViHrYx66t+w1oJyB M5g37SiaRCVAAk0x67iWla/GTNWM/MOn0I5b2g31f+wTjC0caDspcf6RKA4RHvFnxtxA4Z9Ge s0n6igy0lRSvBuJzbUqK/gaT3fHSbXvDkwqhMQUJ8ANCD546SiyudpR1R2nlz2ZqJKtm+2B5A NYAKDhAc7qqrKrK/9hQqLUVMgaLww4FQJdw1xU265gAtj0ZFKt6/UAxj+vY9D0rX1E4MPKZgR KYfShMmkj/XtVkBYk158eotiyY6HjrJPszdAsGo+wnQDH5xD+r9VWv9E61D1OEnbvg5k8Afq+ u7gkCFncTXxCJ+Y1gd5GcDBq5CYMTYcijAeIlcoKrASxL/Ytlv7XpGh3bgPcxvMXEQcWjB1xO PAbcDs/7j6lTruRvaq7aHpbyr2np3SH+yNpm6zHpol23+KgdqMlxAZLdLh+COSDxhVePGGNW Received-SPF: pass client-ip=212.227.15.19; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.93, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:148396 Archived-At: On Mon, 25 Nov 2024 20:45:22 +0000 Heime wrot= e: >> > 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 whos= e >> 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. Then you might try looping over lists of functions and arguments like in the above schematic example I gave, though depending upon how you want to combine the functions and arguments (e.g. if the functions don't all have the same arity), this could become complicated. But without specific examples of what you want to do I can't give more specific advice. >> On Mon, 25 Nov 2024 17:59:22 +0000 Heime heimeborgia@protonmail.com wro= te: >> >> > 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"= ))) This is probably because you have something like this: (eval ((add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN")) ...)) That is, you're applying eval to a list, and eval treats a list like a function call, so it expects the first element to be (or evaluate to) a function, but `(add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN"))' is, again, not a function but a function call. Steve Berman