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

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

Re: Invoking a function from a list of functions


From: Andreas Röhler
Subject: Re: Invoking a function from a list of functions
Date: Fri, 9 Nov 2018 09:58:53 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

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



reply via email to

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