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 13:10:57 +0000 Message-ID: References: <87wmgss0k6.fsf@gmx.net> <87sergrz2j.fsf@gmx.net> <87mshn8xd8.fsf@gmx.net> 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="17569"; 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 14:11:39 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 1tFYsN-0004NW-0s for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 14:11:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFYrw-0000v4-8d; Mon, 25 Nov 2024 08:11:12 -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 1tFYrt-0000us-9E for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 08:11:10 -0500 Original-Received: from mail-43166.protonmail.ch ([185.70.43.166]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFYro-0003p1-0q for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 08:11:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732540261; x=1732799461; bh=e3+cQc/7SFDos1CtMxk/TeMlk2SQiUGCK727T6Qkdt4=; 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=lD96zO24Ascy321LASerH5rurKtT9hsck5x5xZZtytPrdyUfBYRTJVfwDk7d2SnYF YGIGCc67+xwK4OMFQqMXhE9JO+XRqb1DxXvjC6DRc3O5fjcqHAABE6B/cIcv4sepam zpNbYjS8SGbUCPJP7tHlHg68+b2uhzGnBUm3+2+QICWFisznvbkMlwgQNbLwKKuo0L xg+zWkFM58FA7NUMUOkIUXD6qDVuRT2lIYlKRkBrA+U/fdhc8xWkNoJU/Va7khmYaZ VTwIf12qJf4LBN0BLQwsb5H9ATfLBjWRvQismRRpDBajaDQcftSf91nwinUHVRstnI iH4bP8oKtHshQ== In-Reply-To: <87mshn8xd8.fsf@gmx.net> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 587ae0f59cc966fc78b3b71b511c79e332ab2155 Received-SPF: pass client-ip=185.70.43.166; envelope-from=heimeborgia@protonmail.com; helo=mail-43166.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:148389 Archived-At: Sent with Proton Mail secure email. On Monday, November 25th, 2024 at 9:40 PM, Stephen Berman wrote: > On Mon, 25 Nov 2024 01:05:10 +0000 Heime heimeborgia@protonmail.com wrote= : >=20 > > On Monday, November 25th, 2024 at 11:39 AM, Heime via Users list for th= e GNU > > Emacs text editor help-gnu-emacs@gnu.org wrote: > >=20 > > > Sent with Proton Mail secure email. > > >=20 > > > On Monday, November 25th, 2024 at 11:28 AM, Stephen Berman > > > stephen.berman@gmx.net wrote: > > >=20 > > > > On Sun, 24 Nov 2024 23:13:51 +0000 Heime heimeborgia@protonmail.com= wrote: > > > >=20 > > > > > On Monday, November 25th, 2024 at 10:56 AM, Stephen Berman > > > > > stephen.berman@gmx.net wrote: > > > > >=20 > > > > > > On Sun, 24 Nov 2024 21:51:38 +0000 Heime via Users list for the= GNU Emacs > > > > > > text editor help-gnu-emacs@gnu.org wrote: > > > > > >=20 > > > > > > > What changes can I make to the following to allow me to execu= te more > > > > > > > commands than just one (as in alkotr-ar and alkotr-go). > > > > > > >=20 > > > > > > > For ar I want to call functions alkotr-ar and alkotr-af > > > > > > >=20 > > > > > > > (let ( (lookup-alist > > > > > > > '((ar . alkotr-ar) > > > > > > > (go . alkotr-go)))) > > > > > > >=20 > > > > > > > (dolist (actm symbol-list) > > > > > > > (let ((func (cdr (assoc actm lookup-alist)))) > > > > > > > (if func > > > > > > > (funcall func) > > > > > > > (message "ACTM Unrecognised: %s%s" "'" actm))))) > > > > > >=20 > > > > > > Something like this: > > > > > >=20 > > > > > > (let ((symbol-list '(ar go)) > > > > > > (lookup-alist '((ar alkotr-ar alkotr-af) > > > > > > (go alkotr-go alkotr-gc)))) > > > > > > (dolist (actm symbol-list) > > > > > > (let ((fnlist (cdr (assoc actm lookup-alist)))) > > > > > > (while fnlist > > > > > > (let ((func (pop fnlist))) > > > > > > (if (functionp func) > > > > > > (funcall func) > > > > > > (message "ACTM Unrecognised: %s%s" "'" actm))))))) > > > > > >=20 > > > > > > Steve Berman > > > > >=20 > > > > > Have thought about this. Any criticisms about it? > > > > >=20 > > > > > '((ar . (lambda () > > > > > (alkotr-ar) > > > > > (alkotr-af))) > > > > >=20 > > > > > (go . (lambda () > > > > > (alkotr-go) > > > > > (alkotr-gc)))) > > > >=20 > > > > That seems fine if the functions take no arguments, though probably= not > > > > as flexible as looping over a list. > > >=20 > > > Could you explain? Can't I do > > >=20 > > > (go . (lambda () > > > (alkotr-go go) > > > (alkotr-gc gc)) >=20 >=20 > Yes (but as Stefan Monnier pointed out and I overlooked, you have to > evaluate the lambda expressions). I was just referring to the specific > function calls you used. >=20 > > > > > What would you suggest for function commands requiring arguments, > > > > > e.g. (alkotr-ar ar) and (alkotr-af af)? > > > >=20 > > > > (funcall 'alkotr-ar ar) > > > > (funcall 'alkotr-ar af) > > >=20 > > > How would the above solution fit with argument incorporation within > > > lookup-alist? >=20 >=20 > I'm not sure what you're asking here. >=20 > > Does one use > >=20 > > (lookup-alist '( (ar (alkotr-ar arg-ar) (alkotr-af arg-af)) > > (go (alkotr-go arg-go) (alkotr-gc arg-gc))) )) >=20 >=20 > Use it for what? >=20 > Steve Berman (defun fpln-test (symbol-list) (let ((symbol-list '(ar go)) (lookup-alist '((ar alkotr-ar alkotr-af) (go alkotr-go alkotr-gc)))) (dolist (actm symbol-list) (let ((fnlist (cdr (assoc actm lookup-alist)))) (while fnlist (let ((func (pop fnlist))) (if (functionp func) (funcall func) (message "ACTM Unrecognised: %s%s" "'" actm)))))))) You suggested the use use of (funcall 'alkotr-ar ar) (funcall 'alkotr-ar af) Where are they to be introduced? I was planning to introduce the arguments in the lookup-alist. So that for ar one can include arguments to alkotr-ar and alkotr-af.