From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Invoking a function from a list of functions
Date: Fri, 9 Nov 2018 09:58:53 +0100 [thread overview]
Message-ID: <42ac8b40-7d1e-b578-f7e3-bbadefad62ea@easy-emacs.de> (raw)
In-Reply-To: <20181108230125.GA2179@mail.akwebsoft.com>
On 09.11.2018 00:01, Tim Johnson wrote:
> Given a list of functions:
> (setq funcs '(scroll-up-line scroll-down-line))
>
> And assuming that these functions have a similar argument list,
> I can invoke a function as:
>
> (funcall (nth 1 funcs))
> ;; or optionally
> (funcall (nth 1 funcs) 2)
>
> That approach is sufficient for my needs at the moment, an example
> of which might be to cycle through color themes invoked by my own
> functions.
>
> However, in the quest for futher edification I'd welcome URLs to
> documentation or discussion, as well as any contributions other
> emacsen might choose to make. Keywords also.
>
> I had a heck of a time getting relevant responses from google. I
> actually don't know what keywords to search with.
>
> thanks
> GNU Emacs 26.1 GTK+ Version, Ubuntu 16.04
>
Maybe that way:
(defun foo ()
(message "%s" "foo"))
(defun bar ()
(message "%s" "bar"))
(setq my-list-of-functions (list 'foo 'bar))
(funcall (nth 1 my-list-of-functions))
;;;;;
The point is to hand over functions as symbols, not their value
next prev parent reply other threads:[~2018-11-09 8:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-08 23:01 Invoking a function from a list of functions Tim Johnson
2018-11-09 1:25 ` Eric Abrahamsen
2018-11-09 6:03 ` Tim Johnson
2018-11-09 10:30 ` Marcin Borkowski
2018-11-09 11:52 ` Noam Postavsky
2018-11-09 13:12 ` Van L
2018-11-09 16:14 ` Tim Johnson
2018-11-09 14:16 ` Yuri Khan
2018-11-09 16:22 ` Tim Johnson
2018-11-09 16:37 ` Stefan Monnier
[not found] ` <mailman.3694.1541743398.1284.help-gnu-emacs@gnu.org>
2018-11-09 7:09 ` Ihor Radchenko
2018-11-09 8:58 ` Andreas Röhler [this message]
2018-11-09 16:24 ` Tim Johnson
[not found] <mailman.3677.1541718983.1284.help-gnu-emacs@gnu.org>
2018-11-12 5:39 ` Rusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42ac8b40-7d1e-b578-f7e3-bbadefad62ea@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.