elisp - Emacs Lisp map over a list of function names and call them all with the same arg -


i'm having trouble understanding approach need take fold on list of functions , invoke them particular argument.

here assumed work. i've tried various variations on it, using eval etc. pointers?

(mapcar (lambda (fn) (fn 'utf-8))         (list #'set-terminal-coding-system               #'set-keyboard-coding-system               #'prefer-coding-system)) 

when run "symbol's function definition void: fn".

edit | ok, works, seems odd need use apply when above example passes functions #'function-name synax.

(mapcar (lambda (fn) (apply fn '(utf-8)))         '(set-terminal-coding-system           set-keyboard-coding-system           prefer-coding-system)) 

in emacs lisp, symbols have separate value , function slots1.

function arguments passed in value of argument's symbol, when evaluate (fn 'utf-8) using fn symbol's function slot, not contain want (or in instance, @ all; hence error "symbol's function definition void: fn").

to call function held in variable, must therefore funcall or apply (or similar).

see also:

1 i.e. so-called "lisp-2", opposed "lisp-1" there single name-space both.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -