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 10:40:35 +0100 Message-ID: <87mshn8xd8.fsf@gmx.net> References: <87wmgss0k6.fsf@gmx.net> <87sergrz2j.fsf@gmx.net> 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="11967"; 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 10:41:22 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 1tFVas-0002sM-2y for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 10:41:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFVaH-0006AG-QF; Mon, 25 Nov 2024 04:40:45 -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 1tFVaF-00069e-U9 for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 04:40:43 -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 1tFVaB-0004Pg-94 for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 04:40:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1732527636; x=1733132436; i=stephen.berman@gmx.net; bh=Df5wrG5vgveS6zgKrLgvjTJsrV7mNu/5nAEG05p51k4=; 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=WVEyi78izLlxg1QVg8IbFRkftWyotBA5zWkpKKHZloKz9ixQs+Slw8ysBEpfQHzE Va/UC0Pl7Yj0FZ789R38ZA+MuFZ0AMA9a2hx/XmLN9hfD09VX/+5NkgKFS2T2EOnv pzV3nUc7E4uuNB3N8+1TiSo3J2PPRRnamF80yhe+A7slwvhnCpoOYLF34KVtsjbVD +BY/cMP0jcXog+Le53h9yYPwNn2u4MvDsYChPb1m4bBeQEXLndwM+Nq8LLfyWunLz 564hgKIF4sbfFFjQ8p3HDtIbz15ne0lfQC7hjy8kEVmBEqxWQiD5GQpufw/MAxUn+ ogzQOeZrP7MZoYbhcQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.50.169]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MCbEf-1tPAMp1K3X-004m5a; Mon, 25 Nov 2024 10:40:36 +0100 In-Reply-To: (Heime's message of "Mon, 25 Nov 2024 01:05:10 +0000") X-Provags-ID: V03:K1:QjciF279TmsiWWstff05VQkR7rs8+9RvFtFQvVM+Q/pQ8i3eV/s BY3F5pB0ep9jH8jki/AhbWRZSfFDEhqghYxTqIzDE/ZCS3S7uwMCdKp4tOCwMqgYSD0X6DP 9NDIgVh1qsjIotXl9iYkd2110BUft8YJeD4AKsfHe7K4YGPHe6vcUzIv+uoay55xA1SgG3Z 4unpzmUWURbeYM0a1QuZQ== UI-OutboundReport: notjunk:1;M01:P0:eGAwtQB6w08=;FmedZZWHR1c6jYYdq1V8Io5QCYk QF/Bga+jvFaBAIywaOrqWD5IuRs8p7sMkgLR89iVTiRtr1X2huxTX/sjIaod/K+xp3I0JUs0s RXmtQFeDXc5V/69H87aJxXLwsNS9cU/QietGH5Rx6tvWd2xKh0WucXauv0Aday6aQYBC/M4sS HjLZz4Z0uqbKI/RgF7IuEURk9jMnE3hp6TvEY4nAp8eXqeWHvBjFXblaE7IW6h/y7ssuOOk8H 4BsXbCXmkvm9eDjV0dpeGlqXusAh70IoueB6yjHTsJqFMnw0qbHugWCirW1MrYg9TzP/Wons9 ubo1g1l0CRYBdJSbPiiW2XaKb9YabYMl7uwa4sOmY4/jGu0UfHTgwiy0DNBB+w9S7bSW119gV Hs89qNAk6hsSueZJ28ErdrDRkeYTXDoG7QDvXBqNVfxw8/xBE5HQhKTOg6dLpG0F4+KvUqh6V 3bEb6S7VH45fRR2DYbtUswqjfWARDF2pJpvJAoRkuRZ8rD+KtaKlO271i6Yga8jNyNWikzQwF RQWQaCBKNQNCtNw20Zo87rlCZjv6+K211dsgV23pf1onqVKO0mIJ9//m13ecLqxSvYrRkOhJs W66qIrVVYtqq23o3Pfi8Yb7A+l5HqK7LkB4bqtPLkj039dY0NmzuBFykYlBjovWOotPZKS8R1 gcGyXXU0etfpPOy/+zco69FhjY1h/zbKknsA0kTGyDyEGEgvAznFuW93+FnIxyKzogreRlmRm MPOuLL+eMJ3w21rzAvqtCasHB3k/lcSGuRefTUiqWmDaX+6VUtmGZpyGFedf9MAkCsPw8uuJ 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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:148386 Archived-At: On Mon, 25 Nov 2024 01:05:10 +0000 Heime wrot= e: > On Monday, November 25th, 2024 at 11:39 AM, Heime via Users list for the= GNU > Emacs text editor wrote: > >> Sent with Proton Mail secure email. >> >> On Monday, November 25th, 2024 at 11:28 AM, Stephen Berman >> stephen.berman@gmx.net wrote: >> >> > On Sun, 24 Nov 2024 23:13:51 +0000 Heime heimeborgia@protonmail.com w= rote: >> > >> > > On Monday, November 25th, 2024 at 10:56 AM, Stephen Berman >> > > stephen.berman@gmx.net wrote: >> > > >> > > > On Sun, 24 Nov 2024 21:51:38 +0000 Heime via Users list for the G= NU Emacs >> > > > text editor help-gnu-emacs@gnu.org wrote: >> > > > >> > > > > What changes can I make to the following to allow me to execute= more >> > > > > commands than just one (as in alkotr-ar and alkotr-go). >> > > > > >> > > > > For ar I want to call functions alkotr-ar and alkotr-af >> > > > > >> > > > > (let ( (lookup-alist >> > > > > '((ar . alkotr-ar) >> > > > > (go . alkotr-go)))) >> > > > > >> > > > > (dolist (actm symbol-list) >> > > > > (let ((func (cdr (assoc actm lookup-alist)))) >> > > > > (if func >> > > > > (funcall func) >> > > > > (message "ACTM Unrecognised: %s%s" "'" actm))))) >> > > > >> > > > Something like this: >> > > > >> > > > (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))))))) >> > > > >> > > > Steve Berman >> > > >> > > Have thought about this. Any criticisms about it? >> > > >> > > '((ar . (lambda () >> > > (alkotr-ar) >> > > (alkotr-af))) >> > > >> > > (go . (lambda () >> > > (alkotr-go) >> > > (alkotr-gc)))) >> > >> > That seems fine if the functions take no arguments, though probably n= ot >> > as flexible as looping over a list. >> >> >> Could you explain? Can't I do >> >> (go . (lambda () >> (alkotr-go go) >> (alkotr-gc gc)) 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. >> > > What would you suggest for function commands requiring arguments, >> > > e.g. (alkotr-ar ar) and (alkotr-af af)? >> > >> > (funcall 'alkotr-ar ar) >> > (funcall 'alkotr-ar af) >> >> >> How would the above solution fit with argument incorporation within >> lookup-alist? I'm not sure what you're asking here. > Does one use > > (lookup-alist '( (ar (alkotr-ar arg-ar) (alkotr-af arg-af)) > (go (alkotr-go arg-go) (alkotr-gc arg-gc))) )) Use it for what? Steve Berman