help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making alist that executes multiple commands


From: Heime
Subject: Re: Making alist that executes multiple commands
Date: Sun, 24 Nov 2024 23:39:59 +0000





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 wrote:
> 
> > 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 GNU 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 not
> as flexible as looping over a list.

Could you explain?  Can't I do 

 (go . (lambda ()
         (alkotr-go go)
         (alkotr-gc gc))

> > 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]